@Override protected HandlerResult preHandle(ProcessState state, ProcessInstance process) { for (Host host : objectManager.children(state.getResource(), Host.class)) { log.debug("Setting host [{}] agentState to [{}] on pre", host.getId(), state.getState()); setState(host, state.getState()); } return null; }
@Override protected HandlerResult postHandle(ProcessState state, ProcessInstance process) { Agent agent = (Agent)state.getResource(); String newState = transitioningToDone.get(state.getState()); if (newState == null) { return null; } for (Host host : objectManager.children(agent, Host.class)) { log.debug("Setting host [{}] agentState to [{}] on post", host.getId(), newState); setState(host, newState); } return null; }
protected void assertState(String previousState) { ProcessState state = instanceContext.getState(); state.reload(); String newState = state.getState(); if (!previousState.equals(newState)) { preRunStateCheck(); throw new ProcessExecutionExitException("Previous state [" + previousState + "] does not equal current state [" + newState + "]", STATE_CHANGED); } }
protected String setTransitioning() { ProcessState state = instanceContext.getState(); String previousState = state.getState(); String newState = state.setTransitioning(); log.debug("Changing state [{}->{}] on [{}:{}]", previousState, newState, record.getResourceType(), record.getResourceId()); execution.getTransitions().add(new ProcessStateTransition(previousState, newState, "transitioning", now())); publishChanged(previousState, newState, schedule); return newState; }
protected boolean setDone(String previousState) { boolean chained = false; final ProcessState state = instanceContext.getState(); assertState(previousState); if (chainProcess != null) { scheduleChain(chainProcess); chained = true; } String newState = chained ? state.getState() : state.setDone(); log.debug("Changing state [{}->{}] on [{}:{}]", previousState, newState, record.getResourceType(), record.getResourceId()); execution.getTransitions().add(new ProcessStateTransition(previousState, newState, chained ? "chain" : "done", now())); publishChanged(previousState, newState, schedule); return chained; }