/** * Notification that a state transition failed. * * @param state the failed transition */ synchronized void transitionFailed(final InternalState state) { final InternalState current = this.internalState; if(state == current) { // Revert transition and mark as failed switch (current) { case PROCESS_ADDING: this.internalState = InternalState.PROCESS_STOPPED; break; case PROCESS_STARTED: internalSetState(getTransitionTask(InternalState.PROCESS_STOPPING), InternalState.PROCESS_STARTED, InternalState.PROCESS_ADDED); break; case PROCESS_STARTING: this.internalState = InternalState.PROCESS_ADDED; break; case SEND_STDIN: case SERVER_STARTING: this.internalState = InternalState.PROCESS_STARTED; break; } this.requiredState = InternalState.FAILED; notifyAll(); } }
/** * Notification that a state transition failed. * * @param state the failed transition */ synchronized void transitionFailed(final InternalState state) { final InternalState current = this.internalState; if(state == current) { // Revert transition and mark as failed switch (current) { case PROCESS_ADDING: this.internalState = InternalState.PROCESS_STOPPED; break; case PROCESS_STARTED: internalSetState(getTransitionTask(InternalState.PROCESS_STOPPING), InternalState.PROCESS_STARTED, InternalState.PROCESS_ADDED); break; case PROCESS_STARTING: this.internalState = InternalState.PROCESS_ADDED; break; case SEND_STDIN: case SERVER_STARTING: this.internalState = InternalState.PROCESS_STARTED; break; } this.requiredState = InternalState.FAILED; notifyAll(); } }
/** * Finish a state transition from a notification. * * @param current * @param next */ private synchronized void finishTransition(final InternalState current, final InternalState next) { internalSetState(getTransitionTask(next), current, next); transition(); }
/** * Finish a state transition from a notification. * * @param current * @param next */ private synchronized void finishTransition(final InternalState current, final InternalState next) { internalSetState(getTransitionTask(next), current, next); transition(); }
/** * Notification that a state transition failed. * * @param state the failed transition */ synchronized void transitionFailed(final InternalState state) { final InternalState current = this.internalState; if(state == current) { // Revert transition and mark as failed switch (current) { case PROCESS_ADDING: this.internalState = InternalState.PROCESS_STOPPED; break; case PROCESS_STARTED: internalSetState(getTransitionTask(InternalState.PROCESS_STOPPING), InternalState.PROCESS_STARTED, InternalState.PROCESS_ADDED); break; case PROCESS_STARTING: this.internalState = InternalState.PROCESS_ADDED; break; case SEND_STDIN: case SERVER_STARTING: this.internalState = InternalState.PROCESS_STARTED; break; } this.requiredState = InternalState.FAILED; notifyAll(); } }
/** * Finish a state transition from a notification. * * @param current * @param next */ private synchronized void finishTransition(final InternalState current, final InternalState next) { internalSetState(getTransitionTask(next), current, next); transition(); }
/** * Notification that the server process finished. */ synchronized void processFinished() { final InternalState required = this.requiredState; final InternalState state = this.internalState; // If the server was not stopped if(required == InternalState.STOPPED && state == InternalState.PROCESS_STOPPING) { finishTransition(InternalState.PROCESS_STOPPING, InternalState.PROCESS_STOPPED); } else { this.requiredState = InternalState.STOPPED; if ( !(internalSetState(getTransitionTask(InternalState.PROCESS_STOPPING), internalState, InternalState.PROCESS_STOPPING) && internalSetState(getTransitionTask(InternalState.PROCESS_REMOVING), internalState, InternalState.PROCESS_REMOVING) && internalSetState(getTransitionTask(InternalState.STOPPED), internalState, InternalState.STOPPED)) ){ this.requiredState = InternalState.FAILED; internalSetState(null, internalState, InternalState.PROCESS_STOPPED); } } }
/** * Notification that the server process finished. */ synchronized void processFinished() { final InternalState required = this.requiredState; final InternalState state = this.internalState; // If the server was not stopped if(required == InternalState.STOPPED && state == InternalState.PROCESS_STOPPING) { finishTransition(InternalState.PROCESS_STOPPING, InternalState.PROCESS_STOPPED); } else { this.requiredState = InternalState.STOPPED; if ( !(internalSetState(getTransitionTask(InternalState.PROCESS_STOPPING), internalState, InternalState.PROCESS_STOPPING) && internalSetState(getTransitionTask(InternalState.PROCESS_REMOVING), internalState, InternalState.PROCESS_REMOVING) && internalSetState(getTransitionTask(InternalState.STOPPED), internalState, InternalState.STOPPED)) ){ this.requiredState = InternalState.FAILED; internalSetState(null, internalState, InternalState.PROCESS_STOPPED); } } }
private synchronized void transition(boolean checkAsync) { final InternalState required = this.requiredState; final InternalState current = this.internalState; // Check if we are waiting for a notification from the server if(checkAsync && current.isAsync()) { return; } final InternalState next = nextState(current, required); if (next != null) { final TransitionTask task = getTransitionTask(next); internalSetState(task, current, next); } }
private synchronized void transition(boolean checkAsync) { final InternalState required = this.requiredState; final InternalState current = this.internalState; // Check if we are waiting for a notification from the server if(checkAsync && current.isAsync()) { return; } final InternalState next = nextState(current, required); if (next != null) { final TransitionTask task = getTransitionTask(next); internalSetState(task, current, next); } }
private synchronized void transition(boolean checkAsync) { final InternalState required = this.requiredState; final InternalState current = this.internalState; // Check if we are waiting for a notification from the server if(checkAsync && current.isAsync()) { return; } final InternalState next = nextState(current, required); if(next != null) { final TransitionTask task = getTransitionTask(next); internalSetState(task, current, next); } }