Java Code Examples for org.apache.flink.runtime.iterative.concurrent.SuperstepKickoffLatch

The following examples show how to use org.apache.flink.runtime.iterative.concurrent.SuperstepKickoffLatch. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Flink-CEPplus   Source File: IterationIntermediateTask.java    License: Apache License 2.0 4 votes vote down vote up
@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 {
			incrementIterationCounter();
		}
	}
}
 
Example 2
Source Project: Flink-CEPplus   Source File: IterationTailTask.java    License: Apache License 2.0 4 votes vote down vote up
@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();
		}
	}
}
 
Example 3
Source Project: flink   Source File: IterationIntermediateTask.java    License: Apache License 2.0 4 votes vote down vote up
@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 {
			incrementIterationCounter();
		}
	}
}
 
Example 4
Source Project: flink   Source File: IterationTailTask.java    License: Apache License 2.0 4 votes vote down vote up
@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();
		}
	}
}
 
Example 5
Source Project: flink   Source File: IterationIntermediateTask.java    License: Apache License 2.0 4 votes vote down vote up
@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 {
			incrementIterationCounter();
		}
	}
}
 
Example 6
Source Project: flink   Source File: IterationTailTask.java    License: Apache License 2.0 4 votes vote down vote up
@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();
		}
	}
}