Java Code Examples for org.apache.flink.streaming.runtime.streamstatus.StreamStatus#isActive()

The following examples show how to use org.apache.flink.streaming.runtime.streamstatus.StreamStatus#isActive() . 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: StreamTwoInputProcessor.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void handleStreamStatus(StreamStatus streamStatus) {
	try {
		synchronized (lock) {
			firstStatus = streamStatus;

			// check if we need to toggle the task's stream status
			if (!streamStatus.equals(streamStatusMaintainer.getStreamStatus())) {
				if (streamStatus.isActive()) {
					// we're no longer idle if at least one input has become active
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.ACTIVE);
				} else if (secondStatus.isIdle()) {
					// we're idle once both inputs are idle
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.IDLE);
				}
			}
		}
	} catch (Exception e) {
		throw new RuntimeException("Exception occurred while processing valve output stream status: ", e);
	}
}
 
Example 2
Source File: StreamTwoInputProcessor.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void handleStreamStatus(StreamStatus streamStatus) {
	try {
		synchronized (lock) {
			secondStatus = streamStatus;

			// check if we need to toggle the task's stream status
			if (!streamStatus.equals(streamStatusMaintainer.getStreamStatus())) {
				if (streamStatus.isActive()) {
					// we're no longer idle if at least one input has become active
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.ACTIVE);
				} else if (firstStatus.isIdle()) {
					// we're idle once both inputs are idle
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.IDLE);
				}
			}
		}
	} catch (Exception e) {
		throw new RuntimeException("Exception occurred while processing valve output stream status: ", e);
	}
}
 
Example 3
Source File: StreamTwoInputProcessor.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void handleStreamStatus(StreamStatus streamStatus) {
	try {
		synchronized (lock) {
			firstStatus = streamStatus;

			// check if we need to toggle the task's stream status
			if (!streamStatus.equals(streamStatusMaintainer.getStreamStatus())) {
				if (streamStatus.isActive()) {
					// we're no longer idle if at least one input has become active
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.ACTIVE);
				} else if (secondStatus.isIdle()) {
					// we're idle once both inputs are idle
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.IDLE);
				}
			}
		}
	} catch (Exception e) {
		throw new RuntimeException("Exception occurred while processing valve output stream status: ", e);
	}
}
 
Example 4
Source File: StreamTwoInputProcessor.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void handleStreamStatus(StreamStatus streamStatus) {
	try {
		synchronized (lock) {
			secondStatus = streamStatus;

			// check if we need to toggle the task's stream status
			if (!streamStatus.equals(streamStatusMaintainer.getStreamStatus())) {
				if (streamStatus.isActive()) {
					// we're no longer idle if at least one input has become active
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.ACTIVE);
				} else if (firstStatus.isIdle()) {
					// we're idle once both inputs are idle
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.IDLE);
				}
			}
		}
	} catch (Exception e) {
		throw new RuntimeException("Exception occurred while processing valve output stream status: ", e);
	}
}
 
Example 5
Source File: StreamTwoInputProcessor.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void emitStreamStatus(StreamStatus streamStatus) {
	final StreamStatus anotherStreamStatus;
	if (inputIndex == 0) {
		firstStatus = streamStatus;
		anotherStreamStatus = secondStatus;
	} else {
		secondStatus = streamStatus;
		anotherStreamStatus = firstStatus;
	}

	// check if we need to toggle the task's stream status
	if (!streamStatus.equals(streamStatusMaintainer.getStreamStatus())) {
		if (streamStatus.isActive()) {
			// we're no longer idle if at least one input has become active
			streamStatusMaintainer.toggleStreamStatus(StreamStatus.ACTIVE);
		} else if (anotherStreamStatus.isIdle()) {
			// we're idle once both inputs are idle
			streamStatusMaintainer.toggleStreamStatus(StreamStatus.IDLE);
		}
	}
}
 
Example 6
Source File: StreamMultipleInputProcessor.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void emitStreamStatus(StreamStatus streamStatus) {
	final StreamStatus anotherStreamStatus;

	streamStatuses[inputIndex] = streamStatus;

	// check if we need to toggle the task's stream status
	if (!streamStatus.equals(streamStatusMaintainer.getStreamStatus())) {
		if (streamStatus.isActive()) {
			// we're no longer idle if at least one input has become active
			streamStatusMaintainer.toggleStreamStatus(StreamStatus.ACTIVE);
		} else if (allStreamStatusesAreIdle()) {
			streamStatusMaintainer.toggleStreamStatus(StreamStatus.IDLE);
		}
	}
}
 
Example 7
Source File: StreamTwoInputSelectableProcessor.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void handleStreamStatus(StreamStatus streamStatus) {
	try {
		synchronized (lock) {
			final StreamStatus anotherStreamStatus;
			if (inputIndex == 0) {
				firstStatus = streamStatus;
				anotherStreamStatus = secondStatus;
			} else {
				secondStatus = streamStatus;
				anotherStreamStatus = firstStatus;
			}

			// check if we need to toggle the task's stream status
			if (!streamStatus.equals(streamStatusMaintainer.getStreamStatus())) {
				if (streamStatus.isActive()) {
					// we're no longer idle if at least one input has become active
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.ACTIVE);
				} else if (anotherStreamStatus.isIdle()) {
					// we're idle once both inputs are idle
					streamStatusMaintainer.toggleStreamStatus(StreamStatus.IDLE);
				}
			}
		}
	} catch (Exception e) {
		throw new RuntimeException("Exception occurred while processing valve output stream status of input"
			+ (inputIndex + 1) + ": ", e);
	}
}
 
Example 8
Source File: StreamMultipleInputProcessor.java    From flink with Apache License 2.0 5 votes vote down vote up
private boolean allStreamStatusesAreIdle() {
	for (StreamStatus streamStatus : streamStatuses) {
		if (streamStatus.isActive()) {
			return false;
		}
	}
	return true;
}