public synchronized boolean transitionToSchedulingSplits() { return stageState.setIf(SCHEDULING_SPLITS, currentState -> currentState == PLANNED || currentState == SCHEDULING); }
public synchronized boolean transitionToScheduled() { schedulingComplete.compareAndSet(null, DateTime.now()); return stageState.setIf(SCHEDULED, currentState -> currentState == PLANNED || currentState == SCHEDULING || currentState == SCHEDULING_SPLITS); }
public boolean transitionToAborted() { return stageState.setIf(ABORTED, currentState -> !currentState.isDone()); }
public boolean transitionToRunning() { return stageState.setIf(RUNNING, currentState -> currentState != RUNNING && !currentState.isDone()); }
public boolean transitionToFinished() { return stageState.setIf(FINISHED, currentState -> !currentState.isDone()); }
public boolean transitionToCanceled() { return stageState.setIf(CANCELED, currentState -> !currentState.isDone()); }
private void transitionToDoneState(TaskState doneState) { requireNonNull(doneState, "doneState is null"); checkArgument(doneState.isDone(), "doneState %s is not a done state", doneState); taskState.setIf(doneState, currentState -> !currentState.isDone()); }
@Override public void destroy() { // ignore destroy if the buffer already in a terminal state. if (state.setIf(FINISHED, oldState -> !oldState.isTerminal())) { partitions.forEach(ClientBuffer::destroy); memoryManager.setNoBlockOnFull(); forceFreeMemory(); } }
@Override public void fail() { OutputBuffer outputBuffer; synchronized (this) { if (delegate == null) { // ignore fail if the buffer already in a terminal state. state.setIf(FAILED, state -> !state.isTerminal()); // Do not free readers on fail return; } outputBuffer = delegate; } outputBuffer.fail(); }
@Override public void destroy() { checkState(!Thread.holdsLock(this), "Can not destroy while holding a lock on this"); // ignore destroy if the buffer already in a terminal state. if (state.setIf(FINISHED, oldState -> !oldState.isTerminal())) { noMoreBuffers(); safeGetBuffersSnapshot().forEach(ClientBuffer::destroy); memoryManager.setNoBlockOnFull(); forceFreeMemory(); } }
public boolean transitionToFailed(Throwable throwable) { requireNonNull(throwable, "throwable is null"); failureCause.compareAndSet(null, Failures.toFailure(throwable)); boolean failed = stageState.setIf(FAILED, currentState -> !currentState.isDone()); if (failed) { log.error(throwable, "Stage %s failed", stageId); } else { log.debug(throwable, "Failure after stage %s finished", stageId); } return failed; }
@Override public void fail() { // ignore fail if the buffer already in a terminal state. if (state.setIf(FAILED, oldState -> !oldState.isTerminal())) { memoryManager.setNoBlockOnFull(); forceFreeMemory(); // DO NOT destroy buffers or set no more pages. The coordinator manages the teardown of failed queries. } }
public boolean transitionToWaitingForResources() { queryStateTimer.beginWaitingForResources(); return queryState.setIf(WAITING_FOR_RESOURCES, currentState -> currentState.ordinal() < WAITING_FOR_RESOURCES.ordinal()); }
public boolean transitionToStarting() { queryStateTimer.beginStarting(); return queryState.setIf(STARTING, currentState -> currentState.ordinal() < STARTING.ordinal()); }
public boolean transitionToRunning() { queryStateTimer.beginRunning(); return queryState.setIf(RUNNING, currentState -> currentState.ordinal() < RUNNING.ordinal()); }
@Override public void fail() { // ignore fail if the buffer already in a terminal state. if (state.setIf(FAILED, oldState -> !oldState.isTerminal())) { memoryManager.setNoBlockOnFull(); forceFreeMemory(); // DO NOT destroy buffers or set no more pages. The coordinator manages the teardown of failed queries. } }
public boolean transitionToPlanning() { queryStateTimer.beginPlanning(); return queryState.setIf(PLANNING, currentState -> currentState.ordinal() < PLANNING.ordinal()); }
private void transitionToFinished() { cleanupQueryQuietly(); queryStateTimer.endQuery(); queryState.setIf(FINISHED, currentState -> !currentState.isDone()); }
@Override public void fail() { // ignore fail if the buffer already in a terminal state. if (state.setIf(FAILED, oldState -> !oldState.isTerminal())) { memoryManager.setNoBlockOnFull(); forceFreeMemory(); // DO NOT destroy buffers or set no more pages. The coordinator manages the teardown of failed queries. } }
@Override public void destroy() { checkState(!Thread.holdsLock(this), "Can not destroy while holding a lock on this"); // ignore destroy if the buffer already in a terminal state. if (state.setIf(FINISHED, oldState -> !oldState.isTerminal())) { noMoreBuffers(); masterBuffer.destroy(); safeGetBuffersSnapshot().forEach(ClientBuffer::destroy); memoryManager.setNoBlockOnFull(); forceFreeMemory(); } }