add Apache Licensed and add check native

This commit is contained in:
tuna 2013-12-10 10:21:09 +07:00
parent 69302e147c
commit 5e23f00b1a
8 changed files with 128 additions and 8 deletions

View File

@ -1,3 +1,19 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api; package com.cloud.agent.api;
public class PerformanceMonitorAnswer extends Answer { public class PerformanceMonitorAnswer extends Answer {

View File

@ -1,3 +1,19 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api; package com.cloud.agent.api;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,3 +1,19 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.as; package com.cloud.network.as;
import javax.persistence.Column; import javax.persistence.Column;

View File

@ -1,3 +1,19 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.as.dao; package com.cloud.network.as.dao;
import java.util.List; import java.util.List;

View File

@ -1,3 +1,19 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.as.dao; package com.cloud.network.as.dao;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,20 @@
#!/usr/bin/python #!/usr/bin/python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import pprint import pprint
import XenAPI import XenAPI

View File

@ -623,7 +623,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
List<AutoScaleVmGroupVO> asGroups = _asGroupDao.listAll(); List<AutoScaleVmGroupVO> asGroups = _asGroupDao.listAll();
for (AutoScaleVmGroupVO asGroup : asGroups) { for (AutoScaleVmGroupVO asGroup : asGroups) {
// check group state // check group state
if (asGroup.getState().equals("enabled")) { if ((asGroup.getState().equals("enabled")) && (is_native(asGroup.getId()))) {
// check minimum vm of group // check minimum vm of group
Integer currentVM = _asGroupVmDao.countByGroup(asGroup.getId()); Integer currentVM = _asGroupVmDao.countByGroup(asGroup.getId());
if (currentVM < asGroup.getMinMembers()) { if (currentVM < asGroup.getMinMembers()) {
@ -733,7 +733,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
} }
} }
String scaleAction = getAutoscaleAction(avgCounter, asGroup.getId(), currentVM); String scaleAction = getAutoscaleAction(avgCounter, asGroup.getId(), currentVM, params);
if (scaleAction != null) { if (scaleAction != null) {
s_logger.debug("[AutoScale] Doing scale action: " + scaleAction + " for group " + asGroup.getId()); s_logger.debug("[AutoScale] Doing scale action: " + scaleAction + " for group " + asGroup.getId());
if (scaleAction.equals("scaleup")) { if (scaleAction.equals("scaleup")) {
@ -758,7 +758,21 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
} }
private String getAutoscaleAction(HashMap<Long, Double> avgCounter, long groupId, long currentVM) { private boolean is_native(long groupId) {
List <AutoScaleVmGroupPolicyMapVO> vos = _asGroupPolicyDao.listByVmGroupId(groupId);
for (AutoScaleVmGroupPolicyMapVO vo : vos) {
List<AutoScalePolicyConditionMapVO> ConditionPolicies = _asConditionMapDao.findByPolicyId(vo.getPolicyId());
for (AutoScalePolicyConditionMapVO ConditionPolicy : ConditionPolicies) {
ConditionVO condition = _asConditionDao.findById(ConditionPolicy.getConditionId());
CounterVO counter = _asCounterDao.findById(condition.getCounterid());
if (counter.getSource() == Counter.Source.cpu || counter.getSource() == Counter.Source.memory)
return true;
}
}
return false;
}
private String getAutoscaleAction(HashMap<Long, Double> avgCounter, long groupId, long currentVM, Map<String, String> params) {
List<AutoScaleVmGroupPolicyMapVO> listMap = _asGroupPolicyDao.listByVmGroupId(groupId); List<AutoScaleVmGroupPolicyMapVO> listMap = _asGroupPolicyDao.listByVmGroupId(groupId);
if ( (listMap == null) || (listMap.size() == 0) ) if ( (listMap == null) || (listMap.size() == 0) )
@ -785,9 +799,19 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
for (ConditionVO conditionVO : lstConditions) { for (ConditionVO conditionVO : lstConditions) {
long thresholdValue = conditionVO.getThreshold(); long thresholdValue = conditionVO.getThreshold();
Double thresholdPercent = (double)thresholdValue / 100; Double thresholdPercent = (double)thresholdValue / 100;
Double sum = avgCounter.get(conditionVO.getCounterid()); CounterVO counterVO = _asCounterDao.findById(conditionVO.getCounterid());
Double avg = sum/ currentVM; // Double sum = avgCounter.get(conditionVO.getCounterid());
long counter_count=1;
do {
String counter_param = params.get("counter" + String.valueOf(counter_count));
Counter.Source counter_source = counterVO.getSource();
if (counter_param.equals(counter_source.toString()))
break;
counter_count++;
} while (1==1);
Double sum = avgCounter.get(counter_count);
Double avg = sum / currentVM;
Operator op = conditionVO.getRelationalOperator(); Operator op = conditionVO.getRelationalOperator();
boolean bConditionCheck = ((op == com.cloud.network.as.Condition.Operator.EQ) && (thresholdPercent == avg)) boolean bConditionCheck = ((op == com.cloud.network.as.Condition.Operator.EQ) && (thresholdPercent == avg))
|| ((op == com.cloud.network.as.Condition.Operator.GE) && (avg >= thresholdPercent)) || ((op == com.cloud.network.as.Condition.Operator.GE) && (avg >= thresholdPercent))

View File

@ -417,8 +417,8 @@ INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (1,
INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (2, UUID(), 'snmp','Linux System CPU - percentage', '1.3.6.1.4.1.2021.11.10.0', now()); INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (2, UUID(), 'snmp','Linux System CPU - percentage', '1.3.6.1.4.1.2021.11.10.0', now());
INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (3, UUID(), 'snmp','Linux CPU Idle - percentage', '1.3.6.1.4.1.2021.11.11.0', now()); INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (3, UUID(), 'snmp','Linux CPU Idle - percentage', '1.3.6.1.4.1.2021.11.11.0', now());
INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (100, UUID(), 'netscaler','Response Time - microseconds', 'RESPTIME', now()); INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (100, UUID(), 'netscaler','Response Time - microseconds', 'RESPTIME', now());
INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (4, UUID(), 'cpu','Linux User CPU - percentage', '1.3.6.1.4.1.2021.11.9.1', now()); INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (4, UUID(), 'cpu','Linux User CPU - percentage - native', '1.3.6.1.4.1.2021.11.9.1', now());
INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (5, UUID(), 'memory','Linux User RAM - percentage', '1.3.6.1.4.1.2021.11.10.1', now()); INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (5, UUID(), 'memory','Linux User RAM - percentage - native', '1.3.6.1.4.1.2021.11.10.1', now());
CREATE TABLE `cloud`.`user_ipv6_address` ( CREATE TABLE `cloud`.`user_ipv6_address` (
`id` bigint unsigned NOT NULL UNIQUE auto_increment, `id` bigint unsigned NOT NULL UNIQUE auto_increment,