Example #1
0
  private void subtaskInFinalState(int subtask) {
    synchronized (stateMonitor) {
      if (!finishedSubtasks[subtask]) {
        finishedSubtasks[subtask] = true;

        if (numSubtasksInFinalState + 1 == parallelism) {

          // call finalizeOnMaster hook
          try {
            getJobVertex().finalizeOnMaster(getGraph().getUserClassLoader());
          } catch (Throwable t) {
            getGraph().fail(t);
          }

          numSubtasksInFinalState++;

          // we are in our final state
          stateMonitor.notifyAll();

          // tell the graph
          graph.jobVertexInFinalState();
        } else {
          numSubtasksInFinalState++;
        }
      }
    }
  }
Example #2
0
 public void waitForAllVerticesToReachFinishingState() throws InterruptedException {
   synchronized (stateMonitor) {
     while (numSubtasksInFinalState < parallelism) {
       stateMonitor.wait();
     }
   }
 }