From b2eda8c71be34a417cb9dc0d6ef96a7fbcd2f25e Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Mon, 28 Mar 2011 09:48:33 -0700 Subject: [PATCH] Changes to the planners --- .../com/cloud/deploy/BareMetalPlanner.java | 2 +- .../src/com/cloud/deploy/FirstFitPlanner.java | 17 ++-- .../src/com/cloud/deploy/SimplePlanner.java | 79 ------------------- .../com/cloud/storage/StorageManagerImpl.java | 1 - 4 files changed, 7 insertions(+), 92 deletions(-) delete mode 100644 server/src/com/cloud/deploy/SimplePlanner.java diff --git a/server/src/com/cloud/deploy/BareMetalPlanner.java b/server/src/com/cloud/deploy/BareMetalPlanner.java index e1319997967..e75f661bc4b 100644 --- a/server/src/com/cloud/deploy/BareMetalPlanner.java +++ b/server/src/com/cloud/deploy/BareMetalPlanner.java @@ -22,7 +22,7 @@ public class BareMetalPlanner extends FirstFitPlanner implements DeploymentPlann private static final Logger s_logger = Logger.getLogger(BareMetalPlanner.class); @Override - public DeployDestination plan(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException { + public DeployDestination plan(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException { VirtualMachine vm = vmProfile.getVirtualMachine(); ServiceOffering offering = vmProfile.getServiceOffering(); String hostTag = null; diff --git a/server/src/com/cloud/deploy/FirstFitPlanner.java b/server/src/com/cloud/deploy/FirstFitPlanner.java index 94afd89c844..1fd6d7ca902 100644 --- a/server/src/com/cloud/deploy/FirstFitPlanner.java +++ b/server/src/com/cloud/deploy/FirstFitPlanner.java @@ -25,10 +25,7 @@ import com.cloud.dc.Pod; import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.HostPodDao; -import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.exception.InsufficientServerCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.PermissionDeniedException; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.Status; @@ -51,8 +48,6 @@ import com.cloud.storage.dao.GuestOSDao; import com.cloud.storage.dao.StoragePoolDao; import com.cloud.storage.dao.StoragePoolHostDao; import com.cloud.storage.dao.VolumeDao; -import com.cloud.user.Account; -import com.cloud.user.UserContext; import com.cloud.utils.Pair; import com.cloud.utils.component.Adapters; import com.cloud.utils.component.Inject; @@ -90,7 +85,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { private static int RETURN_UPTO_ALL = -1; @Override - public DeployDestination plan(VirtualMachineProfile vmProfile, + public DeployDestination plan(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException { String _allocationAlgorithm = _configDao.getValue(Config.VmAllocationAlgorithm.key()); @@ -311,7 +306,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { - private DeployDestination checkClustersforDestination(List clusterList, VirtualMachineProfile vmProfile, + private DeployDestination checkClustersforDestination(List clusterList, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, DataCenter dc, String _allocationAlgorithm){ if (s_logger.isDebugEnabled()) { @@ -391,7 +386,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { List reorderedClusters = new ArrayList(); for (Long pod : podIds){ if(podClusterMap.containsKey(pod)){ - List clustersOfThisPod = (List)podClusterMap.get(pod); + List clustersOfThisPod = podClusterMap.get(pod); if(clustersOfThisPod != null){ for(Long clusterId : clusterIds){ if(clustersOfThisPod.contains(clusterId)){ @@ -489,7 +484,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { return hostCanAccessSPool; } - protected List findSuitableHosts(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo){ + protected List findSuitableHosts(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo){ List suitableHosts = new ArrayList(); Enumeration enHost = _hostAllocators.enumeration(); s_logger.debug("Calling HostAllocators to find suitable hosts"); @@ -508,7 +503,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { return suitableHosts; } - protected Map> findSuitablePoolsForVolumes(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo){ + protected Map> findSuitablePoolsForVolumes(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo){ List volumesTobeCreated = _volsDao.findUsableVolumesForInstance(vmProfile.getId()); Map> suitableVolumeStoragePools = new HashMap>(); @@ -571,7 +566,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { @Override - public boolean check(VirtualMachineProfile vm, DeploymentPlan plan, + public boolean check(VirtualMachineProfile vm, DeploymentPlan plan, DeployDestination dest, ExcludeList exclude) { // TODO Auto-generated method stub return false; diff --git a/server/src/com/cloud/deploy/SimplePlanner.java b/server/src/com/cloud/deploy/SimplePlanner.java deleted file mode 100644 index e309daff268..00000000000 --- a/server/src/com/cloud/deploy/SimplePlanner.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -package com.cloud.deploy; - -import java.util.List; - -import javax.ejb.Local; - -import com.cloud.dc.DataCenterVO; -import com.cloud.dc.Pod; -import com.cloud.dc.dao.ClusterDao; -import com.cloud.dc.dao.DataCenterDao; -import com.cloud.dc.dao.HostPodDao; -import com.cloud.deploy.DeploymentPlanner.ExcludeList; -import com.cloud.host.Host; -import com.cloud.host.Host.Type; -import com.cloud.host.HostVO; -import com.cloud.host.dao.HostDao; -import com.cloud.org.Cluster; -import com.cloud.utils.component.Inject; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.VirtualMachineProfile; - -@Local(value=DeploymentPlanner.class) -public class SimplePlanner extends PlannerBase implements DeploymentPlanner { - @Inject DataCenterDao _dcDao; - @Inject HostPodDao _podDao; - @Inject HostDao _hostDao; - @Inject ClusterDao _clusterDao; - - @Override - public DeployDestination plan(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeList avoid) { - DataCenterVO dc = _dcDao.findById(plan.getDataCenterId()); - List hosts = _hostDao.listBy(Type.Routing, plan.getDataCenterId()); - - if (hosts.size() == 0) { - return null; - } - - Host host = hosts.get(0); - Pod pod = _podDao.findById(host.getPodId()); - - Cluster cluster = null; - if (host.getClusterId() != null) { - cluster = _clusterDao.findById(host.getClusterId()); - } - - return new DeployDestination(dc, pod, cluster, host); - } - - public boolean check(VirtualMachineProfile vm, DeploymentPlan plan, DeployDestination dest, ExcludeList avoid) { - return true; - } - - protected SimplePlanner() { - super(); - } - - //TODO: set it to true if you want to use it - @Override - public boolean canHandle(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeList avoid) { - return false; - } -} diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index f57f6f5f36b..5db20e1b356 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -2422,7 +2422,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag } } - @Override public void prepare(VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException {