Java Code Examples for org.apache.flink.streaming.api.TimeCharacteristic#EventTime

The following examples show how to use org.apache.flink.streaming.api.TimeCharacteristic#EventTime . 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: KeyedStream.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Specifies the time boundaries over which the join operation works, so that
 * <pre>leftElement.timestamp + lowerBound <= rightElement.timestamp <= leftElement.timestamp + upperBound</pre>
 * By default both the lower and the upper bound are inclusive. This can be configured
 * with {@link IntervalJoined#lowerBoundExclusive()} and
 * {@link IntervalJoined#upperBoundExclusive()}
 *
 * @param lowerBound The lower bound. Needs to be smaller than or equal to the upperBound
 * @param upperBound The upper bound. Needs to be bigger than or equal to the lowerBound
 */
@PublicEvolving
public IntervalJoined<T1, T2, KEY> between(Time lowerBound, Time upperBound) {

	TimeCharacteristic timeCharacteristic =
		streamOne.getExecutionEnvironment().getStreamTimeCharacteristic();

	if (timeCharacteristic != TimeCharacteristic.EventTime) {
		throw new UnsupportedTimeCharacteristicException("Time-bounded stream joins are only supported in event time");
	}

	checkNotNull(lowerBound, "A lower bound needs to be provided for a time-bounded join");
	checkNotNull(upperBound, "An upper bound needs to be provided for a time-bounded join");

	return new IntervalJoined<>(
		streamOne,
		streamTwo,
		lowerBound.toMilliseconds(),
		upperBound.toMilliseconds(),
		true,
		true
	);
}
 
Example 2
Source File: KeyedStream.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Specifies the time boundaries over which the join operation works, so that
 * <pre>leftElement.timestamp + lowerBound <= rightElement.timestamp <= leftElement.timestamp + upperBound</pre>
 * By default both the lower and the upper bound are inclusive. This can be configured
 * with {@link IntervalJoined#lowerBoundExclusive()} and
 * {@link IntervalJoined#upperBoundExclusive()}
 *
 * @param lowerBound The lower bound. Needs to be smaller than or equal to the upperBound
 * @param upperBound The upper bound. Needs to be bigger than or equal to the lowerBound
 */
@PublicEvolving
public IntervalJoined<T1, T2, KEY> between(Time lowerBound, Time upperBound) {

	TimeCharacteristic timeCharacteristic =
		streamOne.getExecutionEnvironment().getStreamTimeCharacteristic();

	if (timeCharacteristic != TimeCharacteristic.EventTime) {
		throw new UnsupportedTimeCharacteristicException("Time-bounded stream joins are only supported in event time");
	}

	checkNotNull(lowerBound, "A lower bound needs to be provided for a time-bounded join");
	checkNotNull(upperBound, "An upper bound needs to be provided for a time-bounded join");

	return new IntervalJoined<>(
		streamOne,
		streamTwo,
		lowerBound.toMilliseconds(),
		upperBound.toMilliseconds(),
		true,
		true
	);
}
 
Example 3
Source File: KeyedStream.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Specifies the time boundaries over which the join operation works, so that
 * <pre>leftElement.timestamp + lowerBound <= rightElement.timestamp <= leftElement.timestamp + upperBound</pre>
 * By default both the lower and the upper bound are inclusive. This can be configured
 * with {@link IntervalJoined#lowerBoundExclusive()} and
 * {@link IntervalJoined#upperBoundExclusive()}
 *
 * @param lowerBound The lower bound. Needs to be smaller than or equal to the upperBound
 * @param upperBound The upper bound. Needs to be bigger than or equal to the lowerBound
 */
@PublicEvolving
public IntervalJoined<T1, T2, KEY> between(Time lowerBound, Time upperBound) {

	TimeCharacteristic timeCharacteristic =
		streamOne.getExecutionEnvironment().getStreamTimeCharacteristic();

	if (timeCharacteristic != TimeCharacteristic.EventTime) {
		throw new UnsupportedTimeCharacteristicException("Time-bounded stream joins are only supported in event time");
	}

	checkNotNull(lowerBound, "A lower bound needs to be provided for a time-bounded join");
	checkNotNull(upperBound, "An upper bound needs to be provided for a time-bounded join");

	return new IntervalJoined<>(
		streamOne,
		streamTwo,
		lowerBound.toMilliseconds(),
		upperBound.toMilliseconds(),
		true,
		true
	);
}
 
Example 4
Source File: ExecutionContext.java    From flink with Apache License 2.0 6 votes vote down vote up
private TableConfig createTableConfig() {
	final TableConfig config = new TableConfig();
	config.addConfiguration(flinkConfig);
	Configuration conf = config.getConfiguration();
	environment.getConfiguration().asMap().forEach(conf::setString);
	ExecutionEntry execution = environment.getExecution();
	config.setIdleStateRetentionTime(
			Time.milliseconds(execution.getMinStateRetention()),
			Time.milliseconds(execution.getMaxStateRetention()));

	conf.set(CoreOptions.DEFAULT_PARALLELISM, execution.getParallelism());
	conf.set(PipelineOptions.MAX_PARALLELISM, execution.getMaxParallelism());
	conf.set(StreamPipelineOptions.TIME_CHARACTERISTIC, execution.getTimeCharacteristic());
	if (execution.getTimeCharacteristic() == TimeCharacteristic.EventTime) {
		conf.set(PipelineOptions.AUTO_WATERMARK_INTERVAL,
				Duration.ofMillis(execution.getPeriodicWatermarksInterval()));
	}

	setRestartStrategy(conf);
	return config;
}
 
Example 5
Source File: ExecutionContext.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private StreamExecutionEnvironment createStreamExecutionEnvironment() {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setRestartStrategy(mergedEnv.getExecution().getRestartStrategy());
	env.setParallelism(mergedEnv.getExecution().getParallelism());
	env.setMaxParallelism(mergedEnv.getExecution().getMaxParallelism());
	env.setStreamTimeCharacteristic(mergedEnv.getExecution().getTimeCharacteristic());
	if (env.getStreamTimeCharacteristic() == TimeCharacteristic.EventTime) {
		env.getConfig().setAutoWatermarkInterval(mergedEnv.getExecution().getPeriodicWatermarksInterval());
	}
	return env;
}
 
Example 6
Source File: StreamTableEnvironmentImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
private void validateTimeCharacteristic(boolean isRowtimeDefined) {
	if (isRowtimeDefined && executionEnvironment.getStreamTimeCharacteristic() != TimeCharacteristic.EventTime) {
		throw new ValidationException(String.format(
			"A rowtime attribute requires an EventTime time characteristic in stream environment. But is: %s",
			executionEnvironment.getStreamTimeCharacteristic()));
	}
}
 
Example 7
Source File: ExecutionContext.java    From flink with Apache License 2.0 5 votes vote down vote up
private StreamExecutionEnvironment createStreamExecutionEnvironment() {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setRestartStrategy(mergedEnv.getExecution().getRestartStrategy());
	env.setParallelism(mergedEnv.getExecution().getParallelism());
	env.setMaxParallelism(mergedEnv.getExecution().getMaxParallelism());
	env.setStreamTimeCharacteristic(mergedEnv.getExecution().getTimeCharacteristic());
	if (env.getStreamTimeCharacteristic() == TimeCharacteristic.EventTime) {
		env.getConfig().setAutoWatermarkInterval(mergedEnv.getExecution().getPeriodicWatermarksInterval());
	}
	return env;
}
 
Example 8
Source File: ExecutionContext.java    From flink with Apache License 2.0 5 votes vote down vote up
private StreamExecutionEnvironment createStreamExecutionEnvironment() {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	// for TimeCharacteristic validation in StreamTableEnvironmentImpl
	env.setStreamTimeCharacteristic(environment.getExecution().getTimeCharacteristic());
	if (env.getStreamTimeCharacteristic() == TimeCharacteristic.EventTime) {
		env.getConfig().setAutoWatermarkInterval(environment.getExecution().getPeriodicWatermarksInterval());
	}
	return env;
}
 
Example 9
Source File: StreamTableEnvironmentImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
private void validateTimeCharacteristic(boolean isRowtimeDefined) {
	if (isRowtimeDefined && executionEnvironment.getStreamTimeCharacteristic() != TimeCharacteristic.EventTime) {
		throw new ValidationException(String.format(
			"A rowtime attribute requires an EventTime time characteristic in stream environment. But is: %s",
			executionEnvironment.getStreamTimeCharacteristic()));
	}
}
 
Example 10
Source File: StreamTask.java    From flink with Apache License 2.0 4 votes vote down vote up
boolean isSerializingTimestamps() {
	TimeCharacteristic tc = configuration.getTimeCharacteristic();
	return tc == TimeCharacteristic.EventTime | tc == TimeCharacteristic.IngestionTime;
}
 
Example 11
Source File: FailingSource.java    From flink with Apache License 2.0 4 votes vote down vote up
public FailingSource(
	@Nonnull EventEmittingGenerator eventEmittingGenerator,
	@Nonnegative int numberOfGeneratorInvocations) {
	this(eventEmittingGenerator, numberOfGeneratorInvocations, TimeCharacteristic.EventTime);
}
 
Example 12
Source File: ValidatingSink.java    From flink with Apache License 2.0 4 votes vote down vote up
public ValidatingSink(
	@Nonnull CountUpdater<T> countUpdater,
	@Nonnull ResultChecker resultChecker) {
	this(countUpdater, resultChecker, TimeCharacteristic.EventTime);
}
 
Example 13
Source File: StreamTask.java    From flink with Apache License 2.0 4 votes vote down vote up
boolean isSerializingTimestamps() {
	TimeCharacteristic tc = configuration.getTimeCharacteristic();
	return tc == TimeCharacteristic.EventTime | tc == TimeCharacteristic.IngestionTime;
}
 
Example 14
Source File: FailingSource.java    From flink with Apache License 2.0 4 votes vote down vote up
public FailingSource(
	@Nonnull EventEmittingGenerator eventEmittingGenerator,
	@Nonnegative int numberOfGeneratorInvocations) {
	this(eventEmittingGenerator, numberOfGeneratorInvocations, TimeCharacteristic.EventTime);
}
 
Example 15
Source File: ValidatingSink.java    From flink with Apache License 2.0 4 votes vote down vote up
public ValidatingSink(
	@Nonnull CountUpdater<T> countUpdater,
	@Nonnull ResultChecker resultChecker) {
	this(countUpdater, resultChecker, TimeCharacteristic.EventTime);
}
 
Example 16
Source File: StreamTask.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
boolean isSerializingTimestamps() {
	TimeCharacteristic tc = configuration.getTimeCharacteristic();
	return tc == TimeCharacteristic.EventTime | tc == TimeCharacteristic.IngestionTime;
}
 
Example 17
Source File: FailingSource.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public FailingSource(
	@Nonnull EventEmittingGenerator eventEmittingGenerator,
	@Nonnegative int numberOfGeneratorInvocations) {
	this(eventEmittingGenerator, numberOfGeneratorInvocations, TimeCharacteristic.EventTime);
}
 
Example 18
Source File: ValidatingSink.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public ValidatingSink(
	@Nonnull CountUpdater<T> countUpdater,
	@Nonnull ResultChecker resultChecker) {
	this(countUpdater, resultChecker, TimeCharacteristic.EventTime);
}