cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject git commit: updated refs/heads/4.2 to 04abb82
Date Mon, 12 Aug 2013 19:33:52 GMT
Updated Branches:
  refs/heads/4.2 12b05cfbc -> 04abb8278


CLOUDSTACK-4222: [VMWare] NPE: VM Failed to start after Volume Migration

- ExplicitDedicationProcessor should process only if group of this type is used!


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

Branch: refs/heads/4.2
Commit: 04abb82786cf6e2060f2bea647a1c7ff966b0d46
Parents: 12b05cf
Author: Prachi Damle <prachi@cloud.com>
Authored: Mon Aug 12 12:16:36 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Mon Aug 12 12:16:36 2013 -0700

----------------------------------------------------------------------
 .../affinity/ExplicitDedicationProcessor.java   | 257 ++++++++++---------
 1 file changed, 130 insertions(+), 127 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/04abb827/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java
b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java
index 3489b57..364c057 100644
--- a/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java
+++ b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java
@@ -93,169 +93,172 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase
implement
         DataCenter dc = _dcDao.findById(vm.getDataCenterId());
         List<DedicatedResourceVO> resourceList = new ArrayList<DedicatedResourceVO>();
 
-        for (AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
-            if (vmGroupMapping != null) {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Processing affinity group " + vmGroupMapping.getAffinityGroupId()
-                            + "of type 'ExplicitDedication' for VM Id: " + vm.getId());
-                }
+        if (vmGroupMappings != null && !vmGroupMappings.isEmpty()) {
 
-                long affinityGroupId = vmGroupMapping.getAffinityGroupId();
+            for (AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
+                if (vmGroupMapping != null) {
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Processing affinity group " + vmGroupMapping.getAffinityGroupId()
+                                + "of type 'ExplicitDedication' for VM Id: " + vm.getId());
+                    }
 
-                // List<DedicatedResourceVO> dr = _dedicatedDao.listByAccountId(accountId);
-                // List<DedicatedResourceVO> drOfDomain =
-                // searchInDomainResources(domainId);
-                // List<DedicatedResourceVO> drOfParentDomain =
-                // searchInParentDomainResources(domainId);
+                    long affinityGroupId = vmGroupMapping.getAffinityGroupId();
 
-                List<DedicatedResourceVO> dr = _dedicatedDao.listByAffinityGroupId(affinityGroupId);
-                resourceList.addAll(dr);
+                    // List<DedicatedResourceVO> dr =
+                    // _dedicatedDao.listByAccountId(accountId);
+                    // List<DedicatedResourceVO> drOfDomain =
+                    // searchInDomainResources(domainId);
+                    // List<DedicatedResourceVO> drOfParentDomain =
+                    // searchInParentDomainResources(domainId);
 
-            }
-        }
+                    List<DedicatedResourceVO> dr = _dedicatedDao.listByAffinityGroupId(affinityGroupId);
+                    resourceList.addAll(dr);
 
-        boolean canUse = false;
-
-        if (plan.getHostId() != null) {
-            HostVO host = _hostDao.findById(plan.getHostId());
-            ClusterVO clusterofHost = _clusterDao.findById(host.getClusterId());
-            HostPodVO podOfHost = _podDao.findById(host.getPodId());
-            DataCenterVO zoneOfHost = _dcDao.findById(host.getDataCenterId());
-            if (resourceList != null && resourceList.size() != 0) {
-                for (DedicatedResourceVO resource : resourceList) {
-                    if ((resource.getHostId() != null && resource.getHostId() ==
plan.getHostId())
-                            || (resource.getClusterId() != null && resource.getClusterId()
== clusterofHost.getId())
-                            || (resource.getPodId() != null && resource.getPodId()
== podOfHost.getId())
-                            || (resource.getDataCenterId() != null && resource.getDataCenterId()
== zoneOfHost.getId())) {
-                        canUse = true;
-                    }
                 }
             }
-            if (!canUse) {
-                throw new CloudRuntimeException("Cannot use this host " + host.getName()
+ " for explicit dedication");
-            }
-        } else if (plan.getClusterId() != null) {
-            ClusterVO cluster = _clusterDao.findById(plan.getClusterId());
-            HostPodVO podOfCluster = _podDao.findById(cluster.getPodId());
-            DataCenterVO zoneOfCluster = _dcDao.findById(cluster.getDataCenterId());
-            List<HostVO> hostToUse = new ArrayList<HostVO>();
-            // check whether this cluster or its pod is dedicated
-            if (resourceList != null && resourceList.size() != 0) {
-                for (DedicatedResourceVO resource : resourceList) {
-                    if ((resource.getClusterId() != null && resource.getClusterId()
== cluster.getId())
-                            || (resource.getPodId() != null && resource.getPodId()
== podOfCluster.getId())
-                            || (resource.getDataCenterId() != null && resource.getDataCenterId()
== zoneOfCluster
-                                    .getId())) {
-                        canUse = true;
+
+            boolean canUse = false;
+
+            if (plan.getHostId() != null) {
+                HostVO host = _hostDao.findById(plan.getHostId());
+                ClusterVO clusterofHost = _clusterDao.findById(host.getClusterId());
+                HostPodVO podOfHost = _podDao.findById(host.getPodId());
+                DataCenterVO zoneOfHost = _dcDao.findById(host.getDataCenterId());
+                if (resourceList != null && resourceList.size() != 0) {
+                    for (DedicatedResourceVO resource : resourceList) {
+                        if ((resource.getHostId() != null && resource.getHostId()
== plan.getHostId())
+                                || (resource.getClusterId() != null && resource.getClusterId()
== clusterofHost.getId())
+                                || (resource.getPodId() != null && resource.getPodId()
== podOfHost.getId())
+                                || (resource.getDataCenterId() != null && resource.getDataCenterId()
== zoneOfHost
+                                        .getId())) {
+                            canUse = true;
+                        }
                     }
+                }
+                if (!canUse) {
+                    throw new CloudRuntimeException("Cannot use this host " + host.getName()
+                            + " for explicit dedication");
+                }
+            } else if (plan.getClusterId() != null) {
+                ClusterVO cluster = _clusterDao.findById(plan.getClusterId());
+                HostPodVO podOfCluster = _podDao.findById(cluster.getPodId());
+                DataCenterVO zoneOfCluster = _dcDao.findById(cluster.getDataCenterId());
+                List<HostVO> hostToUse = new ArrayList<HostVO>();
+                // check whether this cluster or its pod is dedicated
+                if (resourceList != null && resourceList.size() != 0) {
+                    for (DedicatedResourceVO resource : resourceList) {
+                        if ((resource.getClusterId() != null && resource.getClusterId()
== cluster.getId())
+                                || (resource.getPodId() != null && resource.getPodId()
== podOfCluster.getId())
+                                || (resource.getDataCenterId() != null && resource.getDataCenterId()
== zoneOfCluster
+                                        .getId())) {
+                            canUse = true;
+                        }
 
-                    // check for all dedicated host; if it belongs to this
-                    // cluster
-                    if (!canUse) {
-                        if (resource.getHostId() != null) {
-                            HostVO dHost = _hostDao.findById(resource.getHostId());
-                            if (dHost.getClusterId() == cluster.getId()) {
-                                hostToUse.add(dHost);
+                        // check for all dedicated host; if it belongs to this
+                        // cluster
+                        if (!canUse) {
+                            if (resource.getHostId() != null) {
+                                HostVO dHost = _hostDao.findById(resource.getHostId());
+                                if (dHost.getClusterId() == cluster.getId()) {
+                                    hostToUse.add(dHost);
+                                }
                             }
                         }
-                    }
 
+                    }
                 }
-            }
 
-            if (hostToUse.isEmpty() && !canUse) {
-                throw new CloudRuntimeException("Cannot use this cluster " + cluster.getName()
-                        + " for explicit dedication");
-            }
+                if (hostToUse.isEmpty() && !canUse) {
+                    throw new CloudRuntimeException("Cannot use this cluster " + cluster.getName()
+                            + " for explicit dedication");
+                }
 
-            if (hostToUse != null && hostToUse.size() != 0) {
-                // add other non-dedicated hosts to avoid list
-                List<HostVO> hostList = _hostDao.findByClusterId(cluster.getId());
-                for (HostVO host : hostList) {
-                    if (!hostToUse.contains(host)) {
-                        avoid.addHost(host.getId());
+                if (hostToUse != null && hostToUse.size() != 0) {
+                    // add other non-dedicated hosts to avoid list
+                    List<HostVO> hostList = _hostDao.findByClusterId(cluster.getId());
+                    for (HostVO host : hostList) {
+                        if (!hostToUse.contains(host)) {
+                            avoid.addHost(host.getId());
+                        }
                     }
                 }
-            }
 
-        } else if (plan.getPodId() != null) {
-            HostPodVO pod = _podDao.findById(plan.getPodId());
-            DataCenterVO zoneOfPod = _dcDao.findById(pod.getDataCenterId());
-            List<ClusterVO> clustersToUse = new ArrayList<ClusterVO>();
-            List<HostVO> hostsToUse = new ArrayList<HostVO>();
-            // check whether this cluster or its pod is dedicated
-            if (resourceList != null && resourceList.size() != 0) {
-                for (DedicatedResourceVO resource : resourceList) {
-                    if ((resource.getPodId() != null && resource.getPodId() == pod.getId())
-                            || (resource.getDataCenterId() != null && resource.getDataCenterId()
== zoneOfPod.getId())) {
-                        canUse = true;
-                    }
+            } else if (plan.getPodId() != null) {
+                HostPodVO pod = _podDao.findById(plan.getPodId());
+                DataCenterVO zoneOfPod = _dcDao.findById(pod.getDataCenterId());
+                List<ClusterVO> clustersToUse = new ArrayList<ClusterVO>();
+                List<HostVO> hostsToUse = new ArrayList<HostVO>();
+                // check whether this cluster or its pod is dedicated
+                if (resourceList != null && resourceList.size() != 0) {
+                    for (DedicatedResourceVO resource : resourceList) {
+                        if ((resource.getPodId() != null && resource.getPodId() ==
pod.getId())
+                                || (resource.getDataCenterId() != null && resource.getDataCenterId()
== zoneOfPod
+                                        .getId())) {
+                            canUse = true;
+                        }
 
-                    // check for all dedicated cluster/host; if it belongs to
-                    // this pod
-                    if (!canUse) {
-                        if (resource.getClusterId() != null) {
-                            ClusterVO dCluster = _clusterDao.findById(resource.getClusterId());
-                            if (dCluster.getPodId() == pod.getId()) {
-                                clustersToUse.add(dCluster);
+                        // check for all dedicated cluster/host; if it belongs
+                        // to
+                        // this pod
+                        if (!canUse) {
+                            if (resource.getClusterId() != null) {
+                                ClusterVO dCluster = _clusterDao.findById(resource.getClusterId());
+                                if (dCluster.getPodId() == pod.getId()) {
+                                    clustersToUse.add(dCluster);
+                                }
                             }
-                        }
-                        if (resource.getHostId() != null) {
-                            HostVO dHost = _hostDao.findById(resource.getHostId());
-                            if (dHost.getPodId() == pod.getId()) {
-                                hostsToUse.add(dHost);
+                            if (resource.getHostId() != null) {
+                                HostVO dHost = _hostDao.findById(resource.getHostId());
+                                if (dHost.getPodId() == pod.getId()) {
+                                    hostsToUse.add(dHost);
+                                }
                             }
                         }
+
                     }
+                }
 
+                if (hostsToUse.isEmpty() && clustersToUse.isEmpty() && !canUse)
{
+                    throw new CloudRuntimeException("Cannot use this pod " + pod.getName()
+ " for explicit dedication");
                 }
-            }
 
-            if (hostsToUse.isEmpty() && clustersToUse.isEmpty() && !canUse)
{
-                throw new CloudRuntimeException("Cannot use this pod " + pod.getName() +
" for explicit dedication");
-            }
+                if (clustersToUse != null && clustersToUse.size() != 0) {
+                    // add other non-dedicated clusters to avoid list
+                    List<ClusterVO> clusterList = _clusterDao.listByPodId(pod.getId());
+                    for (ClusterVO cluster : clusterList) {
+                        if (!clustersToUse.contains(cluster)) {
+                            avoid.addCluster(cluster.getId());
+                        }
+                    }
+                }
 
-            if (clustersToUse != null && clustersToUse.size() != 0) {
-                // add other non-dedicated clusters to avoid list
-                List<ClusterVO> clusterList = _clusterDao.listByPodId(pod.getId());
-                for (ClusterVO cluster : clusterList) {
-                    if (!clustersToUse.contains(cluster)) {
-                        avoid.addCluster(cluster.getId());
+                if (hostsToUse != null && hostsToUse.size() != 0) {
+                    // add other non-dedicated hosts to avoid list
+                    List<HostVO> hostList = _hostDao.findByPodId(pod.getId());
+                    for (HostVO host : hostList) {
+                        if (!hostsToUse.contains(host)) {
+                            avoid.addHost(host.getId());
+                        }
                     }
                 }
-            }
 
-            if (hostsToUse != null && hostsToUse.size() != 0) {
-                // add other non-dedicated hosts to avoid list
-                List<HostVO> hostList = _hostDao.findByPodId(pod.getId());
-                for (HostVO host : hostList) {
-                    if (!hostsToUse.contains(host)) {
-                        avoid.addHost(host.getId());
+            } else {
+                // check all resources under this zone
+                if (resourceList != null && resourceList.size() != 0) {
+                    avoid = updateAvoidList(resourceList, avoid, dc);
+                } else {
+                    avoid.addDataCenter(dc.getId());
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("No dedicated resources available for this domain
or account under this group");
                     }
                 }
-            }
 
-        } else {
-            // check all resources under this zone
-            if (resourceList != null && resourceList.size() != 0) {
-                avoid = updateAvoidList(resourceList, avoid, dc);
-            } /*
-               * else if(drOfDomain != null && drOfDomain.size() != 0){ avoid =
-               * updateAvoidList(drOfDomain, avoid, dc); } else
-               * if(drOfParentDomain != null && drOfParentDomain.size() != 0){
-               * avoid = updateAvoidList(drOfParentDomain, avoid, dc); }
-               */else {
-                avoid.addDataCenter(dc.getId());
                 if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("No dedicated resources available for this domain or account
under this group");
+                    s_logger.debug("ExplicitDedicationProcessor returns Avoid List as: Deploy
avoids pods: "
+                            + avoid.getPodsToAvoid() + ", clusters: " + avoid.getClustersToAvoid()
+ ", hosts: "
+                            + avoid.getHostsToAvoid());
                 }
             }
-
-            if (s_logger.isDebugEnabled()) {
-                s_logger.debug("ExplicitDedicationProcessor returns Avoid List as: Deploy
avoids pods: "
-                        + avoid.getPodsToAvoid() + ", clusters: " + avoid.getClustersToAvoid()
+ ", hosts: "
-                        + avoid.getHostsToAvoid());
-            }
         }
 
     }


Mime
View raw message