mirror of https://github.com/apache/cloudstack.git
Fixed up the rest of the management server code that calls clustermanager
This commit is contained in:
parent
1caa566280
commit
111febc567
|
|
@ -28,7 +28,6 @@ import java.util.UUID;
|
|||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.storage.command.CopyCommand;
|
||||
|
|
@ -48,10 +47,10 @@ import com.cloud.agent.api.to.DataStoreTO;
|
|||
import com.cloud.agent.api.to.DataTO;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
|
|
@ -100,7 +99,6 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
@Inject HostDao _hostDao;
|
||||
@Inject HostDetailsDao _hostDetailsDao;
|
||||
@Inject CommandExecLogDao _cmdExecLogDao;
|
||||
@Inject ClusterManager _clusterMgr;
|
||||
@Inject VmwareManager _vmwareMgr;
|
||||
@Inject SecondaryStorageVmManager _secStorageMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,13 @@ import com.vmware.vim25.AboutInfo;
|
|||
import com.vmware.vim25.HostConnectSpec;
|
||||
import com.vmware.vim25.ManagedObjectReference;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd;
|
||||
import org.apache.cloudstack.api.command.admin.zone.ListVmwareDcsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.zone.RemoveVmwareDcCmd;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.api.AgentControlAnswer;
|
||||
|
|
@ -51,7 +58,6 @@ import com.cloud.agent.api.Answer;
|
|||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.ClusterDetailsDao;
|
||||
|
|
@ -116,12 +122,6 @@ import com.cloud.utils.script.Script;
|
|||
import com.cloud.utils.ssh.SshHelper;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd;
|
||||
import org.apache.cloudstack.api.command.admin.zone.ListVmwareDcsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.zone.RemoveVmwareDcCmd;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
|
||||
|
||||
@Local(value = {VmwareManager.class, VmwareDatacenterService.class})
|
||||
public class VmwareManagerImpl extends ManagerBase implements VmwareManager, VmwareStorageMount, Listener, VmwareDatacenterService {
|
||||
|
|
@ -142,7 +142,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
@Inject ClusterDao _clusterDao;
|
||||
@Inject ClusterDetailsDao _clusterDetailsDao;
|
||||
@Inject CommandExecLogDao _cmdExecLogDao;
|
||||
@Inject ClusterManager _clusterMgr;
|
||||
@Inject SecondaryStorageVmManager _ssvmMgr;
|
||||
@Inject DataStoreManager _dataStoreMgr;
|
||||
@Inject CiscoNexusVSMDeviceDao _nexusDao;
|
||||
|
|
@ -664,7 +663,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
|
||||
private String setupMountPoint(String parent) {
|
||||
String mountPoint = null;
|
||||
long mshostId = _clusterMgr.getManagementNodeId();
|
||||
long mshostId = ManagementServerNode.getManagementServerId();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
String mntPt = parent + File.separator + String.valueOf(mshostId) + "." + Integer.toHexString(_rand.nextInt(Integer.MAX_VALUE));
|
||||
File file = new File(mntPt);
|
||||
|
|
@ -683,7 +682,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
private void startupCleanup(String parent) {
|
||||
s_logger.info("Cleanup mounted NFS mount points used in previous session");
|
||||
|
||||
long mshostId = _clusterMgr.getManagementNodeId();
|
||||
long mshostId = ManagementServerNode.getManagementServerId();
|
||||
|
||||
// cleanup left-over NFS mounts from previous session
|
||||
String[] mounts = _storage.listFiles(parent + File.separator + String.valueOf(mshostId) + ".*");
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ import com.cloud.host.Status;
|
|||
import com.cloud.host.Status.Event;
|
||||
import com.cloud.resource.ResourceState;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.storage.resource.DummySecondaryStorageResource;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.Profiler;
|
||||
|
|
@ -166,6 +167,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
_clusterMgr.registerListener(this);
|
||||
_clusterMgr.registerDispatcher(new ClusterDispatcher());
|
||||
|
||||
_gson = GsonHelper.getGson();
|
||||
|
||||
return super.configure(name, xmlParams);
|
||||
}
|
||||
|
||||
|
|
@ -1237,31 +1240,6 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
return send(hostId, commands);
|
||||
}
|
||||
|
||||
public Boolean propagateResourceEvent(long agentId, ResourceState.Event event) throws AgentUnavailableException {
|
||||
final String msPeer = getPeerName(agentId);
|
||||
if (msPeer == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId);
|
||||
}
|
||||
Command[] cmds = new Command[1];
|
||||
cmds[0] = new PropagateResourceEventCommand(agentId, event);
|
||||
|
||||
String AnsStr = _clusterMgr.execute(msPeer, agentId, _gson.toJson(cmds), true);
|
||||
if (AnsStr == null) {
|
||||
throw new AgentUnavailableException(agentId);
|
||||
}
|
||||
|
||||
Answer[] answers = _gson.fromJson(AnsStr, Answer[].class);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Result for agent change is " + answers[0].getResult());
|
||||
}
|
||||
|
||||
return answers[0].getResult();
|
||||
}
|
||||
|
||||
public boolean executeResourceUserRequest(long hostId, ResourceState.Event event) throws AgentUnavailableException {
|
||||
return _resourceMgr.executeUserRequest(hostId, event);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ import com.cloud.api.ApiDispatcher;
|
|||
import com.cloud.api.ApiGsonHelper;
|
||||
import com.cloud.api.ApiSerializerHelper;
|
||||
import com.cloud.async.dao.AsyncJobDao;
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.cluster.ClusterManagerListener;
|
||||
import com.cloud.cluster.ManagementServerHostVO;
|
||||
import com.cloud.configuration.Config;
|
||||
|
|
@ -101,7 +100,6 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||
|
||||
@Inject private AsyncJobExecutorContext _context;
|
||||
@Inject private SyncQueueManager _queueMgr;
|
||||
@Inject private ClusterManager _clusterMgr;
|
||||
@Inject private AccountManager _accountMgr;
|
||||
@Inject private AccountDao _accountDao;
|
||||
@Inject private AsyncJobDao _jobDao;
|
||||
|
|
|
|||
|
|
@ -221,6 +221,8 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
|||
IPAddressDao _ipAddressDao;
|
||||
@Inject
|
||||
ManagementServer _ms;
|
||||
@Inject
|
||||
ClusterManager _clusterMgr;
|
||||
|
||||
private ConsoleProxyListener _listener;
|
||||
|
||||
|
|
@ -981,7 +983,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
|||
|
||||
private synchronized Map<Long, ZoneHostInfo> getZoneHostInfo() {
|
||||
Date cutTime = DateUtil.currentGMTTime();
|
||||
List<RunningHostCountInfo> l = _hostDao.getRunningHostCounts(new Date(cutTime.getTime() - ClusterManager.DEFAULT_HEARTBEAT_THRESHOLD));
|
||||
List<RunningHostCountInfo> l = _hostDao.getRunningHostCounts(new Date(cutTime.getTime() - _clusterMgr.getHeartbeatThreshold()));
|
||||
|
||||
RunningHostInfoAgregator aggregator = new RunningHostInfoAgregator();
|
||||
if (l.size() > 0) {
|
||||
|
|
|
|||
|
|
@ -30,10 +30,11 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
|
||||
import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
|
||||
|
|
@ -53,10 +54,12 @@ import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
|||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.AgentManager.TapAgentsAction;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.GetHostStatsAnswer;
|
||||
import com.cloud.agent.api.GetHostStatsCommand;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.PropagateResourceEventCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.UnsupportedAnswer;
|
||||
|
|
@ -119,6 +122,7 @@ import com.cloud.org.Cluster;
|
|||
import com.cloud.org.Grouping;
|
||||
import com.cloud.org.Grouping.AllocationState;
|
||||
import com.cloud.org.Managed;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.GuestOSCategoryVO;
|
||||
import com.cloud.storage.StorageManager;
|
||||
|
|
@ -165,6 +169,8 @@ import com.cloud.vm.dao.VMInstanceDao;
|
|||
public class ResourceManagerImpl extends ManagerBase implements ResourceManager, ResourceService, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(ResourceManagerImpl.class);
|
||||
|
||||
Gson _gson;
|
||||
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
|
|
@ -908,7 +914,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
@Override
|
||||
public boolean deleteHost(long hostId, boolean isForced, boolean isForceDeleteStorage) {
|
||||
try {
|
||||
Boolean result = _clusterMgr.propagateResourceEvent(hostId, ResourceState.Event.DeleteHost);
|
||||
Boolean result = propagateResourceEvent(hostId, ResourceState.Event.DeleteHost);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1222,7 +1228,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
|
||||
@Override
|
||||
public boolean maintain(final long hostId) throws AgentUnavailableException {
|
||||
Boolean result = _clusterMgr.propagateResourceEvent(hostId, ResourceState.Event.AdminAskMaintenace);
|
||||
Boolean result = propagateResourceEvent(hostId, ResourceState.Event.AdminAskMaintenace);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1329,6 +1335,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_defaultSystemVMHypervisor = HypervisorType.getType(_configDao.getValue(Config.SystemVMDefaultHypervisor.toString()));
|
||||
_gson = GsonHelper.getGson();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2138,7 +2145,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
|
||||
private boolean cancelMaintenance(long hostId) {
|
||||
try {
|
||||
Boolean result = _clusterMgr.propagateResourceEvent(hostId, ResourceState.Event.AdminCancelMaintenance);
|
||||
Boolean result = propagateResourceEvent(hostId, ResourceState.Event.AdminCancelMaintenance);
|
||||
|
||||
if (result != null) {
|
||||
return result;
|
||||
|
|
@ -2186,7 +2193,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
@Override
|
||||
public boolean umanageHost(long hostId) {
|
||||
try {
|
||||
Boolean result = _clusterMgr.propagateResourceEvent(hostId, ResourceState.Event.Unmanaged);
|
||||
Boolean result = propagateResourceEvent(hostId, ResourceState.Event.Unmanaged);
|
||||
|
||||
if (result != null) {
|
||||
return result;
|
||||
|
|
@ -2218,7 +2225,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
if (cmd.getClusterId() == null) {
|
||||
// update agent attache password
|
||||
try {
|
||||
Boolean result = _clusterMgr.propagateResourceEvent(cmd.getHostId(), ResourceState.Event.UpdatePassword);
|
||||
Boolean result = propagateResourceEvent(cmd.getHostId(), ResourceState.Event.UpdatePassword);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
|
@ -2235,7 +2242,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
* FIXME: this is a buggy logic, check with alex. Shouldn't
|
||||
* return if propagation return non null
|
||||
*/
|
||||
Boolean result = _clusterMgr.propagateResourceEvent(h.getId(), ResourceState.Event.UpdatePassword);
|
||||
Boolean result = propagateResourceEvent(h.getId(), ResourceState.Event.UpdatePassword);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
|
@ -2249,6 +2256,45 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
}
|
||||
}
|
||||
|
||||
public String getPeerName(long agentHostId) {
|
||||
|
||||
HostVO host = _hostDao.findById(agentHostId);
|
||||
if (host != null && host.getManagementServerId() != null) {
|
||||
if (_clusterMgr.getSelfPeerName().equals(Long.toString(host.getManagementServerId()))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Long.toString(host.getManagementServerId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean propagateResourceEvent(long agentId, ResourceState.Event event) throws AgentUnavailableException {
|
||||
final String msPeer = getPeerName(agentId);
|
||||
if (msPeer == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId);
|
||||
}
|
||||
Command[] cmds = new Command[1];
|
||||
cmds[0] = new PropagateResourceEventCommand(agentId, event);
|
||||
|
||||
String AnsStr = _clusterMgr.execute(msPeer, agentId, _gson.toJson(cmds), true);
|
||||
if (AnsStr == null) {
|
||||
throw new AgentUnavailableException(agentId);
|
||||
}
|
||||
|
||||
Answer[] answers = _gson.fromJson(AnsStr, Answer[].class);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Result for agent change is " + answers[0].getResult());
|
||||
}
|
||||
|
||||
return answers[0].getResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean maintenanceFailed(long hostId) {
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
|
|
|
|||
|
|
@ -438,14 +438,12 @@ import com.cloud.alert.AlertManager;
|
|||
import com.cloud.alert.AlertVO;
|
||||
import com.cloud.alert.dao.AlertDao;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.capacity.Capacity;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.ConfigurationVO;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.consoleproxy.ConsoleProxyManagementState;
|
||||
|
|
@ -513,7 +511,6 @@ import com.cloud.projects.ProjectManager;
|
|||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.server.auth.UserAuthenticator;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.GuestOS;
|
||||
import com.cloud.storage.GuestOSCategoryVO;
|
||||
|
|
@ -530,13 +527,11 @@ import com.cloud.storage.VolumeVO;
|
|||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.GuestOSCategoryDao;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.storage.dao.UploadDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.s3.S3Manager;
|
||||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.storage.upload.UploadMonitor;
|
||||
import com.cloud.tags.ResourceTagVO;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import com.cloud.template.TemplateManager;
|
||||
|
|
@ -584,7 +579,6 @@ import com.cloud.vm.VirtualMachineManager;
|
|||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VirtualMachineProfileImpl;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.InstanceGroupDao;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
|
@ -606,8 +600,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
@Inject
|
||||
private IPAddressDao _publicIpAddressDao;
|
||||
@Inject
|
||||
private DomainRouterDao _routerDao;
|
||||
@Inject
|
||||
private ConsoleProxyDao _consoleProxyDao;
|
||||
@Inject
|
||||
private ClusterDao _clusterDao;
|
||||
|
|
@ -638,8 +630,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
@Inject
|
||||
private SecondaryStorageVmManager _secStorageVmMgr;
|
||||
@Inject
|
||||
private ServiceOfferingDao _offeringsDao;
|
||||
@Inject
|
||||
private DiskOfferingDao _diskOfferingDao;
|
||||
@Inject
|
||||
private VMTemplateDao _templateDao;
|
||||
|
|
@ -671,17 +661,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
private VMInstanceDao _vmInstanceDao;
|
||||
@Inject
|
||||
private VolumeDao _volumeDao;
|
||||
@Inject
|
||||
private AsyncJobManager _asyncMgr;
|
||||
private int _purgeDelay;
|
||||
private int _alertPurgeDelay;
|
||||
@Inject
|
||||
private InstanceGroupDao _vmGroupDao;
|
||||
@Inject
|
||||
private UploadMonitor _uploadMonitor;
|
||||
@Inject
|
||||
private UploadDao _uploadDao;
|
||||
@Inject
|
||||
private SSHKeyPairDao _sshKeyPairDao;
|
||||
@Inject
|
||||
private LoadBalancerDao _loadbalancerDao;
|
||||
|
|
@ -691,8 +675,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
@Inject
|
||||
private List<StoragePoolAllocator> _storagePoolAllocators;
|
||||
@Inject
|
||||
private ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
private ResourceTagDao _resourceTagDao;
|
||||
|
||||
@Inject
|
||||
|
|
|
|||
Loading…
Reference in New Issue