private synchronized void checkTaskCompletion() { if (taskStateMachine.getState().isDone()) { return; } // are there more partition splits expected? if (partitionedDriverFactory != null && !partitionedDriverFactory.isNoMoreSplits()) { return; } // do we still have running tasks? if (remainingDrivers.get() != 0) { return; } // no more output will be created sharedBuffer.finish(); // are there still pages in the output buffer if (!sharedBuffer.isFinished()) { return; } // Cool! All done! taskStateMachine.finished(); }