mirror of https://github.com/apache/cloudstack.git
Bug 11522 - New agent manager
1. get rid of host allocation state 2. remove Updating status from agent status
This commit is contained in:
parent
6d95422f34
commit
30f95e638a
|
|
@ -60,11 +60,6 @@ public interface Host extends StateObject<Status> {
|
|||
}
|
||||
}
|
||||
|
||||
public enum HostAllocationState {
|
||||
Disabled,
|
||||
Enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return id of the host.
|
||||
*/
|
||||
|
|
@ -199,8 +194,6 @@ public interface Host extends StateObject<Status> {
|
|||
|
||||
String getStorageMacAddressDeux();
|
||||
|
||||
HostAllocationState getHostAllocationState();
|
||||
|
||||
String getHypervisorVersion();
|
||||
|
||||
boolean isInMaintenanceStates();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ public enum Status {
|
|||
Up(true, false, false),
|
||||
Down(true, true, true),
|
||||
Disconnected(true, true, true),
|
||||
Updating(true, true, false),
|
||||
Alert(true, true, true),
|
||||
Removed(true, false, true),
|
||||
Error(true, false, true),
|
||||
|
|
@ -61,7 +60,6 @@ public enum Status {
|
|||
public enum Event {
|
||||
AgentConnected(false, "Agent connected"),
|
||||
PingTimeout(false, "Agent is behind on ping"),
|
||||
UpdateNeeded(false, "UpdateRequested"),
|
||||
ShutdownRequested(false, "Shutdown requested by the agent"),
|
||||
AgentDisconnected(false, "Agent disconnected"),
|
||||
HostDown(false, "Host is found to be down by the investigator"),
|
||||
|
|
@ -125,13 +123,11 @@ public enum Status {
|
|||
s_fsm.addTransition(Status.Connecting, Event.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Connecting, Event.Ready, Status.Up);
|
||||
s_fsm.addTransition(Status.Connecting, Event.PingTimeout, Status.Alert);
|
||||
s_fsm.addTransition(Status.Connecting, Event.UpdateNeeded, Status.Updating);
|
||||
s_fsm.addTransition(Status.Connecting, Event.ShutdownRequested, Status.Disconnected);
|
||||
s_fsm.addTransition(Status.Connecting, Event.HostDown, Status.Alert);
|
||||
s_fsm.addTransition(Status.Connecting, Event.Ping, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Connecting, Event.ManagementServerDown, Status.Disconnected);
|
||||
s_fsm.addTransition(Status.Connecting, Event.AgentDisconnected, Status.Alert);
|
||||
//s_fsm.addTransition(Status.Connecting, Event.Error, Status.Error);
|
||||
s_fsm.addTransition(Status.Up, Event.PingTimeout, Status.Alert);
|
||||
s_fsm.addTransition(Status.Up, Event.AgentDisconnected, Status.Alert);
|
||||
s_fsm.addTransition(Status.Up, Event.ShutdownRequested, Status.Disconnected);
|
||||
|
|
@ -140,13 +136,6 @@ public enum Status {
|
|||
s_fsm.addTransition(Status.Up, Event.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Up, Event.ManagementServerDown, Status.Disconnected);
|
||||
s_fsm.addTransition(Status.Up, Event.StartAgentRebalance, Status.Rebalancing);
|
||||
//s_fsm.addTransition(Status.Up, Event.Error, Status.Error);
|
||||
s_fsm.addTransition(Status.Updating, Event.PingTimeout, Status.Alert);
|
||||
s_fsm.addTransition(Status.Updating, Event.Ping, Status.Updating);
|
||||
s_fsm.addTransition(Status.Updating, Event.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Updating, Event.ManagementServerDown, Status.Disconnected);
|
||||
s_fsm.addTransition(Status.Updating, Event.WaitedTooLong, Status.Alert);
|
||||
//s_fsm.addTransition(Status.Updating, Event.Error, Status.Error);
|
||||
s_fsm.addTransition(Status.Disconnected, Event.PingTimeout, Status.Alert);
|
||||
s_fsm.addTransition(Status.Disconnected, Event.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Disconnected, Event.Ping, Status.Up);
|
||||
|
|
@ -155,19 +144,16 @@ public enum Status {
|
|||
s_fsm.addTransition(Status.Disconnected, Event.WaitedTooLong, Status.Alert);
|
||||
s_fsm.addTransition(Status.Disconnected, Event.Remove, Status.Removed);
|
||||
s_fsm.addTransition(Status.Disconnected, Event.AgentDisconnected, Status.Disconnected);
|
||||
//s_fsm.addTransition(Status.Disconnected, Event.Error, Status.Error);
|
||||
s_fsm.addTransition(Status.Down, Event.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Down, Event.Remove, Status.Removed);
|
||||
s_fsm.addTransition(Status.Down, Event.ManagementServerDown, Status.Down);
|
||||
s_fsm.addTransition(Status.Down, Event.AgentDisconnected, Status.Down);
|
||||
//s_fsm.addTransition(Status.Down, Event.Error, Status.Error);
|
||||
s_fsm.addTransition(Status.Alert, Event.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Alert, Event.Ping, Status.Up);
|
||||
s_fsm.addTransition(Status.Alert, Event.Remove, Status.Removed);
|
||||
s_fsm.addTransition(Status.Alert, Event.ManagementServerDown, Status.Alert);
|
||||
s_fsm.addTransition(Status.Alert, Event.AgentDisconnected, Status.Alert);
|
||||
s_fsm.addTransition(Status.Alert, Event.ShutdownRequested, Status.Disconnected);
|
||||
//s_fsm.addTransition(Status.Alert, Event.Error, Status.Error);
|
||||
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceFailed, Status.Disconnected);
|
||||
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceCompleted, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Rebalancing, Event.AgentConnected, Status.Connecting);
|
||||
|
|
|
|||
|
|
@ -127,10 +127,6 @@ public class HostVO implements Host {
|
|||
|
||||
@Column(name="setup")
|
||||
private boolean setup = false;
|
||||
|
||||
@Column(name="allocation_state", nullable=false)
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private HostAllocationState hostAllocationState;
|
||||
|
||||
@Column(name="resource_state", nullable=false)
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
|
|
@ -364,7 +360,6 @@ public class HostVO implements Host {
|
|||
this.status = Status.Creating;
|
||||
this.totalMemory = 0;
|
||||
this.dom0MinMemory = 0;
|
||||
this.hostAllocationState = Host.HostAllocationState.Enabled;
|
||||
this.resourceState = ResourceState.Creating;
|
||||
}
|
||||
|
||||
|
|
@ -401,8 +396,7 @@ public class HostVO implements Host {
|
|||
this(id, name, type, privateIpAddress, privateNetmask, privateMacAddress, publicIpAddress, publicNetmask, publicMacAddress, storageIpAddress, storageNetmask, storageMacAddress, guid, status, version, iqn, disconnectedOn, dcId, podId, serverId, ping, null, null, null, 0, null);
|
||||
this.parent = parent;
|
||||
this.totalSize = totalSize;
|
||||
this.fsType = fsType;
|
||||
this.hostAllocationState = Host.HostAllocationState.Enabled;
|
||||
this.fsType = fsType;
|
||||
}
|
||||
|
||||
public HostVO(long id,
|
||||
|
|
@ -459,8 +453,7 @@ public class HostVO implements Host {
|
|||
this.caps = caps;
|
||||
this.disconnectedOn = disconnectedOn;
|
||||
this.dom0MinMemory = dom0MinMemory;
|
||||
this.storageUrl = url;
|
||||
this.hostAllocationState = Host.HostAllocationState.Enabled;
|
||||
this.storageUrl = url;
|
||||
}
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
|
|
@ -677,16 +670,6 @@ public class HostVO implements Host {
|
|||
return hypervisorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostAllocationState getHostAllocationState() {
|
||||
return hostAllocationState;
|
||||
}
|
||||
|
||||
public void setHostAllocationState(HostAllocationState hostAllocationState) {
|
||||
this.hostAllocationState = hostAllocationState;
|
||||
}
|
||||
|
||||
|
||||
public void setHypervisorVersion(String hypervisorVersion) {
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ import com.cloud.ha.HighAvailabilityManager;
|
|||
import com.cloud.ha.HighAvailabilityManager.WorkType;
|
||||
import com.cloud.host.DetailVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.HostAllocationState;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
|
|
@ -184,6 +183,7 @@ import edu.emory.mathcs.backport.java.util.Collections;
|
|||
@Local(value = { AgentManager.class })
|
||||
public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(AgentManagerImpl.class);
|
||||
private static final Logger status_logger = Logger.getLogger(Status.class);
|
||||
|
||||
protected ConcurrentHashMap<Long, AgentAttache> _agents = new ConcurrentHashMap<Long, AgentAttache>(10007);
|
||||
protected List<Pair<Integer, Listener>> _hostMonitors = new ArrayList<Pair<Integer, Listener>>(17);
|
||||
|
|
@ -885,7 +885,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
}
|
||||
|
||||
if (forRebalance) {
|
||||
Host h = _resourceMgr.createHostAndAgent(host.getId(), resource, host.getDetails(), false, null, null, true);
|
||||
Host h = _resourceMgr.createHostAndAgent(host.getId(), resource, host.getDetails(), false, null, true);
|
||||
return (h == null ? false : true);
|
||||
} else {
|
||||
_executor.execute(new SimulateStartTask(host.getId(), resource, host.getDetails(), null));
|
||||
|
|
@ -1091,14 +1091,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
s_logger.debug("Host has been determined to be disconnected but it hasn't passed the wait time yet.");
|
||||
return false;
|
||||
}
|
||||
} else if (currentStatus == Status.Updating) {
|
||||
if (((System.currentTimeMillis() >> 10) - host.getLastPinged()) > _updateWait) {
|
||||
s_logger.warn("Host " + host.getId() + " has been updating for too long");
|
||||
event = Status.Event.WaitedTooLong;
|
||||
} else {
|
||||
s_logger.debug("Host has been determined to be disconnected but it hasn't passed the wait time yet.");
|
||||
return false;
|
||||
}
|
||||
} else if (currentStatus == Status.Up) {
|
||||
DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId());
|
||||
HostPodVO podVO = _podDao.findById(host.getPodId());
|
||||
|
|
@ -1332,7 +1324,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
s_logger.debug("Simulating start for resource " + resource.getName() + " id " + id);
|
||||
}
|
||||
|
||||
_resourceMgr.createHostAndAgent(id, resource, details, false, null, null, false);
|
||||
_resourceMgr.createHostAndAgent(id, resource, details, false, null, false);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to simulate start on resource " + id + " name " + resource.getName(), e);
|
||||
} finally {
|
||||
|
|
@ -1456,7 +1448,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
final String reason = shutdown.getReason();
|
||||
s_logger.info("Host " + attache.getId() + " has informed us that it is shutting down with reason " + reason + " and detail " + shutdown.getDetail());
|
||||
if (reason.equals(ShutdownCommand.Update)) {
|
||||
disconnectWithoutInvestigation(attache, Event.UpdateNeeded);
|
||||
//disconnectWithoutInvestigation(attache, Event.UpdateNeeded);
|
||||
throw new CloudRuntimeException("Agent update not implemented");
|
||||
} else if (reason.equals(ShutdownCommand.Requested)) {
|
||||
disconnectWithoutInvestigation(attache, Event.ShutdownRequested);
|
||||
}
|
||||
|
|
@ -1587,48 +1580,23 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isAgentEventAllowedByResourceState(HostVO host, Status.Event event) {
|
||||
host = _hostDao.findById(host.getId());
|
||||
ResourceState state = host.getResourceState();
|
||||
boolean allow = true;
|
||||
if (state == ResourceState.Enabled) {
|
||||
|
||||
} else if (state == ResourceState.Disabled) {
|
||||
if (event == Status.Event.AgentConnected) {
|
||||
allow = false;
|
||||
}
|
||||
} else if (state == ResourceState.Unmanaged) {
|
||||
if (event == Status.Event.AgentConnected) {
|
||||
allow = false;
|
||||
}
|
||||
} else if (state == ResourceState.PrepareForMaintenance) {
|
||||
|
||||
} else if (state == ResourceState.Maintenance) {
|
||||
|
||||
} else if (state == ResourceState.Creating) {
|
||||
} else if (state == ResourceState.Error) {
|
||||
allow = false;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Unknown resource state " + state);
|
||||
}
|
||||
|
||||
return allow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean agentStatusTransitTo(HostVO host, Status.Event e, long msId) {
|
||||
if (!isAgentEventAllowedByResourceState(host, e)) {
|
||||
String err = String.format("Cannot proceed agent event %1$s because it is not allowed by current resource state %2$s fort host %3$s", e, host.getResourceState(), host.getId());
|
||||
s_logger.debug(err);
|
||||
throw new CloudRuntimeException(err);
|
||||
if (status_logger.isDebugEnabled()) {
|
||||
ResourceState state = host.getResourceState();
|
||||
StringBuilder msg = new StringBuilder("Transition:");
|
||||
msg.append("[Resource state = ").append(state);
|
||||
msg.append(", Agent event = ").append(e.toString());
|
||||
msg.append(", Host id = ").append(host.getId()).append("]");
|
||||
status_logger.debug(msg);
|
||||
}
|
||||
|
||||
host.setManagementServerId(msId);
|
||||
try {
|
||||
return _statusStateMachine.transitTo(host, e, host.getId(), _hostDao);
|
||||
} catch (NoTransitionException e1) {
|
||||
s_logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", mangement server id is " + msId);
|
||||
status_logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", mangement server id is " + msId);
|
||||
throw new CloudRuntimeException("Cannot transit agent status with event " + e + " for host " + host.getId() + ", mangement server id is " + msId + "," + e1.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import com.cloud.vm.dao.VMInstanceDao;
|
|||
|
||||
public class AgentMonitor extends Thread implements Listener {
|
||||
private static Logger s_logger = Logger.getLogger(AgentMonitor.class);
|
||||
private static Logger status_Logger = Logger.getLogger(Status.class);
|
||||
private long _pingTimeout;
|
||||
private HostDao _hostDao;
|
||||
private boolean _stop;
|
||||
|
|
@ -138,10 +139,20 @@ public class AgentMonitor extends Thread implements Listener {
|
|||
}
|
||||
|
||||
try {
|
||||
|
||||
List<Long> behindAgents = findAgentsBehindOnPing();
|
||||
for (Long agentId : behindAgents) {
|
||||
_agentMgr.disconnectWithInvestigation(agentId, Event.PingTimeout);
|
||||
SearchCriteriaService<HostVO, ResourceState> sc = SearchCriteria2.create(HostVO.class, ResourceState.class);
|
||||
sc.selectField(sc.getEntity().getResourceState());
|
||||
sc.addAnd(sc.getEntity().getId(), Op.EQ, agentId);
|
||||
ResourceState resourceState = sc.find();
|
||||
if (resourceState == ResourceState.Disabled || resourceState == ResourceState.Maintenance || resourceState == ResourceState.Unmanaged || resourceState == ResourceState.ErrorInMaintenance) {
|
||||
/* Host is in non-operation state, so no investigation and direct put agent to Disconnected */
|
||||
status_Logger.debug("Ping timeout but host " + agentId + " is in resource state of " + resourceState + ", so no investigation");
|
||||
_agentMgr.disconnectWithoutInvestigation(agentId, Event.ShutdownRequested);
|
||||
} else {
|
||||
status_Logger.debug("Ping timeout for host " + agentId + ", do invstigation");
|
||||
_agentMgr.disconnectWithInvestigation(agentId, Event.PingTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
|
|
|
|||
|
|
@ -195,14 +195,7 @@ public class FirstFitAllocator implements HostAllocator {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(host.getHostAllocationState() != Host.HostAllocationState.Enabled){
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +" is in " + host.getHostAllocationState().name() + " state, skipping this and trying other available hosts");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//find number of guest VMs occupying capacity on this host.
|
||||
Long vmCount = _vmInstanceDao.countRunningByHostId(host.getId());
|
||||
Long maxGuestLimit = getHostMaxGuestLimit(host);
|
||||
|
|
|
|||
|
|
@ -96,13 +96,6 @@ public class RandomAllocator implements HostAllocator {
|
|||
break;
|
||||
}
|
||||
|
||||
if(host.getHostAllocationState() != Host.HostAllocationState.Enabled){
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +" is in " + host.getHostAllocationState().name() + " state, skipping this and trying other available hosts");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!avoid.shouldAvoid(host)) {
|
||||
suitableHosts.add(host);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -607,7 +607,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
hostResponse.setEvents(events);
|
||||
}
|
||||
|
||||
hostResponse.setAllocationState(host.getHostAllocationState().toString());
|
||||
hostResponse.setAllocationState(host.getResourceState().toString());
|
||||
|
||||
hostResponse.setObjectName("host");
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.HostAllocationState;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.resource.ResourceState;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.StoragePoolHostVO;
|
||||
|
|
@ -177,7 +178,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||
if(host == null){
|
||||
s_logger.debug("The last host of this VM cannot be found");
|
||||
}else{
|
||||
if (host.getStatus() == Status.Up && host.getHostAllocationState() == Host.HostAllocationState.Enabled) {
|
||||
if (host.getStatus() == Status.Up && host.getResourceState() == ResourceState.Enabled) {
|
||||
if(_capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, true, cpuOverprovisioningFactor, true)){
|
||||
s_logger.debug("The last host of this VM is UP and has enough capacity");
|
||||
s_logger.debug("Now checking for suitable pools under zone: "+host.getDataCenterId() +", pod: "+ host.getPodId()+", cluster: "+ host.getClusterId());
|
||||
|
|
@ -209,7 +210,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||
s_logger.debug("The last host of this VM does not have enough capacity");
|
||||
}
|
||||
}else{
|
||||
s_logger.debug("The last host of this VM is not UP or is not enabled, host status is: "+host.getStatus().name() + ", host allocation state is: "+host.getHostAllocationState().name());
|
||||
s_logger.debug("The last host of this VM is not UP or is not enabled, host status is: "+host.getStatus().name() + ", host resource state is: "+host.getResourceState());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
@TableGenerator(name = "host_req_sq", table = "op_host", pkColumnName = "id", valueColumnName = "sequence", allocationSize = 1)
|
||||
public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao {
|
||||
private static final Logger s_logger = Logger.getLogger(HostDaoImpl.class);
|
||||
private static final Logger status_logger = Logger.getLogger(Status.class);
|
||||
|
||||
protected final SearchBuilder<HostVO> TypePodDcStatusSearch;
|
||||
|
||||
|
|
@ -625,7 +626,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
int result = update(ub, sc, null);
|
||||
assert result <= 1 : "How can this update " + result + " rows? ";
|
||||
|
||||
if (s_logger.isDebugEnabled() && result == 0) {
|
||||
if (status_logger.isDebugEnabled() && result == 0) {
|
||||
HostVO ho = findById(host.getId());
|
||||
assert ho != null : "How how how? : " + host.getId();
|
||||
|
||||
|
|
@ -636,7 +637,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
.append(oldPingTime).append("]");
|
||||
str.append("; DB=[status=").append(vo.getStatus().toString()).append(":msid=").append(vo.getManagementServerId()).append(":lastpinged=")
|
||||
.append(vo.getLastPinged()).append("]");
|
||||
s_logger.debug(str.toString());
|
||||
status_logger.debug(str.toString());
|
||||
}
|
||||
|
||||
StringBuilder msg = new StringBuilder("Agent status update: [");
|
||||
|
|
@ -644,7 +645,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
msg.append("; old status = " + oldStatus);
|
||||
msg.append("; event = " + event);
|
||||
msg.append("; new status = " + newStatus + "]");
|
||||
s_logger.debug(msg.toString());
|
||||
status_logger.debug(msg.toString());
|
||||
|
||||
return result > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public interface ResourceManager {
|
|||
public void unregisterResourceStateAdapter(String name);
|
||||
|
||||
public Host createHostAndAgent(Long hostId, ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags,
|
||||
String allocationState, boolean forRebalance);
|
||||
boolean forRebalance);
|
||||
|
||||
public Host addHost(long zoneId, ServerResource resource, Type hostType, Map<String, String> hostDetails);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ import com.cloud.ha.HighAvailabilityManager;
|
|||
import com.cloud.ha.HighAvailabilityManager.WorkType;
|
||||
import com.cloud.host.DetailVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.HostAllocationState;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
|
|
@ -419,7 +418,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
break;
|
||||
}
|
||||
|
||||
HostVO host = (HostVO)createHostAndAgent(resource, entry.getValue(), true, null, null, false);
|
||||
HostVO host = (HostVO)createHostAndAgent(resource, entry.getValue(), true, null, false);
|
||||
if (host != null) {
|
||||
hosts.add(host);
|
||||
}
|
||||
|
|
@ -483,23 +482,18 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
}
|
||||
}
|
||||
|
||||
String allocationState = cmd.getAllocationState();
|
||||
if (allocationState == null) {
|
||||
allocationState = Host.HostAllocationState.Enabled.toString();
|
||||
}
|
||||
|
||||
return discoverHostsFull(dcId, podId, clusterId, clusterName, url, username, password, cmd.getHypervisor(), hostTags, cmd.getFullUrlParams(), allocationState);
|
||||
return discoverHostsFull(dcId, podId, clusterId, clusterName, url, username, password, cmd.getHypervisor(), hostTags, cmd.getFullUrlParams());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Host> discoverHosts(AddSecondaryStorageCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException {
|
||||
Long dcId = cmd.getZoneId();
|
||||
String url = cmd.getUrl();
|
||||
return discoverHostsFull(dcId, null, null, null, url, null, null, "SecondaryStorage", null, null, null);
|
||||
return discoverHostsFull(dcId, null, null, null, url, null, null, "SecondaryStorage", null, null);
|
||||
}
|
||||
|
||||
private List<HostVO> discoverHostsFull(Long dcId, Long podId, Long clusterId, String clusterName, String url, String username, String password, String hypervisorType, List<String> hostTags,
|
||||
Map<String, String> params, String allocationState) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException {
|
||||
Map<String, String> params) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException {
|
||||
URI uri = null;
|
||||
|
||||
// Check if the zone exists in the system
|
||||
|
|
@ -641,7 +635,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
return null;
|
||||
}
|
||||
|
||||
HostVO host = (HostVO)createHostAndAgent(resource, entry.getValue(), true, hostTags, allocationState, false);
|
||||
HostVO host = (HostVO)createHostAndAgent(resource, entry.getValue(), true, hostTags, false);
|
||||
if (host != null) {
|
||||
hosts.add(host);
|
||||
}
|
||||
|
|
@ -1100,6 +1094,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
_hostDetailsDao.persist(hostId, hostDetails);
|
||||
}
|
||||
|
||||
/*
|
||||
String allocationState = cmd.getAllocationState();
|
||||
if (allocationState != null) {
|
||||
// Verify that the host exists
|
||||
|
|
@ -1123,6 +1118,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
|
||||
_hostDao.update(hostId, host);
|
||||
}
|
||||
*/
|
||||
|
||||
List<String> hostTags = cmd.getHostTags();
|
||||
if (hostTags != null) {
|
||||
|
|
@ -1412,7 +1408,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
return host;
|
||||
}
|
||||
|
||||
private Host createHostAndAgent(ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags, String allocationState,
|
||||
private Host createHostAndAgent(ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags,
|
||||
boolean forRebalance) {
|
||||
HostVO host = null;
|
||||
AgentAttache attache = null;
|
||||
|
|
@ -1467,10 +1463,9 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
}
|
||||
|
||||
@Override
|
||||
public Host createHostAndAgent(Long hostId, ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags,
|
||||
String allocationState, boolean forRebalance) {
|
||||
public Host createHostAndAgent(Long hostId, ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags, boolean forRebalance) {
|
||||
_agentMgr.tapLoadingAgents(hostId, TapAgentsAction.Add);
|
||||
Host host = createHostAndAgent(resource, details, old, hostTags, allocationState, forRebalance);
|
||||
Host host = createHostAndAgent(resource, details, old, hostTags, forRebalance);
|
||||
_agentMgr.tapLoadingAgents(hostId, TapAgentsAction.Del);
|
||||
return host;
|
||||
}
|
||||
|
|
@ -1491,7 +1486,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
}
|
||||
}
|
||||
|
||||
return createHostAndAgent(resource, hostDetails, true, null, null, false);
|
||||
return createHostAndAgent(resource, hostDetails, true, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1719,7 +1714,6 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
}
|
||||
|
||||
resourceStateTransitTo(host, ResourceState.Event.Unmanaged, _nodeId);
|
||||
_agentMgr.disconnectWithoutInvestigation(hostId, Status.Event.AgentDisconnected);
|
||||
return true;
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Cannot transmit host " + hostId + "to Enabled state", e);
|
||||
|
|
|
|||
Loading…
Reference in New Issue