cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [45/50] [abbrv] git commit: updated refs/heads/rbd-snap-clone to bc82173
Date Sat, 18 May 2013 12:57:10 GMT
CLOUDSTACK-2102: Anti-Affinity - Even after reserved capacity has been released for a Vm in
"Stopped" state , we are not allowed to deploy new Vms as part of same anti-affinity group
in the last_host_id where the stopped Vm was running.

Changes:
Do not add the last_host_id of a Stopped VM to avoid set, if the VM has been stopped for more
that capacity.skip.counting.hours time limit


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/55c1e282
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/55c1e282
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/55c1e282

Branch: refs/heads/rbd-snap-clone
Commit: 55c1e282e390e95a2639df28e1cfd743772ee001
Parents: 5646f5e
Author: Prachi Damle <prachi@cloud.com>
Authored: Fri May 17 11:39:20 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Fri May 17 11:40:00 2013 -0700

----------------------------------------------------------------------
 .../affinity/HostAntiAffinityProcessor.java        |   31 ++++++++++++---
 1 files changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55c1e282/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
b/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
index 4c2c7f1..6c3f57f 100644
--- a/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
+++ b/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
@@ -17,17 +17,24 @@
 package org.apache.cloudstack.affinity;
 
 import java.util.List;
+import java.util.Map;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
+import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
 import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
+import org.apache.cloudstack.framework.messagebus.MessageSubscriber;
 import org.apache.log4j.Logger;
 
+import com.cloud.configuration.Config;
+import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.deploy.DeploymentPlan;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.exception.AffinityConflictException;
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.NumbersUtil;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
@@ -46,7 +53,10 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements
     protected AffinityGroupDao _affinityGroupDao;
     @Inject
     protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
-
+    private int _vmCapacityReleaseInterval;
+    @Inject 
+    protected ConfigurationDao _configDao;
+    
     @Override
     public void process(VirtualMachineProfile<? extends VirtualMachine> vmProfile,
DeploymentPlan plan,
             ExcludeList avoid)
@@ -76,12 +86,14 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements
                             }
                         } else if (VirtualMachine.State.Stopped.equals(groupVM.getState())
                                 && groupVM.getLastHostId() != null) {
-                            avoid.addHost(groupVM.getLastHostId());
-                            if (s_logger.isDebugEnabled()) {
-                                s_logger.debug("Added host " + groupVM.getLastHostId() +
" to avoid set, since VM "
-                                        + groupVM.getId() + " is present on the host, in
Stopped state");
+                            long secondsSinceLastUpdate = (DateUtil.currentGMTTime().getTime()
- groupVM.getUpdateTime().getTime()) / 1000;
+                            if (secondsSinceLastUpdate < _vmCapacityReleaseInterval) {
+                                avoid.addHost(groupVM.getLastHostId());
+                                if (s_logger.isDebugEnabled()) {
+                                    s_logger.debug("Added host " + groupVM.getLastHostId()
+ " to avoid set, since VM "
+                                            + groupVM.getId() + " is present on the host,
in Stopped state but has reserved capacity");
+                                }
                             }
-
                         }
                     }
                 }
@@ -89,5 +101,12 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements
         }
 
     }
+    
+    @Override
+    public boolean configure(final String name, final Map<String, Object> params) throws
ConfigurationException {
+        super.configure(name, params);
+        _vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()),3600);
+        return true;
+    }
 
 }


Mime
View raw message