/** * @return a builder of StateMachine */ public static Builder newBuilder() { return new Builder(); }
/** * Static initializer of the Pair class. * @param left left element. * @param right right element. * @param <A> Type of the left element. * @param <B> Type of the right element. * @return the newly created Pair. */ public static <A, B> Pair<A, B> of(final A left, final B right) { return new Pair<>(left, right); } }
/** * @param rangeStartInclusive the start of the range (inclusive) * @param rangeEndExclusive the end of the range (exclusive) * @param isSkewed whether or not the range is skewed * @return A hash range descriptor representing [{@code rangeBeginInclusive}, {@code rangeEndExclusive}) */ public static HashRange of(final int rangeStartInclusive, final int rangeEndExclusive, final boolean isSkewed) { return new HashRange(rangeStartInclusive, rangeEndExclusive, isSkewed); }
private StateMachine buildBlockStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.IN_PROGRESS, "The block is in the progress of being created."); stateMachineBuilder.addState(State.AVAILABLE, "The block is available."); stateMachineBuilder.addState(State.NOT_AVAILABLE, "The block is not available."); // From IN_PROGRESS stateMachineBuilder.addTransition(State.IN_PROGRESS, State.AVAILABLE, "The block is successfully created"); stateMachineBuilder.addTransition(State.IN_PROGRESS, State.NOT_AVAILABLE, "The block is lost before being created"); // From AVAILABLE stateMachineBuilder.addTransition(State.AVAILABLE, State.NOT_AVAILABLE, "The block is not available"); stateMachineBuilder.setInitialState(State.IN_PROGRESS); return stateMachineBuilder.build(); }
@Override public String toString() { return stateMachine.getCurrentState().toString(); } }
/** * @return whether this hash range descriptor represents the whole data or not. */ @Override public boolean isAll() { return this.equals(ALL); }
/** * {@inheritDoc} * This method should be overridden for a readable representation of KeyRange. * The generic type K should override {@link Object}'s toString() as well. */ @Override public String toString() { return String.format("[%d, %d)", rangeBeginInclusive, rangeEndExclusive()); }
private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.INCOMPLETE, "Some tasks in this stage are not complete."); stateMachineBuilder.addState(State.COMPLETE, "All of this stage's tasks have completed."); // Add transitions stateMachineBuilder.addTransition( State.INCOMPLETE, State.INCOMPLETE, "A task in the stage needs to be retried"); stateMachineBuilder.addTransition(State.INCOMPLETE, State.COMPLETE, "All tasks complete"); stateMachineBuilder.addTransition(State.COMPLETE, State.INCOMPLETE, "Completed before, but a task in this stage should be retried"); stateMachineBuilder.addTransition(State.COMPLETE, State.COMPLETE, "Completed before, but probably a cloned task has completed again"); stateMachineBuilder.setInitialState(State.INCOMPLETE); return stateMachineBuilder.build(); }
@Override public String toString() { return stateMachine.getCurrentState().toString(); } }
/** * @return a builder of StateMachine */ public static Builder newBuilder() { return new Builder(); }
/** * Static initializer of the Pair class. * @param left left element. * @param right right element. * @param <A> Type of the left element. * @param <B> Type of the right element. * @return the newly created Pair. */ public static <A, B> Pair<A, B> of(final A left, final B right) { return new Pair<>(left, right); } }
/** * @param rangeStartInclusive the start of the range (inclusive) * @param rangeEndExclusive the end of the range (exclusive) * @param isSkewed whether or not the range is skewed * @return A hash range descriptor representing [{@code rangeBeginInclusive}, {@code rangeEndExclusive}) */ public static HashRange of(final int rangeStartInclusive, final int rangeEndExclusive, final boolean isSkewed) { return new HashRange(rangeStartInclusive, rangeEndExclusive, isSkewed); }
/** * @return whether this hash range descriptor represents the whole data or not. */ @Override public boolean isAll() { return this.equals(ALL); }
private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.INCOMPLETE, "Some tasks in this stage are not complete."); stateMachineBuilder.addState(State.COMPLETE, "All of this stage's tasks have completed."); // Add transitions stateMachineBuilder.addTransition( State.INCOMPLETE, State.INCOMPLETE, "A task in the stage needs to be retried"); stateMachineBuilder.addTransition(State.INCOMPLETE, State.COMPLETE, "All tasks complete"); stateMachineBuilder.addTransition(State.COMPLETE, State.INCOMPLETE, "Completed before, but a task in this stage should be retried"); stateMachineBuilder.addTransition(State.COMPLETE, State.COMPLETE, "Completed before, but probably a cloned task has completed again"); stateMachineBuilder.setInitialState(State.INCOMPLETE); return stateMachineBuilder.build(); }
/** * @return the state of this block. */ BlockState.State getBlockState() { return (BlockState.State) blockState.getStateMachine().getCurrentState(); }
private StateMachine buildBlockStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.IN_PROGRESS, "The block is in the progress of being created."); stateMachineBuilder.addState(State.AVAILABLE, "The block is available."); stateMachineBuilder.addState(State.NOT_AVAILABLE, "The block is not available."); // From IN_PROGRESS stateMachineBuilder.addTransition(State.IN_PROGRESS, State.AVAILABLE, "The block is successfully created"); stateMachineBuilder.addTransition(State.IN_PROGRESS, State.NOT_AVAILABLE, "The block is lost before being created"); // From AVAILABLE stateMachineBuilder.addTransition(State.AVAILABLE, State.NOT_AVAILABLE, "The block is not available"); stateMachineBuilder.setInitialState(State.IN_PROGRESS); return stateMachineBuilder.build(); }
/** * @return the state of the plan. */ public synchronized PlanState.State getPlanState() { return (PlanState.State) planState.getStateMachine().getCurrentState(); }
private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.READY, "The plan has been created and submitted to runtime."); stateMachineBuilder.addState(State.EXECUTING, "The plan is executing (with its stages executing)."); stateMachineBuilder.addState(State.COMPLETE, "The plan is complete."); stateMachineBuilder.addState(State.FAILED, "Plan failed."); // Add transitions stateMachineBuilder.addTransition(State.READY, State.EXECUTING, "Begin executing!"); stateMachineBuilder.addTransition(State.EXECUTING, State.COMPLETE, "All stages complete, plan complete"); stateMachineBuilder.addTransition(State.EXECUTING, State.FAILED, "Unrecoverable failure in a stage"); stateMachineBuilder.setInitialState(State.READY); return stateMachineBuilder.build(); }
/** * @return the state of this block. */ BlockState.State getBlockState() { return (BlockState.State) blockState.getStateMachine().getCurrentState(); }
private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.READY, "The plan has been created and submitted to runtime."); stateMachineBuilder.addState(State.EXECUTING, "The plan is executing (with its stages executing)."); stateMachineBuilder.addState(State.COMPLETE, "The plan is complete."); stateMachineBuilder.addState(State.FAILED, "Plan failed."); // Add transitions stateMachineBuilder.addTransition(State.READY, State.EXECUTING, "Begin executing!"); stateMachineBuilder.addTransition(State.EXECUTING, State.COMPLETE, "All stages complete, plan complete"); stateMachineBuilder.addTransition(State.EXECUTING, State.FAILED, "Unrecoverable failure in a stage"); stateMachineBuilder.setInitialState(State.READY); return stateMachineBuilder.build(); }