mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Replace Adapters<T> with standard List<T> to work with Spring injection
This commit is contained in:
parent
8a9cf04008
commit
25d14418b9
@ -199,6 +199,7 @@
|
||||
<maxIdleTime>60000</maxIdleTime>
|
||||
</connector>
|
||||
</connectors>
|
||||
<jvmArgs>-XX:MaxPermSize=256m -Xmx2g</jvmArgs>
|
||||
<contextPath>/client</contextPath>
|
||||
<webXml>${basedir}/target/${project.artifactId}-${project.version}/WEB-INF/web.xml</webXml>
|
||||
<webAppSourceDirectory>${basedir}/target/${project.artifactId}-${project.version}</webAppSourceDirectory>
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
<!--
|
||||
@DB support
|
||||
-->
|
||||
|
||||
<!--
|
||||
<aop:config proxy-target-class="true">
|
||||
<aop:aspect id="dbContextBuilder" ref="transactionContextBuilder">
|
||||
<aop:pointcut id="captureAnyMethod"
|
||||
@ -26,6 +28,7 @@
|
||||
<aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod"/>
|
||||
</aop:aspect>
|
||||
</aop:config>
|
||||
-->
|
||||
|
||||
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
|
||||
|
||||
|
||||
@ -28,14 +28,14 @@ public class AsyncSampleEventDrivenStyleCaller {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void MethodThatWillCallAsyncMethod() {
|
||||
String vol = new String("Hello");
|
||||
AsyncCallbackDispatcher<AsyncSampleEventDrivenStyleCaller> caller = AsyncCallbackDispatcher.create(this);
|
||||
AsyncCallbackDispatcher<AsyncSampleEventDrivenStyleCaller, Object> caller = AsyncCallbackDispatcher.create(this);
|
||||
_ds.createVolume(vol, caller
|
||||
.setCallback(caller.getTarget().HandleVolumeCreateAsyncCallback(null, null))
|
||||
.setContext(vol)
|
||||
);
|
||||
}
|
||||
|
||||
public Void HandleVolumeCreateAsyncCallback(AsyncCallbackDispatcher<AsyncSampleEventDrivenStyleCaller> callback, String context) {
|
||||
public Void HandleVolumeCreateAsyncCallback(AsyncCallbackDispatcher<AsyncSampleEventDrivenStyleCaller, Object> callback, String context) {
|
||||
Object resultVol = callback.getResult();
|
||||
|
||||
return null;
|
||||
|
||||
@ -116,8 +116,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
||||
@Inject
|
||||
protected HostTransferMapDao _hostTransferDao;
|
||||
|
||||
@com.cloud.utils.component.Inject(adapter = AgentLoadBalancerPlanner.class)
|
||||
protected Adapters<AgentLoadBalancerPlanner> _lbPlanners;
|
||||
// @com.cloud.utils.component.Inject(adapter = AgentLoadBalancerPlanner.class)
|
||||
@Inject protected List<AgentLoadBalancerPlanner> _lbPlanners;
|
||||
|
||||
@Inject
|
||||
protected AgentManager _agentMgr;
|
||||
|
||||
@ -22,6 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
@ -112,9 +113,13 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
|
||||
@Inject PxeServerManager _pxeMgr;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
@com.cloud.utils.component.Inject (adapter=TemplateAdapter.class)
|
||||
protected Adapters<TemplateAdapter> _adapters;
|
||||
// @com.cloud.utils.component.Inject (adapter=TemplateAdapter.class)
|
||||
@Inject protected List<TemplateAdapter> _adapters;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attachISOToVM(long vmId, long isoId, boolean attach) {
|
||||
s_logger.warn("attachISOToVM is not supported by Bare Metal, just fake a true");
|
||||
|
||||
@ -58,8 +58,9 @@ public class PxeServerManagerImpl implements PxeServerManager, ResourceStateAdap
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject ExternalDhcpManager exDhcpMgr;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
@com.cloud.utils.component.Inject(adapter=PxeServerService.class)
|
||||
protected Adapters<PxeServerService> _services;
|
||||
|
||||
// @com.cloud.utils.component.Inject(adapter=PxeServerService.class)
|
||||
@Inject protected List<PxeServerService> _services;
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
|
||||
@ -211,8 +211,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
ClusterDao _clusterDao;
|
||||
@Inject
|
||||
AlertManager _alertMgr;
|
||||
@com.cloud.utils.component.Inject(adapter = SecurityChecker.class)
|
||||
Adapters<SecurityChecker> _secChecker;
|
||||
// @com.cloud.utils.component.Inject(adapter = SecurityChecker.class)
|
||||
@Inject
|
||||
List<SecurityChecker> _secChecker;
|
||||
|
||||
@Inject
|
||||
CapacityDao _capacityDao;
|
||||
@Inject
|
||||
|
||||
@ -106,10 +106,11 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
@Inject protected AccountManager _accountMgr;
|
||||
@Inject protected StorageManager _storageMgr;
|
||||
|
||||
@com.cloud.utils.component.Inject(adapter=StoragePoolAllocator.class)
|
||||
protected Adapters<StoragePoolAllocator> _storagePoolAllocators;
|
||||
@com.cloud.utils.component.Inject(adapter=HostAllocator.class)
|
||||
protected Adapters<HostAllocator> _hostAllocators;
|
||||
//@com.cloud.utils.component.Inject(adapter=StoragePoolAllocator.class)
|
||||
@Inject protected List<StoragePoolAllocator> _storagePoolAllocators;
|
||||
|
||||
//@com.cloud.utils.component.Inject(adapter=HostAllocator.class)
|
||||
@Inject protected List<HostAllocator> _hostAllocators;
|
||||
protected String _allocationAlgorithm = "random";
|
||||
|
||||
|
||||
@ -714,17 +715,13 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
|
||||
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");
|
||||
|
||||
while (enHost.hasMoreElements()) {
|
||||
final HostAllocator allocator = enHost.nextElement();
|
||||
for(HostAllocator allocator : _hostAllocators) {
|
||||
suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, avoid, returnUpTo);
|
||||
if (suitableHosts != null && !suitableHosts.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(suitableHosts.isEmpty()){
|
||||
s_logger.debug("No suitable hosts found");
|
||||
}
|
||||
@ -812,12 +809,8 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
}
|
||||
diskProfile.setUseLocalStorage(useLocalStorage);
|
||||
|
||||
|
||||
boolean foundPotentialPools = false;
|
||||
|
||||
Enumeration<StoragePoolAllocator> enPool = _storagePoolAllocators.enumeration();
|
||||
while (enPool.hasMoreElements()) {
|
||||
final StoragePoolAllocator allocator = enPool.nextElement();
|
||||
for(StoragePoolAllocator allocator : _storagePoolAllocators) {
|
||||
final List<StoragePool> suitablePools = allocator.allocateToPool(diskProfile, vmProfile, plan, avoid, returnUpTo);
|
||||
if (suitablePools != null && !suitablePools.isEmpty()) {
|
||||
suitableVolumeStoragePools.put(toBeCreated, suitablePools);
|
||||
@ -825,7 +818,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!foundPotentialPools){
|
||||
s_logger.debug("No suitable pools found for volume: "+toBeCreated +" under cluster: "+plan.getClusterId());
|
||||
//No suitable storage pools found under this cluster for this volume. - remove any suitable pools found for other volumes.
|
||||
|
||||
@ -272,10 +272,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
RemoteAccessVpnService _vpnMgr;
|
||||
@Inject
|
||||
PodVlanMapDao _podVlanMapDao;
|
||||
@com.cloud.utils.component.Inject(adapter = NetworkGuru.class)
|
||||
Adapters<NetworkGuru> _networkGurus;
|
||||
@com.cloud.utils.component.Inject(adapter = NetworkElement.class)
|
||||
Adapters<NetworkElement> _networkElements;
|
||||
|
||||
//@com.cloud.utils.component.Inject(adapter = NetworkGuru.class)
|
||||
@Inject
|
||||
List<NetworkGuru> _networkGurus;
|
||||
|
||||
// @com.cloud.utils.component.Inject(adapter = NetworkElement.class)
|
||||
@Inject
|
||||
List<NetworkElement> _networkElements;
|
||||
|
||||
@Inject
|
||||
NetworkDomainDao _networkDomainDao;
|
||||
@Inject
|
||||
@ -351,7 +356,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
@Override
|
||||
public NetworkElement getElementImplementingProvider(String providerName) {
|
||||
String elementName = s_providerToNetworkElementMap.get(providerName);
|
||||
NetworkElement element = _networkElements.get(elementName);
|
||||
NetworkElement element = Adapters.getAdapterByName(_networkElements, elementName);
|
||||
return element;
|
||||
}
|
||||
|
||||
@ -1791,7 +1796,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
NetworkVO ntwkVO = _networksDao.findById(network.getId());
|
||||
s_logger.debug("Allocating nic for vm " + vm.getVirtualMachine() + " in network " + network + " with requested profile " + requested);
|
||||
NetworkGuru guru = _networkGurus.get(ntwkVO.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, ntwkVO.getGuruName());
|
||||
|
||||
if (requested != null && requested.getMode() == null) {
|
||||
requested.setMode(network.getMode());
|
||||
@ -1936,7 +1941,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
try {
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
Network.State state = network.getState();
|
||||
if (state == Network.State.Implemented || state == Network.State.Setup || state == Network.State.Implementing) {
|
||||
s_logger.debug("Network id=" + networkId + " is already implemented");
|
||||
@ -2124,7 +2129,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
|
||||
Integer networkRate = getNetworkRate(network.getId(), vmProfile.getId());
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
NicVO nic = _nicDao.findById(nicId);
|
||||
|
||||
NicProfile profile = null;
|
||||
@ -2186,7 +2191,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NetworkVO network = _networksDao.findById(nic.getNetworkId());
|
||||
Integer networkRate = getNetworkRate(network.getId(), vm.getId());
|
||||
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate,
|
||||
isSecurityGroupSupportedInNetwork(network), getNetworkTag(vm.getHypervisorType(), network));
|
||||
guru.updateNicProfile(profile, network);
|
||||
@ -2216,7 +2221,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (nic.getState() == Nic.State.Reserved || nic.getState() == Nic.State.Reserving) {
|
||||
Nic.State originalState = nic.getState();
|
||||
if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) {
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
nic.setState(Nic.State.Releasing);
|
||||
_nicDao.update(nic.getId(), nic);
|
||||
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null,
|
||||
@ -2262,7 +2267,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NetworkVO network = _networksDao.findById(nic.getNetworkId());
|
||||
Integer networkRate = getNetworkRate(network.getId(), vm.getId());
|
||||
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
|
||||
networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag(vm.getHypervisorType(), network));
|
||||
guru.updateNicProfile(profile, network);
|
||||
@ -2283,7 +2288,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NetworkVO network = _networksDao.findById(networkId);
|
||||
Integer networkRate = getNetworkRate(network.getId(), vm.getId());
|
||||
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
|
||||
networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag(vm.getHypervisorType(), network));
|
||||
guru.updateNicProfile(profile, network);
|
||||
@ -2438,7 +2443,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NetworkVO network = _networksDao.findById(nic.getNetworkId());
|
||||
NicProfile profile = new NicProfile(nic, network, null, null, null,
|
||||
isSecurityGroupSupportedInNetwork(network), getNetworkTag(vm.getHypervisorType(), network));
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
guru.deallocate(network, profile, vm);
|
||||
_nicDao.remove(nic.getId());
|
||||
s_logger.debug("Removed nic id=" + nic.getId());
|
||||
@ -3414,7 +3419,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Network id=" + networkId + " is shutdown successfully, cleaning up corresponding resources now.");
|
||||
}
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
NetworkProfile profile = convertNetworkToNetworkProfile(network.getId());
|
||||
guru.shutdown(profile, _networkOfferingDao.findById(network.getNetworkOfferingId()));
|
||||
|
||||
@ -3574,7 +3579,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Network id=" + networkId + " is destroyed successfully, cleaning up corresponding resources now.");
|
||||
}
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
Account owner = _accountMgr.getAccount(network.getAccountId());
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
@ -4258,7 +4263,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
@Override
|
||||
public NetworkProfile convertNetworkToNetworkProfile(long networkId) {
|
||||
NetworkVO network = _networksDao.findById(networkId);
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NetworkGuru guru = Adapters.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
NetworkProfile profile = new NetworkProfile(network);
|
||||
guru.updateNetworkProfile(profile);
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
@ -204,14 +205,18 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
protected HighAvailabilityManager _haMgr;
|
||||
@Inject
|
||||
protected StorageService _storageSvr;
|
||||
@com.cloud.utils.component.Inject(adapter = Discoverer.class)
|
||||
protected Adapters<? extends Discoverer> _discoverers;
|
||||
//@com.cloud.utils.component.Inject(adapter = Discoverer.class)
|
||||
@Inject
|
||||
protected List<? extends Discoverer> _discoverers;
|
||||
@Inject
|
||||
protected ClusterManager _clusterMgr;
|
||||
@Inject
|
||||
protected StoragePoolHostDao _storagePoolHostDao;
|
||||
@com.cloud.utils.component.Inject(adapter = PodAllocator.class)
|
||||
protected Adapters<PodAllocator> _podAllocators = null;
|
||||
|
||||
// @com.cloud.utils.component.Inject(adapter = PodAllocator.class)
|
||||
@Inject
|
||||
protected List<PodAllocator> _podAllocators = null;
|
||||
|
||||
@Inject
|
||||
protected VMTemplateDao _templateDao;
|
||||
@Inject
|
||||
@ -226,6 +231,11 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
protected HashMap<Integer, List<ResourceListener>> _lifeCycleListeners = new HashMap<Integer, List<ResourceListener>>();
|
||||
private HypervisorType _defaultSystemVMHypervisor;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// TODO initialize pod allocators here instead
|
||||
}
|
||||
|
||||
private void insertListener(Integer event, ResourceListener listener) {
|
||||
List<ResourceListener> lst = _lifeCycleListeners.get(event);
|
||||
if (lst == null) {
|
||||
@ -497,13 +507,10 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
|
||||
@Override
|
||||
public Discoverer getMatchingDiscover(Hypervisor.HypervisorType hypervisorType) {
|
||||
Enumeration<? extends Discoverer> en = _discoverers.enumeration();
|
||||
while (en.hasMoreElements()) {
|
||||
Discoverer discoverer = en.nextElement();
|
||||
if (discoverer.getHypervisorType() == hypervisorType) {
|
||||
for(Discoverer discoverer : _discoverers) {
|
||||
if (discoverer.getHypervisorType() == hypervisorType)
|
||||
return discoverer;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -670,10 +677,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
|
||||
List<HostVO> hosts = new ArrayList<HostVO>();
|
||||
s_logger.info("Trying to add a new host at " + url + " in data center " + dcId);
|
||||
Enumeration<? extends Discoverer> en = _discoverers.enumeration();
|
||||
boolean isHypervisorTypeSupported = false;
|
||||
while (en.hasMoreElements()) {
|
||||
Discoverer discoverer = en.nextElement();
|
||||
for ( Discoverer discoverer : _discoverers) {
|
||||
if (params != null) {
|
||||
discoverer.putParam(params);
|
||||
}
|
||||
@ -2161,9 +2166,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
|
||||
@Override
|
||||
public Pair<HostPodVO, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long accountId, Set<Long> avoids) {
|
||||
final Enumeration en = _podAllocators.enumeration();
|
||||
while (en.hasMoreElements()) {
|
||||
final PodAllocator allocator = (PodAllocator) en.nextElement();
|
||||
for(PodAllocator allocator : _podAllocators) {
|
||||
final Pair<HostPodVO, Long> pod = allocator.allocateTo(template, offering, dc, accountId, avoids);
|
||||
if (pod != null) {
|
||||
return pod;
|
||||
|
||||
@ -25,6 +25,7 @@ import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
@ -49,6 +50,7 @@ import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
|
||||
@Component
|
||||
@Primary
|
||||
@Local(value = { SecondaryStorageVmManager.class })
|
||||
public class PremiumSecondaryStorageManagerImpl extends SecondaryStorageManagerImpl {
|
||||
private static final Logger s_logger = Logger.getLogger(PremiumSecondaryStorageManagerImpl.class);
|
||||
|
||||
@ -329,11 +329,11 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
|
||||
protected DownloadMonitor _downloadMonitor;
|
||||
@Inject
|
||||
protected ResourceTagDao _resourceTagDao;
|
||||
@Inject
|
||||
protected List<StoragePoolAllocator> _storagePoolAllocators;
|
||||
|
||||
@com.cloud.utils.component.Inject(adapter = StoragePoolAllocator.class)
|
||||
protected Adapters<StoragePoolAllocator> _storagePoolAllocators;
|
||||
@com.cloud.utils.component.Inject(adapter = StoragePoolDiscoverer.class)
|
||||
protected Adapters<StoragePoolDiscoverer> _discoverers;
|
||||
@Inject
|
||||
protected List<StoragePoolDiscoverer> _discoverers;
|
||||
|
||||
|
||||
protected SearchBuilder<VMTemplateHostVO> HostTemplateStatesSearch;
|
||||
@ -463,9 +463,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
|
||||
protected StoragePoolVO findStoragePool(DiskProfile dskCh, final DataCenterVO dc, HostPodVO pod, Long clusterId, Long hostId, VMInstanceVO vm, final Set<StoragePool> avoid) {
|
||||
|
||||
VirtualMachineProfile<VMInstanceVO> profile = new VirtualMachineProfileImpl<VMInstanceVO>(vm);
|
||||
Enumeration<StoragePoolAllocator> en = _storagePoolAllocators.enumeration();
|
||||
while (en.hasMoreElements()) {
|
||||
final StoragePoolAllocator allocator = en.nextElement();
|
||||
for (StoragePoolAllocator allocator : _storagePoolAllocators) {
|
||||
final List<StoragePool> poolList = allocator.allocateToPool(dskCh, profile, dc.getId(), pod.getId(), clusterId, hostId, avoid, 1);
|
||||
if (poolList != null && !poolList.isEmpty()) {
|
||||
return (StoragePoolVO) poolList.get(0);
|
||||
@ -1354,11 +1352,10 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
|
||||
hostPath.replaceFirst("/", "");
|
||||
pool = new StoragePoolVO(StoragePoolType.IscsiLUN, storageHost, port, hostPath);
|
||||
} else {
|
||||
Enumeration<StoragePoolDiscoverer> en = _discoverers.enumeration();
|
||||
while (en.hasMoreElements()) {
|
||||
for (StoragePoolDiscoverer discoverer : _discoverers) {
|
||||
Map<StoragePoolVO, Map<String, String>> pools;
|
||||
try {
|
||||
pools = en.nextElement().find(cmd.getZoneId(), podId, uri, details);
|
||||
pools = discoverer.find(cmd.getZoneId(), podId, uri, details);
|
||||
} catch (DiscoveryException e) {
|
||||
throw new IllegalArgumentException("Not enough information for discovery " + uri, e);
|
||||
}
|
||||
|
||||
@ -173,8 +173,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
private int _mgmt_port = 8250;
|
||||
|
||||
private String _name;
|
||||
@com.cloud.utils.component.Inject(adapter = SecondaryStorageVmAllocator.class)
|
||||
private Adapters<SecondaryStorageVmAllocator> _ssVmAllocators;
|
||||
@Inject
|
||||
private List<SecondaryStorageVmAllocator> _ssVmAllocators;
|
||||
|
||||
@Inject
|
||||
protected SecondaryStorageVmDao _secStorageVmDao;
|
||||
@ -589,11 +589,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
private SecondaryStorageVmAllocator getCurrentAllocator() {
|
||||
|
||||
// for now, only one adapter is supported
|
||||
Enumeration<SecondaryStorageVmAllocator> it = _ssVmAllocators.enumeration();
|
||||
if (it.hasMoreElements()) {
|
||||
return it.nextElement();
|
||||
}
|
||||
|
||||
if(_ssVmAllocators.size() > 0)
|
||||
return _ssVmAllocators.get(0);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -210,16 +210,16 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
||||
ScheduledExecutorService _swiftTemplateSyncExecutor;
|
||||
|
||||
|
||||
@com.cloud.utils.component.Inject (adapter=TemplateAdapter.class)
|
||||
protected Adapters<TemplateAdapter> _adapters;
|
||||
@Inject
|
||||
protected List<TemplateAdapter> _adapters;
|
||||
|
||||
private TemplateAdapter getAdapter(HypervisorType type) {
|
||||
TemplateAdapter adapter = null;
|
||||
if (type == HypervisorType.BareMetal) {
|
||||
adapter = _adapters.get(TemplateAdapterType.BareMetal.getName());
|
||||
adapter = Adapters.getAdapterByName(_adapters, TemplateAdapterType.BareMetal.getName());
|
||||
} else {
|
||||
// see HyervisorTemplateAdapter
|
||||
adapter = _adapters.get(TemplateAdapterType.Hypervisor.getName());
|
||||
adapter = Adapters.getAdapterByName(_adapters, TemplateAdapterType.Hypervisor.getName());
|
||||
}
|
||||
|
||||
if (adapter == null) {
|
||||
|
||||
@ -230,10 +230,10 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
@Inject
|
||||
protected NetworkDao _networkDao;
|
||||
|
||||
@com.cloud.utils.component.Inject(adapter = DeploymentPlanner.class)
|
||||
protected Adapters<DeploymentPlanner> _planners;
|
||||
@Inject
|
||||
protected List<DeploymentPlanner> _planners;
|
||||
|
||||
@com.cloud.utils.component.Inject(adapter = HostAllocator.class)
|
||||
@Inject
|
||||
protected Adapters<HostAllocator> _hostAllocators;
|
||||
|
||||
@Inject
|
||||
|
||||
@ -95,9 +95,9 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager{
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
|
||||
|
||||
@com.cloud.utils.component.Inject(adapter = NetworkElement.class)
|
||||
Adapters<NetworkElement> _networkElements;
|
||||
|
||||
@Inject
|
||||
List<NetworkElement> _networkElements;
|
||||
|
||||
private static HashMap<String, String> s_providerToNetworkElementMap = new HashMap<String, String>();
|
||||
private static final Logger s_logger = Logger.getLogger(MockNetworkManagerImpl.class);
|
||||
|
||||
@ -82,4 +82,12 @@ public class Adapters<T> implements Iterable<T> {
|
||||
public boolean isSet() {
|
||||
return _map.size() != 0;
|
||||
}
|
||||
|
||||
public static <T extends Adapter> T getAdapterByName(List<T> adapters, String name) {
|
||||
for(T adapter : adapters) {
|
||||
if(adapter.getName().equals(name))
|
||||
return adapter;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user