cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [05/21] git commit: updated refs/heads/ui-vm-affinity to 6629eb7
Date Fri, 12 Apr 2013 17:37:51 GMT
Single AffinityGroupProcessor could process multiple groups of same type.


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

Branch: refs/heads/ui-vm-affinity
Commit: c1a85401ae6f7387341c529f829fe5578a15ec5a
Parents: 370a7fd
Author: Prachi Damle <prachi@cloud.com>
Authored: Thu Apr 11 17:18:24 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu Apr 11 17:29:42 2013 -0700

----------------------------------------------------------------------
 .../affinity/HostAntiAffinityProcessor.java        |   50 ++++++++-------
 .../affinity/dao/AffinityGroupVMMapDao.java        |    2 +-
 .../affinity/dao/AffinityGroupVMMapDaoImpl.java    |    4 +-
 3 files changed, 29 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1a85401/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 430cf92..4c2c7f1 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
@@ -52,35 +52,37 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements
             ExcludeList avoid)
             throws AffinityConflictException {
         VirtualMachine vm = vmProfile.getVirtualMachine();
-        AffinityGroupVMMapVO vmGroupMapping = _affinityGroupVMMapDao.findByVmIdType(vm.getId(),
getType());
+        List<AffinityGroupVMMapVO> vmGroupMappings = _affinityGroupVMMapDao.findByVmIdType(vm.getId(),
getType());
 
-        if (vmGroupMapping != null) {
-            AffinityGroupVO group = _affinityGroupDao.findById(vmGroupMapping.getAffinityGroupId());
+        for (AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
+            if (vmGroupMapping != null) {
+                AffinityGroupVO group = _affinityGroupDao.findById(vmGroupMapping.getAffinityGroupId());
 
-            if (s_logger.isDebugEnabled()) {
-                s_logger.debug("Processing affinity group " + group.getName() + " for VM
Id: " + vm.getId());
-            }
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Processing affinity group " + group.getName() + " for
VM Id: " + vm.getId());
+                }
 
-            List<Long> groupVMIds = _affinityGroupVMMapDao.listVmIdsByAffinityGroup(group.getId());
-            groupVMIds.remove(vm.getId());
+                List<Long> groupVMIds = _affinityGroupVMMapDao.listVmIdsByAffinityGroup(group.getId());
+                groupVMIds.remove(vm.getId());
 
-            for (Long groupVMId : groupVMIds) {
-                VMInstanceVO groupVM = _vmInstanceDao.findById(groupVMId);
-                if (groupVM != null && !groupVM.isRemoved()) {
-                    if (groupVM.getHostId() != null) {
-                        avoid.addHost(groupVM.getHostId());
-                        if (s_logger.isDebugEnabled()) {
-                            s_logger.debug("Added host " + groupVM.getHostId() + " to avoid
set, since VM "
-                                    + groupVM.getId() + " is present on the host");
-                        }
-                    } 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");
-                        }
+                for (Long groupVMId : groupVMIds) {
+                    VMInstanceVO groupVM = _vmInstanceDao.findById(groupVMId);
+                    if (groupVM != null && !groupVM.isRemoved()) {
+                        if (groupVM.getHostId() != null) {
+                            avoid.addHost(groupVM.getHostId());
+                            if (s_logger.isDebugEnabled()) {
+                                s_logger.debug("Added host " + groupVM.getHostId() + " to
avoid set, since VM "
+                                        + groupVM.getId() + " is present on the host");
+                            }
+                        } 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");
+                            }
 
+                        }
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1a85401/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDao.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDao.java b/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDao.java
index a98ae0f..f2951bc 100644
--- a/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDao.java
+++ b/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDao.java
@@ -41,7 +41,7 @@ public interface AffinityGroupVMMapDao extends GenericDao<AffinityGroupVMMapVO,
 
     int deleteVM(long instanceId);
 
-    AffinityGroupVMMapVO findByVmIdType(long instanceId, String type);
+    List<AffinityGroupVMMapVO> findByVmIdType(long instanceId, String type);
 
     void updateMap(Long vmId, List<Long> affinityGroupIds);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1a85401/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java
b/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java
index abc2a2b..e03e73c 100644
--- a/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java
+++ b/server/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java
@@ -140,11 +140,11 @@ public class AffinityGroupVMMapDaoImpl extends GenericDaoBase<AffinityGroupVMMap
 	}
 
     @Override
-    public AffinityGroupVMMapVO findByVmIdType(long instanceId, String type) {
+    public List<AffinityGroupVMMapVO> findByVmIdType(long instanceId, String type)
{
         SearchCriteria<AffinityGroupVMMapVO> sc = ListByVmIdType.create();
         sc.setParameters("instanceId", instanceId);
         sc.setJoinParameters("groupSearch", "type", type);
-        return findOneBy(sc);
+        return listBy(sc);
     }
 
     @Override


Mime
View raw message