@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { Object resource = state.getResource(); Long agentId = AgentLocatorImpl.getAgentId(resource); Agent agent = objectManager.loadResource(Agent.class, agentId); if (agent == null || agent.getRemoved() != null) { return null; } try { objectProcessManager.scheduleStandardProcess(StandardProcess.DEACTIVATE, agent, ProcessUtils.chainInData(state.getData(), AgentConstants.PROCESS_DEACTIVATE, AgentConstants.PROCESS_REMOVE)); } catch (ProcessCancelException e) { objectProcessManager.scheduleStandardProcess(StandardProcess.REMOVE, agent, state.getData()); } return null; } }
@Override public <T extends Event> T callSync(Event event, Class<T> reply, EventCallOptions options) { /* * NOTE: Forever blocking get() used only because underlying future will * always timeout */ try { return AsyncUtils.get(call(event, reply, options)); } catch (TimeoutException e) { Agent agent = objectManager.loadResource(Agent.class, agentId); if (agent == null || agent.getRemoved() != null) { throw new AgentRemovedException("Agent [" + agentId + "] is removed", event); } throw e; } catch (AgentRemovedException e) { throw e; } catch (EventExecutionException e) { /* * This is done so that the exception will have a better stack * trace. Normally the exceptions from a future will have a pretty * sparse stack not giving too much context */ throw EventExecutionException.fromEvent(e.getEvent()); } }
/** * {@inheritDoc} */ @Override public void from(io.cattle.platform.core.model.Agent from) { setId(from.getId()); setName(from.getName()); setAccountId(from.getAccountId()); setKind(from.getKind()); setUuid(from.getUuid()); setDescription(from.getDescription()); setState(from.getState()); setCreated(from.getCreated()); setRemoved(from.getRemoved()); setRemoveTime(from.getRemoveTime()); setData(from.getData()); setUri(from.getUri()); setManagedConfig(from.getManagedConfig()); setZoneId(from.getZoneId()); setExternalId(from.getExternalId()); }
if (agent.getRemoved() != null) { continue;