@Override public boolean evaluate(Host obj) { if (!host.getState().equals(HostConstants.STATE_PROVISIONING)) { throw new ResourceTimeoutException(host, "provisioning canceled"); } return obj.getAgentId() != null; }
private boolean isAgentDisconnected(Host host) { if (host == null) { return false; } Agent agent = context.objectManager.loadResource(Agent.class, host.getAgentId()); if (agent != null && (AgentConstants.STATE_RECONNECTING.equals(agent.getState()) || AgentConstants.STATE_DISCONNECTED.equals(agent.getState()) || AgentConstants.STATE_DISCONNECTING .equals(agent.getState()))) { return true; } return false; }
if (host == null || host.getAgentId() == null) { log.error("Failed to find host to delegate to for agent [{}] uri [{}]", agent.getId(), agent.getUri()); return null; outInstanceData.putAll(instanceData); return objectManager.loadResource(Agent.class, host.getAgentId());
if (physicalHostId.equals(host.getPhysicalHostId()) && host.getAgentId() == null) { PhysicalHost physicalHost = objectManager.loadResource(PhysicalHost.class, physicalHostId);
List<StatsAccess> serviceStatsQuery = new ArrayList<>(); for (Host host : hosts) { Agent agent = objectManager.loadResource(Agent.class, host.getAgentId()); if (agent == null || !CommonStatesConstants.ACTIVE.equals(agent.getState())) { continue;
protected void handleReconnecting(ProcessState state, Instance instance) { boolean reconnecting = false; InstanceHealthCheck healthCheck = DataAccessor.field(instance, InstanceConstants.FIELD_HEALTH_CHECK, jsonMapper, InstanceHealthCheck.class); for (InstanceHostMap map : mapDao.findNonRemoved(InstanceHostMap.class, Instance.class, instance.getId())) { Host host = objectManager.loadResource(Host.class, map.getHostId()); Agent agent = host == null ? null : objectManager.loadResource(Agent.class, host.getAgentId()); if (agent != null && (AgentConstants.STATE_RECONNECTING.equals(agent.getState()) || AgentConstants.STATE_DISCONNECTED.equals(agent.getState()))) { reconnecting = true; } else { reconnecting = false; break; } } if (reconnecting && (healthCheck != null || instance.getFirstRunning() == null)) { getObjectProcessManager().scheduleProcessInstance(InstanceConstants.PROCESS_STOP, instance, CollectionUtils.asMap(InstanceConstants.REMOVE_OPTION, true)); } }
Agent agent = objectManager.loadResource(Agent.class, host.getAgentId()); if (agent == null || !CommonStatesConstants.ACTIVE.equals(agent.getState())) { throw new ClientVisibleException(ResponseCodes.SERVICE_UNAVAILABLE);
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { // event's account id is set to the agent that submitted. This will // change it to the actual user's account id. // Checks to make sure agent's resource account id and the host's // account id match ContainerEvent event = (ContainerEvent)state.getResource(); Agent agent = objectManager.findAny(Agent.class, AGENT.ACCOUNT_ID, event.getAccountId()); Long resourceAccId = null; Host host = objectManager.loadResource(Host.class, event.getHostId()); if ( agent != null ) { resourceAccId = DataAccessor.fromDataFieldOf(agent) .withKey(AgentConstants.DATA_AGENT_RESOURCES_ACCOUNT_ID).as(Long.class); } else if ( event.getAccountId().equals(host.getAccountId()) ){ resourceAccId = event.getAccountId(); } if ( host.getAccountId().equals(resourceAccId) ) { Map<Object, Object> newFields = new HashMap<Object, Object>(); newFields.put(CONTAINER_EVENT.ACCOUNT_ID, host.getAccountId()); DataAccessor.fromMap(state.getData()).withScope(ContainerEventCreate.class).withKey(AGENT_ID).set(host.getAgentId()); return new HandlerResult(newFields); } return null; }
setComputeFree(from.getComputeFree()); setComputeTotal(from.getComputeTotal()); setAgentId(from.getAgentId()); setZoneId(from.getZoneId()); setPhysicalHostId(from.getPhysicalHostId());