mirror of https://github.com/apache/cloudstack.git
Bug 11522 - New agent manager
move all listxxx interface from HostDao to managers(ResourceManager, SecondaryStorageVmManager etc) with decent name using SearchCriteria2 or direct call SearchCriteria2 on demand
This commit is contained in:
parent
683113cc38
commit
89e04458b6
|
|
@ -133,6 +133,7 @@ import com.cloud.storage.dao.StoragePoolDao;
|
|||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.resource.DummySecondaryStorageResource;
|
||||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
|
|
@ -242,6 +243,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
|
||||
@Inject StorageService _storageSvr = null;
|
||||
@Inject StorageManager _storageMgr = null;
|
||||
@Inject SecondaryStorageVmManager _ssvmMgr;
|
||||
|
||||
protected int _retry = 2;
|
||||
|
||||
|
|
@ -494,7 +496,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
return ssHost;
|
||||
} else if ( ssHost.getType() == Host.Type.SecondaryStorage) {
|
||||
Long dcId = ssHost.getDataCenterId();
|
||||
List<HostVO> ssAHosts = _hostDao.listSecondaryStorageVM(dcId);
|
||||
List<HostVO> ssAHosts = _ssvmMgr.listUpSecondaryStorageVmHost(dcId);
|
||||
if (ssAHosts == null || ssAHosts.isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -520,7 +522,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
|
||||
|
||||
private long sendToSSVM(final long dcId, final Command cmd, final Listener listener) {
|
||||
List<HostVO> ssAHosts = _hostDao.listSecondaryStorageVM(dcId);
|
||||
List<HostVO> ssAHosts = _ssvmMgr.listUpSecondaryStorageVmHost(dcId);
|
||||
if (ssAHosts == null || ssAHosts.isEmpty() ) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -534,7 +536,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
}
|
||||
|
||||
private Answer sendToSSVM(final long dcId, final Command cmd) {
|
||||
List<HostVO> ssAHosts = _hostDao.listSecondaryStorageVM(dcId);
|
||||
List<HostVO> ssAHosts = _ssvmMgr.listUpSecondaryStorageVmHost(dcId);
|
||||
if (ssAHosts == null || ssAHosts.isEmpty() ) {
|
||||
return new Answer(cmd, false, "can not find secondary storage VM agent for data center " + dcId);
|
||||
}
|
||||
|
|
@ -548,7 +550,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
List<ClusterVO> clusters = _clusterDao.listByDcHyType(dcId, type.toString());
|
||||
int retry = 0;
|
||||
for (ClusterVO cluster : clusters) {
|
||||
List<HostVO> hosts = _hostDao.listBy(Host.Type.Routing, cluster.getId(), null, dcId);
|
||||
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), null, dcId);
|
||||
for (HostVO host : hosts) {
|
||||
retry++;
|
||||
if (retry > _retry) {
|
||||
|
|
@ -793,7 +795,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
}
|
||||
|
||||
public void startDirectlyConnectedHosts() {
|
||||
List<HostVO> hosts = _hostDao.findDirectlyConnectedHosts();
|
||||
List<HostVO> hosts = _resourceMgr.findDirectlyConnectedHosts();
|
||||
for (HostVO host : hosts) {
|
||||
loadDirectlyConnectedHost(host, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ import com.cloud.resource.ResourceState;
|
|||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.ConnectionConcierge;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.time.InaccurateClock;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
|
@ -141,7 +143,10 @@ public class AgentMonitor extends Thread implements Listener {
|
|||
_agentMgr.disconnectWithInvestigation(agentId, Event.PingTimeout);
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _hostDao.listByResourceState(ResourceState.PrepareForMaintenance, ResourceState.ErrorInMaintenance);
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getResourceState(), Op.IN, ResourceState.PrepareForMaintenance, ResourceState.ErrorInMaintenance);
|
||||
List<HostVO> hosts = sc.list();
|
||||
|
||||
for (HostVO host : hosts) {
|
||||
long hostId = host.getId();
|
||||
DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId());
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ import com.cloud.configuration.Config;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.Status.Event;
|
||||
|
|
@ -71,7 +72,9 @@ import com.cloud.utils.component.ComponentLocator;
|
|||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.nio.Link;
|
||||
import com.cloud.utils.nio.Task;
|
||||
|
|
@ -709,7 +712,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
public void startRebalanceAgents() {
|
||||
s_logger.debug("Management server " + _nodeId + " is asking other peers to rebalance their agents");
|
||||
List<ManagementServerHostVO> allMS = _mshostDao.listBy(ManagementServerHost.State.Up);
|
||||
List<HostVO> allManagedAgents = _hostDao.listManagedRoutingAgents();
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getManagementServerId(), Op.NNULL);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
|
||||
List<HostVO> allManagedAgents = sc.list();
|
||||
|
||||
int avLoad = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import com.cloud.host.dao.HostDetailsDao;
|
|||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.GuestOSCategoryVO;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
|
|
@ -77,7 +78,8 @@ public class FirstFitAllocator implements HostAllocator {
|
|||
@Inject GuestOSDao _guestOSDao = null;
|
||||
@Inject GuestOSCategoryDao _guestOSCategoryDao = null;
|
||||
@Inject HypervisorCapabilitiesDao _hypervisorCapabilitiesDao = null;
|
||||
@Inject VMInstanceDao _vmInstanceDao = null;
|
||||
@Inject VMInstanceDao _vmInstanceDao = null;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
float _factor = 1;
|
||||
protected String _allocationAlgorithm = "random";
|
||||
@Inject CapacityManager _capacityMgr;
|
||||
|
|
@ -115,7 +117,7 @@ public class FirstFitAllocator implements HostAllocator {
|
|||
|
||||
List<HostVO> clusterHosts = new ArrayList<HostVO>();
|
||||
if(hostTagOnOffering == null && hostTagOnTemplate == null){
|
||||
clusterHosts = _hostDao.listBy(type, clusterId, podId, dcId);
|
||||
clusterHosts = _resourceMgr.listAllUpAndEnabledHosts(type, clusterId, podId, dcId);
|
||||
}else{
|
||||
List<HostVO> hostsMatchingOfferingTag = new ArrayList<HostVO>();
|
||||
List<HostVO> hostsMatchingTemplateTag = new ArrayList<HostVO>();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.cloud.host.Host.Type;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
|
@ -44,6 +45,7 @@ public class RandomAllocator implements HostAllocator {
|
|||
private static final Logger s_logger = Logger.getLogger(RandomAllocator.class);
|
||||
private String _name;
|
||||
private HostDao _hostDao;
|
||||
private ResourceManager _resourceMgr;
|
||||
|
||||
@Override
|
||||
public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
|
||||
|
|
@ -78,7 +80,7 @@ public class RandomAllocator implements HostAllocator {
|
|||
if(hostTag != null){
|
||||
hosts = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTag);
|
||||
}else{
|
||||
hosts = _hostDao.listBy(type, clusterId, podId, dcId);
|
||||
hosts = _resourceMgr.listAllUpAndEnabledHosts(type, clusterId, podId, dcId);
|
||||
}
|
||||
|
||||
s_logger.debug("Random Allocator found " + hosts.size() + " hosts");
|
||||
|
|
@ -126,6 +128,7 @@ public class RandomAllocator implements HostAllocator {
|
|||
public boolean configure(String name, Map<String, Object> params) {
|
||||
ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
||||
_hostDao = locator.getDao(HostDao.class);
|
||||
_resourceMgr = locator.getManager(ResourceManager.class);
|
||||
if (_hostDao == null) {
|
||||
s_logger.error("Unable to get host dao.");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class BareMetalPingServiceImpl extends BareMetalPxeServiceBase implements
|
|||
throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
|
||||
}
|
||||
|
||||
List<HostVO> pxeServers = _hostDao.listBy(Host.Type.PxeServer, null, podId, zoneId);
|
||||
List<HostVO> pxeServers = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.PxeServer, null, podId, zoneId);
|
||||
if (pxeServers.size() != 0) {
|
||||
throw new InvalidParameterValueException("Already had a PXE server in Pod: " + podId + " zone: " + zoneId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
|
|
@ -34,6 +35,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
public class BareMetalTemplateAdapter extends TemplateAdapterBase implements TemplateAdapter {
|
||||
private final static Logger s_logger = Logger.getLogger(BareMetalTemplateAdapter.class);
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
@Override
|
||||
public TemplateProfile prepare(RegisterTemplateCmd cmd) throws ResourceAllocationException {
|
||||
|
|
@ -43,13 +45,13 @@ public class BareMetalTemplateAdapter extends TemplateAdapterBase implements Tem
|
|||
if (profile.getZoneId() == null || profile.getZoneId() == -1) {
|
||||
List<DataCenterVO> dcs = _dcDao.listAllIncludingRemoved();
|
||||
for (DataCenterVO dc : dcs) {
|
||||
List<HostVO> pxeServers = _hostDao.listAllBy(Host.Type.PxeServer, dc.getId());
|
||||
List<HostVO> pxeServers = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.PxeServer, dc.getId());
|
||||
if (pxeServers.size() == 0) {
|
||||
throw new CloudRuntimeException("Please add PXE server before adding baremetal template in zone " + dc.getName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<HostVO> pxeServers = _hostDao.listAllBy(Host.Type.PxeServer, profile.getZoneId());
|
||||
List<HostVO> pxeServers = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.PxeServer, profile.getZoneId());
|
||||
if (pxeServers.size() == 0) {
|
||||
throw new CloudRuntimeException("Please add PXE server before adding baremetal template in zone " + profile.getZoneId());
|
||||
}
|
||||
|
|
@ -86,7 +88,7 @@ public class BareMetalTemplateAdapter extends TemplateAdapterBase implements Tem
|
|||
if (zoneId == null || zoneId == -1) {
|
||||
List<DataCenterVO> dcs = _dcDao.listAllIncludingRemoved();
|
||||
for (DataCenterVO dc : dcs) {
|
||||
HostVO pxe = _hostDao.listAllBy(Host.Type.PxeServer, dc.getId()).get(0);
|
||||
HostVO pxe = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.PxeServer, dc.getId()).get(0);
|
||||
|
||||
vmTemplateHost = _tmpltHostDao.findByHostTemplate(dc.getId(), template.getId());
|
||||
if (vmTemplateHost == null) {
|
||||
|
|
@ -97,7 +99,7 @@ public class BareMetalTemplateAdapter extends TemplateAdapterBase implements Tem
|
|||
}
|
||||
}
|
||||
} else {
|
||||
HostVO pxe = _hostDao.listAllBy(Host.Type.PxeServer, zoneId).get(0);
|
||||
HostVO pxe = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.PxeServer, zoneId).get(0);
|
||||
vmTemplateHost = new VMTemplateHostVO(pxe.getId(), template.getId(), new Date(), 100,
|
||||
Status.DOWNLOADED, null, null, null, null, template.getUrl());
|
||||
_tmpltHostDao.persist(vmTemplateHost);
|
||||
|
|
|
|||
|
|
@ -58,12 +58,14 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.HostAllocationState;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
|
|
@ -108,7 +110,8 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
|
|||
StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
private static final Logger s_logger = Logger.getLogger(BareMetalVmManagerImpl.class);
|
||||
private ConfigurationDao _configDao;
|
||||
@Inject PxeServerManager _pxeMgr;
|
||||
@Inject PxeServerManager _pxeMgr;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
@Inject (adapter=TemplateAdapter.class)
|
||||
protected Adapters<TemplateAdapter> _adapters;
|
||||
|
|
@ -161,7 +164,7 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
|
|||
throw new InvalidParameterValueException("Cannot find host with id " + hostId);
|
||||
}
|
||||
|
||||
List<HostVO> pxes = _hostDao.listBy(Host.Type.PxeServer, null, host.getPodId(), host.getDataCenterId());
|
||||
List<HostVO> pxes = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.PxeServer, null, host.getPodId(), host.getDataCenterId());
|
||||
if (pxes.size() == 0) {
|
||||
throw new CloudRuntimeException("Please add PXE server in Pod before taking image");
|
||||
}
|
||||
|
|
@ -405,7 +408,7 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
|
|||
long vmId = cmd.getEntityId();
|
||||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
|
||||
List<HostVO> servers = _hostDao.listBy(Host.Type.PxeServer, vm.getDataCenterIdToDeployIn());
|
||||
List<HostVO> servers = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByType(Host.Type.PxeServer, vm.getDataCenterIdToDeployIn());
|
||||
if (servers.size() == 0) {
|
||||
throw new CloudRuntimeException("Cannot find PXE server, please make sure there is one PXE server per zone");
|
||||
}
|
||||
|
|
@ -474,7 +477,7 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
|
|||
}
|
||||
s_logger.debug("This is a PXE start, prepare PXE server first");
|
||||
|
||||
List<HostVO> servers = _hostDao.listBy(Host.Type.PxeServer, vm.getDataCenterIdToDeployIn());
|
||||
List<HostVO> servers = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByType(Host.Type.PxeServer, dest.getDataCenter().getId());
|
||||
if (servers.size() == 0) {
|
||||
throw new CloudRuntimeException("Cannot find PXE server, please make sure there is one PXE server per zone");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public class ExternalDhcpManagerImpl implements ExternalDhcpManager, ResourceSta
|
|||
throw new InvalidParameterValueException("Could not find pod with ID: " + podId);
|
||||
}
|
||||
|
||||
List<HostVO> dhcps = _hostDao.listBy(Host.Type.ExternalDhcp, null, podId, zoneId);
|
||||
List<HostVO> dhcps = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.ExternalDhcp, null, podId, zoneId);
|
||||
if (dhcps.size() != 0) {
|
||||
throw new InvalidParameterValueException("Already had a DHCP server in Pod: " + podId + " zone: " + zoneId);
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ public class ExternalDhcpManagerImpl implements ExternalDhcpManager, ResourceSta
|
|||
return;
|
||||
}
|
||||
|
||||
List<HostVO> servers = _hostDao.listBy(Host.Type.PxeServer, null, vm.getPodIdToDeployIn(), vm.getDataCenterIdToDeployIn());
|
||||
List<HostVO> servers = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.PxeServer, null, vm.getPodIdToDeployIn(), vm.getDataCenterIdToDeployIn());
|
||||
if (servers.size() != 1) {
|
||||
throw new CloudRuntimeException("Wrong number of PXE server found in zone " + vm.getDataCenterIdToDeployIn()
|
||||
+ " Pod " + vm.getPodIdToDeployIn() + ", number is " + servers.size());
|
||||
|
|
@ -209,7 +209,7 @@ public class ExternalDhcpManagerImpl implements ExternalDhcpManager, ResourceSta
|
|||
ReservationContext context) throws ResourceUnavailableException {
|
||||
Long zoneId = profile.getVirtualMachine().getDataCenterIdToDeployIn();
|
||||
Long podId = profile.getVirtualMachine().getPodIdToDeployIn();
|
||||
List<HostVO> hosts = _hostDao.listBy(Type.ExternalDhcp, null, podId, zoneId);
|
||||
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(Type.ExternalDhcp, null, podId, zoneId);
|
||||
if (hosts.size() == 0) {
|
||||
throw new CloudRuntimeException("No external Dhcp found in zone " + zoneId + " pod " + podId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import com.cloud.host.HostVO;
|
|||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.utils.DateUtil;
|
||||
|
|
@ -78,6 +79,8 @@ public class CapacityManagerImpl implements CapacityManager, StateListener<State
|
|||
VMInstanceDao _vmDao;
|
||||
@Inject
|
||||
AgentManager _agentManager;
|
||||
@Inject
|
||||
ResourceManager _resourceMgr;
|
||||
|
||||
private int _hostCapacityCheckerDelay;
|
||||
private int _hostCapacityCheckerInterval;
|
||||
|
|
@ -419,7 +422,7 @@ public class CapacityManagerImpl implements CapacityManager, StateListener<State
|
|||
public void run() {
|
||||
s_logger.debug("HostCapacityCollector is running...");
|
||||
// get all hosts...even if they are not in 'UP' state
|
||||
List<HostVO> hosts = _hostDao.listByType(Host.Type.Routing);
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInAllZonesByType(Host.Type.Routing);
|
||||
for (HostVO host : hosts) {
|
||||
updateCapacityForHost(host);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import com.cloud.configuration.Config;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status.Event;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
|
|
@ -73,6 +74,8 @@ import com.cloud.utils.component.Inject;
|
|||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.ConnectionConcierge;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.events.SubscriptionMgr;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
|
@ -619,8 +622,14 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||
|
||||
//initiate agent lb task will be scheduled and executed only once, and only when number of agents loaded exceeds _connectedAgentsThreshold
|
||||
if (_agentLBEnabled && !_agentLbHappened) {
|
||||
List<HostVO> allManagedRoutingAgents = _hostDao.listManagedRoutingAgents();
|
||||
List<HostVO> allAgents = _hostDao.listAllRoutingAgents();
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getManagementServerId(), Op.NNULL);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
|
||||
List<HostVO> allManagedRoutingAgents = sc.list();
|
||||
|
||||
sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
|
||||
List<HostVO> allAgents = sc.list();
|
||||
double allHostsCount = allAgents.size();
|
||||
double managedHostsCount = allManagedRoutingAgents.size();
|
||||
if (allHostsCount > 0.0) {
|
||||
|
|
|
|||
14
server/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
Normal file → Executable file
14
server/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
Normal file → Executable file
|
|
@ -30,10 +30,13 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
|
||||
@Local(value=AgentLoadBalancerPlanner.class)
|
||||
|
|
@ -66,14 +69,21 @@ public class ClusterBasedAgentLoadBalancerPlanner implements AgentLoadBalancerPl
|
|||
|
||||
@Override
|
||||
public List<HostVO> getHostsToRebalance(long msId, int avLoad) {
|
||||
List<HostVO> allHosts = _hostDao.listRoutingHostsByManagementServer(msId);
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
|
||||
sc.addAnd(sc.getEntity().getManagementServerId(), Op.EQ, msId);
|
||||
List<HostVO> allHosts = sc.list();
|
||||
|
||||
if (allHosts.size() <= avLoad) {
|
||||
s_logger.debug("Agent load = " + allHosts.size() + " for management server " + msId + " doesn't exceed average system agent load = " + avLoad + "; so it doesn't participate in agent rebalancing process");
|
||||
return null;
|
||||
}
|
||||
|
||||
List<HostVO> directHosts = _hostDao.listDirectHostsBy(msId, Status.Up);
|
||||
sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getManagementServerId(), Op.EQ, msId);
|
||||
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
|
||||
List<HostVO> directHosts = sc.list();
|
||||
|
||||
if (directHosts.isEmpty()) {
|
||||
s_logger.debug("No direct agents in status " + Status.Up + " exist for the management server " + msId + "; so it doesn't participate in agent rebalancing process");
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
|||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.info.ConsoleProxyInfo;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
|
|
@ -36,11 +37,12 @@ import com.cloud.vm.dao.ConsoleProxyDao;
|
|||
public class StaticConsoleProxyManager extends AgentBasedConsoleProxyManager implements ConsoleProxyManager {
|
||||
String _ip = null;
|
||||
@Inject ConsoleProxyDao _proxyDao;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
@Override
|
||||
protected HostVO findHost(VMInstanceVO vm) {
|
||||
|
||||
List<HostVO> hosts = _hostDao.listBy(Type.ConsoleProxy, vm.getDataCenterIdToDeployIn());
|
||||
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByType(Type.ConsoleProxy, vm.getDataCenterIdToDeployIn());
|
||||
|
||||
return hosts.isEmpty() ? null : hosts.get(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import com.cloud.host.dao.HostDao;
|
|||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
|
@ -57,6 +58,7 @@ public class BareMetalPlanner implements DeploymentPlanner {
|
|||
@Inject protected HostDao _hostDao;
|
||||
@Inject protected ConfigurationDao _configDao;
|
||||
@Inject protected CapacityManager _capacityMgr;
|
||||
@Inject protected ResourceManager _resourceMgr;
|
||||
String _name;
|
||||
|
||||
@Override
|
||||
|
|
@ -94,7 +96,7 @@ public class BareMetalPlanner implements DeploymentPlanner {
|
|||
int cpu_requested;
|
||||
long ram_requested;
|
||||
HostVO target = null;
|
||||
List<HostVO> hosts = _hostDao.listByCluster(cluster.getId());
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
|
||||
if (hostTag != null) {
|
||||
for (HostVO h : hosts) {
|
||||
_hostDao.loadDetails(h);
|
||||
|
|
|
|||
|
|
@ -33,9 +33,13 @@ import com.cloud.agent.api.PingTestCommand;
|
|||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
public abstract class AbstractInvestigatorImpl implements Investigator {
|
||||
private static final Logger s_logger = Logger.getLogger(AbstractInvestigatorImpl.class);
|
||||
|
|
@ -43,6 +47,7 @@ public abstract class AbstractInvestigatorImpl implements Investigator {
|
|||
private String _name = null;
|
||||
@Inject private HostDao _hostDao = null;
|
||||
@Inject private AgentManager _agentMgr = null;
|
||||
@Inject private ResourceManager _resourceMgr = null;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -69,7 +74,12 @@ public abstract class AbstractInvestigatorImpl implements Investigator {
|
|||
|
||||
// Host.status is up and Host.type is routing
|
||||
protected List<Long> findHostByPod(long podId, Long excludeHostId) {
|
||||
List<Long> hostIds = _hostDao.listBy(null, podId, null, Type.Routing, Status.Up);
|
||||
SearchCriteria2<HostVO, Long> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Type.Routing);
|
||||
sc.addAnd(sc.getEntity().getPodId(), Op.EQ, podId);
|
||||
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
|
||||
List<Long> hostIds = sc.list();
|
||||
|
||||
if (excludeHostId != null){
|
||||
hostIds.remove(excludeHostId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import com.cloud.host.HostVO;
|
|||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
|
||||
|
|
@ -46,6 +47,7 @@ public class KVMFencer implements FenceBuilder {
|
|||
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
|
|
@ -82,7 +84,7 @@ public class KVMFencer implements FenceBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _hostDao.listByCluster(host.getClusterId());
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
|
||||
FenceCommand fence = new FenceCommand(vm, host);
|
||||
|
||||
for (HostVO h : hosts) {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.cloud.host.HostVO;
|
|||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
|
||||
|
|
@ -45,6 +46,7 @@ public class XenServerFencer implements FenceBuilder {
|
|||
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
|
|
@ -53,7 +55,7 @@ public class XenServerFencer implements FenceBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _hostDao.listByCluster(host.getClusterId());
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
|
||||
FenceCommand fence = new FenceCommand(vm, host);
|
||||
|
||||
for (HostVO h : hosts) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import com.cloud.host.HostVO;
|
|||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
|
|
@ -40,6 +41,7 @@ public class XenServerInvestigator extends AdapterBase implements Investigator {
|
|||
private final static Logger s_logger = Logger.getLogger(XenServerInvestigator.class);
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
protected XenServerInvestigator() {
|
||||
}
|
||||
|
|
@ -51,7 +53,7 @@ public class XenServerInvestigator extends AdapterBase implements Investigator {
|
|||
}
|
||||
|
||||
CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
|
||||
List<HostVO> neighbors = _hostDao.listByCluster(agent.getClusterId());
|
||||
List<HostVO> neighbors = _resourceMgr.listAllHostsInCluster(agent.getClusterId());
|
||||
for (HostVO neighbor : neighbors) {
|
||||
if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != HypervisorType.XenServer) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -35,18 +35,8 @@ import com.cloud.utils.fsm.StateDao;
|
|||
* Data Access Object for server
|
||||
*
|
||||
*/
|
||||
public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Status.Event, Host> {
|
||||
List<HostVO> listBy(Host.Type type, Long clusterId, Long podId, long dcId);
|
||||
|
||||
public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Status.Event, Host> {
|
||||
long countBy(long clusterId, ResourceState... states);
|
||||
|
||||
List<HostVO> listByDataCenter(long dcId);
|
||||
List<HostVO> listByHostPod(long podId);
|
||||
List<HostVO> listByStatus(Status... status);
|
||||
List<HostVO> listByResourceState(ResourceState...states);
|
||||
List<HostVO> listBy(Host.Type type, long dcId);
|
||||
List<HostVO> listAllBy(Host.Type type, long dcId);
|
||||
List<HostVO> listByCluster(long clusterId);
|
||||
|
||||
/**
|
||||
* Mark all hosts associated with a certain management server
|
||||
|
|
@ -60,37 +50,12 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
|
|||
|
||||
List<HostVO> findHostsLike(String hostName);
|
||||
|
||||
/**
|
||||
* Find hosts that are directly connected.
|
||||
*/
|
||||
List<HostVO> findDirectlyConnectedHosts();
|
||||
|
||||
List<HostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId);
|
||||
|
||||
HostVO findByStorageIpAddressInDataCenter(long dcId, String privateIpAddress);
|
||||
HostVO findByPrivateIpAddressInDataCenter(long dcId, String privateIpAddress);
|
||||
|
||||
public HostVO findByGuid(String guid);
|
||||
|
||||
public HostVO findByName(String name);
|
||||
|
||||
|
||||
/**
|
||||
* find all hosts of a certain type in a data center
|
||||
* @param type
|
||||
* @param routingCapable
|
||||
* @param dcId
|
||||
* @return
|
||||
*/
|
||||
List<HostVO> listByTypeDataCenter(Host.Type type, long dcId);
|
||||
|
||||
/**
|
||||
* find all hosts of a particular type
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
List<HostVO> listByType(Type type);
|
||||
|
||||
List<RunningHostCountInfo> getRunningHostCounts(Date cutTime);
|
||||
|
||||
long getNextSequence(long hostId);
|
||||
|
|
@ -101,46 +66,15 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
|
|||
|
||||
HostVO findConsoleProxyHost(String name, Type type);
|
||||
|
||||
List<HypervisorType> getAvailHypervisorInZone(Long hostId, Long zoneId);
|
||||
|
||||
/**
|
||||
* Returns a list of host ids given the conditions.
|
||||
* @param dataCenterId if specified, then must be in this data center.
|
||||
* @param podId if specified, then must be in this pod.
|
||||
* @param clusterId if specified, then must be in this cluster.
|
||||
* @param hostType TODO
|
||||
* @param statuses the host needs to be in.
|
||||
* @return ids of the host meeting the search parameters.
|
||||
*/
|
||||
List<Long> listBy(Long dataCenterId, Long podId, Long clusterId, Type hostType, Status... statuses);
|
||||
|
||||
List<HostVO> listBy(Long clusterId, Long podId, long dcId);
|
||||
|
||||
void loadHostTags(HostVO host);
|
||||
|
||||
List<HostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag);
|
||||
|
||||
long countRoutingHostsByDataCenter(long dcId);
|
||||
|
||||
List<HostVO> listDirectHostsBy(long msId, Status status);
|
||||
|
||||
List<HostVO> listManagedDirectAgents();
|
||||
|
||||
List<HostVO> listManagedRoutingAgents();
|
||||
|
||||
|
||||
HostVO findTrafficMonitorHost();
|
||||
|
||||
List<HostVO> listRoutingHostsByManagementServer(long msId);
|
||||
|
||||
List<HostVO> listSecondaryStorageVM(long dcId);
|
||||
|
||||
List<HostVO> listAllRoutingAgents();
|
||||
|
||||
List<HostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId);
|
||||
|
||||
List<HostVO> listByInAllStatus(Type type, Long clusterId, Long podId, long dcId);
|
||||
|
||||
List<HostVO> listByClusterStatus(long clusterId, Status status);
|
||||
|
||||
boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,6 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
UnmanagedDirectConnectSearch.done();
|
||||
|
||||
|
||||
|
||||
DirectConnectSearch = createSearchBuilder();
|
||||
DirectConnectSearch.and("resource", DirectConnectSearch.entity().getResource(), SearchCriteria.Op.NNULL);
|
||||
DirectConnectSearch.and("id", DirectConnectSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -321,13 +320,6 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return hosts.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> findDirectlyConnectedHosts() {
|
||||
SearchCriteria<HostVO> sc = DirectlyConnectedSearch.create();
|
||||
sc.setParameters("resourceState", ResourceState.Disabled);
|
||||
return search(sc, null);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public List<HostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
|
@ -391,56 +383,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
ub = getUpdateBuilder(host);
|
||||
update(ub, sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listBy(Host.Type type, Long clusterId, Long podId, long dcId) {
|
||||
SearchCriteria<HostVO> sc = TypePodDcStatusSearch.create();
|
||||
if (type != null) {
|
||||
sc.setParameters("type", type.toString());
|
||||
}
|
||||
if (clusterId != null) {
|
||||
sc.setParameters("cluster", clusterId);
|
||||
}
|
||||
if (podId != null) {
|
||||
sc.setParameters("pod", podId);
|
||||
}
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setParameters("status", Status.Up.toString());
|
||||
sc.setParameters("resourceState", ResourceState.Enabled.toString());
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByInAllStatus(Host.Type type, Long clusterId, Long podId, long dcId) {
|
||||
SearchCriteria<HostVO> sc = TypePodDcStatusSearch.create();
|
||||
if ( type != null ) {
|
||||
sc.setParameters("type", type.toString());
|
||||
}
|
||||
if (clusterId != null) {
|
||||
sc.setParameters("cluster", clusterId);
|
||||
}
|
||||
if (podId != null ) {
|
||||
sc.setParameters("pod", podId);
|
||||
}
|
||||
sc.setParameters("dc", dcId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listBy(Long clusterId, Long podId, long dcId) {
|
||||
SearchCriteria<HostVO> sc = TypePodDcStatusSearch.create();
|
||||
if (podId != null) {
|
||||
sc.setParameters("pod", podId);
|
||||
}
|
||||
if (clusterId != null) {
|
||||
sc.setParameters("cluster", clusterId);
|
||||
}
|
||||
sc.setParameters("dc", dcId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) {
|
||||
|
||||
|
|
@ -473,66 +416,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByCluster(long clusterId) {
|
||||
SearchCriteria<HostVO> sc = ClusterStatusSearch.create();
|
||||
|
||||
sc.setParameters("cluster", clusterId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByClusterStatus(long clusterId, Status status) {
|
||||
SearchCriteria<HostVO> sc = ClusterStatusSearch.create();
|
||||
|
||||
sc.setParameters("cluster", clusterId);
|
||||
sc.setParameters("status", status.toString());
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<HostVO> listBy(Host.Type type, long dcId) {
|
||||
SearchCriteria<HostVO> sc = TypeDcStatusSearch.create();
|
||||
sc.setParameters("type", type.toString());
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setParameters("status", Status.Up.toString());
|
||||
sc.setParameters("resourceState", ResourceState.Enabled.toString());
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listAllBy(Host.Type type, long dcId) {
|
||||
SearchCriteria<HostVO> sc = TypeDcSearch.create();
|
||||
sc.setParameters("type", type.toString());
|
||||
sc.setParameters("dc", dcId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostVO findByPrivateIpAddressInDataCenter(long dcId, String privateIpAddress) {
|
||||
SearchCriteria<HostVO> sc = DcPrivateIpAddressSearch.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setParameters("privateIpAddress", privateIpAddress);
|
||||
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostVO findByStorageIpAddressInDataCenter(long dcId, String privateIpAddress) {
|
||||
SearchCriteria<HostVO> sc = DcStorageIpAddressSearch.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setParameters("storageIpAddress", privateIpAddress);
|
||||
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDetails(HostVO host) {
|
||||
Map<String, String> details = _detailsDao.findDetails(host.getId());
|
||||
|
|
@ -596,14 +480,6 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByDataCenter(long dcId) {
|
||||
SearchCriteria<HostVO> sc = DcSearch.create("dc", dcId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostVO findConsoleProxyHost(String name, Type type) {
|
||||
SearchCriteria<HostVO> sc = ConsoleProxyHostSearch.create();
|
||||
|
|
@ -617,54 +493,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return hostList.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByHostPod(long podId) {
|
||||
SearchCriteria<HostVO> sc = PodSearch.create("pod", podId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByStatus(Status... status) {
|
||||
SearchCriteria<HostVO> sc = StatusSearch.create();
|
||||
sc.setParameters("status", (Object[]) status);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByResourceState(ResourceState... states) {
|
||||
SearchCriteria<HostVO> sc = ResourceStateSearch.create();
|
||||
sc.setParameters("resourceState", (Object[]) states);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByTypeDataCenter(Type type, long dcId) {
|
||||
SearchCriteria<HostVO> sc = TypeDcSearch.create();
|
||||
sc.setParameters("type", type.toString());
|
||||
sc.setParameters("dc", dcId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listSecondaryStorageVM(long dcId) {
|
||||
SearchCriteria<HostVO> sc = SecondaryStorageVMSearch.create();
|
||||
sc.setParameters("type", Type.SecondaryStorageVM);
|
||||
sc.setParameters("status", Status.Up);
|
||||
sc.setParameters("dc", dcId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByType(Type type) {
|
||||
SearchCriteria<HostVO> sc = TypeSearch.create();
|
||||
sc.setParameters("type", type.toString());
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDetails(HostVO host) {
|
||||
Map<String, String> details = host.getDetails();
|
||||
|
|
@ -775,48 +604,6 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return s_seqFetcher.getNextSequence(Long.class, tg, hostId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HypervisorType> getAvailHypervisorInZone(Long hostId, Long zoneId) {
|
||||
SearchCriteria<HostVO> sc = AvailHypevisorInZone.create();
|
||||
if ( zoneId != null ) {
|
||||
sc.setParameters("zoneId", zoneId);
|
||||
}
|
||||
if ( hostId != null ) {
|
||||
sc.setParameters("hostId", hostId);
|
||||
}
|
||||
sc.setParameters("type", Host.Type.Routing);
|
||||
List<HostVO> hosts = listBy(sc);
|
||||
List<HypervisorType> hypers = new ArrayList<HypervisorType>(4);
|
||||
for (HostVO host : hosts) {
|
||||
hypers.add(host.getHypervisorType());
|
||||
}
|
||||
return hypers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listBy(Long dataCenterId, Long podId, Long clusterId, Type hostType, Status... statuses) {
|
||||
SearchCriteria<Long> sc = HostsInStatusSearch.create();
|
||||
if (dataCenterId != null) {
|
||||
sc.setParameters("dc", dataCenterId);
|
||||
}
|
||||
|
||||
if (podId != null) {
|
||||
sc.setParameters("pod", podId);
|
||||
}
|
||||
|
||||
if (clusterId != null) {
|
||||
sc.setParameters("cluster", clusterId);
|
||||
}
|
||||
|
||||
if (hostType != null) {
|
||||
sc.setParameters("type", hostType);
|
||||
}
|
||||
|
||||
sc.setParameters("statuses", (Object[]) statuses);
|
||||
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
/*TODO: this is used by mycloud, check if it needs resource state Enabled */
|
||||
@Override
|
||||
public long countRoutingHostsByDataCenter(long dcId) {
|
||||
|
|
@ -840,46 +627,6 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listDirectHostsBy(long msId, Status status) {
|
||||
SearchCriteria<HostVO> sc = DirectlyConnectedSearch.create();
|
||||
sc.setParameters("ms", msId);
|
||||
if (status != null) {
|
||||
sc.setParameters("statuses", Status.Up);
|
||||
}
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listManagedDirectAgents() {
|
||||
SearchCriteria<HostVO> sc = ManagedDirectConnectSearch.create();
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listManagedRoutingAgents() {
|
||||
SearchCriteria<HostVO> sc = ManagedRoutingServersSearch.create();
|
||||
sc.setParameters("type", Type.Routing);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listRoutingHostsByManagementServer(long msId) {
|
||||
SearchCriteria<HostVO> sc = MsStatusSearch.create();
|
||||
sc.setParameters("ms", msId);
|
||||
sc.setParameters("type", Type.Routing);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listAllRoutingAgents() {
|
||||
SearchCriteria<HostVO> sc = RoutingSearch.create();
|
||||
sc.setParameters("type", Type.Routing);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateState(Status oldStatus, Event event, Status newStatus, Host vo, Long id) {
|
||||
HostVO host = (HostVO) vo;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|||
import com.cloud.hypervisor.hyperv.resource.HypervDummyResourceBase;
|
||||
import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.DiscovererBase;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.nio.HandlerFactory;
|
||||
|
|
@ -65,6 +66,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
|
|||
@Inject AlertManager _alertMgr;
|
||||
@Inject ClusterDetailsDao _clusterDetailsDao;
|
||||
@Inject HostDao _hostDao = null;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
Link _link;
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
|
|
@ -204,7 +206,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
|
|||
|
||||
private HostVO waitForHostConnect(long dcId, long podId, long clusterId, String guid) {
|
||||
for (int i = 0; i < _waitTime *2; i++) {
|
||||
List<HostVO> hosts = _hostDao.listBy(Host.Type.Routing, clusterId, podId, dcId);
|
||||
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, clusterId, podId, dcId);
|
||||
for (HostVO host : hosts) {
|
||||
if (host.getGuid().equalsIgnoreCase(guid)) {
|
||||
return host;
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
|||
|
||||
private HostVO waitForHostConnect(long dcId, long podId, long clusterId, String guid) {
|
||||
for (int i = 0; i < _waitTime *2; i++) {
|
||||
List<HostVO> hosts = _hostDao.listBy(Host.Type.Routing, clusterId, podId, dcId);
|
||||
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, clusterId, podId, dcId);
|
||||
for (HostVO host : hosts) {
|
||||
if (host.getGuid().equalsIgnoreCase(guid)) {
|
||||
return host;
|
||||
|
|
@ -315,7 +315,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
|||
|
||||
/* KVM requires host are the same in cluster */
|
||||
ClusterVO clusterVO = _clusterDao.findById(host.getClusterId());
|
||||
List<HostVO> hostsInCluster = _hostDao.listByCluster(clusterVO.getId());
|
||||
List<HostVO> hostsInCluster = _resourceMgr.listAllHostsInCluster(clusterVO.getId());
|
||||
if (!hostsInCluster.isEmpty()) {
|
||||
HostVO oneHost = hostsInCluster.get(0);
|
||||
_hostDao.loadDetails(oneHost);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||
return null;
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _hostDao.listByCluster(clusterId);
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
|
||||
if(hosts.size() >= _vmwareMgr.getMaxHostsPerCluster()) {
|
||||
String msg = "VMware cluster " + cluster.getName() + " is too big to add new host now. (current configured cluster size: " + _vmwareMgr.getMaxHostsPerCluster() + ")";
|
||||
s_logger.error(msg);
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
}
|
||||
|
||||
try {
|
||||
List<HostVO> eHosts = _hostDao.listByCluster(clusterId);
|
||||
List<HostVO> eHosts = _resourceMgr.listAllHostsInCluster(clusterId);
|
||||
if( eHosts.size() > 0 ) {
|
||||
HostVO eHost = eHosts.get(0);
|
||||
_hostDao.loadDetails(eHost);
|
||||
|
|
@ -180,7 +180,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
if ( clu.getGuid()== null ) {
|
||||
clu.setGuid(poolUuid);
|
||||
} else {
|
||||
List<HostVO> clusterHosts = _hostDao.listByCluster(clusterId);
|
||||
List<HostVO> clusterHosts = _resourceMgr.listAllHostsInCluster(clusterId);
|
||||
if( clusterHosts != null && clusterHosts.size() > 0) {
|
||||
if (!clu.getGuid().equals(poolUuid)) {
|
||||
if (hosts.size() == 1) {
|
||||
|
|
@ -348,7 +348,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
protected boolean addHostsToPool(Connection conn, String hostIp, Long clusterId) throws XenAPIException, XmlRpcException, DiscoveryException {
|
||||
|
||||
List<HostVO> hosts;
|
||||
hosts = _hostDao.listByCluster(clusterId);
|
||||
hosts = _resourceMgr.listAllHostsInCluster(clusterId);
|
||||
|
||||
String masterIp = null;
|
||||
String username = null;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import com.cloud.host.HostVO;
|
|||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.xen.resource.XenServerConnectionPool;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
|
|
@ -68,6 +69,7 @@ public class Db21to22MigrationUtil {
|
|||
private InstanceGroupVMMapDao _groupVMMapDao;
|
||||
private ConfigurationDao _configurationDao;
|
||||
private DataCenterDao _zoneDao;
|
||||
private ResourceManager _resourceMgr;
|
||||
|
||||
private void doMigration() {
|
||||
setupComponents();
|
||||
|
|
@ -88,7 +90,7 @@ public class Db21to22MigrationUtil {
|
|||
XenServerConnectionPool _connPool = XenServerConnectionPool.getInstance();
|
||||
List<ClusterVO> clusters = _clusterDao.listByHyTypeWithoutGuid(HypervisorType.XenServer.toString());
|
||||
for (ClusterVO cluster : clusters) {
|
||||
List<HostVO> hosts = _hostDao.listByCluster(cluster.getId());
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
|
||||
for (HostVO host : hosts) {
|
||||
String ip = host.getPrivateIpAddress();
|
||||
String username = host.getDetail("username");
|
||||
|
|
@ -179,6 +181,7 @@ public class Db21to22MigrationUtil {
|
|||
_groupVMMapDao = locator.getDao(InstanceGroupVMMapDao.class);
|
||||
_configurationDao = locator.getDao(ConfigurationDao.class);
|
||||
_zoneDao = locator.getDao(DataCenterDao.class);
|
||||
_resourceMgr = locator.getManager(ResourceManager.class);
|
||||
}
|
||||
|
||||
private void setupInstanceGroups() {
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ public class ExternalNetworkManagerImpl implements ExternalNetworkManager, Resou
|
|||
s_logger.debug("Zone " + zone.getName() + " is not configured for external networking.");
|
||||
return null;
|
||||
} else {
|
||||
List<HostVO> externalNetworkAppliancesInZone = _hostDao.listBy(type, zoneId);
|
||||
List<HostVO> externalNetworkAppliancesInZone = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByType(type, zoneId);
|
||||
if (externalNetworkAppliancesInZone.size() != 1) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -225,7 +225,7 @@ public class ExternalNetworkManagerImpl implements ExternalNetworkManager, Resou
|
|||
zoneName = zone.getName();
|
||||
}
|
||||
|
||||
List<HostVO> externalLoadBalancersInZone = _hostDao.listByTypeDataCenter(Host.Type.ExternalLoadBalancer, zoneId);
|
||||
List<HostVO> externalLoadBalancersInZone = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.ExternalLoadBalancer, zoneId);
|
||||
if (externalLoadBalancersInZone.size() != 0) {
|
||||
throw new InvalidParameterValueException("Already found an external load balancer in zone: " + zoneName);
|
||||
}
|
||||
|
|
@ -340,7 +340,7 @@ public class ExternalNetworkManagerImpl implements ExternalNetworkManager, Resou
|
|||
@Override
|
||||
public List<HostVO> listExternalLoadBalancers(ListExternalLoadBalancersCmd cmd) {
|
||||
long zoneId = cmd.getZoneId();
|
||||
return _hostDao.listByTypeDataCenter(Host.Type.ExternalLoadBalancer, zoneId);
|
||||
return _resourceMgr.listAllHostsInOneZoneByType(Host.Type.ExternalLoadBalancer, zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -542,7 +542,7 @@ public class ExternalNetworkManagerImpl implements ExternalNetworkManager, Resou
|
|||
zoneName = zone.getName();
|
||||
}
|
||||
|
||||
List<HostVO> externalFirewallsInZone = _hostDao.listByTypeDataCenter(Host.Type.ExternalFirewall, zoneId);
|
||||
List<HostVO> externalFirewallsInZone = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.ExternalFirewall, zoneId);
|
||||
if (externalFirewallsInZone.size() != 0) {
|
||||
throw new InvalidParameterValueException("Already added an external firewall in zone: " + zoneName);
|
||||
}
|
||||
|
|
@ -717,7 +717,7 @@ public class ExternalNetworkManagerImpl implements ExternalNetworkManager, Resou
|
|||
@Override
|
||||
public List<HostVO> listExternalFirewalls(ListExternalFirewallsCmd cmd) {
|
||||
long zoneId = cmd.getZoneId();
|
||||
return _hostDao.listByTypeDataCenter(Host.Type.ExternalFirewall, zoneId);
|
||||
return _resourceMgr.listAllHostsInOneZoneByType(Host.Type.ExternalFirewall, zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
|||
import com.cloud.network.resource.F5BigIpResource;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.api.response.ExternalLoadBalancerResponse;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
|
|
@ -72,6 +73,8 @@ public class F5BigIpManagerImpl extends ExternalNetworkManagerImpl implements Ex
|
|||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
ResourceManager _resourcMgr;
|
||||
|
||||
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(F5BigIpManagerImpl.class);
|
||||
|
||||
|
|
@ -87,7 +90,7 @@ public class F5BigIpManagerImpl extends ExternalNetworkManagerImpl implements Ex
|
|||
zoneName = zone.getName();
|
||||
}
|
||||
|
||||
List<HostVO> externalLoadBalancersInZone = _hostDao.listByTypeDataCenter(Host.Type.ExternalLoadBalancer, zoneId);
|
||||
List<HostVO> externalLoadBalancersInZone = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.ExternalLoadBalancer, zoneId);
|
||||
if (externalLoadBalancersInZone.size() != 0) {
|
||||
throw new InvalidParameterValueException("Already found an external load balancer in zone: " + zoneName);
|
||||
}
|
||||
|
|
@ -183,7 +186,7 @@ public class F5BigIpManagerImpl extends ExternalNetworkManagerImpl implements Ex
|
|||
@Override
|
||||
public List<HostVO> listExternalLoadBalancers(ListExternalLoadBalancersCmd cmd) {
|
||||
long zoneId = cmd.getZoneId();
|
||||
return _hostDao.listByTypeDataCenter(Host.Type.ExternalLoadBalancer, zoneId);
|
||||
return _resourceMgr.listAllHostsInOneZoneByType(Host.Type.ExternalLoadBalancer, zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class JuniperSrxManagerImpl extends ExternalNetworkManagerImpl implements
|
|||
zoneName = zone.getName();
|
||||
}
|
||||
|
||||
List<HostVO> externalFirewallsInZone = _hostDao.listByTypeDataCenter(Host.Type.ExternalFirewall, zoneId);
|
||||
List<HostVO> externalFirewallsInZone = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.ExternalFirewall, zoneId);
|
||||
if (externalFirewallsInZone.size() != 0) {
|
||||
throw new InvalidParameterValueException("Already added an external firewall in zone: " + zoneName);
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ public class JuniperSrxManagerImpl extends ExternalNetworkManagerImpl implements
|
|||
@Override
|
||||
public List<HostVO> listExternalFirewalls(ListExternalFirewallsCmd cmd) {
|
||||
long zoneId = cmd.getZoneId();
|
||||
return _hostDao.listByTypeDataCenter(Host.Type.ExternalFirewall, zoneId);
|
||||
return _resourceMgr.listAllHostsInOneZoneByType(Host.Type.ExternalFirewall, zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.api.response.NetworkDeviceResponse;
|
||||
import com.cloud.server.api.response.NwDeviceDhcpResponse;
|
||||
import com.cloud.server.api.response.PxePingResponse;
|
||||
|
|
@ -38,6 +39,7 @@ public class NetworkDeviceManagerImpl implements NetworkDeviceManager {
|
|||
@Inject ExternalDhcpManager _dhcpMgr;
|
||||
@Inject PxeServerManager _pxeMgr;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
|
|
@ -137,14 +139,14 @@ public class NetworkDeviceManagerImpl implements NetworkDeviceManager {
|
|||
private List<Host> listNetworkDevice(Long zoneId, Long podId, Host.Type type) {
|
||||
List<Host> res = new ArrayList<Host>();
|
||||
if (podId != null) {
|
||||
List<HostVO> devs = _hostDao.listBy(type, null, podId, zoneId);
|
||||
List<HostVO> devs = _resourceMgr.listAllUpAndEnabledHosts(type, null, podId, zoneId);
|
||||
if (devs.size() == 1) {
|
||||
res.add(devs.get(0));
|
||||
} else {
|
||||
s_logger.debug("List " + type + ": " + devs.size() + " found");
|
||||
}
|
||||
} else {
|
||||
List<HostVO> devs = _hostDao.listBy(type, zoneId);
|
||||
List<HostVO> devs = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByType(type, zoneId);
|
||||
res.addAll(devs);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager, ResourceSta
|
|||
}
|
||||
|
||||
|
||||
List<HostVO> trafficMonitorsInZone = _hostDao.listByTypeDataCenter(Host.Type.TrafficMonitor, zoneId);
|
||||
List<HostVO> trafficMonitorsInZone = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.TrafficMonitor, zoneId);
|
||||
if (trafficMonitorsInZone.size() != 0) {
|
||||
throw new InvalidParameterValueException("Already added an traffic monitor in zone: " + zoneName);
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager, ResourceSta
|
|||
@Override
|
||||
public List<HostVO> listTrafficMonitors(ListTrafficMonitorsCmd cmd) {
|
||||
long zoneId = cmd.getZoneId();
|
||||
return _hostDao.listByTypeDataCenter(Host.Type.TrafficMonitor, zoneId);
|
||||
return _resourceMgr.listAllHostsInOneZoneByType(Host.Type.TrafficMonitor, zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ import com.cloud.network.ovs.dao.OvsWorkDao;
|
|||
import com.cloud.network.ovs.dao.OvsWorkVO.Step;
|
||||
import com.cloud.network.ovs.dao.VlanMappingDao;
|
||||
import com.cloud.network.ovs.dao.VlanMappingVO;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
||||
public class OvsListener implements Listener {
|
||||
|
|
@ -53,6 +55,7 @@ public class OvsListener implements Listener {
|
|||
GreTunnelDao _tunnelDao;
|
||||
VlanMappingDao _mappingDao;
|
||||
HostDao _hostDao;
|
||||
ResourceManager _resourceMgr;
|
||||
|
||||
public OvsListener(OvsNetworkManager ovsMgr, OvsWorkDao workDao, GreTunnelDao tunnelDao,
|
||||
VlanMappingDao mappingDao, HostDao hostDao) {
|
||||
|
|
@ -61,6 +64,8 @@ public class OvsListener implements Listener {
|
|||
this._tunnelDao = tunnelDao;
|
||||
this._mappingDao = mappingDao;
|
||||
this._hostDao = hostDao;
|
||||
ComponentLocator locator = ComponentLocator.getLocator("management-server");
|
||||
_resourceMgr = locator.getManager(ResourceManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -131,7 +136,7 @@ public class OvsListener implements Listener {
|
|||
}
|
||||
|
||||
try {
|
||||
List<HostVO> hosts = _hostDao.listByType(Host.Type.Routing);
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInAllZonesByType(Host.Type.Routing);
|
||||
for (HostVO h : hosts) {
|
||||
if (h.getId() == host.getId()) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -38,15 +38,20 @@ import com.cloud.host.dao.HostDao;
|
|||
import com.cloud.network.ovs.dao.GreTunnelVO;
|
||||
import com.cloud.network.ovs.dao.OvsTunnelDao;
|
||||
import com.cloud.network.ovs.dao.OvsTunnelVO;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
|
||||
public class OvsTunnelListener implements Listener {
|
||||
public static final Logger s_logger = Logger.getLogger(OvsListener.class.getName());
|
||||
HostDao _hostDao;
|
||||
OvsTunnelDao _tunnelDao;
|
||||
ResourceManager _resourceMgr;
|
||||
|
||||
public OvsTunnelListener(OvsTunnelDao tunnelDao, HostDao hostDao) {
|
||||
this._hostDao = hostDao;
|
||||
this._tunnelDao = tunnelDao;
|
||||
ComponentLocator locator = ComponentLocator.getLocator("management-server");
|
||||
_resourceMgr = locator.getManager(ResourceManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -76,7 +81,7 @@ public class OvsTunnelListener implements Listener {
|
|||
}
|
||||
|
||||
try {
|
||||
List<HostVO> hosts = _hostDao.listByType(Host.Type.Routing);
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInAllZonesByType(Host.Type.Routing);
|
||||
for (HostVO h : hosts) {
|
||||
if (h.getId() == host.getId()) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.cloud.dc.DataCenterVO;
|
|||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
|
@ -83,4 +84,20 @@ public interface ResourceManager {
|
|||
public boolean maintain(final long hostId) throws AgentUnavailableException;
|
||||
|
||||
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> listAllHostsInOneZoneByType(Host.Type type, long dcId);
|
||||
|
||||
public List<HostVO> listAllHostsInAllZonesByType(Type type);
|
||||
|
||||
public List<HypervisorType> listAvailHypervisorInZone(Long hostId, Long zoneId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ import com.cloud.utils.component.Inject;
|
|||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
|
|
@ -472,7 +474,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
throw new InvalidParameterValueException("can not fine cluster for clusterId " + clusterId);
|
||||
} else {
|
||||
if (cluster.getGuid() == null) {
|
||||
List<HostVO> hosts = _hostDao.listByCluster(clusterId);
|
||||
List<HostVO> hosts = listAllHostsInCluster(clusterId);
|
||||
if (!hosts.isEmpty()) {
|
||||
throw new CloudRuntimeException("Guid is not updated for cluster " + clusterId + " need to wait hosts in this cluster up");
|
||||
}
|
||||
|
|
@ -622,7 +624,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
if (resource instanceof KvmDummyResourceBase) {
|
||||
Map<String, String> details = entry.getValue();
|
||||
String guid = details.get("guid");
|
||||
List<HostVO> kvmHosts = _hostDao.listBy(Host.Type.Routing, clusterId, podId, dcId);
|
||||
List<HostVO> kvmHosts = listAllUpAndEnabledHosts(Host.Type.Routing, clusterId, podId, dcId);
|
||||
for (HostVO host : kvmHosts) {
|
||||
if (host.getGuid().equalsIgnoreCase(guid)) {
|
||||
if(hostTags != null){
|
||||
|
|
@ -709,7 +711,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
|
||||
_hostDao.remove(hostId);
|
||||
if (clusterId != null) {
|
||||
List<HostVO> hosts = _hostDao.listByCluster(clusterId);
|
||||
List<HostVO> hosts = listAllHostsInCluster(clusterId);
|
||||
if (hosts.size() == 0) {
|
||||
ClusterVO cluster = _clusterDao.findById(clusterId);
|
||||
cluster.setGuid(null);
|
||||
|
|
@ -778,7 +780,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
return true;
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _hostDao.listByCluster(cmd.getId());
|
||||
List<HostVO> hosts = this.listAllHostsInCluster(cmd.getId());
|
||||
if (hosts.size() > 0) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cluster: " + cmd.getId() + " still has hosts");
|
||||
|
|
@ -886,7 +888,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
cluster.setManagedState(Managed.ManagedState.PrepareUnmanaged);
|
||||
_clusterDao.update(cluster.getId(), cluster);
|
||||
txn.commit();
|
||||
List<HostVO> hosts = _hostDao.listBy(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
|
||||
List<HostVO> hosts = listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
|
||||
for( HostVO host : hosts ) {
|
||||
if(host.getType().equals(Host.Type.Routing) && !host.getStatus().equals(Status.Down) && !host.getStatus().equals(Status.Disconnected)
|
||||
&& !host.getStatus().equals(Status.Up) && !host.getStatus().equals(Status.Alert) ) {
|
||||
|
|
@ -908,7 +910,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
Thread.sleep(20 * 1000);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
hosts = _hostDao.listBy(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
|
||||
hosts = listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
|
||||
for( HostVO host : hosts ) {
|
||||
if ( !host.getStatus().equals(Status.Down) && !host.getStatus().equals(Status.Disconnected)
|
||||
&& !host.getStatus().equals(Status.Alert)) {
|
||||
|
|
@ -1010,8 +1012,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
return true;
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _hostDao.listBy(host.getClusterId(), host.getPodId(), host.getDataCenterId());
|
||||
|
||||
List<HostVO> hosts = listAllUpAndEnabledHosts(Host.Type.Routing, host.getClusterId(), host.getPodId(), host.getDataCenterId());
|
||||
for (final VMInstanceVO vm : vms) {
|
||||
if (hosts == null || hosts.size() <= 1 || !answer.getMigrate()) {
|
||||
// for the last host in this cluster, stop all the VMs
|
||||
|
|
@ -1486,7 +1487,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
|
||||
Map<String, String> details = hostDetails;
|
||||
String guid = details.get("guid");
|
||||
List<HostVO> currentHosts = _hostDao.listBy(hostType, zoneId);
|
||||
List<HostVO> currentHosts = this.listAllUpAndEnabledHostsInOneZoneByType(hostType, zoneId);
|
||||
for (HostVO currentHost : currentHosts) {
|
||||
if (currentHost.getGuid().equals(guid)) {
|
||||
return currentHost;
|
||||
|
|
@ -1775,7 +1776,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
return doUpdateHostPassword(cmd.getHostId());
|
||||
} else {
|
||||
// get agents for the cluster
|
||||
List<HostVO> hosts = _hostDao.listByCluster(cmd.getClusterId());
|
||||
List<HostVO> hosts = this.listAllHostsInCluster(cmd.getClusterId());
|
||||
for (HostVO h : hosts) {
|
||||
try {
|
||||
/*FIXME: this is a buggy logic, check with alex. Shouldn't return if propagation return non null*/
|
||||
|
|
@ -1810,4 +1811,90 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> findDirectlyConnectedHosts() {
|
||||
/* The resource column is not null for direct connected resource */
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getResource(), Op.NNULL);
|
||||
sc.addAnd(sc.getEntity().getResourceState(), Op.NIN, ResourceState.Disabled);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listAllUpAndEnabledHosts(Type type, Long clusterId, Long podId, long dcId) {
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
if (type != null) {
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, type);
|
||||
}
|
||||
if (clusterId != null) {
|
||||
sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, clusterId);
|
||||
}
|
||||
if (podId != null) {
|
||||
sc.addAnd(sc.getEntity().getPodId(), Op.EQ, podId);
|
||||
}
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
|
||||
sc.addAnd(sc.getEntity(), Op.EQ, Status.Up);
|
||||
sc.addAnd(sc.getEntity().getResourceState(), Op.EQ, ResourceState.Enabled);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listAllHostsInCluster(long clusterId) {
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, clusterId);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listHostsInClusterByStatus(long clusterId, Status status) {
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, clusterId);
|
||||
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, status);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listAllUpAndEnabledHostsInOneZoneByType(Type type, long dcId) {
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, type);
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
|
||||
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
|
||||
sc.addAnd(sc.getEntity().getResourceState(), Op.EQ, ResourceState.Enabled);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listAllHostsInOneZoneByType(Type type, long dcId) {
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, type);
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listAllHostsInAllZonesByType(Type type) {
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, type);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HypervisorType> listAvailHypervisorInZone(Long hostId, Long zoneId) {
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
if (zoneId != null) {
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, zoneId);
|
||||
}
|
||||
if (hostId != null) {
|
||||
sc.addAnd(sc.getEntity().getHostId(), Op.EQ, hostId);
|
||||
}
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
|
||||
List<HostVO> hosts = sc.list();
|
||||
|
||||
List<HypervisorType> hypers = new ArrayList<HypervisorType>(5);
|
||||
for (HostVO host : hosts) {
|
||||
hypers.add(host.getHypervisorType());
|
||||
}
|
||||
return hypers;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ import com.cloud.network.NetworkVO;
|
|||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
|
|
@ -308,6 +309,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
private final LoadBalancerDao _loadbalancerDao;
|
||||
private final HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
||||
private final Adapters<HostAllocator> _hostAllocators;
|
||||
private final ResourceManager _resourceMgr;
|
||||
|
||||
private final KeystoreManager _ksMgr;
|
||||
|
||||
|
|
@ -372,6 +374,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
_sshKeyPairDao = locator.getDao(SSHKeyPairDao.class);
|
||||
_itMgr = locator.getManager(VirtualMachineManager.class);
|
||||
_ksMgr = locator.getManager(KeystoreManager.class);
|
||||
_resourceMgr = locator.getManager(ResourceManager.class);
|
||||
|
||||
_hypervisorCapabilitiesDao = locator.getDao(HypervisorCapabilitiesDao.class);
|
||||
|
||||
|
|
@ -1321,7 +1324,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
List<HypervisorType> hypers = null;
|
||||
if( ! isIso ) {
|
||||
hypers = _hostDao.getAvailHypervisorInZone(null, null);
|
||||
hypers = _resourceMgr.listAvailHypervisorInZone(null, null);
|
||||
}
|
||||
Set<Pair<Long, Long>> templateZonePairSet = new HashSet<Pair<Long, Long>>();
|
||||
|
||||
|
|
@ -3328,7 +3331,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
String secondaryStorageURL = _storageMgr.getSecondaryStorageURL(zoneId);
|
||||
StoragePoolVO srcPool = _poolDao.findById(volume.getPoolId());
|
||||
List<HostVO> storageServers = _hostDao.listByTypeDataCenter(Host.Type.SecondaryStorage, zoneId);
|
||||
List<HostVO> storageServers = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.SecondaryStorage, zoneId);
|
||||
HostVO sserver = storageServers.get(0);
|
||||
|
||||
List<UploadVO> extractURLList = _uploadDao.listByTypeUploadStatus(volumeId, Upload.Type.VOLUME, UploadVO.Status.DOWNLOAD_URL_CREATED);
|
||||
|
|
@ -3769,7 +3772,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
} else {
|
||||
// get all the hosts in this cluster
|
||||
List<HostVO> hosts = _hostDao.listByCluster(cmd.getClusterId());
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(cmd.getClusterId());
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
for (HostVO h : hosts) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import com.cloud.storage.dao.StoragePoolDao;
|
|||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Local(value ={OCFS2Manager.class})
|
||||
|
|
@ -129,7 +131,12 @@ public class OCFS2ManagerImpl implements OCFS2Manager, ResourceListener {
|
|||
throw new CloudRuntimeException("Cannot find cluster for ID " + clusterId);
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _hostDao.listByInAllStatus(Host.Type.Routing, clusterId, cluster.getPodId(), cluster.getDataCenterId());
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, clusterId);
|
||||
sc.addAnd(sc.getEntity().getPodId(), Op.EQ, cluster.getPodId());
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, cluster.getDataCenterId());
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
|
||||
List<HostVO> hosts = sc.list();
|
||||
if (hosts.isEmpty()) {
|
||||
s_logger.debug("There is no host in cluster " + clusterId + ", no need to prepare OCFS2 nodes");
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ import com.cloud.hypervisor.HypervisorGuruManager;
|
|||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
|
|
@ -289,6 +290,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
protected ResourceLimitService _resourceLimitMgr;
|
||||
@Inject
|
||||
protected SecondaryStorageVmManager _ssvmMgr;
|
||||
@Inject
|
||||
protected ResourceManager _resourceMgr;
|
||||
|
||||
@Inject(adapter = StoragePoolAllocator.class)
|
||||
protected Adapters<StoragePoolAllocator> _storagePoolAllocators;
|
||||
|
|
@ -939,7 +942,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
public Pair<String, String> getAbsoluteIsoPath(long templateId, long dataCenterId) {
|
||||
String isoPath = null;
|
||||
|
||||
List<HostVO> storageHosts = _hostDao.listAllBy(Host.Type.SecondaryStorage, dataCenterId);
|
||||
List<HostVO> storageHosts = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.SecondaryStorage, dataCenterId);
|
||||
if (storageHosts != null) {
|
||||
for (HostVO storageHost : storageHosts) {
|
||||
VMTemplateHostVO templateHostVO = _vmTemplateHostDao.findByHostTemplate(storageHost.getId(), templateId);
|
||||
|
|
@ -1105,7 +1108,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
}
|
||||
|
||||
// Check if there is host up in this cluster
|
||||
List<HostVO> allHosts = _hostDao.listBy(Host.Type.Routing, clusterId, podId, zoneId);
|
||||
List<HostVO> allHosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, clusterId, podId, zoneId);
|
||||
if (allHosts.isEmpty()) {
|
||||
throw new ResourceUnavailableException("No host up to associate a storage pool with in cluster " + clusterId, HostPodVO.class, podId);
|
||||
}
|
||||
|
|
@ -1739,9 +1742,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
}
|
||||
|
||||
// Check that there is at least one host in the specified zone
|
||||
List<HostVO> hosts = _hostDao.listByDataCenter(zoneId);
|
||||
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByType(Host.Type.Routing, zoneId);
|
||||
if (hosts.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Please add a host in the specified zone before creating a new volume.");
|
||||
throw new InvalidParameterValueException("There is no workable host in data center id " + zoneId + ", please check hosts' agent status and see if they are disabled");
|
||||
}
|
||||
|
||||
if (!sharedPoolExists) {
|
||||
|
|
@ -2072,7 +2075,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
}
|
||||
|
||||
|
||||
List<HostVO> hosts = _hostDao.listByClusterStatus(primaryStorage.getClusterId(), Status.Up);
|
||||
List<HostVO> hosts = _resourceMgr.listHostsInClusterByStatus(primaryStorage.getClusterId(), Status.Up);
|
||||
if( hosts == null || hosts.size() == 0 ) {
|
||||
primaryStorage.setStatus(StoragePoolStatus.Maintenance);
|
||||
_storagePoolDao.update(primaryStorageId, primaryStorage);
|
||||
|
|
@ -2304,7 +2307,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
primaryStorage.setStatus(StoragePoolStatus.Up);
|
||||
_storagePoolDao.update(primaryStorageId, primaryStorage);
|
||||
txn.commit();
|
||||
List<HostVO> hosts = _hostDao.listByClusterStatus(primaryStorage.getClusterId(), Status.Up);
|
||||
List<HostVO> hosts = _resourceMgr.listHostsInClusterByStatus(primaryStorage.getClusterId(), Status.Up);
|
||||
if( hosts == null || hosts.size() == 0 ) {
|
||||
return _storagePoolDao.findById(primaryStorageId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import com.cloud.host.Host;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
|
|
@ -127,6 +128,8 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||
private ClusterDao _clusterDao;
|
||||
@Inject
|
||||
private HostDao _hostDao;
|
||||
@Inject
|
||||
private ResourceManager _resourceMgr;
|
||||
|
||||
private String _name;
|
||||
private Boolean _sslCopy = new Boolean(false);
|
||||
|
|
@ -421,14 +424,14 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||
|
||||
@Override
|
||||
public void handleSysTemplateDownload(HostVO host) {
|
||||
List<HypervisorType> hypers = _hostDao.getAvailHypervisorInZone(host.getId(), host.getDataCenterId());
|
||||
List<HypervisorType> hypers = _resourceMgr.listAvailHypervisorInZone(host.getId(), host.getDataCenterId());
|
||||
HypervisorType hostHyper = host.getHypervisorType();
|
||||
if (hypers.contains(hostHyper)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<VMTemplateVO> toBeDownloaded = new HashSet<VMTemplateVO>();
|
||||
List<HostVO> ssHosts = _hostDao.listBy(Host.Type.SecondaryStorage, host.getDataCenterId());
|
||||
List<HostVO> ssHosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByType(Host.Type.SecondaryStorage, host.getDataCenterId());
|
||||
if (ssHosts == null || ssHosts.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1310,4 +1310,13 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
sc.addAnd(sc.getEntity().getType(), Op.IN, Host.Type.LocalSecondaryStorage, Host.Type.SecondaryStorage);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listUpSecondaryStorageVmHost(long dcId) {
|
||||
SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
|
||||
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, com.cloud.host.Status.Up);
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
|
||||
return sc.list();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,5 +51,6 @@ public interface SecondaryStorageVmManager extends Manager {
|
|||
public List<HostVO> listSecondaryStorageHostsInAllZones();
|
||||
public List<HostVO> listSecondaryStorageHostsInOneZone(long dataCenterId);
|
||||
public List<HostVO> listLocalSecondaryStorageHostsInOneZone(long dataCenterId);
|
||||
public List<HostVO> listAllTypesSecondaryStorageHostsInOneZone(long dataCenterId);
|
||||
public List<HostVO> listAllTypesSecondaryStorageHostsInOneZone(long dataCenterId);
|
||||
public List<HostVO> listUpSecondaryStorageVmHost(long dcId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ import com.cloud.host.HostVO;
|
|||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Snapshot.Status;
|
||||
import com.cloud.storage.Snapshot.Type;
|
||||
|
|
@ -170,6 +171,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
private SwiftDao _swiftDao;
|
||||
@Inject
|
||||
private SecondaryStorageVmManager _ssvmMgr;
|
||||
@Inject
|
||||
private ResourceManager _resourceMgr;
|
||||
String _name;
|
||||
private int _totalRetries;
|
||||
private int _pauseInterval;
|
||||
|
|
@ -373,7 +376,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
if (_volsDao.getHypervisorType(v.getId()).equals(HypervisorType.KVM)) {
|
||||
StoragePoolVO storagePool = _storagePoolDao.findById(v.getPoolId());
|
||||
ClusterVO cluster = _clusterDao.findById(storagePool.getClusterId());
|
||||
List<HostVO> hosts = _hostDao.listByCluster(cluster.getId());
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
|
||||
if (hosts != null && !hosts.isEmpty()) {
|
||||
HostVO host = hosts.get(0);
|
||||
if (!hostSupportSnapsthot(host)) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
|||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Upload;
|
||||
import com.cloud.storage.Upload.Mode;
|
||||
|
|
@ -95,6 +96,8 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||
private AgentManager _agentMgr;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
ResourceManager _resourceMgr;
|
||||
|
||||
private String _name;
|
||||
private Boolean _sslCopy = new Boolean(false);
|
||||
|
|
@ -165,7 +168,7 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||
|
||||
Type type = (template.getFormat() == ImageFormat.ISO) ? Type.ISO : Type.TEMPLATE ;
|
||||
|
||||
List<HostVO> storageServers = _serverDao.listByTypeDataCenter(Host.Type.SecondaryStorage, dataCenterId);
|
||||
List<HostVO> storageServers = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.SecondaryStorage, dataCenterId);
|
||||
HostVO sserver = storageServers.get(0);
|
||||
|
||||
UploadVO uploadTemplateObj = new UploadVO(sserver.getId(), template.getId(), new Date(),
|
||||
|
|
@ -264,7 +267,7 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||
String errorString = "";
|
||||
boolean success = false;
|
||||
try{
|
||||
List<HostVO> storageServers = _serverDao.listByTypeDataCenter(Host.Type.SecondaryStorage, dataCenterId);
|
||||
List<HostVO> storageServers = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.SecondaryStorage, dataCenterId);
|
||||
if(storageServers == null ){
|
||||
errorString = "No Storage Server found at the datacenter - " +dataCenterId;
|
||||
throw new CloudRuntimeException(errorString);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,13 @@ public class SearchCriteria2<T, K> extends SearchCriteria<K> {
|
|||
GenericDao<? extends Serializable, ? extends Serializable> dao = (GenericDao<? extends Serializable, ? extends Serializable>)GenericDaoBase.getDao(entityType);
|
||||
assert dao != null : "Can not find DAO for " + entityType.getName();
|
||||
SearchBuilder<T> sb = (SearchBuilder<T>) dao.createSearchBuilder();
|
||||
SearchCriteria2<T, T> sc = new SearchCriteria2(sb, dao);
|
||||
SearchCriteria2<T, K> sc = new SearchCriteria2(sb, dao);
|
||||
return (SearchCriteria2<T, K>) sc;
|
||||
}
|
||||
|
||||
public void selectField(Object... useless) {
|
||||
_sb.selectField(useless);
|
||||
}
|
||||
|
||||
public void addAnd(Object useless, Op op, Object...values) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
|
|
|||
Loading…
Reference in New Issue