Examples of SuperstepKickoffLatch


Examples of org.apache.flink.runtime.iterative.concurrent.SuperstepKickoffLatch

  }

  @Override
  public void run() throws Exception {
   
    SuperstepKickoffLatch nextSuperstepLatch = SuperstepKickoffLatchBroker.instance().get(brokerKey());

    while (this.running && !terminationRequested()) {

      if (log.isInfoEnabled()) {
        log.info(formatLogString("starting iteration [" + currentIteration() + "]"));
      }

      super.run();

      // check if termination was requested
      verifyEndOfSuperstepState();

      if (isWorksetUpdate && isWorksetIteration) {
        long numCollected = worksetUpdateOutputCollector.getElementsCollectedAndReset();
        worksetAggregator.aggregate(numCollected);
      }
     
      if (log.isInfoEnabled()) {
        log.info(formatLogString("finishing iteration [" + currentIteration() + "]"));
      }
     
      // let the successors know that the end of this superstep data is reached
      sendEndOfSuperstep();
     
      if (isWorksetUpdate) {
        // notify iteration head if responsible for workset update
        worksetBackChannel.notifyOfEndOfSuperstep();
      }
     
      boolean terminated = nextSuperstepLatch.awaitStartOfSuperstepOrTermination(currentIteration() + 1);

      if (terminated) {
        requestTermination();
      }
      else {
View Full Code Here

Examples of org.apache.flink.runtime.iterative.concurrent.SuperstepKickoffLatch

    boolean waitForSolutionSetUpdate = config.getWaitForSolutionSetUpdate();
    boolean isWorksetIteration = config.getIsWorksetIteration();

    try {
      /* used for receiving the current iteration result from iteration tail */
      SuperstepKickoffLatch nextStepKickoff = new SuperstepKickoffLatch();
      SuperstepKickoffLatchBroker.instance().handIn(brokerKey, nextStepKickoff);
     
      BlockingBackChannel backChannel = initBackChannel();
      SuperstepBarrier barrier = initSuperstepBarrier();
      SolutionSetUpdateBarrier solutionSetUpdateBarrier = null;

      feedbackDataInput = config.getIterationHeadPartialSolutionOrWorksetInputIndex();
      feedbackTypeSerializer = this.<Y>getInputSerializer(feedbackDataInput);
      excludeFromReset(feedbackDataInput);

      if (isWorksetIteration) {
        initialSolutionSetInput = config.getIterationHeadSolutionSetInputIndex();
        TypeSerializerFactory<X> solutionTypeSerializerFactory = config
            .getSolutionSetSerializer(getUserCodeClassLoader());
        solutionTypeSerializer = solutionTypeSerializerFactory;

        // setup the index for the solution set
        @SuppressWarnings("unchecked")
        MutableObjectIterator<X> solutionSetInput = (MutableObjectIterator<X>) createInputIterator(inputReaders[initialSolutionSetInput], solutionTypeSerializer);
       
        // read the initial solution set
        if (objectSolutionSet) {
          solutionSetObjectMap = initJoinHashMap();
          readInitialSolutionSet(solutionSetObjectMap, solutionSetInput);
          SolutionSetBroker.instance().handIn(brokerKey, solutionSetObjectMap);
        } else {
          solutionSet = initCompactingHashTable();
          readInitialSolutionSet(solutionSet, solutionSetInput);
          SolutionSetBroker.instance().handIn(brokerKey, solutionSet);
        }

        if (waitForSolutionSetUpdate) {
          solutionSetUpdateBarrier = new SolutionSetUpdateBarrier();
          SolutionSetUpdateBarrierBroker.instance().handIn(brokerKey, solutionSetUpdateBarrier);
        }
      } else {
        // bulk iteration case
        initialSolutionSetInput = -1;

        @SuppressWarnings("unchecked")
        TypeSerializerFactory<X> solSer = (TypeSerializerFactory<X>) feedbackTypeSerializer;
        solutionTypeSerializer = solSer;
       
        // = termination Criterion tail
        if (waitForSolutionSetUpdate) {
          solutionSetUpdateBarrier = new SolutionSetUpdateBarrier();
          SolutionSetUpdateBarrierBroker.instance().handIn(brokerKey, solutionSetUpdateBarrier);
        }
      }

      // instantiate all aggregators and register them at the iteration global registry
      aggregatorRegistry = new RuntimeAggregatorRegistry(config.getIterationAggregators
          (getUserCodeClassLoader()));
      IterationAggregatorBroker.instance().handIn(brokerKey, aggregatorRegistry);

      DataInputView superstepResult = null;

      while (this.running && !terminationRequested()) {

        if (log.isInfoEnabled()) {
          log.info(formatLogString("starting iteration [" + currentIteration() + "]"));
        }

        barrier.setup();

        if (waitForSolutionSetUpdate) {
          solutionSetUpdateBarrier.setup();
        }

        if (!inFirstIteration()) {
          feedBackSuperstepResult(superstepResult);
        }

        super.run();

        // signal to connected tasks that we are done with the superstep
        sendEndOfSuperstepToAllIterationOutputs();

        if (waitForSolutionSetUpdate) {
          solutionSetUpdateBarrier.waitForSolutionSetUpdate();
        }

        // blocking call to wait for the result
        superstepResult = backChannel.getReadEndAfterSuperstepEnded();
        if (log.isInfoEnabled()) {
          log.info(formatLogString("finishing iteration [" + currentIteration() + "]"));
        }

        sendEventToSync(new WorkerDoneEvent(workerIndex, aggregatorRegistry.getAllAggregators()));

        if (log.isInfoEnabled()) {
          log.info(formatLogString("waiting for other workers in iteration [" + currentIteration() + "]"));
        }

        barrier.waitForOtherWorkers();

        if (barrier.terminationSignaled()) {
          if (log.isInfoEnabled()) {
            log.info(formatLogString("head received termination request in iteration ["
              + currentIteration()
              + "]"));
          }
          requestTermination();
          nextStepKickoff.signalTermination();
        } else {
          incrementIterationCounter();

          String[] globalAggregateNames = barrier.getAggregatorNames();
          Value[] globalAggregates = barrier.getAggregates();
          aggregatorRegistry.updateGlobalAggregatesAndReset(globalAggregateNames, globalAggregates);
         
          nextStepKickoff.triggerNextSuperstep();
        }
      }

      if (log.isInfoEnabled()) {
        log.info(formatLogString("streaming out final result after [" + currentIteration() + "] iterations"));
View Full Code Here

Examples of org.apache.flink.runtime.iterative.concurrent.SuperstepKickoffLatch

  }

  @Override
  public void run() throws Exception {
   
    SuperstepKickoffLatch nextSuperStepLatch = SuperstepKickoffLatchBroker.instance().get(brokerKey());
   
    while (this.running && !terminationRequested()) {

      if (log.isInfoEnabled()) {
        log.info(formatLogString("starting iteration [" + currentIteration() + "]"));
      }

      super.run();

      // check if termination was requested
      verifyEndOfSuperstepState();

      if (isWorksetUpdate && isWorksetIteration) {
        // aggregate workset update element count
        long numCollected = worksetUpdateOutputCollector.getElementsCollectedAndReset();
        worksetAggregator.aggregate(numCollected);

      }

      if (log.isInfoEnabled()) {
        log.info(formatLogString("finishing iteration [" + currentIteration() + "]"));
      }
     
      if (isWorksetUpdate) {
        // notify iteration head if responsible for workset update
        worksetBackChannel.notifyOfEndOfSuperstep();
      } else if (isSolutionSetUpdate) {
        // notify iteration head if responsible for solution set update
        solutionSetUpdateBarrier.notifySolutionSetUpdate();
      }

      boolean terminate = nextSuperStepLatch.awaitStartOfSuperstepOrTermination(currentIteration() + 1);
      if (terminate) {
        requestTermination();
      }
      else {
        incrementIterationCounter();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.