You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by tu...@apache.org on 2013/12/10 05:52:11 UTC
[4/9] git commit: updated refs/heads/master to ccfe557
fix duration
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0b0e2627
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0b0e2627
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0b0e2627
Branch: refs/heads/master
Commit: 0b0e2627d632828a1d17fd0fbd1f51dabced8fe8
Parents: fca6d56
Author: tuna <ng...@gmail.com>
Authored: Mon Oct 14 17:54:12 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Tue Dec 10 10:36:30 2013 +0700
----------------------------------------------------------------------
server/src/com/cloud/server/StatsCollector.java | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0b0e2627/server/src/com/cloud/server/StatsCollector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java
index 89685df..33597e0 100755
--- a/server/src/com/cloud/server/StatsCollector.java
+++ b/server/src/com/cloud/server/StatsCollector.java
@@ -767,7 +767,11 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
AutoScalePolicyVO policyVO = _asPolicyDao.findById(asVmgPmap.getPolicyId());
if (policyVO != null) {
Integer quitetime = policyVO.getQuietTime();
- long last_quitetime = policyVO.getLastQuiteTime().getTime();
+ Date quitetimeDate = policyVO.getLastQuiteTime();
+ long last_quitetime = 0L;
+ if (quitetimeDate != null) {
+ last_quitetime = policyVO.getLastQuiteTime().getTime();
+ }
long current_time = (new Date()).getTime();
// check quite time for this policy
@@ -779,16 +783,17 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
if ((lstConditions != null) && (lstConditions.size() > 0)) {
// check whole conditions of this policy
for (ConditionVO conditionVO : lstConditions) {
- long threholdValue = conditionVO.getThreshold();
+ long thresholdValue = conditionVO.getThreshold();
+ Double thresholdPercent = (double)thresholdValue / 100;
Double sum = avgCounter.get(conditionVO.getCounterid());
Double avg = sum/ currentVM;
Operator op = conditionVO.getRelationalOperator();
- boolean bConditionCheck = ((op == com.cloud.network.as.Condition.Operator.EQ) && (threholdValue == avg))
- || ((op == com.cloud.network.as.Condition.Operator.GE) && (avg >= threholdValue))
- || ((op == com.cloud.network.as.Condition.Operator.GT) && (avg > threholdValue))
- || ((op == com.cloud.network.as.Condition.Operator.LE) && (avg <= threholdValue))
- || ((op == com.cloud.network.as.Condition.Operator.LT) && (avg < threholdValue));
+ 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.GT) && (avg > thresholdPercent))
+ || ((op == com.cloud.network.as.Condition.Operator.LE) && (avg <= thresholdPercent))
+ || ((op == com.cloud.network.as.Condition.Operator.LT) && (avg < thresholdPercent));
if (!bConditionCheck) {
bValid = false;