cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [09/10] git commit: updated refs/heads/vmsync to 3ecc52a
Date Thu, 04 Jul 2013 00:57:42 GMT
Moved HostAllocator and PodAllocator from server to api package, where they are supposed to be.  In the process, I had to change the VO objects used by these two itnerfaces to interface equivalent.  This makes sense because there's really no reasons why allocators require write access to the database.  One of the files have been reformatted because it contained a bunch of tabs instead of spaces for indentation.


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

Branch: refs/heads/vmsync
Commit: 43ab9506ab5d768d74131140f7d57bb5ddb89a71
Parents: 410dff9
Author: Alex Huang <alex.huang@gmail.com>
Authored: Wed Jul 3 17:48:31 2013 -0700
Committer: Alex Huang <alex.huang@gmail.com>
Committed: Wed Jul 3 17:48:53 2013 -0700

----------------------------------------------------------------------
 .../agent/manager/allocator/HostAllocator.java  |  85 +++++
 .../agent/manager/allocator/PodAllocator.java   |  33 ++
 .../manager/allocator/impl/RandomAllocator.java |   5 +-
 .../agent/manager/allocator/HostAllocator.java  |  85 -----
 .../agent/manager/allocator/PodAllocator.java   |  35 --
 .../allocator/impl/FirstFitAllocator.java       | 378 ++++++++++---------
 .../allocator/impl/TestingAllocator.java        |   8 +-
 .../impl/UserConcentratedAllocator.java         |  30 +-
 .../src/com/cloud/capacity/CapacityManager.java |   5 +-
 .../com/cloud/capacity/CapacityManagerImpl.java |   7 +-
 .../src/com/cloud/resource/ResourceManager.java |  94 ++---
 .../com/cloud/resource/ResourceManagerImpl.java |  24 +-
 .../src/com/cloud/storage/StorageManager.java   |   5 +-
 .../com/cloud/storage/StorageManagerImpl.java   |  35 +-
 .../com/cloud/storage/VolumeManagerImpl.java    |  41 +-
 .../cloud/resource/MockResourceManagerImpl.java |  24 +-
 16 files changed, 444 insertions(+), 450 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/manager/allocator/HostAllocator.java b/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
new file mode 100755
index 0000000..fcd1fc1
--- /dev/null
+++ b/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
@@ -0,0 +1,85 @@
+// 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.
+package com.cloud.agent.manager.allocator;
+
+import java.util.List;
+
+import com.cloud.deploy.DeploymentPlan;
+import com.cloud.deploy.DeploymentPlanner.ExcludeList;
+import com.cloud.host.Host;
+import com.cloud.host.Host.Type;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.utils.component.Adapter;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+
+public interface HostAllocator extends Adapter {
+
+	/**
+	 * @param UserVm vm
+	 * @param ServiceOffering offering
+	 **/
+	boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering);
+
+	/**
+	* Determines which physical hosts are suitable to
+	* allocate the guest virtual machines on
+	* 
+	* @param VirtualMachineProfile vmProfile
+	* @param DeploymentPlan plan
+	* @param GuestType type
+	* @param ExcludeList avoid
+	* @param int returnUpTo (use -1 to return all possible hosts)
+	* @return List<Host> List of hosts that are suitable for VM allocation
+	**/
+	
+	public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);
+	
+    /**
+    * Determines which physical hosts are suitable to
+    * allocate the guest virtual machines on
+    * 
+    * @param VirtualMachineProfile vmProfile
+    * @param DeploymentPlan plan
+    * @param GuestType type
+    * @param ExcludeList avoid
+    * @param int returnUpTo (use -1 to return all possible hosts)
+    * @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
+    * @return List<Host> List of hosts that are suitable for VM allocation
+    **/
+    
+    public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);
+
+    /**
+     * Determines which physical hosts are suitable to
+     * allocate the guest virtual machines on
+     *
+     * @param VirtualMachineProfile vmProfile
+     * @param DeploymentPlan plan
+     * @param GuestType type
+     * @param ExcludeList avoid
+     * @param List<HostVO> hosts
+     * @param int returnUpTo (use -1 to return all possible hosts)
+     * @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
+     * @return List<Host> List of hosts that are suitable for VM allocation
+     **/
+    public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<? extends Host> hosts,
+            int returnUpTo, boolean considerReservedCapacity);
+
+     public static int RETURN_UPTO_ALL = -1;
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/api/src/com/cloud/agent/manager/allocator/PodAllocator.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/manager/allocator/PodAllocator.java b/api/src/com/cloud/agent/manager/allocator/PodAllocator.java
new file mode 100755
index 0000000..44cf640
--- /dev/null
+++ b/api/src/com/cloud/agent/manager/allocator/PodAllocator.java
@@ -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.
+package com.cloud.agent.manager.allocator;
+
+import java.util.Set;
+
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.Pod;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.Adapter;
+import com.cloud.vm.VirtualMachineProfile;
+
+public interface PodAllocator extends Adapter {
+    Pair<Pod, Long> allocateTo(VirtualMachineTemplate template, ServiceOffering offering, DataCenter dc, long userId, Set<Long> avoids);
+    
+    Pod allocateTo(VirtualMachineProfile vm, DataCenter dc, Set<? extends Pod> avoids);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
----------------------------------------------------------------------
diff --git a/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java b/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
index 8243f3a..303e438 100755
--- a/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
+++ b/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
@@ -11,7 +11,7 @@
 // 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 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 package com.cloud.agent.manager.allocator.impl;
@@ -19,7 +19,6 @@ package com.cloud.agent.manager.allocator.impl;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
@@ -55,7 +54,7 @@ public class RandomAllocator extends AdapterBase implements HostAllocator {
 
     @Override
     public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
-            ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity) {
+            ExcludeList avoid, List<? extends Host> hosts, int returnUpTo, boolean considerReservedCapacity) {
         long dcId = plan.getDataCenterId();
         Long podId = plan.getPodId();
         Long clusterId = plan.getClusterId();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/agent/manager/allocator/HostAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/HostAllocator.java b/server/src/com/cloud/agent/manager/allocator/HostAllocator.java
deleted file mode 100755
index 6700f22..0000000
--- a/server/src/com/cloud/agent/manager/allocator/HostAllocator.java
+++ /dev/null
@@ -1,85 +0,0 @@
-// 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.
-package com.cloud.agent.manager.allocator;
-
-import java.util.List;
-
-import com.cloud.deploy.DeploymentPlan;
-import com.cloud.deploy.DeploymentPlanner.ExcludeList;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.host.Host.Type;
-import com.cloud.offering.ServiceOffering;
-import com.cloud.utils.component.Adapter;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-
-public interface HostAllocator extends Adapter {
-
-	/**
-	 * @param UserVm vm
-	 * @param ServiceOffering offering
-	 **/
-	boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering);
-
-	/** 
-	* Determines which physical hosts are suitable to 
-	* allocate the guest virtual machines on 
-	* 
-	* @param VirtualMachineProfile vmProfile
-	* @param DeploymentPlan plan
-	* @param GuestType type
-	* @param ExcludeList avoid
-	* @param int returnUpTo (use -1 to return all possible hosts)
-	* @return List<Host> List of hosts that are suitable for VM allocation
-	**/ 
-	
-	public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);
-	
-    /** 
-    * Determines which physical hosts are suitable to 
-    * allocate the guest virtual machines on 
-    * 
-    * @param VirtualMachineProfile vmProfile
-    * @param DeploymentPlan plan
-    * @param GuestType type
-    * @param ExcludeList avoid
-    * @param int returnUpTo (use -1 to return all possible hosts)
-    * @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
-    * @return List<Host> List of hosts that are suitable for VM allocation
-    **/ 
-    
-    public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);
-
-    /**
-     * Determines which physical hosts are suitable to
-     * allocate the guest virtual machines on
-     *
-     * @param VirtualMachineProfile vmProfile
-     * @param DeploymentPlan plan
-     * @param GuestType type
-     * @param ExcludeList avoid
-     * @param List<HostVO> hosts
-     * @param int returnUpTo (use -1 to return all possible hosts)
-     * @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
-     * @return List<Host> List of hosts that are suitable for VM allocation
-     **/
-     public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity);
-
-     public static int RETURN_UPTO_ALL = -1;
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/agent/manager/allocator/PodAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/PodAllocator.java b/server/src/com/cloud/agent/manager/allocator/PodAllocator.java
deleted file mode 100755
index eb5a9db..0000000
--- a/server/src/com/cloud/agent/manager/allocator/PodAllocator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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.
-package com.cloud.agent.manager.allocator;
-
-import java.util.Set;
-
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.HostPodVO;
-import com.cloud.dc.Pod;
-import com.cloud.service.ServiceOfferingVO;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.utils.Pair;
-import com.cloud.utils.component.Adapter;
-import com.cloud.vm.VirtualMachineProfile;
-
-public interface PodAllocator extends Adapter {
-    Pair<HostPodVO, Long> allocateTo(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long userId, Set<Long> avoids);
-    
-    Pod allocateTo(VirtualMachineProfile vm, DataCenter dc, Set<? extends Pod> avoids);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
index b6286aa..4329c70 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
@@ -26,16 +26,15 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import com.cloud.dc.ClusterDetailsDao;
-import com.cloud.dc.ClusterDetailsVO;
-import com.cloud.dc.dao.ClusterDao;
-import com.cloud.org.Cluster;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.agent.manager.allocator.HostAllocator;
 import com.cloud.capacity.CapacityManager;
 import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.dc.ClusterDetailsDao;
+import com.cloud.dc.ClusterDetailsVO;
+import com.cloud.dc.dao.ClusterDao;
 import com.cloud.deploy.DeploymentPlan;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.host.DetailVO;
@@ -45,6 +44,7 @@ import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.host.dao.HostDetailsDao;
 import com.cloud.offering.ServiceOffering;
+import com.cloud.org.Cluster;
 import com.cloud.resource.ResourceManager;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.GuestOSCategoryVO;
@@ -67,52 +67,67 @@ import com.cloud.vm.dao.VMInstanceDao;
  * An allocator that tries to find a fit on a computing host.  This allocator does not care whether or not the host supports routing.
  */
 @Component
-@Local(value={HostAllocator.class})
+@Local(value = {HostAllocator.class})
 public class FirstFitAllocator extends AdapterBase implements HostAllocator {
     private static final Logger s_logger = Logger.getLogger(FirstFitAllocator.class);
-    @Inject HostDao _hostDao = null;
-    @Inject HostDetailsDao _hostDetailsDao = null;
-    @Inject UserVmDao _vmDao = null;
-    @Inject ServiceOfferingDao _offeringDao = null;
-    @Inject DomainRouterDao _routerDao = null;
-    @Inject ConsoleProxyDao _consoleProxyDao = null;
-    @Inject SecondaryStorageVmDao _secStorgaeVmDao = null;
-    @Inject ConfigurationDao _configDao = null;
-    @Inject GuestOSDao _guestOSDao = null;
-    @Inject GuestOSCategoryDao _guestOSCategoryDao = null;
-    @Inject VMInstanceDao _vmInstanceDao = null;
-    @Inject ResourceManager _resourceMgr;
-    @Inject ClusterDao _clusterDao;
-    @Inject ClusterDetailsDao _clusterDetailsDao;
+    @Inject
+    HostDao _hostDao = null;
+    @Inject
+    HostDetailsDao _hostDetailsDao = null;
+    @Inject
+    UserVmDao _vmDao = null;
+    @Inject
+    ServiceOfferingDao _offeringDao = null;
+    @Inject
+    DomainRouterDao _routerDao = null;
+    @Inject
+    ConsoleProxyDao _consoleProxyDao = null;
+    @Inject
+    SecondaryStorageVmDao _secStorgaeVmDao = null;
+    @Inject
+    ConfigurationDao _configDao = null;
+    @Inject
+    GuestOSDao _guestOSDao = null;
+    @Inject
+    GuestOSCategoryDao _guestOSCategoryDao = null;
+    @Inject
+    VMInstanceDao _vmInstanceDao = null;
+    @Inject
+    ResourceManager _resourceMgr;
+    @Inject
+    ClusterDao _clusterDao;
+    @Inject
+    ClusterDetailsDao _clusterDetailsDao;
     float _factor = 1;
     boolean _checkHvm = true;
     protected String _allocationAlgorithm = "random";
-    @Inject CapacityManager _capacityMgr;
+    @Inject
+    CapacityManager _capacityMgr;
 
-
-	@Override
-	public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
-			ExcludeList avoid, int returnUpTo) {
-	    return allocateTo(vmProfile, plan, type, avoid, returnUpTo, true);
-	}
+    @Override
+    public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
+            ExcludeList avoid, int returnUpTo) {
+        return allocateTo(vmProfile, plan, type, avoid, returnUpTo, true);
+    }
 
     @Override
-    public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity) {
+    public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo,
+            boolean considerReservedCapacity) {
 
-	    long dcId = plan.getDataCenterId();
-		Long podId = plan.getPodId();
-		Long clusterId = plan.getClusterId();
-		ServiceOffering offering = vmProfile.getServiceOffering();
-		VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();
-		Account account = vmProfile.getOwner();
+        long dcId = plan.getDataCenterId();
+        Long podId = plan.getPodId();
+        Long clusterId = plan.getClusterId();
+        ServiceOffering offering = vmProfile.getServiceOffering();
+        VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();
+        Account account = vmProfile.getOwner();
 
         if (type == Host.Type.Storage) {
             // FirstFitAllocator should be used for user VMs only since it won't care whether the host is capable of routing or not
-        	return new ArrayList<Host>();
+            return new ArrayList<Host>();
         }
 
-        if(s_logger.isDebugEnabled()){
-            s_logger.debug("Looking for hosts in dc: " + dcId + "  pod:" + podId + "  cluster:" + clusterId );
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Looking for hosts in dc: " + dcId + "  pod:" + podId + "  cluster:" + clusterId);
         }
 
         String hostTagOnOffering = offering.getHostTag();
@@ -127,40 +142,40 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         if (haVmTag != null) {
             clusterHosts = _hostDao.listByHostTag(type, clusterId, podId, dcId, haVmTag);
         } else {
-            if (hostTagOnOffering == null && hostTagOnTemplate == null){
+            if (hostTagOnOffering == null && hostTagOnTemplate == null) {
                 clusterHosts = _resourceMgr.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId);
             } else {
                 List<HostVO> hostsMatchingOfferingTag = new ArrayList<HostVO>();
                 List<HostVO> hostsMatchingTemplateTag = new ArrayList<HostVO>();
-                if (hasSvcOfferingTag){
-                    if (s_logger.isDebugEnabled()){
+                if (hasSvcOfferingTag) {
+                    if (s_logger.isDebugEnabled()) {
                         s_logger.debug("Looking for hosts having tag specified on SvcOffering:" + hostTagOnOffering);
                     }
                     hostsMatchingOfferingTag = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnOffering);
-                    if (s_logger.isDebugEnabled()){
+                    if (s_logger.isDebugEnabled()) {
                         s_logger.debug("Hosts with tag '" + hostTagOnOffering + "' are:" + hostsMatchingOfferingTag);
                     }
                 }
-                if (hasTemplateTag){
-                    if (s_logger.isDebugEnabled()){
+                if (hasTemplateTag) {
+                    if (s_logger.isDebugEnabled()) {
                         s_logger.debug("Looking for hosts having tag specified on Template:" + hostTagOnTemplate);
                     }
                     hostsMatchingTemplateTag = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnTemplate);
-                    if (s_logger.isDebugEnabled()){
-                        s_logger.debug("Hosts with tag '" + hostTagOnTemplate+"' are:" + hostsMatchingTemplateTag);
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Hosts with tag '" + hostTagOnTemplate + "' are:" + hostsMatchingTemplateTag);
                     }
                 }
 
-                if (hasSvcOfferingTag && hasTemplateTag){
+                if (hasSvcOfferingTag && hasTemplateTag) {
                     hostsMatchingOfferingTag.retainAll(hostsMatchingTemplateTag);
                     clusterHosts = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnTemplate);
-                    if (s_logger.isDebugEnabled()){
-                        s_logger.debug("Found "+ hostsMatchingOfferingTag.size() +" Hosts satisfying both tags, host ids are:" + hostsMatchingOfferingTag);
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Found " + hostsMatchingOfferingTag.size() + " Hosts satisfying both tags, host ids are:" + hostsMatchingOfferingTag);
                     }
 
                     clusterHosts = hostsMatchingOfferingTag;
                 } else {
-                    if (hasSvcOfferingTag){
+                    if (hasSvcOfferingTag) {
                         clusterHosts = hostsMatchingOfferingTag;
                     } else {
                         clusterHosts = hostsMatchingTemplateTag;
@@ -181,7 +196,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
 
     @Override
     public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan,
-            Type type, ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity) {
+            Type type, ExcludeList avoid, List<? extends Host> hosts, int returnUpTo, boolean considerReservedCapacity) {
         long dcId = plan.getDataCenterId();
         Long podId = plan.getPodId();
         Long clusterId = plan.getClusterId();
@@ -205,7 +220,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         if (haVmTag != null) {
             hosts.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, haVmTag));
         } else {
-            if (hostTagOnOffering == null && hostTagOnTemplate == null){
+            if (hostTagOnOffering == null && hostTagOnTemplate == null) {
                 hosts.retainAll(_resourceMgr.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId));
             } else {
                 if (hasSvcOfferingTag) {
@@ -226,16 +241,17 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         return suitableHosts;
     }
 
-    protected List<Host> allocateTo(DeploymentPlan plan, ServiceOffering offering, VMTemplateVO template, ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity, Account account) {
+    protected List<Host> allocateTo(DeploymentPlan plan, ServiceOffering offering, VMTemplateVO template, ExcludeList avoid, List<? extends Host> hosts, int returnUpTo,
+            boolean considerReservedCapacity, Account account) {
         if (_allocationAlgorithm.equals("random") || _allocationAlgorithm.equals("userconcentratedpod_random")) {
-        	// Shuffle this so that we don't check the hosts in the same order.
+            // Shuffle this so that we don't check the hosts in the same order.
             Collections.shuffle(hosts);
-        }else if(_allocationAlgorithm.equals("userdispersing")){
+        } else if (_allocationAlgorithm.equals("userdispersing")) {
             hosts = reorderHostsByNumberOfVms(plan, hosts, account);
         }
 
-    	if (s_logger.isDebugEnabled()) {
-            s_logger.debug("FirstFitAllocator has " + hosts.size() + " hosts to check for allocation: "+hosts);
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("FirstFitAllocator has " + hosts.size() + " hosts to check for allocation: " + hosts);
         }
 
         // We will try to reorder the host lists such that we give priority to hosts that have
@@ -243,7 +259,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         hosts = prioritizeHosts(template, hosts);
 
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Found " + hosts.size() + " hosts for allocation after prioritization: "+ hosts);
+            s_logger.debug("Found " + hosts.size() + " hosts for allocation after prioritization: " + hosts);
         }
 
         if (s_logger.isDebugEnabled()) {
@@ -252,36 +268,38 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
 
         List<Host> suitableHosts = new ArrayList<Host>();
 
-        for (HostVO host : hosts) {
-        	if(suitableHosts.size() == returnUpTo){
-        		break;
-        	}
+        for (Host host : hosts) {
+            if (suitableHosts.size() == returnUpTo) {
+                break;
+            }
             if (avoid.shouldAvoid(host)) {
                 if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +" is in avoid set, skipping this and trying other available hosts");
+                    s_logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId() + " is in avoid set, skipping this and trying other available hosts");
                 }
                 continue;
             }
 
             //find number of guest VMs occupying capacity on this host.
-            if (_capacityMgr.checkIfHostReachMaxGuestLimit(host)){
+            if (_capacityMgr.checkIfHostReachMaxGuestLimit(host)) {
                 if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +" already has max Running VMs(count includes system VMs), skipping this and trying other available hosts");
+                    s_logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId()
+                            + " already has max Running VMs(count includes system VMs), skipping this and trying other available hosts");
                 }
                 continue;
             }
 
             boolean numCpusGood = host.getCpus().intValue() >= offering.getCpu();
             boolean cpuFreqGood = host.getSpeed().intValue() >= offering.getSpeed();
-    		int cpu_requested = offering.getCpu() * offering.getSpeed();
-    		long ram_requested = offering.getRamSize() * 1024L * 1024L;
+            int cpu_requested = offering.getCpu() * offering.getSpeed();
+            long ram_requested = offering.getRamSize() * 1024L * 1024L;
             Cluster cluster = _clusterDao.findById(host.getClusterId());
-            ClusterDetailsVO clusterDetailsCpuOvercommit = _clusterDetailsDao.findDetail(cluster.getId(),"cpuOvercommitRatio");
-            ClusterDetailsVO clusterDetailsRamOvercommmt = _clusterDetailsDao.findDetail(cluster.getId(),"memoryOvercommitRatio");
+            ClusterDetailsVO clusterDetailsCpuOvercommit = _clusterDetailsDao.findDetail(cluster.getId(), "cpuOvercommitRatio");
+            ClusterDetailsVO clusterDetailsRamOvercommmt = _clusterDetailsDao.findDetail(cluster.getId(), "memoryOvercommitRatio");
             Float cpuOvercommitRatio = Float.parseFloat(clusterDetailsCpuOvercommit.getValue());
             Float memoryOvercommitRatio = Float.parseFloat(clusterDetailsRamOvercommmt.getValue());
 
-            boolean hostHasCapacity = _capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, false,cpuOvercommitRatio,memoryOvercommitRatio, considerReservedCapacity);
+            boolean hostHasCapacity = _capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, false, cpuOvercommitRatio, memoryOvercommitRatio,
+                    considerReservedCapacity);
 
             if (numCpusGood && cpuFreqGood && hostHasCapacity) {
                 if (s_logger.isDebugEnabled()) {
@@ -297,14 +315,14 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         }
 
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Host Allocator returning "+suitableHosts.size() +" suitable hosts");
+            s_logger.debug("Host Allocator returning " + suitableHosts.size() + " suitable hosts");
         }
 
         return suitableHosts;
     }
 
-    private List<HostVO> reorderHostsByNumberOfVms(DeploymentPlan plan, List<HostVO> hosts, Account account) {
-        if(account == null){
+    private List<? extends Host> reorderHostsByNumberOfVms(DeploymentPlan plan, List<? extends Host> hosts, Account account) {
+        if (account == null) {
             return hosts;
         }
         long dcId = plan.getDataCenterId();
@@ -313,20 +331,20 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
 
         List<Long> hostIdsByVmCount = _vmInstanceDao.listHostIdsByVmCount(dcId, podId, clusterId, account.getAccountId());
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("List of hosts in ascending order of number of VMs: "+ hostIdsByVmCount);
+            s_logger.debug("List of hosts in ascending order of number of VMs: " + hostIdsByVmCount);
         }
 
         //now filter the given list of Hosts by this ordered list
-        Map<Long, HostVO> hostMap = new HashMap<Long, HostVO>();
-        for (HostVO host : hosts) {
+        Map<Long, Host> hostMap = new HashMap<Long, Host>();
+        for (Host host : hosts) {
             hostMap.put(host.getId(), host);
         }
         List<Long> matchingHostIds = new ArrayList<Long>(hostMap.keySet());
 
         hostIdsByVmCount.retainAll(matchingHostIds);
 
-        List<HostVO> reorderedHosts = new ArrayList<HostVO>();
-        for(Long id: hostIdsByVmCount){
+        List<Host> reorderedHosts = new ArrayList<Host>();
+        for (Long id : hostIdsByVmCount) {
             reorderedHosts.add(hostMap.get(id));
         }
 
@@ -340,133 +358,133 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
         return true;
     }
 
-    protected List<HostVO> prioritizeHosts(VMTemplateVO template, List<HostVO> hosts) {
-    	if (template == null) {
-    		return hosts;
-    	}
-
-    	// Determine the guest OS category of the template
-    	String templateGuestOSCategory = getTemplateGuestOSCategory(template);
-
-    	List<HostVO> prioritizedHosts = new ArrayList<HostVO>();
-	List<HostVO> noHvmHosts = new ArrayList<HostVO>();
-
-    	// If a template requires HVM and a host doesn't support HVM, remove it from consideration
-    	List<HostVO> hostsToCheck = new ArrayList<HostVO>();
-    	if (template.isRequiresHvm()) {
-    		for (HostVO host : hosts) {
-    			if (hostSupportsHVM(host)) {
-    				hostsToCheck.add(host);
-			} else {
-				noHvmHosts.add(host);
-    			}
-    		}
-    	} else {
-    		hostsToCheck.addAll(hosts);
-    	}
-
-	if (s_logger.isDebugEnabled()) {
-		if (noHvmHosts.size() > 0) {
-			s_logger.debug("Not considering hosts: "  + noHvmHosts + "  to deploy template: " + template +" as they are not HVM enabled");
-		}
-	}
-    	// If a host is tagged with the same guest OS category as the template, move it to a high priority list
-    	// If a host is tagged with a different guest OS category than the template, move it to a low priority list
-    	List<HostVO> highPriorityHosts = new ArrayList<HostVO>();
-    	List<HostVO> lowPriorityHosts = new ArrayList<HostVO>();
-    	for (HostVO host : hostsToCheck) {
-    		String hostGuestOSCategory = getHostGuestOSCategory(host);
-    		if (hostGuestOSCategory == null) {
-    			continue;
-    		} else if (templateGuestOSCategory.equals(hostGuestOSCategory)) {
-    			highPriorityHosts.add(host);
-    		} else {
-    			lowPriorityHosts.add(host);
-    		}
-    	}
-
-    	hostsToCheck.removeAll(highPriorityHosts);
-    	hostsToCheck.removeAll(lowPriorityHosts);
-
-    	// Prioritize the remaining hosts by HVM capability
-    	for (HostVO host : hostsToCheck) {
-    		if (!template.isRequiresHvm() && !hostSupportsHVM(host)) {
-    			// Host and template both do not support hvm, put it as first consideration
-    			prioritizedHosts.add(0, host);
-    		} else {
-    			// Template doesn't require hvm, but the machine supports it, make it last for consideration
-    			prioritizedHosts.add(host);
-    		}
-    	}
-
-    	// Merge the lists
-    	prioritizedHosts.addAll(0, highPriorityHosts);
-    	prioritizedHosts.addAll(lowPriorityHosts);
-
-    	return prioritizedHosts;
+    protected List<? extends Host> prioritizeHosts(VMTemplateVO template, List<? extends Host> hosts) {
+        if (template == null) {
+            return hosts;
+        }
+
+        // Determine the guest OS category of the template
+        String templateGuestOSCategory = getTemplateGuestOSCategory(template);
+
+        List<Host> prioritizedHosts = new ArrayList<Host>();
+        List<Host> noHvmHosts = new ArrayList<Host>();
+
+        // If a template requires HVM and a host doesn't support HVM, remove it from consideration
+        List<Host> hostsToCheck = new ArrayList<Host>();
+        if (template.isRequiresHvm()) {
+            for (Host host : hosts) {
+                if (hostSupportsHVM(host)) {
+                    hostsToCheck.add(host);
+                } else {
+                    noHvmHosts.add(host);
+                }
+            }
+        } else {
+            hostsToCheck.addAll(hosts);
+        }
+
+        if (s_logger.isDebugEnabled()) {
+            if (noHvmHosts.size() > 0) {
+                s_logger.debug("Not considering hosts: " + noHvmHosts + "  to deploy template: " + template + " as they are not HVM enabled");
+            }
+        }
+        // If a host is tagged with the same guest OS category as the template, move it to a high priority list
+        // If a host is tagged with a different guest OS category than the template, move it to a low priority list
+        List<Host> highPriorityHosts = new ArrayList<Host>();
+        List<Host> lowPriorityHosts = new ArrayList<Host>();
+        for (Host host : hostsToCheck) {
+            String hostGuestOSCategory = getHostGuestOSCategory(host);
+            if (hostGuestOSCategory == null) {
+                continue;
+            } else if (templateGuestOSCategory.equals(hostGuestOSCategory)) {
+                highPriorityHosts.add(host);
+            } else {
+                lowPriorityHosts.add(host);
+            }
+        }
+
+        hostsToCheck.removeAll(highPriorityHosts);
+        hostsToCheck.removeAll(lowPriorityHosts);
+
+        // Prioritize the remaining hosts by HVM capability
+        for (Host host : hostsToCheck) {
+            if (!template.isRequiresHvm() && !hostSupportsHVM(host)) {
+                // Host and template both do not support hvm, put it as first consideration
+                prioritizedHosts.add(0, host);
+            } else {
+                // Template doesn't require hvm, but the machine supports it, make it last for consideration
+                prioritizedHosts.add(host);
+            }
+        }
+
+        // Merge the lists
+        prioritizedHosts.addAll(0, highPriorityHosts);
+        prioritizedHosts.addAll(lowPriorityHosts);
+
+        return prioritizedHosts;
     }
 
-    protected boolean hostSupportsHVM(HostVO host) {
-        if ( !_checkHvm ) {
+    protected boolean hostSupportsHVM(Host host) {
+        if (!_checkHvm) {
             return true;
         }
-    	// Determine host capabilities
-		String caps = host.getCapabilities();
+        // Determine host capabilities
+        String caps = host.getCapabilities();
 
-		if (caps != null) {
+        if (caps != null) {
             String[] tokens = caps.split(",");
             for (String token : tokens) {
-            	if (token.contains("hvm")) {
-            	    return true;
-            	}
+                if (token.contains("hvm")) {
+                    return true;
+                }
             }
-		}
+        }
 
-		return false;
+        return false;
     }
 
-    protected String getHostGuestOSCategory(HostVO host) {
-		DetailVO hostDetail = _hostDetailsDao.findDetail(host.getId(), "guest.os.category.id");
-		if (hostDetail != null) {
-			String guestOSCategoryIdString = hostDetail.getValue();
-			long guestOSCategoryId;
-
-			try {
-				guestOSCategoryId = Long.parseLong(guestOSCategoryIdString);
-			} catch (Exception e) {
-				return null;
-			}
-
-			GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
-
-			if (guestOSCategory != null) {
-				return guestOSCategory.getName();
-			} else {
-				return null;
-			}
-		} else {
-			return null;
-		}
+    protected String getHostGuestOSCategory(Host host) {
+        DetailVO hostDetail = _hostDetailsDao.findDetail(host.getId(), "guest.os.category.id");
+        if (hostDetail != null) {
+            String guestOSCategoryIdString = hostDetail.getValue();
+            long guestOSCategoryId;
+
+            try {
+                guestOSCategoryId = Long.parseLong(guestOSCategoryIdString);
+            } catch (Exception e) {
+                return null;
+            }
+
+            GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
+
+            if (guestOSCategory != null) {
+                return guestOSCategory.getName();
+            } else {
+                return null;
+            }
+        } else {
+            return null;
+        }
     }
 
     protected String getTemplateGuestOSCategory(VMTemplateVO template) {
-    	long guestOSId = template.getGuestOSId();
-    	GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
-    	long guestOSCategoryId = guestOS.getCategoryId();
-    	GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
-    	return guestOSCategory.getName();
+        long guestOSId = template.getGuestOSId();
+        GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
+        long guestOSCategoryId = guestOS.getCategoryId();
+        GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
+        return guestOSCategory.getName();
     }
 
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
-    	if (_configDao != null) {
-    		Map<String, String> configs = _configDao.getConfiguration(params);
+        if (_configDao != null) {
+            Map<String, String> configs = _configDao.getConfiguration(params);
             String opFactor = configs.get("cpu.overprovisioning.factor");
             _factor = NumbersUtil.parseFloat(opFactor, 1);
 
             String allocationAlgorithm = configs.get("vm.allocation.algorithm");
             if (allocationAlgorithm != null) {
-            	_allocationAlgorithm = allocationAlgorithm;
+                _allocationAlgorithm = allocationAlgorithm;
             }
             String value = configs.get("xen.check.hvm");
             _checkHvm = value == null ? true : Boolean.parseBoolean(value);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java
index 890c047..3c69694 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/TestingAllocator.java
@@ -23,13 +23,10 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.springframework.stereotype.Component;
-
 import com.cloud.agent.manager.allocator.HostAllocator;
 import com.cloud.deploy.DeploymentPlan;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.host.Host;
-import com.cloud.host.HostVO;
 import com.cloud.host.Host.Type;
 import com.cloud.host.dao.HostDao;
 import com.cloud.offering.ServiceOffering;
@@ -37,7 +34,6 @@ import com.cloud.utils.component.AdapterBase;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
-@Component
 @Local(value={HostAllocator.class})
 public class TestingAllocator extends AdapterBase implements HostAllocator {
     @Inject HostDao _hostDao;
@@ -53,7 +49,7 @@ public class TestingAllocator extends AdapterBase implements HostAllocator {
 
     @Override
     public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
-            ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity) {
+            ExcludeList avoid, List<? extends Host> hosts, int returnUpTo, boolean considerReservedCapacity) {
         return allocateTo(vmProfile, plan, type, avoid, returnUpTo, considerReservedCapacity);
     }
 
@@ -61,7 +57,7 @@ public class TestingAllocator extends AdapterBase implements HostAllocator {
     public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
             ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity) {
         List<Host> availableHosts = new ArrayList<Host>();
-        Host host = null;    	
+        Host host = null;
         if (type == Host.Type.Routing && _routingHost != null) {
             host = _hostDao.findById(_routingHost);
         } else if (type == Host.Type.Storage && _storageHost != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
index af4e411..82548c9 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
@@ -34,15 +34,12 @@ import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.HostPodVO;
 import com.cloud.dc.Pod;
 import com.cloud.dc.dao.HostPodDao;
 import com.cloud.offering.ServiceOffering;
-import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.VolumeVO;
-import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.dao.VMTemplatePoolDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.template.VirtualMachineTemplate;
@@ -85,7 +82,7 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
     private int _secondsToSkipDestroyedVMs = 0;
 
     @Override
-    public Pair<HostPodVO, Long> allocateTo(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO zone, long accountId,
+    public Pair<Pod, Long> allocateTo(VirtualMachineTemplate template, ServiceOffering offering, DataCenter zone, long accountId,
             Set<Long> avoids) {
         long zoneId = zone.getId();
         List<HostPodVO> podsInZone = _podDao.listByDataCenterId(zoneId);
@@ -138,12 +135,12 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
                 // If the pod has VMs or volumes in it, return this pod
                 List<UserVmVO> vmsInPod = _vmDao.listByAccountAndPod(accountId, pod.getId());
                 if (!vmsInPod.isEmpty()) {
-                    return new Pair<HostPodVO, Long>(pod, podHostCandidates.get(podId));
+                    return new Pair<Pod, Long>(pod, podHostCandidates.get(podId));
                 }
 
                 List<VolumeVO> volumesInPod = _volumeDao.findByAccountAndPod(accountId, pod.getId());
                 if (!volumesInPod.isEmpty()) {
-                    return new Pair<HostPodVO, Long>(pod, podHostCandidates.get(podId));
+                    return new Pair<Pod, Long>(pod, podHostCandidates.get(podId));
                 }
 
                 availablePods.add(pod);
@@ -158,7 +155,7 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
             int next = _rand.nextInt(availablePods.size());
             HostPodVO selectedPod = availablePods.get(next);
             s_logger.debug("Found pod " + selectedPod.getName() + " in zone " + zone.getName());
-            return new Pair<HostPodVO, Long>(selectedPod, podHostCandidates.get(selectedPod.getId()));
+            return new Pair<Pod, Long>(selectedPod, podHostCandidates.get(selectedPod.getId()));
         }
     }
 
@@ -319,25 +316,6 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
         _secondsToSkipStoppedVMs = NumbersUtil.parseInt(stoppedValue, 86400);
         _secondsToSkipDestroyedVMs = NumbersUtil.parseInt(destroyedValue, 0);
 
-        /*
-         * ComponentLocator locator = ComponentLocator.getCurrentLocator(); _vmDao = locator.getDao(UserVmDao.class); if (_vmDao
-         * == null) { throw new ConfigurationException("Unable to find UserVMDao."); }
-         *
-         * _volumeDao = locator.getDao(VolumeDao.class); if (_volumeDao == null) { throw new
-         * ConfigurationException("Unable to find VolumeDao."); }
-         *
-         * _templateHostDao = locator.getDao(VMTemplateHostDao.class); if (_templateHostDao == null) { throw new
-         * ConfigurationException("Unable to get template host dao."); }
-         *
-         * _templatePoolDao = locator.getDao(VMTemplatePoolDao.class); if (_templatePoolDao == null) { throw new
-         * ConfigurationException("Unable to get template pool dao."); }
-         *
-         * _podDao = locator.getDao(HostPodDao.class); if (_podDao == null) { throw new
-         * ConfigurationException("Unable to find HostPodDao."); }
-         *
-         * _capacityDao = locator.getDao(CapacityDao.class); if (_capacityDao == null) { throw new
-         * ConfigurationException("Unable to retrieve " + CapacityDao.class); }
-         */
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/capacity/CapacityManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManager.java b/server/src/com/cloud/capacity/CapacityManager.java
index ab02e77..ded1f80 100755
--- a/server/src/com/cloud/capacity/CapacityManager.java
+++ b/server/src/com/cloud/capacity/CapacityManager.java
@@ -19,7 +19,6 @@ package com.cloud.capacity;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 
 import com.cloud.host.Host;
-import com.cloud.host.HostVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.utils.component.Manager;
 import com.cloud.vm.VirtualMachine;
@@ -46,7 +45,7 @@ public interface CapacityManager extends Manager {
     
 	/**
      * @param pool storage pool
-     * @param templateForVmCreation template that will be used for vm creation 
+     * @param templateForVmCreation template that will be used for vm creation
      * @return total allocated capacity for the storage pool
      */
     long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO templateForVmCreation);
@@ -56,5 +55,5 @@ public interface CapacityManager extends Manager {
      * @param host the host to be checked
      * @return true if the count of host's running VMs >= hypervisor limit
      */
-    boolean checkIfHostReachMaxGuestLimit(HostVO host);
+    boolean checkIfHostReachMaxGuestLimit(Host host);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java
index b2f10f2..108de3b 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -27,11 +27,12 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.framework.messagebus.MessageBus;
 import org.apache.cloudstack.framework.messagebus.PublishScope;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.Listener;
@@ -906,7 +907,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
 	}
 
     @Override
-    public boolean checkIfHostReachMaxGuestLimit(HostVO host) {
+    public boolean checkIfHostReachMaxGuestLimit(Host host) {
         Long vmCount = _vmDao.countRunningByHostId(host.getId());
         HypervisorType hypervisorType = host.getHypervisorType();
         String hypervisorVersion = host.getHypervisorVersion();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/resource/ResourceManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManager.java b/server/src/com/cloud/resource/ResourceManager.java
index b0ab926..e35e89a 100755
--- a/server/src/com/cloud/resource/ResourceManager.java
+++ b/server/src/com/cloud/resource/ResourceManager.java
@@ -24,6 +24,7 @@ import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.HostPodVO;
+import com.cloud.dc.Pod;
 import com.cloud.dc.PodCluster;
 import com.cloud.exception.AgentUnavailableException;
 import com.cloud.host.Host;
@@ -42,7 +43,7 @@ import com.cloud.utils.fsm.NoTransitionException;
  * ResourceManager manages how physical resources are organized within the
  * CloudStack. It also manages the life cycle of the physical resources.
  */
-public interface ResourceManager extends ResourceService{
+public interface ResourceManager extends ResourceService {
     /**
      * Register a listener for different types of resource life cycle events.
      * There can only be one type of listener per type of host.
@@ -51,69 +52,70 @@ public interface ResourceManager extends ResourceService{
      * @param listener the listener to notify.
      */
     public void registerResourceEvent(Integer event, ResourceListener listener);
-    
+
     public void unregisterResourceEvent(ResourceListener listener);
-    
+
     /**
      * 
      * @param name of adapter
      * @param adapter
-     * @param hates, a list of names which will be eliminated by this adapter. Especially for the case where 
+     * @param hates, a list of names which will be eliminated by this adapter. Especially for the case where
      * can be only one adapter responds to an event, e.g. startupCommand
      */
     public void registerResourceStateAdapter(String name, ResourceStateAdapter adapter);
-    
+
     public void unregisterResourceStateAdapter(String name);
-    
-	public Host createHostAndAgent(Long hostId, ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags,
-	        boolean forRebalance);
-	
-	public Host addHost(long zoneId, ServerResource resource, Type hostType, Map<String, String> hostDetails);
-	
-	public HostVO createHostVOForConnectedAgent(StartupCommand[] cmds);
-	
-	public void checkCIDR(HostPodVO pod, DataCenterVO dc, String serverPrivateIP, String serverPrivateNetmask);
-	
-	public HostVO fillRoutingHostVO(HostVO host, StartupRoutingCommand ssCmd, HypervisorType hyType, Map<String, String> details, List<String> hostTags);
-	
-	public void deleteRoutingHost(HostVO host, boolean isForced, boolean forceDestroyStorage) throws UnableDeleteHostException;
-	
+
+    public Host createHostAndAgent(Long hostId, ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags,
+            boolean forRebalance);
+
+    public Host addHost(long zoneId, ServerResource resource, Type hostType, Map<String, String> hostDetails);
+
+    public HostVO createHostVOForConnectedAgent(StartupCommand[] cmds);
+
+    public void checkCIDR(HostPodVO pod, DataCenterVO dc, String serverPrivateIP, String serverPrivateNetmask);
+
+    public HostVO fillRoutingHostVO(HostVO host, StartupRoutingCommand ssCmd, HypervisorType hyType, Map<String, String> details, List<String> hostTags);
+
+    public void deleteRoutingHost(HostVO host, boolean isForced, boolean forceDestroyStorage) throws UnableDeleteHostException;
+
     public boolean executeUserRequest(long hostId, ResourceState.Event event) throws AgentUnavailableException;
 
-	boolean resourceStateTransitTo(Host host, Event event, long msId) throws NoTransitionException;
+    boolean resourceStateTransitTo(Host host, Event event, long msId) throws NoTransitionException;
+
+    boolean umanageHost(long hostId);
+
+    boolean maintenanceFailed(long hostId);
 
-	boolean umanageHost(long hostId);
+    public boolean maintain(final long hostId) throws AgentUnavailableException;
 
-	boolean maintenanceFailed(long hostId);
-	
-	public boolean maintain(final long hostId) throws AgentUnavailableException;
-	
     @Override
     public boolean deleteHost(long hostId, boolean isForced, boolean isForceDeleteStorage);
-    
+
     public List<HostVO> findDirectlyConnectedHosts();
-    
+
     public List<HostVO> listAllUpAndEnabledHosts(Host.Type type, Long clusterId, Long podId, long dcId);
-    
+
     public List<HostVO> listAllHostsInCluster(long clusterId);
-    
+
     public List<HostVO> listHostsInClusterByStatus(long clusterId, Status status);
-    
+
     public List<HostVO> listAllUpAndEnabledHostsInOneZoneByType(Host.Type type, long dcId);
+
     public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType type, long dcId);
-    
+
     public List<HostVO> listAllHostsInOneZoneByType(Host.Type type, long dcId);
-    
+
     public List<HostVO> listAllHostsInAllZonesByType(Type type);
-    
+
     public List<HypervisorType> listAvailHypervisorInZone(Long hostId, Long zoneId);
-    
+
     public HostVO findHostByGuid(String guid);
-    
+
     public HostVO findHostByName(String name);
-    
+
     public List<HostVO> listHostsByNameLike(String name);
-    
+
     /**
      * Find a pod based on the user id, template, and data center.
      * 
@@ -122,25 +124,25 @@ public interface ResourceManager extends ResourceService{
      * @param userId
      * @return
      */
-    Pair<HostPodVO, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long accountId, Set<Long> avoids);
-    
+    Pair<Pod, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long accountId, Set<Long> avoids);
+
     HostStats getHostStatistics(long hostId);
-    
+
     Long getGuestOSCategoryId(long hostId);
-    
+
     String getHostTags(long hostId);
-    
+
     List<PodCluster> listByDataCenter(long dcId);
 
-	List<HostVO> listAllNotInMaintenanceHostsInOneZone(Type type, Long dcId);
+    List<HostVO> listAllNotInMaintenanceHostsInOneZone(Type type, Long dcId);
 
-	HypervisorType getDefaultHypervisor(long zoneId);
+    HypervisorType getDefaultHypervisor(long zoneId);
 
-	HypervisorType getAvailableHypervisor(long zoneId);
+    HypervisorType getAvailableHypervisor(long zoneId);
 
     Discoverer getMatchingDiscover(HypervisorType hypervisorType);
 
-	List<HostVO> findHostByGuid(long dcId, String guid);
+    List<HostVO> findHostByGuid(long dcId, String guid);
 
     /**
      * @param type

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index a0ea54e..054ac40 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -30,7 +30,9 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import com.cloud.dc.*;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
 import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
@@ -48,8 +50,6 @@ import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
 import org.apache.cloudstack.region.dao.RegionDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.AgentManager.TapAgentsAction;
@@ -78,9 +78,12 @@ import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.ClusterDetailsDao;
 import com.cloud.dc.ClusterDetailsVO;
 import com.cloud.dc.ClusterVO;
+import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.DataCenterIpAddressVO;
 import com.cloud.dc.DataCenterVO;
+import com.cloud.dc.DedicatedResourceVO;
 import com.cloud.dc.HostPodVO;
+import com.cloud.dc.Pod;
 import com.cloud.dc.PodCluster;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.ClusterVSMMapDao;
@@ -164,7 +167,6 @@ import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.VirtualMachineManager;
 import com.cloud.vm.dao.VMInstanceDao;
-import com.cloud.dc.DataCenter.NetworkType;
 
 @Component
 @Local({ ResourceManager.class, ResourceService.class })
@@ -634,12 +636,12 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
     @Override
     public S3 discoverS3(final AddS3Cmd cmd) throws DiscoveryException {
-        return this._s3Mgr.addS3(cmd);
+        return _s3Mgr.addS3(cmd);
     }
 
     @Override
     public List<S3VO> listS3s(final ListS3sCmd cmd) {
-        return this._s3Mgr.listS3s(cmd);
+        return _s3Mgr.listS3s(cmd);
     }
 
 
@@ -704,7 +706,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
                 // already have a lot of information
                 // in cluster object, to simplify user input, we will construct
                 // neccessary information here
-                Map<String, String> clusterDetails = this._clusterDetailsDao.findDetails(clusterId);
+                Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
                 username = clusterDetails.get("username");
                 assert (username != null);
 
@@ -1971,7 +1973,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
         Map<String, String> details = hostDetails;
         String guid = details.get("guid");
-        List<HostVO> currentHosts = this.listAllUpAndEnabledHostsInOneZoneByType(hostType, zoneId);
+        List<HostVO> currentHosts = listAllUpAndEnabledHostsInOneZoneByType(hostType, zoneId);
         for (HostVO currentHost : currentHosts) {
             if (currentHost.getGuid().equals(guid)) {
                 return currentHost;
@@ -2294,7 +2296,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
             return doUpdateHostPassword(cmd.getHostId());
         } else {
             // get agents for the cluster
-            List<HostVO> hosts = this.listAllHostsInCluster(cmd.getClusterId());
+            List<HostVO> hosts = listAllHostsInCluster(cmd.getClusterId());
             for (HostVO h : hosts) {
                 try {
                     /*
@@ -2468,10 +2470,10 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
     }
 
     @Override
-    public Pair<HostPodVO, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long accountId,
+    public Pair<Pod, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long accountId,
             Set<Long> avoids) {
         for (PodAllocator allocator : _podAllocators) {
-            final Pair<HostPodVO, Long> pod = allocator.allocateTo(template, offering, dc, accountId, avoids);
+            final Pair<Pod, Long> pod = allocator.allocateTo(template, offering, dc, accountId, avoids);
             if (pod != null) {
                 return pod;
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/storage/StorageManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManager.java b/server/src/com/cloud/storage/StorageManager.java
index df69092..af4e8c2 100755
--- a/server/src/com/cloud/storage/StorageManager.java
+++ b/server/src/com/cloud/storage/StorageManager.java
@@ -30,13 +30,12 @@ import com.cloud.agent.api.StoragePoolInfo;
 import com.cloud.agent.manager.Commands;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.HostPodVO;
+import com.cloud.dc.Pod;
 import com.cloud.exception.ConnectionException;
 import com.cloud.exception.StorageUnavailableException;
 import com.cloud.host.Host;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.service.ServiceOfferingVO;
-import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.utils.Pair;
 import com.cloud.vm.DiskProfile;
@@ -108,7 +107,7 @@ public interface StorageManager extends StorageService {
     boolean registerHostListener(String providerUuid, HypervisorHostListener listener);
 
     StoragePool findStoragePool(DiskProfile dskCh, DataCenterVO dc,
-            HostPodVO pod, Long clusterId, Long hostId, VMInstanceVO vm,
+            Pod pod, Long clusterId, Long hostId, VMInstanceVO vm,
             Set<StoragePool> avoid);
 
     void connectHostToSharedPool(long hostId, long poolId)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index 9ddcb78..d9ef853 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -41,6 +41,9 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.api.command.admin.storage.AddImageStoreCmd;
 import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
 import org.apache.cloudstack.api.command.admin.storage.CreateCacheStoreCmd;
@@ -80,8 +83,6 @@ import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
@@ -103,7 +104,7 @@ import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.ClusterVO;
 import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.HostPodVO;
+import com.cloud.dc.Pod;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.deploy.DataCenterDeployment;
@@ -302,7 +303,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
     private int _customDiskOfferingMinSize = 1;
     private int _customDiskOfferingMaxSize = 1024;
-    private Map<String, HypervisorHostListener> hostListeners = new HashMap<String, HypervisorHostListener>();
+    private final Map<String, HypervisorHostListener> hostListeners = new HashMap<String, HypervisorHostListener>();
 
     private boolean _recreateSystemVmEnabled;
 
@@ -399,7 +400,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
     }
 
     @Override
-    public StoragePool findStoragePool(DiskProfile dskCh, final DataCenterVO dc, HostPodVO pod, Long clusterId, Long hostId, VMInstanceVO vm,
+    public StoragePool findStoragePool(DiskProfile dskCh, final DataCenterVO dc, Pod pod, Long clusterId, Long hostId, VMInstanceVO vm,
                                        final Set<StoragePool> avoid) {
 
         VirtualMachineProfile<VMInstanceVO> profile = new VirtualMachineProfileImpl<VMInstanceVO>(vm);
@@ -413,7 +414,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
             final List<StoragePool> poolList = allocator.allocateToPool(dskCh, profile, plan, avoidList, 1);
             if (poolList != null && !poolList.isEmpty()) {
-                return (StoragePool) this.dataStoreMgr.getDataStore(poolList.get(0).getId(), DataStoreRole.Primary);
+                return (StoragePool) dataStoreMgr.getDataStore(poolList.get(0).getId(), DataStoreRole.Primary);
             }
         }
         return null;
@@ -604,7 +605,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
                     pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), "", pInfo.getUuid());
                 }
             }
-            DataStoreProvider provider = this.dataStoreProviderMgr.getDefaultPrimaryDataStoreProvider();
+            DataStoreProvider provider = dataStoreProviderMgr.getDefaultPrimaryDataStoreProvider();
             DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
             if (pool == null) {
                 Map<String, Object> params = new HashMap<String, Object>();
@@ -808,7 +809,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
                 // force expunge non-destroyed volumes
                 List<VolumeVO> vols = _volsDao.listVolumesToBeDestroyed();
                 for (VolumeVO vol : vols) {
-                    AsyncCallFuture<VolumeApiResult> future = this.volService.expungeVolumeAsync(this.volFactory.getVolume(vol.getId()));
+                    AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(vol.getId()));
                     try {
                         future.get();
                     } catch (InterruptedException e) {
@@ -847,7 +848,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
     @Override
     public void connectHostToSharedPool(long hostId, long poolId) throws StorageUnavailableException {
-        StoragePool pool = (StoragePool) this.dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
+        StoragePool pool = (StoragePool) dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
         assert (pool.isShared()) : "Now, did you actually read the name of this method?";
         s_logger.debug("Adding pool " + pool.getName() + " to  host " + hostId);
 
@@ -1032,7 +1033,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
                     for (VolumeVO vol : vols) {
                         try {
 
-                            this.volService.expungeVolumeAsync(this.volFactory.getVolume(vol.getId()));
+                            volService.expungeVolumeAsync(volFactory.getVolume(vol.getId()));
 
                         } catch (Exception e) {
                             s_logger.warn("Unable to destroy " + vol.getId(), e);
@@ -1107,11 +1108,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         // so here we don't need to issue DeleteCommand to resource anymore, only need to remove db entry.
         try {
             // Cleanup templates in template_store_ref
-            List<DataStore> imageStores = this.dataStoreMgr.getImageStoresByScope(new ZoneScope(null));
+            List<DataStore> imageStores = dataStoreMgr.getImageStoresByScope(new ZoneScope(null));
             for (DataStore store : imageStores) {
                 try {
                     long storeId = store.getId();
-                    List<TemplateDataStoreVO> destroyedTemplateStoreVOs = this._templateStoreDao.listDestroyed(storeId);
+                    List<TemplateDataStoreVO> destroyedTemplateStoreVOs = _templateStoreDao.listDestroyed(storeId);
                     s_logger.debug("Secondary storage garbage collector found " + destroyedTemplateStoreVOs.size()
                             + " templates to cleanup on template_store_ref for store: " + store.getName());
                     for (TemplateDataStoreVO destroyedTemplateStoreVO : destroyedTemplateStoreVOs) {
@@ -1311,7 +1312,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         if (hostId != null) {
             hosts.add(hostId);
         } else {
-            List<DataStore> stores = this._dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
+            List<DataStore> stores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
             if (stores != null) {
                 for (DataStore store : stores) {
                     hosts.add(store.getId());
@@ -1699,16 +1700,16 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
         if (((ImageStoreProvider) storeProvider).needDownloadSysTemplate()) {
             // trigger system vm template download
-            this._imageSrv.downloadBootstrapSysTemplate(store);
+            _imageSrv.downloadBootstrapSysTemplate(store);
         }
         else {
             // populate template_store_ref table
-            this._imageSrv.addSystemVMTemplatesToSecondary(store);
+            _imageSrv.addSystemVMTemplatesToSecondary(store);
         }
 
         // associate builtin template with zones associated with this image
         // store
-        this.associateCrosszoneTemplatesToZone(dcId);
+        associateCrosszoneTemplatesToZone(dcId);
 
         return (ImageStore) _dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Image);
     }
@@ -1765,7 +1766,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         }
 
         // search if there are user templates stored on this image store, excluding system, builtin templates
-        List<TemplateJoinVO> templates = this._templateViewDao.listActiveTemplates(storeId);
+        List<TemplateJoinVO> templates = _templateViewDao.listActiveTemplates(storeId);
         if (templates != null && templates.size() > 0) {
             throw new InvalidParameterValueException("Cannot delete image store with active templates backup!");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index d90e798..d63e631 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -31,6 +31,7 @@ import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -41,10 +42,9 @@ import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.ExtractVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
+import org.apache.cloudstack.api.command.user.volume.UpdateVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
-
-import com.cloud.storage.dao.*;
-import org.apache.cloudstack.api.command.user.volume.*;
+import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
@@ -55,7 +55,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
@@ -73,7 +72,6 @@ import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
 import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
-import org.apache.commons.lang.StringUtils;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
@@ -99,6 +97,7 @@ import com.cloud.dc.ClusterVO;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.HostPodVO;
+import com.cloud.dc.Pod;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.HostPodDao;
@@ -142,6 +141,7 @@ import com.cloud.storage.dao.VMTemplatePoolDao;
 import com.cloud.storage.dao.VMTemplateS3Dao;
 import com.cloud.storage.dao.VMTemplateSwiftDao;
 import com.cloud.storage.dao.VolumeDao;
+import com.cloud.storage.dao.VolumeDetailsDao;
 import com.cloud.storage.download.DownloadMonitor;
 import com.cloud.storage.s3.S3Manager;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
@@ -154,8 +154,8 @@ import com.cloud.template.TemplateManager;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.ResourceLimitService;
-import com.cloud.user.VmDiskStatisticsVO;
 import com.cloud.user.UserContext;
+import com.cloud.user.VmDiskStatisticsVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserDao;
 import com.cloud.user.dao.VmDiskStatisticsDao;
@@ -534,8 +534,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
         StoragePool pool = null;
 
         Set<Long> podsToAvoid = new HashSet<Long>();
-        Pair<HostPodVO, Long> pod = null;
-
+        Pair<Pod, Long> pod = null;
 
         DiskOfferingVO diskOffering = _diskOfferingDao
                 .findByIdIncludingRemoved(volume.getDiskOfferingId());
@@ -544,14 +543,12 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
                 snapshot.getHypervisorType());
 
         // Determine what pod to store the volume in
-        while ((pod = _resourceMgr.findPod(null, null, dc, account.getId(),
-                podsToAvoid)) != null) {
+        while ((pod = _resourceMgr.findPod(null, null, dc, account.getId(), podsToAvoid)) != null) {
             podsToAvoid.add(pod.first().getId());
             // Determine what storage pool to store the volume in
             while ((pool = storageMgr.findStoragePool(dskCh, dc, pod.first(), null, null,
                     null, poolsToAvoid)) != null) {
                 break;
-
             }
         }
 
@@ -1415,7 +1412,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
             vol.setDeviceId(1l);
         }
 
-        vol.setFormat(this.getSupportedImageFormatForCluster(vm.getHypervisorType()));
+        vol.setFormat(getSupportedImageFormatForCluster(vm.getHypervisorType()));
         vol = _volsDao.persist(vol);
 
         // Save usage event and update resource count for user vm volumes
@@ -1446,7 +1443,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
         VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(),
                 owner.getDomainId(), owner.getId(), offering.getId(), size,
                 offering.getMinIops(), offering.getMaxIops(), null);
-        vol.setFormat(this.getSupportedImageFormatForCluster(template.getHypervisorType()));
+        vol.setFormat(getSupportedImageFormatForCluster(template.getHypervisorType()));
         if (vm != null) {
             vol.setInstanceId(vm.getId());
         }
@@ -1558,10 +1555,10 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
             }
         }
 
-        VolumeVO volVO = this._volsDao.findById(vol.getId());
-        volVO.setFormat(this.getSupportedImageFormatForCluster(rootDiskHyperType));
-        this._volsDao.update(volVO.getId(), volVO);
-        return this.volFactory.getVolume(volVO.getId());
+        VolumeVO volVO = _volsDao.findById(vol.getId());
+        volVO.setFormat(getSupportedImageFormatForCluster(rootDiskHyperType));
+        _volsDao.update(volVO.getId(), volVO);
+        return volFactory.getVolume(volVO.getId());
     }
 
     private boolean needMoveVolume(VolumeVO rootVolumeOfVm, VolumeInfo volume) {
@@ -2768,15 +2765,15 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
 
         // Clean up code to remove all those previous uploadVO and uploadMonitor code. Previous code is trying to fake an async operation purely in
         // db table with uploadVO and async_job entry, but internal implementation is actually synchronous.
-        StoragePool srcPool = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
-        ImageStoreEntity secStore = (ImageStoreEntity) this.dataStoreMgr.getImageStore(zoneId);
+        StoragePool srcPool = (StoragePool) dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
+        ImageStoreEntity secStore = (ImageStoreEntity) dataStoreMgr.getImageStore(zoneId);
         String secondaryStorageURL = secStore.getUri();
 
-        String value = this._configDao.getValue(Config.CopyVolumeWait.toString());
+        String value = _configDao.getValue(Config.CopyVolumeWait.toString());
         int copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue()));
         // Copy volume from primary to secondary storage
-        VolumeInfo srcVol = this.volFactory.getVolume(volume.getId());
-        AsyncCallFuture<VolumeApiResult> cvAnswer = this.volService.copyVolume(srcVol, secStore);
+        VolumeInfo srcVol = volFactory.getVolume(volume.getId());
+        AsyncCallFuture<VolumeApiResult> cvAnswer = volService.copyVolume(srcVol, secStore);
         // Check if you got a valid answer.
         VolumeApiResult cvResult = null;
         try {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ab9506/server/test/com/cloud/resource/MockResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/resource/MockResourceManagerImpl.java b/server/test/com/cloud/resource/MockResourceManagerImpl.java
index a1c52aa..18cff80 100644
--- a/server/test/com/cloud/resource/MockResourceManagerImpl.java
+++ b/server/test/com/cloud/resource/MockResourceManagerImpl.java
@@ -26,38 +26,42 @@ import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
 import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
-import org.apache.cloudstack.api.command.admin.host.*;
-import org.apache.cloudstack.api.command.admin.storage.*;
-import org.apache.cloudstack.api.command.admin.swift.*;
+import org.apache.cloudstack.api.command.admin.host.AddHostCmd;
+import org.apache.cloudstack.api.command.admin.host.AddSecondaryStorageCmd;
+import org.apache.cloudstack.api.command.admin.host.CancelMaintenanceCmd;
+import org.apache.cloudstack.api.command.admin.host.PrepareForMaintenanceCmd;
+import org.apache.cloudstack.api.command.admin.host.ReconnectHostCmd;
+import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd;
+import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
+import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
+import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
+import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
+import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
 
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
-
 import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.HostPodVO;
+import com.cloud.dc.Pod;
 import com.cloud.dc.PodCluster;
 import com.cloud.exception.AgentUnavailableException;
 import com.cloud.exception.DiscoveryException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceInUseException;
 import com.cloud.host.Host;
+import com.cloud.host.Host.Type;
 import com.cloud.host.HostStats;
 import com.cloud.host.HostVO;
 import com.cloud.host.Status;
-import com.cloud.host.Host.Type;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.org.Cluster;
 import com.cloud.resource.ResourceState.Event;
 import com.cloud.service.ServiceOfferingVO;
-import com.cloud.storage.ImageStore;
 import com.cloud.storage.S3;
 import com.cloud.storage.Swift;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.ManagerBase;
-import com.cloud.utils.component.Manager;
-
-
 import com.cloud.utils.fsm.NoTransitionException;
 
 @Local(value = {ResourceManager.class})
@@ -470,7 +474,7 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana
      * @see com.cloud.resource.ResourceManager#findPod(com.cloud.template.VirtualMachineTemplate, com.cloud.service.ServiceOfferingVO, com.cloud.dc.DataCenterVO, long, java.util.Set)
      */
     @Override
-    public Pair<HostPodVO, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc,
+    public Pair<Pod, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc,
             long accountId, Set<Long> avoids) {
         // TODO Auto-generated method stub
         return null;


Mime
View raw message