Java Code Examples for org.apache.flink.runtime.io.network.api.CancelCheckpointMarker#getCheckpointId()

The following examples show how to use org.apache.flink.runtime.io.network.api.CancelCheckpointMarker#getCheckpointId() . 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 File: CheckpointBarrierUnaligner.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void processCancellationBarrier(CancelCheckpointMarker cancelBarrier) throws Exception {
	final long cancelledId = cancelBarrier.getCheckpointId();
	boolean shouldAbort = threadSafeUnaligner.setCancelledCheckpointId(cancelledId);
	if (shouldAbort) {
		notifyAbort(
			cancelledId,
			new CheckpointException(CheckpointFailureReason.CHECKPOINT_DECLINED_ON_CANCELLATION_BARRIER));
	}

	if (cancelledId >= currentConsumedCheckpointId) {
		resetPendingCheckpoint(cancelledId);
		currentConsumedCheckpointId = cancelledId;
	}
}
 
Example 2
Source File: BarrierBuffer.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private void processCancellationBarrier(CancelCheckpointMarker cancelBarrier) throws Exception {
	final long barrierId = cancelBarrier.getCheckpointId();

	// fast path for single channel cases
	if (totalNumberOfInputChannels == 1) {
		if (barrierId > currentCheckpointId) {
			// new checkpoint
			currentCheckpointId = barrierId;
			notifyAbortOnCancellationBarrier(barrierId);
		}
		return;
	}

	// -- general code path for multiple input channels --

	if (numBarriersReceived > 0) {
		// this is only true if some alignment is in progress and nothing was canceled

		if (barrierId == currentCheckpointId) {
			// cancel this alignment
			if (LOG.isDebugEnabled()) {
				LOG.debug("{}: Checkpoint {} canceled, aborting alignment.",
					inputGate.getOwningTaskName(),
					barrierId);
			}

			releaseBlocksAndResetBarriers();
			notifyAbortOnCancellationBarrier(barrierId);
		}
		else if (barrierId > currentCheckpointId) {
			// we canceled the next which also cancels the current
			LOG.warn("{}: Received cancellation barrier for checkpoint {} before completing current checkpoint {}. " +
					"Skipping current checkpoint.",
				inputGate.getOwningTaskName(),
				barrierId,
				currentCheckpointId);

			// this stops the current alignment
			releaseBlocksAndResetBarriers();

			// the next checkpoint starts as canceled
			currentCheckpointId = barrierId;
			startOfAlignmentTimestamp = 0L;
			latestAlignmentDurationNanos = 0L;

			notifyAbort(currentCheckpointId, new CheckpointDeclineSubsumedException(barrierId));

			notifyAbortOnCancellationBarrier(barrierId);
		}

		// else: ignore trailing (cancellation) barrier from an earlier checkpoint (obsolete now)

	}
	else if (barrierId > currentCheckpointId) {
		// first barrier of a new checkpoint is directly a cancellation

		// by setting the currentCheckpointId to this checkpoint while keeping the numBarriers
		// at zero means that no checkpoint barrier can start a new alignment
		currentCheckpointId = barrierId;

		startOfAlignmentTimestamp = 0L;
		latestAlignmentDurationNanos = 0L;

		if (LOG.isDebugEnabled()) {
			LOG.debug("{}: Checkpoint {} canceled, skipping alignment.",
				inputGate.getOwningTaskName(),
				barrierId);
		}

		notifyAbortOnCancellationBarrier(barrierId);
	}

	// else: trailing barrier from either
	//   - a previous (subsumed) checkpoint
	//   - the current checkpoint if it was already canceled
}
 
Example 3
Source File: BarrierTracker.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private void processCheckpointAbortBarrier(CancelCheckpointMarker barrier, int channelIndex) throws Exception {
	final long checkpointId = barrier.getCheckpointId();

	if (LOG.isDebugEnabled()) {
		LOG.debug("Received cancellation barrier for checkpoint {} from channel {}", checkpointId, channelIndex);
	}

	// fast path for single channel trackers
	if (totalNumberOfInputChannels == 1) {
		notifyAbort(checkpointId);
		return;
	}

	// -- general path for multiple input channels --

	// find the checkpoint barrier in the queue of pending barriers
	// while doing this we "abort" all checkpoints before that one
	CheckpointBarrierCount cbc;
	while ((cbc = pendingCheckpoints.peekFirst()) != null && cbc.checkpointId() < checkpointId) {
		pendingCheckpoints.removeFirst();

		if (cbc.markAborted()) {
			// abort the subsumed checkpoints if not already done
			notifyAbort(cbc.checkpointId());
		}
	}

	if (cbc != null && cbc.checkpointId() == checkpointId) {
		// make sure the checkpoint is remembered as aborted
		if (cbc.markAborted()) {
			// this was the first time the checkpoint was aborted - notify
			notifyAbort(checkpointId);
		}

		// we still count the barriers to be able to remove the entry once all barriers have been seen
		if (cbc.incrementBarrierCount() == totalNumberOfInputChannels) {
			// we can remove this entry
			pendingCheckpoints.removeFirst();
		}
	}
	else if (checkpointId > latestPendingCheckpointID) {
		notifyAbort(checkpointId);

		latestPendingCheckpointID = checkpointId;

		CheckpointBarrierCount abortedMarker = new CheckpointBarrierCount(checkpointId);
		abortedMarker.markAborted();
		pendingCheckpoints.addFirst(abortedMarker);

		// we have removed all other pending checkpoint barrier counts --> no need to check that
		// we don't exceed the maximum checkpoints to track
	} else {
		// trailing cancellation barrier which was already cancelled
	}
}
 
Example 4
Source File: CheckpointBarrierAligner.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public boolean processCancellationBarrier(CancelCheckpointMarker cancelBarrier) throws Exception {
	final long barrierId = cancelBarrier.getCheckpointId();

	// fast path for single channel cases
	if (totalNumberOfInputChannels == 1) {
		if (barrierId > currentCheckpointId) {
			// new checkpoint
			currentCheckpointId = barrierId;
			notifyAbortOnCancellationBarrier(barrierId);
		}
		return false;
	}

	// -- general code path for multiple input channels --

	if (numBarriersReceived > 0) {
		// this is only true if some alignment is in progress and nothing was canceled

		if (barrierId == currentCheckpointId) {
			// cancel this alignment
			if (LOG.isDebugEnabled()) {
				LOG.debug("{}: Checkpoint {} canceled, aborting alignment.", taskName, barrierId);
			}

			releaseBlocksAndResetBarriers();
			notifyAbortOnCancellationBarrier(barrierId);
			return true;
		}
		else if (barrierId > currentCheckpointId) {
			// we canceled the next which also cancels the current
			LOG.warn("{}: Received cancellation barrier for checkpoint {} before completing current checkpoint {}. " +
					"Skipping current checkpoint.",
				taskName,
				barrierId,
				currentCheckpointId);

			// this stops the current alignment
			releaseBlocksAndResetBarriers();

			// the next checkpoint starts as canceled
			currentCheckpointId = barrierId;
			startOfAlignmentTimestamp = 0L;
			latestAlignmentDurationNanos = 0L;

			notifyAbortOnCancellationBarrier(barrierId);
			return true;
		}

		// else: ignore trailing (cancellation) barrier from an earlier checkpoint (obsolete now)

	}
	else if (barrierId > currentCheckpointId) {
		// first barrier of a new checkpoint is directly a cancellation

		// by setting the currentCheckpointId to this checkpoint while keeping the numBarriers
		// at zero means that no checkpoint barrier can start a new alignment
		currentCheckpointId = barrierId;

		startOfAlignmentTimestamp = 0L;
		latestAlignmentDurationNanos = 0L;

		if (LOG.isDebugEnabled()) {
			LOG.debug("{}: Checkpoint {} canceled, skipping alignment.", taskName, barrierId);
		}

		notifyAbortOnCancellationBarrier(barrierId);
		return false;
	}

	// else: trailing barrier from either
	//   - a previous (subsumed) checkpoint
	//   - the current checkpoint if it was already canceled
	return false;
}
 
Example 5
Source File: CheckpointBarrierTracker.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public boolean processCancellationBarrier(CancelCheckpointMarker cancelBarrier) throws Exception {
	final long checkpointId = cancelBarrier.getCheckpointId();

	if (LOG.isDebugEnabled()) {
		LOG.debug("Received cancellation barrier for checkpoint {}", checkpointId);
	}

	// fast path for single channel trackers
	if (totalNumberOfInputChannels == 1) {
		notifyAbortOnCancellationBarrier(checkpointId);
		return false;
	}

	// -- general path for multiple input channels --

	// find the checkpoint barrier in the queue of pending barriers
	// while doing this we "abort" all checkpoints before that one
	CheckpointBarrierCount cbc;
	while ((cbc = pendingCheckpoints.peekFirst()) != null && cbc.checkpointId() < checkpointId) {
		pendingCheckpoints.removeFirst();

		if (cbc.markAborted()) {
			// abort the subsumed checkpoints if not already done
			notifyAbortOnCancellationBarrier(cbc.checkpointId());
		}
	}

	if (cbc != null && cbc.checkpointId() == checkpointId) {
		// make sure the checkpoint is remembered as aborted
		if (cbc.markAborted()) {
			// this was the first time the checkpoint was aborted - notify
			notifyAbortOnCancellationBarrier(checkpointId);
		}

		// we still count the barriers to be able to remove the entry once all barriers have been seen
		if (cbc.incrementBarrierCount() == totalNumberOfInputChannels) {
			// we can remove this entry
			pendingCheckpoints.removeFirst();
		}
	}
	else if (checkpointId > latestPendingCheckpointID) {
		notifyAbortOnCancellationBarrier(checkpointId);

		latestPendingCheckpointID = checkpointId;

		CheckpointBarrierCount abortedMarker = new CheckpointBarrierCount(checkpointId);
		abortedMarker.markAborted();
		pendingCheckpoints.addFirst(abortedMarker);

		// we have removed all other pending checkpoint barrier counts --> no need to check that
		// we don't exceed the maximum checkpoints to track
	} else {
		// trailing cancellation barrier which was already cancelled
	}
	return false;
}
 
Example 6
Source File: CheckpointBarrierAligner.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void processCancellationBarrier(CancelCheckpointMarker cancelBarrier) throws Exception {
	final long barrierId = cancelBarrier.getCheckpointId();

	// fast path for single channel cases
	if (totalNumberOfInputChannels == 1) {
		if (barrierId > currentCheckpointId) {
			// new checkpoint
			currentCheckpointId = barrierId;
			notifyAbortOnCancellationBarrier(barrierId);
		}
		return;
	}

	// -- general code path for multiple input channels --

	if (isCheckpointPending()) {
		// this is only true if some alignment is in progress and nothing was canceled

		if (barrierId == currentCheckpointId) {
			// cancel this alignment
			if (LOG.isDebugEnabled()) {
				LOG.debug("{}: Checkpoint {} canceled, aborting alignment.", taskName, barrierId);
			}

			releaseBlocksAndResetBarriers();
			notifyAbortOnCancellationBarrier(barrierId);
		}
		else if (barrierId > currentCheckpointId) {
			// we canceled the next which also cancels the current
			LOG.warn("{}: Received cancellation barrier for checkpoint {} before completing current checkpoint {}. " +
					"Skipping current checkpoint.",
				taskName,
				barrierId,
				currentCheckpointId);

			// this stops the current alignment
			releaseBlocksAndResetBarriers();

			// the next checkpoint starts as canceled
			currentCheckpointId = barrierId;
			startOfAlignmentTimestamp = 0L;
			latestAlignmentDurationNanos = 0L;

			notifyAbortOnCancellationBarrier(barrierId);
		}

		// else: ignore trailing (cancellation) barrier from an earlier checkpoint (obsolete now)

	}
	else if (barrierId > currentCheckpointId) {
		// first barrier of a new checkpoint is directly a cancellation

		// by setting the currentCheckpointId to this checkpoint while keeping the numBarriers
		// at zero means that no checkpoint barrier can start a new alignment
		currentCheckpointId = barrierId;

		startOfAlignmentTimestamp = 0L;
		latestAlignmentDurationNanos = 0L;

		if (LOG.isDebugEnabled()) {
			LOG.debug("{}: Checkpoint {} canceled, skipping alignment.", taskName, barrierId);
		}

		notifyAbortOnCancellationBarrier(barrierId);
	}

	// else: trailing barrier from either
	//   - a previous (subsumed) checkpoint
	//   - the current checkpoint if it was already canceled
}
 
Example 7
Source File: CheckpointBarrierTracker.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void processCancellationBarrier(CancelCheckpointMarker cancelBarrier) throws Exception {
	final long checkpointId = cancelBarrier.getCheckpointId();

	if (LOG.isDebugEnabled()) {
		LOG.debug("Received cancellation barrier for checkpoint {}", checkpointId);
	}

	// fast path for single channel trackers
	if (totalNumberOfInputChannels == 1) {
		notifyAbortOnCancellationBarrier(checkpointId);
		return;
	}

	// -- general path for multiple input channels --

	// find the checkpoint barrier in the queue of pending barriers
	// while doing this we "abort" all checkpoints before that one
	CheckpointBarrierCount cbc;
	while ((cbc = pendingCheckpoints.peekFirst()) != null && cbc.checkpointId() < checkpointId) {
		pendingCheckpoints.removeFirst();

		if (cbc.markAborted()) {
			// abort the subsumed checkpoints if not already done
			notifyAbortOnCancellationBarrier(cbc.checkpointId());
		}
	}

	if (cbc != null && cbc.checkpointId() == checkpointId) {
		// make sure the checkpoint is remembered as aborted
		if (cbc.markAborted()) {
			// this was the first time the checkpoint was aborted - notify
			notifyAbortOnCancellationBarrier(checkpointId);
		}

		// we still count the barriers to be able to remove the entry once all barriers have been seen
		if (cbc.incrementBarrierCount() == totalNumberOfInputChannels) {
			// we can remove this entry
			pendingCheckpoints.removeFirst();
		}
	}
	else if (checkpointId > latestPendingCheckpointID) {
		notifyAbortOnCancellationBarrier(checkpointId);

		latestPendingCheckpointID = checkpointId;

		CheckpointBarrierCount abortedMarker = new CheckpointBarrierCount(checkpointId);
		abortedMarker.markAborted();
		pendingCheckpoints.addFirst(abortedMarker);

		// we have removed all other pending checkpoint barrier counts --> no need to check that
		// we don't exceed the maximum checkpoints to track
	} else {
		// trailing cancellation barrier which was already cancelled
	}
}