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
|
* @return
|
||||||
*/
|
*/
|
||||||
EndPoint select(DataObject object);
|
EndPoint select(DataObject object);
|
||||||
|
|
||||||
|
EndPoint select(DataStore store);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param store
|
* @param store
|
||||||
* @return
|
* @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.DataObject;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
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.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;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
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.SnapshotInfo;
|
||||||
@ -58,14 +60,12 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
import com.cloud.agent.api.Answer;
|
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.ListTemplateAnswer;
|
||||||
import com.cloud.agent.api.storage.ListTemplateCommand;
|
import com.cloud.agent.api.storage.ListTemplateCommand;
|
||||||
import com.cloud.alert.AlertManager;
|
import com.cloud.alert.AlertManager;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.dao.ClusterDao;
|
import com.cloud.dc.dao.ClusterDao;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.exception.AgentUnavailableException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
import com.cloud.exception.ResourceAllocationException;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
@ -129,6 +129,8 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
@Inject
|
@Inject
|
||||||
TemplateDataFactory _templateFactory;
|
TemplateDataFactory _templateFactory;
|
||||||
@Inject VMTemplatePoolDao _tmpltPoolDao;
|
@Inject VMTemplatePoolDao _tmpltPoolDao;
|
||||||
|
@Inject
|
||||||
|
EndPointSelector _epSelector;
|
||||||
|
|
||||||
class TemplateOpContext<T> extends AsyncRpcConext<T> {
|
class TemplateOpContext<T> extends AsyncRpcConext<T> {
|
||||||
final TemplateObject template;
|
final TemplateObject template;
|
||||||
@ -377,17 +379,8 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
List<UserVmVO> userVmUsingIso = _userVmDao.listByIsoId(tInfo.getId());
|
List<UserVmVO> userVmUsingIso = _userVmDao.listByIsoId(tInfo.getId());
|
||||||
//check if there is any Vm using this ISO.
|
//check if there is any Vm using this ISO.
|
||||||
if (userVmUsingIso == null || userVmUsingIso.isEmpty()) {
|
if (userVmUsingIso == null || userVmUsingIso.isEmpty()) {
|
||||||
VMTemplateVO template = _templateDao.findById(tInfo.getId());
|
deleteTemplateAsync(_templateFactory.getTemplate(tInfo.getId(), store));
|
||||||
DeleteTemplateCommand dtCommand = new DeleteTemplateCommand(store.getTO(), store.getUri(), tInfo.getInstallPath(), template.getId(), template.getAccountId());
|
String description = "Deleted template " + tInfo.getTemplateName() + " on secondary storage " + storeId;
|
||||||
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";
|
|
||||||
s_logger.info(description);
|
s_logger.info(description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,7 +416,8 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
|
|
||||||
private Map<String, TemplateProp> listTemplate(DataStore ssStore) {
|
private Map<String, TemplateProp> listTemplate(DataStore ssStore) {
|
||||||
ListTemplateCommand cmd = new ListTemplateCommand(ssStore.getUri());
|
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()) {
|
if (answer != null && answer.getResult()) {
|
||||||
ListTemplateAnswer tanswer = (ListTemplateAnswer)answer;
|
ListTemplateAnswer tanswer = (ListTemplateAnswer)answer;
|
||||||
return tanswer.getTemplateInfo();
|
return tanswer.getTemplateInfo();
|
||||||
|
|||||||
@ -210,6 +210,12 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
|||||||
@Override
|
@Override
|
||||||
public EndPoint select(DataObject object) {
|
public EndPoint select(DataObject object) {
|
||||||
DataStore store = object.getDataStore();
|
DataStore store = object.getDataStore();
|
||||||
|
return select(store);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EndPoint select(DataStore store) {
|
||||||
if (store.getRole() == DataStoreRole.Primary) {
|
if (store.getRole() == DataStoreRole.Primary) {
|
||||||
return findEndpointForPrimaryStorage(store);
|
return findEndpointForPrimaryStorage(store);
|
||||||
} else if (store.getRole() == DataStoreRole.Image) {
|
} else if (store.getRole() == DataStoreRole.Image) {
|
||||||
@ -219,7 +225,6 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
|||||||
}else {
|
}else {
|
||||||
throw new CloudRuntimeException("not implemented yet");
|
throw new CloudRuntimeException("not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.DataMotionService;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
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.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.ObjectInDataStoreStateMachine.Event;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
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.AgentManager;
|
||||||
import com.cloud.agent.api.Answer;
|
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.ListVolumeAnswer;
|
||||||
import com.cloud.agent.api.storage.ListVolumeCommand;
|
import com.cloud.agent.api.storage.ListVolumeCommand;
|
||||||
import com.cloud.alert.AlertManager;
|
import com.cloud.alert.AlertManager;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.Resource.ResourceType;
|
import com.cloud.configuration.Resource.ResourceType;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.exception.AgentUnavailableException;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
import com.cloud.exception.ResourceAllocationException;
|
||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
@ -119,6 +119,8 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
VolumeDataStoreDao _volumeStoreDao;
|
VolumeDataStoreDao _volumeStoreDao;
|
||||||
@Inject
|
@Inject
|
||||||
VolumeDao _volumeDao;
|
VolumeDao _volumeDao;
|
||||||
|
@Inject
|
||||||
|
EndPointSelector _epSelector;
|
||||||
|
|
||||||
public VolumeServiceImpl() {
|
public VolumeServiceImpl() {
|
||||||
}
|
}
|
||||||
@ -815,16 +817,9 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
//Delete volumes which are not present on DB.
|
//Delete volumes which are not present on DB.
|
||||||
for (Long uniqueName : volumeInfos.keySet()) {
|
for (Long uniqueName : volumeInfos.keySet()) {
|
||||||
TemplateProp vInfo = volumeInfos.get(uniqueName);
|
TemplateProp vInfo = volumeInfos.get(uniqueName);
|
||||||
DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(store.getUri(), vInfo.getInstallPath());
|
this.expungeVolumeAsync(this.volFactory.getVolume(vInfo.getId(), store));
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
s_logger.info(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -832,7 +827,8 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
|
|
||||||
private Map<Long, TemplateProp> listVolume(DataStore store) {
|
private Map<Long, TemplateProp> listVolume(DataStore store) {
|
||||||
ListVolumeCommand cmd = new ListVolumeCommand(store.getUri());
|
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()) {
|
if (answer != null && answer.getResult()) {
|
||||||
ListVolumeAnswer tanswer = (ListVolumeAnswer)answer;
|
ListVolumeAnswer tanswer = (ListVolumeAnswer)answer;
|
||||||
return tanswer.getTemplateInfo();
|
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.DataStore;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
|
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.EndPoint;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
||||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
@ -115,6 +116,7 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
@Inject
|
@Inject
|
||||||
private AgentManager _agentMgr;
|
private AgentManager _agentMgr;
|
||||||
@Inject TemplateDataStoreDao _templateStoreDao;
|
@Inject TemplateDataStoreDao _templateStoreDao;
|
||||||
|
@Inject EndPointSelector _epSelector;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -295,7 +297,9 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
||||||
String installPath = tmplStore.getInstallPath();
|
String installPath = tmplStore.getInstallPath();
|
||||||
if (installPath != null) {
|
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()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
s_logger.debug("Failed to deleted template at store: " + store.getName());
|
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.DataStore;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
|
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.EndPoint;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
||||||
@ -110,6 +111,7 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
@Inject
|
@Inject
|
||||||
private AgentManager _agentMgr;
|
private AgentManager _agentMgr;
|
||||||
@Inject TemplateDataStoreDao _templateStoreDao;
|
@Inject TemplateDataStoreDao _templateStoreDao;
|
||||||
|
@Inject EndPointSelector _epSelector;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String grantAccess(DataObject data, EndPoint ep) {
|
public String grantAccess(DataObject data, EndPoint ep) {
|
||||||
@ -243,7 +245,9 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
||||||
String installPath = tmplStore.getInstallPath();
|
String installPath = tmplStore.getInstallPath();
|
||||||
if (installPath != null) {
|
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()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
s_logger.debug("Failed to deleted template at store: " + store.getName());
|
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.DataStore;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
|
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.EndPoint;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
||||||
@ -110,6 +111,7 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
@Inject
|
@Inject
|
||||||
private AgentManager _agentMgr;
|
private AgentManager _agentMgr;
|
||||||
@Inject TemplateDataStoreDao _templateStoreDao;
|
@Inject TemplateDataStoreDao _templateStoreDao;
|
||||||
|
@Inject EndPointSelector _epSelector;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String grantAccess(DataObject data, EndPoint ep) {
|
public String grantAccess(DataObject data, EndPoint ep) {
|
||||||
@ -236,7 +238,9 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
|
|||||||
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
|
||||||
String installPath = tmplStore.getInstallPath();
|
String installPath = tmplStore.getInstallPath();
|
||||||
if (installPath != null) {
|
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()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
s_logger.debug("Failed to deleted template at store: " + store.getName());
|
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);
|
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 */
|
/* working as a lock while agent is being loaded */
|
||||||
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action);
|
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action);
|
||||||
|
|||||||
@ -39,11 +39,8 @@ import javax.ejb.Local;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
|
||||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
import com.cloud.agent.Listener;
|
import com.cloud.agent.Listener;
|
||||||
import com.cloud.agent.StartupCommandProcessor;
|
import com.cloud.agent.StartupCommandProcessor;
|
||||||
@ -99,7 +96,6 @@ import com.cloud.resource.Discoverer;
|
|||||||
import com.cloud.resource.ResourceManager;
|
import com.cloud.resource.ResourceManager;
|
||||||
import com.cloud.resource.ResourceState;
|
import com.cloud.resource.ResourceState;
|
||||||
import com.cloud.resource.ServerResource;
|
import com.cloud.resource.ServerResource;
|
||||||
import com.cloud.server.ManagementService;
|
|
||||||
import com.cloud.storage.StorageManager;
|
import com.cloud.storage.StorageManager;
|
||||||
import com.cloud.storage.StorageService;
|
import com.cloud.storage.StorageService;
|
||||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||||
@ -110,7 +106,6 @@ import com.cloud.user.AccountManager;
|
|||||||
import com.cloud.utils.ActionDelegate;
|
import com.cloud.utils.ActionDelegate;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.Manager;
|
|
||||||
import com.cloud.utils.component.ManagerBase;
|
import com.cloud.utils.component.ManagerBase;
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
@ -381,17 +376,6 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
|||||||
return attache;
|
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
|
@Override
|
||||||
public Answer sendToSecStorage(HostVO ssHost, Command cmd) {
|
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) {
|
public void disconnectWithInvestigation(final long hostId, final Status.Event event) {
|
||||||
disconnectInternal(hostId, event, true);
|
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.DataStoreManager;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
|
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.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.HostScope;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
|
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||||
@ -328,6 +330,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
DataStoreProviderManager _dataStoreProviderMgr;
|
DataStoreProviderManager _dataStoreProviderMgr;
|
||||||
@Inject
|
@Inject
|
||||||
private TemplateService _imageSrv;
|
private TemplateService _imageSrv;
|
||||||
|
@Inject EndPointSelector _epSelector;
|
||||||
|
|
||||||
protected List<StoragePoolAllocator> _storagePoolAllocators;
|
protected List<StoragePoolAllocator> _storagePoolAllocators;
|
||||||
public List<StoragePoolAllocator> getStoragePoolAllocators() {
|
public List<StoragePoolAllocator> getStoragePoolAllocators() {
|
||||||
@ -1270,17 +1273,16 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
.getInstallPath();
|
.getInstallPath();
|
||||||
|
|
||||||
if (installPath != null) {
|
if (installPath != null) {
|
||||||
|
EndPoint ep = _epSelector.select(store);
|
||||||
Answer answer = _agentMgr.sendToSecStorage(store,
|
Command cmd = new DeleteTemplateCommand(
|
||||||
new DeleteTemplateCommand(
|
|
||||||
store.getTO(),
|
store.getTO(),
|
||||||
store.getUri(),
|
store.getUri(),
|
||||||
destroyedTemplateStoreVO
|
destroyedTemplateStoreVO
|
||||||
.getInstallPath(),
|
.getInstallPath(),
|
||||||
destroyedTemplate.getId(),
|
destroyedTemplate.getId(),
|
||||||
destroyedTemplate.getAccountId()
|
destroyedTemplate.getAccountId()
|
||||||
|
);
|
||||||
));
|
Answer answer = ep.sendMessage(cmd);
|
||||||
|
|
||||||
if (answer == null || !answer.getResult()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
s_logger.debug("Failed to delete "
|
s_logger.debug("Failed to delete "
|
||||||
|
|||||||
@ -287,7 +287,7 @@ public class DownloadListener implements Listener {
|
|||||||
}
|
}
|
||||||
_imageSrv.handleSysTemplateDownload(hostHyper, agent.getDataCenterId());
|
_imageSrv.handleSysTemplateDownload(hostHyper, agent.getDataCenterId());
|
||||||
}
|
}
|
||||||
/* This can be removed since
|
/* This can be removed
|
||||||
else if ( cmd instanceof StartupStorageCommand) {
|
else if ( cmd instanceof StartupStorageCommand) {
|
||||||
StartupStorageCommand storage = (StartupStorageCommand)cmd;
|
StartupStorageCommand storage = (StartupStorageCommand)cmd;
|
||||||
if( storage.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE ||
|
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
|
@Override
|
||||||
public boolean plugNic(Network network, NicTO nic, VirtualMachineTO vm,
|
public boolean plugNic(Network network, NicTO nic, VirtualMachineTO vm,
|
||||||
ReservationContext context, DeployDestination dest) throws ConcurrentOperationException, ResourceUnavailableException,
|
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> listAllTypesSecondaryStorageHostsInOneZone(long dataCenterId);
|
||||||
public List<HostVO> listUpAndConnectingSecondaryStorageVmHost(Long dcId);
|
public List<HostVO> listUpAndConnectingSecondaryStorageVmHost(Long dcId);
|
||||||
public HostVO pickSsvmHost(HostVO ssHost);
|
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.CommandResult;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
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.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.TemplateDataFactory;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
|
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||||
@ -266,6 +268,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||||||
@Inject VolumeManager volumeMgr;
|
@Inject VolumeManager volumeMgr;
|
||||||
@Inject VMTemplateHostDao templateHostDao;
|
@Inject VMTemplateHostDao templateHostDao;
|
||||||
@Inject ImageStoreDao _imageStoreDao;
|
@Inject ImageStoreDao _imageStoreDao;
|
||||||
|
@Inject EndPointSelector _epSelector;
|
||||||
|
|
||||||
|
|
||||||
int _primaryStorageDownloadWait;
|
int _primaryStorageDownloadWait;
|
||||||
@ -807,9 +810,10 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||||||
public String getChecksum(DataStore store, String templatePath) {
|
public String getChecksum(DataStore store, String templatePath) {
|
||||||
|
|
||||||
String secUrl = store.getUri();
|
String secUrl = store.getUri();
|
||||||
Answer answer;
|
EndPoint ep = _epSelector.select(store);
|
||||||
answer = _agentMgr.sendToSecStorage(store, new ComputeChecksumCommand(
|
ComputeChecksumCommand cmd = new ComputeChecksumCommand(
|
||||||
secUrl, templatePath));
|
secUrl, templatePath);
|
||||||
|
Answer answer = ep.sendMessage(cmd);
|
||||||
if (answer != null && answer.getResult()) {
|
if (answer != null && answer.getResult()) {
|
||||||
return answer.getDetails();
|
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
|
@Override
|
||||||
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) {
|
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user