Changes to the planners

This commit is contained in:
Alex Huang 2011-03-28 09:48:33 -07:00
parent 08036d5312
commit b2eda8c71b
4 changed files with 7 additions and 92 deletions

View File

@ -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<? extends VirtualMachine> vmProfile, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException {
VirtualMachine vm = vmProfile.getVirtualMachine();
ServiceOffering offering = vmProfile.getServiceOffering();
String hostTag = null;

View File

@ -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<? extends VirtualMachine> 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<Long> clusterList, VirtualMachineProfile vmProfile,
private DeployDestination checkClustersforDestination(List<Long> clusterList, VirtualMachineProfile<? extends VirtualMachine> 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<Long> reorderedClusters = new ArrayList<Long>();
for (Long pod : podIds){
if(podClusterMap.containsKey(pod)){
List<Long> clustersOfThisPod = (List<Long>)podClusterMap.get(pod);
List<Long> 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<Host> findSuitableHosts(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo){
protected List<Host> findSuitableHosts(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo){
List<Host> suitableHosts = new ArrayList<Host>();
Enumeration<HostAllocator> 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<Volume, List<StoragePool>> findSuitablePoolsForVolumes(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo){
protected Map<Volume, List<StoragePool>> findSuitablePoolsForVolumes(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo){
List<VolumeVO> volumesTobeCreated = _volsDao.findUsableVolumesForInstance(vmProfile.getId());
Map<Volume, List<StoragePool>> suitableVolumeStoragePools = new HashMap<Volume, List<StoragePool>>();
@ -571,7 +566,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
@Override
public boolean check(VirtualMachineProfile vm, DeploymentPlan plan,
public boolean check(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan,
DeployDestination dest, ExcludeList exclude) {
// TODO Auto-generated method stub
return false;

View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
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<HostVO> 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<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid) {
return false;
}
}

View File

@ -2422,7 +2422,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
}
@Override
public void prepare(VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest) throws StorageUnavailableException,
InsufficientStorageCapacityException {