incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject git commit: Moved out user concentrated pod deployment planner to plugins/deployment-planners/user-concentrated-pod
Date Tue, 26 Jun 2012 00:56:19 GMT
Updated Branches:
  refs/heads/master 392ae5cb1 -> 621f2447b


Moved out user concentrated pod deployment planner to plugins/deployment-planners/user-concentrated-pod


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

Branch: refs/heads/master
Commit: 621f2447bb8f759c5d09f2fc28b446744716b1b9
Parents: 392ae5c
Author: Murali reddy <Murali.Reddy@citrix.com>
Authored: Mon Jun 25 17:58:45 2012 -0700
Committer: Murali reddy <Murali.Reddy@citrix.com>
Committed: Mon Jun 25 17:58:45 2012 -0700

----------------------------------------------------------------------
 build/build-cloud.xml                              |   12 +-
 .../user-concentrated-pod/.classpath               |   10 +
 .../user-concentrated-pod/.project                 |   17 ++
 .../user-concentrated-pod/build.xml                |  128 ++++++++++++
 .../cloud/deploy/UserConcentratedPodPlanner.java   |  151 +++++++++++++++
 .../deployment-planners/user-dispersing/.classpath |    2 +-
 .../cloud/deploy/UserConcentratedPodPlanner.java   |  151 ---------------
 7 files changed, 316 insertions(+), 155 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/621f2447/build/build-cloud.xml
----------------------------------------------------------------------
diff --git a/build/build-cloud.xml b/build/build-cloud.xml
index 2b66801..68962ff 100755
--- a/build/build-cloud.xml
+++ b/build/build-cloud.xml
@@ -479,7 +479,7 @@
 
   <target name="build-servers" depends="-init, build-server" />
 
-  <target name="build-opensource" depends="-init, build-server, build-agent, build-scripts,
build-ui, build-console-proxy, build-ovm, package-oss-systemvm-iso, build-netscaler, build-f5,
build-srx, build-dp-user-dispersing">
+  <target name="build-opensource" depends="-init, build-server, build-agent, build-scripts,
build-ui, build-console-proxy, build-ovm, package-oss-systemvm-iso, build-netscaler, build-f5,
build-srx, build-dp-user-dispersing, build-dp-user-concentrated-pod">
     <copy overwrite="true" todir="${dist.dir}">
       <fileset dir="${base.dir}/build/deploy/">
         <include name="deploy-agent.sh" />
@@ -598,13 +598,19 @@
   </target>
   <target name="build-ovm" depends="compile-ovm" />
 
-  <!-- =====================cloud-dp-user-dispersing.jar.Jar ===================== -->
+  <!-- =====================cloud-dp-user-dispersing.Jar ===================== -->
   <target name="compile-dp-user-dispersing" depends="-init, compile-server" description="Compile
dp-user-dispersing">
   	<ant antfile="${base.dir}/plugins/deployment-planners/user-dispersing/build.xml" target="build"/>
   </target>
   <target name="build-dp-user-dispersing" depends="compile-dp-user-dispersing" />
 
-  <!-- ===================== Cloud-Plugin-Netscaler.Jar ===================== -->
+  <!-- =====================cloud-dp-user-concentrated-pod.Jar ===================== -->
+  <target name="compile-dp-user-concentrated-pod" depends="-init, compile-server" description="Compile
">
+  	<ant antfile="${base.dir}/plugins/deployment-planners/user-concentrated-pod/build.xml"
target="build"/>
+  </target>
+  <target name="build-dp-user-concentrated-pod" depends="compile-dp-user-concentrated-pod"
/>
+ 
+ <!-- ===================== Cloud-Plugin-Netscaler.Jar ===================== -->
   <target name="compile-netscaler" depends="-init, compile-server" description="Compile
NetScaler plugin">
   	<ant antfile="${base.dir}/plugins/network-elements/netscaler/build.xml" target="build"/>
   </target>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/621f2447/plugins/deployment-planners/user-concentrated-pod/.classpath
----------------------------------------------------------------------
diff --git a/plugins/deployment-planners/user-concentrated-pod/.classpath b/plugins/deployment-planners/user-concentrated-pod/.classpath
new file mode 100755
index 0000000..e39771a
--- /dev/null
+++ b/plugins/deployment-planners/user-concentrated-pod/.classpath
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/api"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/core"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/server"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/621f2447/plugins/deployment-planners/user-concentrated-pod/.project
----------------------------------------------------------------------
diff --git a/plugins/deployment-planners/user-concentrated-pod/.project b/plugins/deployment-planners/user-concentrated-pod/.project
new file mode 100755
index 0000000..c0cec7e
--- /dev/null
+++ b/plugins/deployment-planners/user-concentrated-pod/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>user-concentrated-pod-dp</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/621f2447/plugins/deployment-planners/user-concentrated-pod/build.xml
----------------------------------------------------------------------
diff --git a/plugins/deployment-planners/user-concentrated-pod/build.xml b/plugins/deployment-planners/user-concentrated-pod/build.xml
new file mode 100755
index 0000000..29d4595
--- /dev/null
+++ b/plugins/deployment-planners/user-concentrated-pod/build.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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 name="Cloud Stack User Concentrated Pod Deployment Planner" default="help" basedir=".">
+  <description>
+		Cloud Stack ant build file
+    </description>
+
+  <dirname property="dp-user-concentrated-pod.base.dir" file="${ant.file.Cloud Stack User
Concentrated Pod Deployment Planner}/"/>
+  <!-- This directory must be set -->
+  <property name="top.dir" location="${dp-user-concentrated-pod.base.dir}/../../.."/>
+  <property name="build.dir" location="${top.dir}/build"/>
+	
+	<echo message="build.dir=${build.dir}; top.dir=${top.dir}; dp-user-concentrated-pod.base.dir=${dp-user-concentrated-pod.base.dir}"/>
+
+  <!-- Import anything that the user wants to set-->
+  <!-- Import properties files and environment variables here -->
+
+  <property environment="env" />
+
+  <condition property="build-cloud.properties.file" value="${build.dir}/override/build-cloud.properties"
else="${build.dir}/build-cloud.properties">
+    <available file="${build.dir}/override/build-cloud.properties" />
+  </condition>
+
+  <condition property="cloud.properties.file" value="${build.dir}/override/cloud.properties"
else="${build.dir}/cloud.properties">
+    <available file="${build.dir}/override/cloud.properties" />
+  </condition>
+
+  <condition property="override.file" value="${build.dir}/override/replace.properties"
else="${build.dir}/replace.properties">
+    <available file="${build.dir}/override/replace.properties" />
+  </condition>
+
+  <echo message="Using build parameters from ${build-cloud.properties.file}" />
+  <property file="${build-cloud.properties.file}" />
+
+  <echo message="Using company info from ${cloud.properties.file}" />
+  <property file="${cloud.properties.file}" />
+
+  <echo message="Using override file from ${override.file}" />
+  <property file="${override.file}" />
+
+  <property file="${build.dir}/build.number" />
+
+  <!-- In case these didn't get defined in the build-cloud.properties -->
+  <property name="branding.name" value="default" />
+  <property name="deprecation" value="off" />
+  <property name="target.compat.version" value="1.6" />
+  <property name="source.compat.version" value="1.6" />
+  <property name="debug" value="true" />
+  <property name="debuglevel" value="lines,source"/>
+
+  <echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
+  <!-- directories for build and distribution -->
+  <property name="target.dir" location="${top.dir}/target" />
+  <property name="classes.dir" location="${target.dir}/classes" />
+  <property name="jar.dir" location="${target.dir}/jar" />
+  <property name="dep.cache.dir" location="${target.dir}/dep-cache" />
+  <property name="build.log" location="${target.dir}/ant_verbose.txt" />
+
+  <property name="deps.dir" location="${top.dir}/deps" />
+  
+  <property name="dp-user-concentrated-pod.jar" value="cloud-dp-user-concentrated-pod.jar"
/>
+  <property name="dp-user-concentrated-pod-scripts.dir" location="${dp-user-concentrated-pod.base.dir}/scripts"
/>
+	
+  <import file="${build.dir}/build-common.xml"/>
+
+  <echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
+	
+  <!-- This section needs to be replaced by some kind of dependency library-->
+  <path id="deps.classpath">
+    <!--filelist files="${deps.classpath}" /-->
+    <fileset dir="${deps.dir}" erroronmissingdir="false">
+      <include name="*.jar" />
+    </fileset>
+  </path>
+	
+  <path id="cloudstack.classpath">
+  	<fileset dir="${jar.dir}">
+  	  <include name="*.jar"/>
+    </fileset>
+  </path>
+	
+  <path id="dp-user-concentrated-pod.classpath">
+	<path refid="deps.classpath"/>
+  	<path refid="cloudstack.classpath"/>
+  </path>
+	
+  <!-- This section needs to be replaced by some kind of dependency library-->
+	
+	
+  <target name="init" description="Initialize binaries directory">
+  	<mkdir dir="${classes.dir}/${user-concentrated-pod.jar}"/>
+  	<mkdir dir="${jar.dir}"/>
+  </target>
+	
+  <target name="compile-dp-user-concentrated-pod" depends="init" description="Compile
user-concentrated-pod">
+    <compile-java jar.name="${dp-user-concentrated-pod.jar}" top.dir="${dp-user-concentrated-pod.base.dir}"
classpath="dp-user-concentrated-pod.classpath" />
+  </target>
+	
+  <target name="help" description="help">
+    <echo level="info" message="This is the build file for dp-user-concentrated-pod."/>
+    <echo level="info" message="You can do a build by doing ant build or clean by ant
clean" />
+  </target>
+
+  <target name="clean-dp-user-concentrated-pod">
+    <delete dir="${classes.dir}/${dp-user-concentrated-pod.jar}"/>
+  </target>
+	
+  <target name="build" depends="compile-dp-user-concentrated-pod"/>
+  <target name="clean" depends="clean-dp-user-concentrated-pod"/>
+	
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/621f2447/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java
----------------------------------------------------------------------
diff --git a/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java
b/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java
new file mode 100644
index 0000000..2b28d19
--- /dev/null
+++ b/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java
@@ -0,0 +1,151 @@
+// Copyright 2012 Citrix Systems, Inc. Licensed under the
+// Apache License, Version 2.0 (the "License"); you may not use this
+// file except in compliance with the License.  Citrix Systems, Inc.
+// reserves all rights not expressly granted by 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.
+// 
+// Automatically generated by addcopyright.py at 04/03/2012
+package com.cloud.deploy;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.utils.Pair;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+
+@Local(value=DeploymentPlanner.class)
+public class UserConcentratedPodPlanner extends FirstFitPlanner implements DeploymentPlanner
{
+
+    private static final Logger s_logger = Logger.getLogger(UserConcentratedPodPlanner.class);
+    
+    /**
+     * This method should reorder the given list of Cluster Ids by applying any necessary
heuristic 
+     * for this planner
+     * For UserConcentratedPodPlanner we need to order the clusters in a zone across pods,
by considering those pods first which have more number of VMs for this account
+     * This reordering is not done incase the clusters within single pod are passed when
the allocation is applied at pod-level.
+     * @return List<Long> ordered list of Cluster Ids
+     */
+    @Override
+    protected List<Long> reorderClusters(long id, boolean isZone, Pair<List<Long>,
Map<Long, Double>> clusterCapacityInfo, VirtualMachineProfile<? extends VirtualMachine>
vmProfile, DeploymentPlan plan){
+        List<Long> clusterIdsByCapacity = clusterCapacityInfo.first();
+        if(vmProfile.getOwner() == null || !isZone){
+            return clusterIdsByCapacity;
+        }
+        return applyUserConcentrationPodHeuristicToClusters(id, clusterIdsByCapacity, vmProfile.getOwner().getAccountId());
+    }
+    
+    private List<Long> applyUserConcentrationPodHeuristicToClusters(long zoneId, List<Long>
prioritizedClusterIds, long accountId){
+        //user has VMs in certain pods. - prioritize those pods first
+        //UserConcentratedPod strategy
+        List<Long> clusterList = new ArrayList<Long>();
+        List<Long> podIds = listPodsByUserConcentration(zoneId, accountId);
+        if(!podIds.isEmpty()){
+            clusterList = reorderClustersByPods(prioritizedClusterIds, podIds);
+        }else{
+            clusterList = prioritizedClusterIds;
+        }
+        return clusterList;
+    }    
+    
+    private List<Long> reorderClustersByPods(List<Long> clusterIds, List<Long>
podIds) {
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Reordering cluster list as per pods ordered by user concentration");
+        }
+
+        Map<Long, List<Long>> podClusterMap = _clusterDao.getPodClusterIdMap(clusterIds);
+
+        if (s_logger.isTraceEnabled()) {
+            s_logger.trace("Pod To cluster Map is: "+podClusterMap );
+        }
+
+        List<Long> reorderedClusters = new ArrayList<Long>();
+        for (Long pod : podIds){
+            if(podClusterMap.containsKey(pod)){
+                List<Long> clustersOfThisPod = podClusterMap.get(pod);
+                if(clustersOfThisPod != null){
+                    for(Long clusterId : clusterIds){
+                        if(clustersOfThisPod.contains(clusterId)){
+                            reorderedClusters.add(clusterId);
+                        }
+                    }
+                    clusterIds.removeAll(clustersOfThisPod);
+                }
+            }
+        }
+        reorderedClusters.addAll(clusterIds);
+
+        if (s_logger.isTraceEnabled()) {
+            s_logger.trace("Reordered cluster list: " + reorderedClusters);
+        }
+        return reorderedClusters;
+    }
+
+    protected List<Long> listPodsByUserConcentration(long zoneId, long accountId){
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Applying UserConcentratedPod heuristic for account: "+ accountId);
+        }
+
+        List<Long> prioritizedPods = _vmDao.listPodIdsHavingVmsforAccount(zoneId, accountId);
+
+        if (s_logger.isTraceEnabled()) {
+            s_logger.trace("List of pods to be considered, after applying UserConcentratedPod
heuristic: "+ prioritizedPods);
+        }
+
+        return prioritizedPods;
+    }
+    
+    /**
+     * This method should reorder the given list of Pod Ids by applying any necessary heuristic

+     * for this planner
+     * For UserConcentratedPodPlanner we need to order the pods by considering those pods
first which have more number of VMs for this account 
+     * @return List<Long> ordered list of Pod Ids
+     */
+    @Override
+    protected List<Long> reorderPods(Pair<List<Long>, Map<Long, Double>>
podCapacityInfo, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan
plan){
+        List<Long> podIdsByCapacity = podCapacityInfo.first();
+        if(vmProfile.getOwner() == null){
+            return podIdsByCapacity;
+        }
+        long accountId = vmProfile.getOwner().getAccountId(); 
+
+        //user has VMs in certain pods. - prioritize those pods first
+        //UserConcentratedPod strategy
+        List<Long> podIds = listPodsByUserConcentration(plan.getDataCenterId(), accountId);
+        if(!podIds.isEmpty()){
+            //remove pods that dont have capacity for this vm
+            podIds.retainAll(podIdsByCapacity);
+            podIdsByCapacity.removeAll(podIds);
+            podIds.addAll(podIdsByCapacity);
+            return podIds;
+        }else{
+            return podIdsByCapacity;
+        }
+        
+    }
+
+    @Override
+    public boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan
plan, ExcludeList avoid) {
+        if(vm.getHypervisorType() != HypervisorType.BareMetal){
+            //check the allocation strategy
+            if (_allocationAlgorithm != null && (_allocationAlgorithm.equals(AllocationAlgorithm.userconcentratedpod_random.toString())
|| _allocationAlgorithm.equals(AllocationAlgorithm.userconcentratedpod_firstfit.toString()))){
+                return true;
+            }
+        }
+        return false;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/621f2447/plugins/deployment-planners/user-dispersing/.classpath
----------------------------------------------------------------------
diff --git a/plugins/deployment-planners/user-dispersing/.classpath b/plugins/deployment-planners/user-dispersing/.classpath
index a246f5e..e39771a 100755
--- a/plugins/deployment-planners/user-dispersing/.classpath
+++ b/plugins/deployment-planners/user-dispersing/.classpath
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/api"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/core"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/server"/>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/621f2447/server/src/com/cloud/deploy/UserConcentratedPodPlanner.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/UserConcentratedPodPlanner.java b/server/src/com/cloud/deploy/UserConcentratedPodPlanner.java
deleted file mode 100644
index 2b28d19..0000000
--- a/server/src/com/cloud/deploy/UserConcentratedPodPlanner.java
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License.  Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-// 
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.deploy;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.utils.Pair;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-
-@Local(value=DeploymentPlanner.class)
-public class UserConcentratedPodPlanner extends FirstFitPlanner implements DeploymentPlanner
{
-
-    private static final Logger s_logger = Logger.getLogger(UserConcentratedPodPlanner.class);
-    
-    /**
-     * This method should reorder the given list of Cluster Ids by applying any necessary
heuristic 
-     * for this planner
-     * For UserConcentratedPodPlanner we need to order the clusters in a zone across pods,
by considering those pods first which have more number of VMs for this account
-     * This reordering is not done incase the clusters within single pod are passed when
the allocation is applied at pod-level.
-     * @return List<Long> ordered list of Cluster Ids
-     */
-    @Override
-    protected List<Long> reorderClusters(long id, boolean isZone, Pair<List<Long>,
Map<Long, Double>> clusterCapacityInfo, VirtualMachineProfile<? extends VirtualMachine>
vmProfile, DeploymentPlan plan){
-        List<Long> clusterIdsByCapacity = clusterCapacityInfo.first();
-        if(vmProfile.getOwner() == null || !isZone){
-            return clusterIdsByCapacity;
-        }
-        return applyUserConcentrationPodHeuristicToClusters(id, clusterIdsByCapacity, vmProfile.getOwner().getAccountId());
-    }
-    
-    private List<Long> applyUserConcentrationPodHeuristicToClusters(long zoneId, List<Long>
prioritizedClusterIds, long accountId){
-        //user has VMs in certain pods. - prioritize those pods first
-        //UserConcentratedPod strategy
-        List<Long> clusterList = new ArrayList<Long>();
-        List<Long> podIds = listPodsByUserConcentration(zoneId, accountId);
-        if(!podIds.isEmpty()){
-            clusterList = reorderClustersByPods(prioritizedClusterIds, podIds);
-        }else{
-            clusterList = prioritizedClusterIds;
-        }
-        return clusterList;
-    }    
-    
-    private List<Long> reorderClustersByPods(List<Long> clusterIds, List<Long>
podIds) {
-
-        if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Reordering cluster list as per pods ordered by user concentration");
-        }
-
-        Map<Long, List<Long>> podClusterMap = _clusterDao.getPodClusterIdMap(clusterIds);
-
-        if (s_logger.isTraceEnabled()) {
-            s_logger.trace("Pod To cluster Map is: "+podClusterMap );
-        }
-
-        List<Long> reorderedClusters = new ArrayList<Long>();
-        for (Long pod : podIds){
-            if(podClusterMap.containsKey(pod)){
-                List<Long> clustersOfThisPod = podClusterMap.get(pod);
-                if(clustersOfThisPod != null){
-                    for(Long clusterId : clusterIds){
-                        if(clustersOfThisPod.contains(clusterId)){
-                            reorderedClusters.add(clusterId);
-                        }
-                    }
-                    clusterIds.removeAll(clustersOfThisPod);
-                }
-            }
-        }
-        reorderedClusters.addAll(clusterIds);
-
-        if (s_logger.isTraceEnabled()) {
-            s_logger.trace("Reordered cluster list: " + reorderedClusters);
-        }
-        return reorderedClusters;
-    }
-
-    protected List<Long> listPodsByUserConcentration(long zoneId, long accountId){
-
-        if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Applying UserConcentratedPod heuristic for account: "+ accountId);
-        }
-
-        List<Long> prioritizedPods = _vmDao.listPodIdsHavingVmsforAccount(zoneId, accountId);
-
-        if (s_logger.isTraceEnabled()) {
-            s_logger.trace("List of pods to be considered, after applying UserConcentratedPod
heuristic: "+ prioritizedPods);
-        }
-
-        return prioritizedPods;
-    }
-    
-    /**
-     * This method should reorder the given list of Pod Ids by applying any necessary heuristic

-     * for this planner
-     * For UserConcentratedPodPlanner we need to order the pods by considering those pods
first which have more number of VMs for this account 
-     * @return List<Long> ordered list of Pod Ids
-     */
-    @Override
-    protected List<Long> reorderPods(Pair<List<Long>, Map<Long, Double>>
podCapacityInfo, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan
plan){
-        List<Long> podIdsByCapacity = podCapacityInfo.first();
-        if(vmProfile.getOwner() == null){
-            return podIdsByCapacity;
-        }
-        long accountId = vmProfile.getOwner().getAccountId(); 
-
-        //user has VMs in certain pods. - prioritize those pods first
-        //UserConcentratedPod strategy
-        List<Long> podIds = listPodsByUserConcentration(plan.getDataCenterId(), accountId);
-        if(!podIds.isEmpty()){
-            //remove pods that dont have capacity for this vm
-            podIds.retainAll(podIdsByCapacity);
-            podIdsByCapacity.removeAll(podIds);
-            podIds.addAll(podIdsByCapacity);
-            return podIds;
-        }else{
-            return podIdsByCapacity;
-        }
-        
-    }
-
-    @Override
-    public boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan
plan, ExcludeList avoid) {
-        if(vm.getHypervisorType() != HypervisorType.BareMetal){
-            //check the allocation strategy
-            if (_allocationAlgorithm != null && (_allocationAlgorithm.equals(AllocationAlgorithm.userconcentratedpod_random.toString())
|| _allocationAlgorithm.equals(AllocationAlgorithm.userconcentratedpod_firstfit.toString()))){
-                return true;
-            }
-        }
-        return false;
-    }
-
-}


Mime
View raw message