cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [1/4] git commit: updated refs/heads/master to e99a1ef
Date Wed, 24 Jul 2013 01:59:33 GMT
Updated Branches:
  refs/heads/master 1ca4f6630 -> e99a1ef1d


Simplify the components that VirtualMachineManager uses


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

Branch: refs/heads/master
Commit: 861be3063cb44d718c4fa5e24d74b86c9a5147c8
Parents: 1ca4f66
Author: Alex Huang <alex.huang@citrix.com>
Authored: Mon Jul 22 20:45:59 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Tue Jul 23 18:24:57 2013 -0700

----------------------------------------------------------------------
 client/tomcatconf/applicationContext.xml.in     |  1 -
 .../vm/ClusteredVirtualMachineManagerImpl.java  |  8 +++--
 .../com/cloud/vm/ReservationContextImpl.java    | 20 ++++-------
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 38 ++++----------------
 .../com/cloud/vm/VirtualMachineProfileImpl.java | 25 ++++++-------
 .../cloud/vm/VirtualMachineManagerImplTest.java |  1 -
 6 files changed, 28 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/861be306/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 48ef7a4a..343a8a1 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -729,7 +729,6 @@
 
   <bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl"
>
     <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
-    <property name="Planners" value="#{deploymentPlanners.Adapters}" />
   </bean>
 
   <bean id="networkManagerImpl" class="com.cloud.network.NetworkManagerImpl" >

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/861be306/server/src/com/cloud/vm/ClusteredVirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/ClusteredVirtualMachineManagerImpl.java b/server/src/com/cloud/vm/ClusteredVirtualMachineManagerImpl.java
index 42ff5d4..2ee2d56 100644
--- a/server/src/com/cloud/vm/ClusteredVirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/ClusteredVirtualMachineManagerImpl.java
@@ -20,17 +20,19 @@ import java.util.List;
 import java.util.Map;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Component;
-
+import com.cloud.cluster.ClusterManager;
 import com.cloud.cluster.ClusterManagerListener;
 import com.cloud.cluster.ManagementServerHostVO;
 
 @Local(value=VirtualMachineManager.class)
 public class ClusteredVirtualMachineManagerImpl extends VirtualMachineManagerImpl implements
ClusterManagerListener {
 
+    @Inject
+    ClusterManager _clusterMgr;
+
     protected ClusteredVirtualMachineManagerImpl() {
     }
     

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/861be306/server/src/com/cloud/vm/ReservationContextImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/ReservationContextImpl.java b/server/src/com/cloud/vm/ReservationContextImpl.java
index f187f2b..b53841c 100644
--- a/server/src/com/cloud/vm/ReservationContextImpl.java
+++ b/server/src/com/cloud/vm/ReservationContextImpl.java
@@ -17,12 +17,10 @@
 package com.cloud.vm;
 
 import com.cloud.domain.Domain;
-import com.cloud.domain.dao.DomainDao;
 import com.cloud.user.Account;
 import com.cloud.user.User;
-import com.cloud.user.dao.AccountDao;
-import com.cloud.user.dao.UserDao;
 import com.cloud.utils.Journal;
+import com.cloud.utils.db.EntityManager;
 
 public class ReservationContextImpl implements ReservationContext {
     User _caller;
@@ -66,16 +64,16 @@ public class ReservationContextImpl implements ReservationContext {
     @Override
     public Account getAccount() {
         if (_account == null) {
-            _account = s_accountDao.findByIdIncludingRemoved(_caller.getId());
+            _account = s_entityMgr.findById(Account.class, _caller.getId());
         }
-        return _account; 
+        return _account;
     }
 
     @Override
     public Domain getDomain() {
         if (_domain == null) {
             getAccount();
-            _domain = s_domainDao.findByIdIncludingRemoved(_account.getDomainId());
+            _domain = s_entityMgr.findById(Domain.class, _account.getDomainId());
         }
         return _domain;
     }
@@ -90,13 +88,9 @@ public class ReservationContextImpl implements ReservationContext {
         return _reservationId;
     }
     
-    static UserDao s_userDao;
-    static DomainDao s_domainDao;
-    static AccountDao s_accountDao;
+    static EntityManager s_entityMgr;
     
-    static public void setComponents(UserDao userDao, DomainDao domainDao, AccountDao accountDao)
{
-        s_userDao = userDao;
-        s_domainDao = domainDao;
-        s_accountDao = accountDao;
+    static public void init(EntityManager entityMgr) {
+        s_entityMgr = entityMgr;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/861be306/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index a0c5c3a..e957280 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -44,6 +44,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.cloudstack.utils.identity.ManagementServerNode;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.AgentManager.OnError;
@@ -81,7 +82,6 @@ import com.cloud.agent.manager.Commands;
 import com.cloud.agent.manager.allocator.HostAllocator;
 import com.cloud.alert.AlertManager;
 import com.cloud.capacity.CapacityManager;
-import com.cloud.cluster.ClusterManager;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.Resource.ResourceType;
@@ -94,11 +94,9 @@ import com.cloud.dc.HostPodVO;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.HostPodDao;
-import com.cloud.dc.dao.VlanDao;
 import com.cloud.deploy.DataCenterDeployment;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.deploy.DeploymentPlan;
-import com.cloud.deploy.DeploymentPlanner;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.deploy.DeploymentPlanningManager;
 import com.cloud.domain.dao.DomainDao;
@@ -145,7 +143,6 @@ import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.Volume;
@@ -164,7 +161,6 @@ import com.cloud.user.AccountManager;
 import com.cloud.user.ResourceLimitService;
 import com.cloud.user.User;
 import com.cloud.user.dao.AccountDao;
-import com.cloud.user.dao.UserDao;
 import com.cloud.utils.Journal;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
@@ -198,8 +194,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     private static final Logger s_logger = Logger.getLogger(VirtualMachineManagerImpl.class);
 
     @Inject
-    protected StorageManager _storageMgr;
-    @Inject
     DataStoreManager dataStoreMgr;
     @Inject
     protected NetworkManager _networkMgr;
@@ -216,14 +210,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     @Inject
     protected VMTemplateDao _templateDao;
     @Inject
-    protected UserDao _userDao;
-    @Inject
     protected AccountDao _accountDao;
     @Inject
     protected DomainDao _domainDao;
     @Inject
-    protected ClusterManager _clusterMgr;
-    @Inject
     protected ItWorkDao _workDao;
     @Inject
     protected UserVmDao _userVmDao;
@@ -278,20 +268,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     @Inject
     protected IPAddressDao _publicIpAddressDao;
     @Inject
-    protected VlanDao _vlanDao;
-    @Inject
     protected NicIpAliasDao _nicIpAliasDao;
     @Inject
     protected EntityManager _entityMgr;
 
-    protected List<DeploymentPlanner> _planners;
-    public List<DeploymentPlanner> getPlanners() {
-        return _planners;
-    }
-    public void setPlanners(List<DeploymentPlanner> _planners) {
-        this._planners = _planners;
-    }
-
     protected List<HostAllocator> _hostAllocators;
     public List<HostAllocator> getHostAllocators() {
         return _hostAllocators;
@@ -574,8 +554,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
         _retry = NumbersUtil.parseInt(params.get(Config.StartRetry.key()), 10);
 
-        ReservationContextImpl.setComponents(_userDao, _domainDao, _accountDao);
-        VirtualMachineProfileImpl.setComponents(_offeringDao, _templateDao, _accountDao);
+        ReservationContextImpl.init(_entityMgr);
+        VirtualMachineProfileImpl.init(_entityMgr);
 
         _cancelWait = NumbersUtil.parseLong(params.get(Config.VmOpCancelInterval.key()),
3600);
         _cleanupWait = NumbersUtil.parseLong(params.get(Config.VmOpCleanupWait.key()), 3600);
@@ -586,7 +566,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         _forceStop = Boolean.parseBoolean(params.get(Config.VmDestroyForcestop.key()));
 
         _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup"));
-        _nodeId = _clusterMgr.getManagementNodeId();
+        _nodeId = ManagementServerNode.getManagementServerId();
 
         _agentMgr.registerForHostEvents(this, true, true, true);
 
@@ -2854,17 +2834,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     ResourceUnavailableException, InsufficientCapacityException {
 
         s_logger.debug("Adding vm " + vm + " to network " + network + "; requested nic profile
" + requested);
-        VMInstanceVO vmVO;
-        if (vm.getType() == VirtualMachine.Type.User) {
-            vmVO = _userVmDao.findById(vm.getId());
-        } else {
-            vmVO = _vmDao.findById(vm.getId());
-        }
+        VMInstanceVO vmVO = _vmDao.findById(vm.getId());
         ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(User.UID_SYSTEM),
                 _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM));
 
-        VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmVO, null,
-                null, null, null);
+        VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmVO, null, null,
null, null);
 
         DataCenter dc = _configMgr.getZone(network.getDataCenterId());
         Host host = _hostDao.findById(vm.getHostId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/861be306/server/src/com/cloud/vm/VirtualMachineProfileImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java b/server/src/com/cloud/vm/VirtualMachineProfileImpl.java
index 5e84c1f..5a3505e 100644
--- a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineProfileImpl.java
@@ -25,13 +25,11 @@ import com.cloud.agent.api.to.DiskTO;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.service.ServiceOfferingVO;
-import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.VMTemplateVO;
-import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.template.VirtualMachineTemplate.BootloaderType;
 import com.cloud.user.Account;
-import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.db.EntityManager;
 
 /**
  * Implementation of VirtualMachineProfile.
@@ -40,8 +38,8 @@ import com.cloud.user.dao.AccountDao;
 public class VirtualMachineProfileImpl implements VirtualMachineProfile {
 
     VirtualMachine _vm;
-    ServiceOfferingVO _offering;
-    VMTemplateVO _template;
+    ServiceOffering _offering;
+    VirtualMachineTemplate _template;
     UserVmDetailVO _userVmDetails;
     Map<Param, Object> _params;
     List<NicProfile> _nics = new ArrayList<NicProfile>();
@@ -88,7 +86,7 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile
{
     @Override
     public ServiceOffering getServiceOffering() {
         if (_offering == null) {
-            _offering = s_offeringDao.findByIdIncludingRemoved(_vm.getServiceOfferingId());
+            _offering = s_entityMgr.findById(ServiceOffering.class, _vm.getServiceOfferingId());
         }
         return _offering;
     }
@@ -106,7 +104,7 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile
{
     @Override
     public VirtualMachineTemplate getTemplate() {
         if (_template == null && _vm != null) {
-            _template = s_templateDao.findByIdIncludingRemoved(_vm.getTemplateId());
+            _template = s_entityMgr.findById(VirtualMachineTemplate.class, _vm.getTemplateId());
         }
         return _template;
     }
@@ -184,7 +182,7 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile
{
     @Override
     public Account getOwner() {
         if (_owner == null) {
-            _owner = s_accountDao.findByIdIncludingRemoved(_vm.getAccountId());
+            _owner = s_entityMgr.findById(Account.class, _vm.getAccountId());
         }
         return _owner;
     }
@@ -194,13 +192,10 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile
{
         return _bootArgs.toString();
     }
 
-    static ServiceOfferingDao s_offeringDao;
-    static VMTemplateDao s_templateDao;
-    static AccountDao s_accountDao;
-    static void setComponents(ServiceOfferingDao offeringDao, VMTemplateDao templateDao,
AccountDao accountDao) {
-        s_offeringDao = offeringDao;
-        s_templateDao = templateDao;
-        s_accountDao = accountDao;
+    static EntityManager s_entityMgr;
+
+    static void init(EntityManager entityMgr) {
+        s_entityMgr = entityMgr;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/861be306/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java b/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
index fba95b3..8490301 100644
--- a/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
+++ b/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
@@ -189,7 +189,6 @@ public class VirtualMachineManagerImplTest {
             _vmMgr._volsDao = _volsDao;
             _vmMgr.volumeMgr = _storageMgr;
             _vmMgr._accountDao = _accountDao;
-            _vmMgr._userDao = _userDao;
             _vmMgr._accountMgr = _accountMgr;
             _vmMgr._configMgr = _configMgr;
             _vmMgr._capacityMgr = _capacityMgr;


Mime
View raw message