use of com.cloud.legacymodel.resource.ResourceState in project cosmic by MissionCriticalCloud.
the class ResourceManagerImpl method resourceStateTransitTo.
@Override
public boolean resourceStateTransitTo(final Host host, final ResourceState.Event event, final long msId) throws NoTransitionException {
final ResourceState currentState = host.getResourceState();
final ResourceState nextState = currentState.getNextState(event);
if (nextState == null) {
throw new NoTransitionException("No next resource state found for current state = " + currentState + " event = " + event);
}
// TO DO - Make it more granular and have better conversion into capacity type
if (host.getType() == HostType.Routing) {
final CapacityState capacityState = nextState == ResourceState.Enabled ? CapacityState.Enabled : CapacityState.Disabled;
final short[] capacityTypes = { Capacity.CAPACITY_TYPE_CPU, Capacity.CAPACITY_TYPE_MEMORY };
this._capacityDao.updateCapacityState(null, null, null, host.getId(), capacityState.toString(), capacityTypes);
}
return this._hostDao.updateResourceState(currentState, event, nextState, host);
}
use of com.cloud.legacymodel.resource.ResourceState in project cosmic by MissionCriticalCloud.
the class AgentManagerImpl method agentStatusTransitTo.
@Override
public boolean agentStatusTransitTo(final HostVO host, final Event e, final long msId) {
try {
this._agentStatusLock.lock();
if (status_logger.isDebugEnabled()) {
final ResourceState state = host.getResourceState();
final 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(", name = " + host.getName()).append("]");
status_logger.debug(msg.toString());
}
host.setManagementServerId(msId);
try {
return new StateMachine2Transitions(this._statusStateMachine).transitTo(host, e, host.getId(), this._hostDao);
} catch (final NoTransitionException e1) {
status_logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", name=" + host.getName() + ", 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());
}
} finally {
this._agentStatusLock.unlock();
}
}
Aggregations