mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Use EndPoint to send local/remote command, and hide agentMgr message
passing.
This commit is contained in:
parent
ffdf567b58
commit
9c584b5500
@ -29,6 +29,9 @@ public interface EndPointSelector {
|
||||
* @return
|
||||
*/
|
||||
EndPoint select(DataObject object);
|
||||
|
||||
EndPoint select(DataStore store);
|
||||
|
||||
/**
|
||||
* @param store
|
||||
* @return
|
||||
|
||||
@ -34,6 +34,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
@ -58,14 +60,12 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
||||
import com.cloud.agent.api.storage.ListTemplateAnswer;
|
||||
import com.cloud.agent.api.storage.ListTemplateCommand;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.StoragePool;
|
||||
@ -129,6 +129,8 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
@Inject
|
||||
TemplateDataFactory _templateFactory;
|
||||
@Inject VMTemplatePoolDao _tmpltPoolDao;
|
||||
@Inject
|
||||
EndPointSelector _epSelector;
|
||||
|
||||
class TemplateOpContext<T> extends AsyncRpcConext<T> {
|
||||
final TemplateObject template;
|
||||
@ -179,7 +181,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handleSysTemplateDownload(HypervisorType hostHyper, Long dcId) {
|
||||
Set<VMTemplateVO> toBeDownloaded = new HashSet<VMTemplateVO>();
|
||||
@ -377,17 +379,8 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
List<UserVmVO> userVmUsingIso = _userVmDao.listByIsoId(tInfo.getId());
|
||||
//check if there is any Vm using this ISO.
|
||||
if (userVmUsingIso == null || userVmUsingIso.isEmpty()) {
|
||||
VMTemplateVO template = _templateDao.findById(tInfo.getId());
|
||||
DeleteTemplateCommand dtCommand = new DeleteTemplateCommand(store.getTO(), store.getUri(), tInfo.getInstallPath(), template.getId(), template.getAccountId());
|
||||
try {
|
||||
_agentMgr.sendToSecStorage(store, dtCommand, null);
|
||||
} catch (AgentUnavailableException e) {
|
||||
String err = "Failed to delete " + tInfo.getTemplateName() + " on secondary storage " + storeId + " which isn't in the database";
|
||||
s_logger.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
String description = "Deleted template " + tInfo.getTemplateName() + " on secondary storage " + storeId + " since it isn't in the database";
|
||||
deleteTemplateAsync(_templateFactory.getTemplate(tInfo.getId(), store));
|
||||
String description = "Deleted template " + tInfo.getTemplateName() + " on secondary storage " + storeId;
|
||||
s_logger.info(description);
|
||||
}
|
||||
}
|
||||
@ -423,7 +416,8 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
private Map<String, TemplateProp> listTemplate(DataStore ssStore) {
|
||||
ListTemplateCommand cmd = new ListTemplateCommand(ssStore.getUri());
|
||||
Answer answer = _agentMgr.sendToSecStorage(ssStore, cmd);
|
||||
EndPoint ep = _epSelector.select(ssStore);
|
||||
Answer answer = ep.sendMessage(cmd);
|
||||
if (answer != null && answer.getResult()) {
|
||||
ListTemplateAnswer tanswer = (ListTemplateAnswer)answer;
|
||||
return tanswer.getTemplateInfo();
|
||||
|
||||
@ -210,6 +210,12 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
||||
@Override
|
||||
public EndPoint select(DataObject object) {
|
||||
DataStore store = object.getDataStore();
|
||||
return select(store);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EndPoint select(DataStore store) {
|
||||
if (store.getRole() == DataStoreRole.Primary) {
|
||||
return findEndpointForPrimaryStorage(store);
|
||||
} else if (store.getRole() == DataStoreRole.Image) {
|
||||
@ -219,7 +225,6 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
||||
}else {
|
||||
throw new CloudRuntimeException("not implemented yet");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -32,6 +32,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
@ -53,14 +55,12 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.storage.DeleteVolumeCommand;
|
||||
import com.cloud.agent.api.storage.ListVolumeAnswer;
|
||||
import com.cloud.agent.api.storage.ListVolumeCommand;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.storage.StoragePool;
|
||||
@ -119,6 +119,8 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
VolumeDataStoreDao _volumeStoreDao;
|
||||
@Inject
|
||||
VolumeDao _volumeDao;
|
||||
@Inject
|
||||
EndPointSelector _epSelector;
|
||||
|
||||
public VolumeServiceImpl() {
|
||||
}
|
||||
@ -659,7 +661,7 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
} else {
|
||||
vo.stateTransit(Volume.Event.OperationSucceeded);
|
||||
}*/
|
||||
|
||||
|
||||
_resourceLimitMgr.incrementResourceCount(vo.getAccountId(), ResourceType.secondary_storage,
|
||||
vo.getSize());
|
||||
VolumeApiResult res = new VolumeApiResult(vo);
|
||||
@ -815,16 +817,9 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
//Delete volumes which are not present on DB.
|
||||
for (Long uniqueName : volumeInfos.keySet()) {
|
||||
TemplateProp vInfo = volumeInfos.get(uniqueName);
|
||||
DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(store.getUri(), vInfo.getInstallPath());
|
||||
try {
|
||||
_agentMgr.sendToSecStorage(store, dtCommand, null);
|
||||
} catch (AgentUnavailableException e) {
|
||||
String err = "Failed to delete " + vInfo.getTemplateName() + " on image store " + storeId + " which isn't in the database";
|
||||
s_logger.error(err);
|
||||
return;
|
||||
}
|
||||
this.expungeVolumeAsync(this.volFactory.getVolume(vInfo.getId(), store));
|
||||
|
||||
String description = "Deleted volume " + vInfo.getTemplateName() + " on image store " + storeId + " since it isn't in the database";
|
||||
String description = "Deleted volume " + vInfo.getTemplateName() + " on image store " + storeId;
|
||||
s_logger.info(description);
|
||||
}
|
||||
|
||||
@ -832,7 +827,8 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
|
||||
private Map<Long, TemplateProp> listVolume(DataStore store) {
|
||||
ListVolumeCommand cmd = new ListVolumeCommand(store.getUri());
|
||||
Answer answer = _agentMgr.sendToSecStorage(store, cmd);
|
||||
EndPoint ep = _epSelector.select(store);
|
||||
Answer answer = ep.sendMessage(cmd);
|
||||
if (answer != null && answer.getResult()) {
|
||||
ListVolumeAnswer tanswer = (ListVolumeAnswer)answer;
|
||||
return tanswer.getTemplateInfo();
|
||||
|
||||
@ -32,6 +32,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
@ -115,6 +116,7 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
|
||||
@Inject
|
||||
private AgentManager _agentMgr;
|
||||
@Inject TemplateDataStoreDao _templateStoreDao;
|
||||
@Inject EndPointSelector _epSelector;
|
||||
|
||||
|
||||
@Override
|
||||
@ -295,7 +297,9 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
|
||||
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
||||
String installPath = tmplStore.getInstallPath();
|
||||
if (installPath != null) {
|
||||
Answer answer = _agentMgr.sendToSecStorage(store, new DeleteTemplateCommand(store.getTO(), store.getUri(), installPath, template.getId(), template.getAccountId()));
|
||||
DeleteTemplateCommand cmd = new DeleteTemplateCommand(store.getTO(), store.getUri(), installPath, template.getId(), template.getAccountId());
|
||||
EndPoint ep = _epSelector.select(templateObj);
|
||||
Answer answer = ep.sendMessage(cmd);
|
||||
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.debug("Failed to deleted template at store: " + store.getName());
|
||||
|
||||
@ -33,6 +33,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
||||
@ -110,6 +111,7 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
|
||||
@Inject
|
||||
private AgentManager _agentMgr;
|
||||
@Inject TemplateDataStoreDao _templateStoreDao;
|
||||
@Inject EndPointSelector _epSelector;
|
||||
|
||||
@Override
|
||||
public String grantAccess(DataObject data, EndPoint ep) {
|
||||
@ -243,7 +245,9 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
|
||||
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
||||
String installPath = tmplStore.getInstallPath();
|
||||
if (installPath != null) {
|
||||
Answer answer = _agentMgr.sendToSecStorage(store, new DeleteTemplateCommand(store.getTO(), store.getUri(), installPath, template.getId(), template.getAccountId()));
|
||||
DeleteTemplateCommand cmd = new DeleteTemplateCommand(store.getTO(), store.getUri(), installPath, template.getId(), template.getAccountId());
|
||||
EndPoint ep = _epSelector.select(templateObj);
|
||||
Answer answer = ep.sendMessage(cmd);
|
||||
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.debug("Failed to deleted template at store: " + store.getName());
|
||||
|
||||
@ -33,6 +33,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
||||
@ -110,6 +111,7 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
|
||||
@Inject
|
||||
private AgentManager _agentMgr;
|
||||
@Inject TemplateDataStoreDao _templateStoreDao;
|
||||
@Inject EndPointSelector _epSelector;
|
||||
|
||||
@Override
|
||||
public String grantAccess(DataObject data, EndPoint ep) {
|
||||
@ -236,7 +238,9 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
|
||||
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
||||
String installPath = tmplStore.getInstallPath();
|
||||
if (installPath != null) {
|
||||
Answer answer = _agentMgr.sendToSecStorage(store, new DeleteTemplateCommand(store.getTO(), store.getUri(), installPath, template.getId(), template.getAccountId()));
|
||||
DeleteTemplateCommand cmd = new DeleteTemplateCommand(store.getTO(), store.getUri(), installPath, template.getId(), template.getAccountId());
|
||||
EndPoint ep = _epSelector.select(templateObj);
|
||||
Answer answer = ep.sendMessage(cmd);
|
||||
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.debug("Failed to deleted template at store: " + store.getName());
|
||||
|
||||
@ -141,9 +141,6 @@ public interface AgentManager extends Manager {
|
||||
|
||||
Answer sendToSecStorage(HostVO ssHost, Command cmd);
|
||||
|
||||
void sendToSecStorage(DataStore ssStore, Command cmd, Listener listener) throws AgentUnavailableException;
|
||||
|
||||
Answer sendToSecStorage(DataStore ssStore, Command cmd);
|
||||
|
||||
/* working as a lock while agent is being loaded */
|
||||
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action);
|
||||
|
||||
@ -39,11 +39,8 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.StartupCommandProcessor;
|
||||
@ -99,7 +96,6 @@ import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ResourceState;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StorageService;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
@ -110,7 +106,6 @@ import com.cloud.user.AccountManager;
|
||||
import com.cloud.utils.ActionDelegate;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.DB;
|
||||
@ -381,17 +376,6 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
||||
return attache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer sendToSecStorage(DataStore ssStore, Command cmd) {
|
||||
HostVO ssAhost = _ssvmMgr.pickSsvmHost(ssStore);
|
||||
return easySend(ssAhost.getId(), cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToSecStorage(DataStore ssStore, Command cmd, Listener listener) throws AgentUnavailableException {
|
||||
HostVO ssAhost = _ssvmMgr.pickSsvmHost(ssStore);
|
||||
send(ssAhost.getId(), new Commands(cmd), listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer sendToSecStorage(HostVO ssHost, Command cmd) {
|
||||
@ -1496,6 +1480,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnectWithInvestigation(final long hostId, final Status.Event event) {
|
||||
disconnectInternal(hostId, event, true);
|
||||
}
|
||||
|
||||
@ -53,6 +53,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||
@ -328,6 +330,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
DataStoreProviderManager _dataStoreProviderMgr;
|
||||
@Inject
|
||||
private TemplateService _imageSrv;
|
||||
@Inject EndPointSelector _epSelector;
|
||||
|
||||
protected List<StoragePoolAllocator> _storagePoolAllocators;
|
||||
public List<StoragePoolAllocator> getStoragePoolAllocators() {
|
||||
@ -1270,17 +1273,16 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
.getInstallPath();
|
||||
|
||||
if (installPath != null) {
|
||||
|
||||
Answer answer = _agentMgr.sendToSecStorage(store,
|
||||
new DeleteTemplateCommand(
|
||||
store.getTO(),
|
||||
store.getUri(),
|
||||
destroyedTemplateStoreVO
|
||||
.getInstallPath(),
|
||||
destroyedTemplate.getId(),
|
||||
destroyedTemplate.getAccountId()
|
||||
|
||||
));
|
||||
EndPoint ep = _epSelector.select(store);
|
||||
Command cmd = new DeleteTemplateCommand(
|
||||
store.getTO(),
|
||||
store.getUri(),
|
||||
destroyedTemplateStoreVO
|
||||
.getInstallPath(),
|
||||
destroyedTemplate.getId(),
|
||||
destroyedTemplate.getAccountId()
|
||||
);
|
||||
Answer answer = ep.sendMessage(cmd);
|
||||
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.debug("Failed to delete "
|
||||
|
||||
@ -152,7 +152,7 @@ public class DownloadListener implements Listener {
|
||||
DownloadAnswer answer = new DownloadAnswer("", Status.NOT_DOWNLOADED);
|
||||
callback(answer);
|
||||
}
|
||||
|
||||
|
||||
public AsyncCompletionCallback<DownloadAnswer> getCallback() {
|
||||
return this._callback;
|
||||
}
|
||||
@ -201,7 +201,7 @@ public class DownloadListener implements Listener {
|
||||
}
|
||||
|
||||
public void logDisconnect() {
|
||||
s_logger.warn("Unable to monitor download progress of " + this.object.getType() + ": " +
|
||||
s_logger.warn("Unable to monitor download progress of " + this.object.getType() + ": " +
|
||||
this.object.getId() + " at host " + _ssAgent.getId());
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ public class DownloadListener implements Listener {
|
||||
public void callback(DownloadAnswer answer) {
|
||||
this._callback.complete(answer);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean processCommands(long agentId, long seq, Command[] req) {
|
||||
return false;
|
||||
@ -287,7 +287,7 @@ public class DownloadListener implements Listener {
|
||||
}
|
||||
_imageSrv.handleSysTemplateDownload(hostHyper, agent.getDataCenterId());
|
||||
}
|
||||
/* This can be removed since
|
||||
/* This can be removed
|
||||
else if ( cmd instanceof StartupStorageCommand) {
|
||||
StartupStorageCommand storage = (StartupStorageCommand)cmd;
|
||||
if( storage.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE ||
|
||||
|
||||
@ -1473,26 +1473,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HostVO pickSsvmHost(DataStore store) {
|
||||
if ( store.getRole() == DataStoreRole.Image){
|
||||
Long dcId = null;
|
||||
Scope storeScope = store.getScope();
|
||||
if ( storeScope.getScopeType() == ScopeType.ZONE ){
|
||||
dcId = storeScope.getScopeId();
|
||||
}
|
||||
// find ssvm that can be used to download data to store. For zone-wide image store, use SSVM for that zone. For region-wide store,
|
||||
// we can arbitrarily pick one ssvm to do that task
|
||||
List<HostVO> ssAHosts = listUpAndConnectingSecondaryStorageVmHost(dcId);
|
||||
if (ssAHosts == null || ssAHosts.isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
Collections.shuffle(ssAHosts);
|
||||
return ssAHosts.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plugNic(Network network, NicTO nic, VirtualMachineTO vm,
|
||||
ReservationContext context, DeployDestination dest) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
|
||||
@ -55,5 +55,4 @@ public interface SecondaryStorageVmManager extends Manager {
|
||||
public List<HostVO> listAllTypesSecondaryStorageHostsInOneZone(long dataCenterId);
|
||||
public List<HostVO> listUpAndConnectingSecondaryStorageVmHost(Long dcId);
|
||||
public HostVO pickSsvmHost(HostVO ssHost);
|
||||
public HostVO pickSsvmHost(DataStore store);
|
||||
}
|
||||
|
||||
@ -59,6 +59,8 @@ import org.apache.cloudstack.api.command.user.template.UpdateTemplatePermissions
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
@ -266,6 +268,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
@Inject VolumeManager volumeMgr;
|
||||
@Inject VMTemplateHostDao templateHostDao;
|
||||
@Inject ImageStoreDao _imageStoreDao;
|
||||
@Inject EndPointSelector _epSelector;
|
||||
|
||||
|
||||
int _primaryStorageDownloadWait;
|
||||
@ -807,9 +810,10 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
public String getChecksum(DataStore store, String templatePath) {
|
||||
|
||||
String secUrl = store.getUri();
|
||||
Answer answer;
|
||||
answer = _agentMgr.sendToSecStorage(store, new ComputeChecksumCommand(
|
||||
secUrl, templatePath));
|
||||
EndPoint ep = _epSelector.select(store);
|
||||
ComputeChecksumCommand cmd = new ComputeChecksumCommand(
|
||||
secUrl, templatePath);
|
||||
Answer answer = ep.sendMessage(cmd);
|
||||
if (answer != null && answer.getResult()) {
|
||||
return answer.getDetails();
|
||||
}
|
||||
|
||||
@ -142,18 +142,6 @@ public class MockAgentManagerImpl extends ManagerBase implements AgentManager {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendToSecStorage(DataStore ssStore, Command cmd, Listener listener) throws AgentUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer sendToSecStorage(DataStore ssStore, Command cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user