cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [06/50] [abbrv] git commit: updated refs/heads/marvin_refactor to 30e2971
Date Fri, 12 Apr 2013 11:58:39 GMT
Separated out host anti-affinity as a plugin.


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

Branch: refs/heads/marvin_refactor
Commit: bf9221a370da0c0720f1411f50738ab7d6d98ab5
Parents: fe2a868
Author: Prachi Damle <prachi@cloud.com>
Authored: Thu Mar 14 17:20:42 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu Apr 11 13:22:45 2013 -0700

----------------------------------------------------------------------
 .../host-anti-affinity/pom.xml                     |   33 +++++++
 .../affinity/HostAntiAffinityProcessor.java        |   66 +++++++++++++++
 plugins/pom.xml                                    |    1 +
 .../affinity/HostAntiAffinityProcessor.java        |   66 ---------------
 4 files changed, 100 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf9221a3/plugins/affinity-group-processors/host-anti-affinity/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/affinity-group-processors/host-anti-affinity/pom.xml b/plugins/affinity-group-processors/host-anti-affinity/pom.xml
new file mode 100644
index 0000000..669febd
--- /dev/null
+++ b/plugins/affinity-group-processors/host-anti-affinity/pom.xml
@@ -0,0 +1,33 @@
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cloud-plugin-host-anti-affinity</artifactId>
+  <name>Apache CloudStack Plugin - Host Anti-Affinity Processor</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-plugins</artifactId>
+    <version>4.2.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <sourceDirectory>src</sourceDirectory>    
+  </build>  
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf9221a3/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
new file mode 100644
index 0000000..93bd358
--- /dev/null
+++ b/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
@@ -0,0 +1,66 @@
+package org.apache.cloudstack.affinity;
+
+import java.util.List;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
+import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
+import org.apache.log4j.Logger;
+
+import com.cloud.deploy.DeploymentPlan;
+import com.cloud.deploy.DeploymentPlanner.ExcludeList;
+import com.cloud.exception.AffinityConflictException;
+import com.cloud.utils.component.AdapterBase;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.UserVmDao;
+import com.cloud.vm.dao.VMInstanceDao;
+
+@Local(value = AffinityGroupProcessor.class)
+public class HostAntiAffinityProcessor extends AdapterBase implements AffinityGroupProcessor
{
+
+    private static final Logger s_logger = Logger.getLogger(HostAntiAffinityProcessor.class);
+    @Inject
+    protected UserVmDao _vmDao;
+    @Inject
+    protected VMInstanceDao _vmInstanceDao;
+    @Inject
+    protected AffinityGroupDao _affinityGroupDao;
+    @Inject
+    protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
+
+    @Override
+    public void process(VirtualMachineProfile<? extends VirtualMachine> vmProfile,
DeploymentPlan plan,
+            ExcludeList avoid)
+            throws AffinityConflictException {
+        VirtualMachine vm = vmProfile.getVirtualMachine();
+        AffinityGroupVMMapVO vmGroupMapping = _affinityGroupVMMapDao.findByVmIdType(vm.getId(),
getType());
+
+        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());
+            }
+
+            List<Long> groupVMIds = _affinityGroupVMMapDao.listVmIdsByAffinityGroup(group.getId());
+
+            for (Long groupVMId : groupVMIds) {
+                VMInstanceVO groupVM = _vmInstanceDao.findById(groupVMId);
+                if (groupVM != null && !groupVM.isRemoved() && groupVM.getHostId()
!= null) {
+                    avoid.addHost(groupVM.getHostId());
+                }
+            }
+        }
+
+    }
+
+    @Override
+    public String getType() {
+        return "HostAntiAffinity";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf9221a3/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 607c50c..12c85ff 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -36,6 +36,7 @@
     <module>api/rate-limit</module>
     <module>api/discovery</module>
     <module>acl/static-role-based</module>
+	<module>affinity-group-processors/host-anti-affinity</module>
     <module>deployment-planners/user-concentrated-pod</module>
     <module>deployment-planners/user-dispersing</module>
     <module>host-allocators/random</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf9221a3/server/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java b/server/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
deleted file mode 100644
index 93bd358..0000000
--- a/server/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.apache.cloudstack.affinity;
-
-import java.util.List;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
-import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
-import org.apache.log4j.Logger;
-
-import com.cloud.deploy.DeploymentPlan;
-import com.cloud.deploy.DeploymentPlanner.ExcludeList;
-import com.cloud.exception.AffinityConflictException;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.vm.VMInstanceVO;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.dao.UserVmDao;
-import com.cloud.vm.dao.VMInstanceDao;
-
-@Local(value = AffinityGroupProcessor.class)
-public class HostAntiAffinityProcessor extends AdapterBase implements AffinityGroupProcessor
{
-
-    private static final Logger s_logger = Logger.getLogger(HostAntiAffinityProcessor.class);
-    @Inject
-    protected UserVmDao _vmDao;
-    @Inject
-    protected VMInstanceDao _vmInstanceDao;
-    @Inject
-    protected AffinityGroupDao _affinityGroupDao;
-    @Inject
-    protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
-
-    @Override
-    public void process(VirtualMachineProfile<? extends VirtualMachine> vmProfile,
DeploymentPlan plan,
-            ExcludeList avoid)
-            throws AffinityConflictException {
-        VirtualMachine vm = vmProfile.getVirtualMachine();
-        AffinityGroupVMMapVO vmGroupMapping = _affinityGroupVMMapDao.findByVmIdType(vm.getId(),
getType());
-
-        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());
-            }
-
-            List<Long> groupVMIds = _affinityGroupVMMapDao.listVmIdsByAffinityGroup(group.getId());
-
-            for (Long groupVMId : groupVMIds) {
-                VMInstanceVO groupVM = _vmInstanceDao.findById(groupVMId);
-                if (groupVM != null && !groupVM.isRemoved() && groupVM.getHostId()
!= null) {
-                    avoid.addHost(groupVM.getHostId());
-                }
-            }
-        }
-
-    }
-
-    @Override
-    public String getType() {
-        return "HostAntiAffinity";
-    }
-
-}


Mime
View raw message