Java Code Examples for org.apache.flink.streaming.api.windowing.triggers.TriggerResult#CONTINUE

The following examples show how to use org.apache.flink.streaming.api.windowing.triggers.TriggerResult#CONTINUE . 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: CustomTrigger.java    From flink-learning with Apache License 2.0 6 votes vote down vote up
@Override
    public TriggerResult onElement(WordEvent element, long timestamp, TimeWindow window, TriggerContext ctx) throws Exception {
        log.info("======onElement====window start = {}, window end = {}", window.getStart(), window.getEnd());

        return TriggerResult.CONTINUE;
//        ReducingState<Long> fireTimestamp = ctx.getPartitionedState(stateDesc);
//
//        timestamp = ctx.getCurrentProcessingTime();
//
//        if (fireTimestamp.get() == null) {
//            long start = timestamp - (timestamp % interval);
//            long nextFireTimestamp = start + interval;
//
//            ctx.registerProcessingTimeTimer(nextFireTimestamp);
//
//            fireTimestamp.add(nextFireTimestamp);
//            return TriggerResult.CONTINUE;
//        }
//        return TriggerResult.CONTINUE;

    }
 
Example 2
Source File: CustomWindow.java    From examples-java with Apache License 2.0 6 votes vote down vote up
@Override
public TriggerResult onElement(SensorReading r, long ts, TimeWindow w, TriggerContext ctx) throws Exception {
    // firstSeen will be false if not set yet
    ValueState<Boolean> firstSeen = ctx.getPartitionedState(
        new ValueStateDescriptor<>("firstSeen", Types.BOOLEAN));

    // register initial timer only for first element
    if (firstSeen.value() == null) {
        // compute time for next early firing by rounding watermark to second
        long t = ctx.getCurrentWatermark() + (1000 - (ctx.getCurrentWatermark() % 1000));
        ctx.registerEventTimeTimer(t);
        // register timer for the end of the window
        ctx.registerEventTimeTimer(w.getEnd());
        firstSeen.update(true);
    }
    // Continue. Do not evaluate window per element
    return TriggerResult.CONTINUE;
}
 
Example 3
Source File: CustomTrigger.java    From flink-learning with Apache License 2.0 6 votes vote down vote up
@Override
    public TriggerResult onElement(WordEvent element, long timestamp, TimeWindow window, TriggerContext ctx) throws Exception {
        log.info("======onElement====window start = {}, window end = {}", window.getStart(), window.getEnd());

        return TriggerResult.CONTINUE;
//        ReducingState<Long> fireTimestamp = ctx.getPartitionedState(stateDesc);
//
//        timestamp = ctx.getCurrentProcessingTime();
//
//        if (fireTimestamp.get() == null) {
//            long start = timestamp - (timestamp % interval);
//            long nextFireTimestamp = start + interval;
//
//            ctx.registerProcessingTimeTimer(nextFireTimestamp);
//
//            fireTimestamp.add(nextFireTimestamp);
//            return TriggerResult.CONTINUE;
//        }
//        return TriggerResult.CONTINUE;

    }
 
Example 4
Source File: WindowOperatorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public TriggerResult onElement(Object element, long timestamp, TimeWindow window, TriggerContext ctx) throws Exception {
	if (window.maxTimestamp() <= ctx.getCurrentWatermark()) {
		// if the watermark is already past the window fire immediately
		return TriggerResult.FIRE;
	} else {
		ctx.registerEventTimeTimer(window.maxTimestamp());
		return TriggerResult.CONTINUE;
	}
}
 
Example 5
Source File: DrivingSegments.java    From flink-training-exercises with Apache License 2.0 5 votes vote down vote up
@Override
public TriggerResult onElement(ConnectedCarEvent event, long timestamp, GlobalWindow window, TriggerContext context) throws Exception {

	// if this is a stop event, set a timer
	if (event.speed == 0.0) {
		context.registerEventTimeTimer(event.timestamp);
	}

	return TriggerResult.CONTINUE;
}
 
Example 6
Source File: AdvertisingTopologyFlinkWindows.java    From yahoo-streaming-benchmark with Apache License 2.0 5 votes vote down vote up
@Override
public TriggerResult onElement(Object element, long timestamp, TimeWindow window, TriggerContext ctx) throws Exception {
  ctx.registerEventTimeTimer(window.maxTimestamp());
  // register system timer only for the first time
  OperatorState<Boolean> firstTimerSet = ctx.getKeyValueState("firstTimerSet", Boolean.class, false);
  if (!firstTimerSet.value()) {
    ctx.registerProcessingTimeTimer(System.currentTimeMillis() + 1000L);
    firstTimerSet.update(true);
  }
  return TriggerResult.CONTINUE;
}
 
Example 7
Source File: WindowOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public TriggerResult onElement(Object element, long timestamp, TimeWindow window, TriggerContext ctx) throws Exception {
	if (window.maxTimestamp() <= ctx.getCurrentWatermark()) {
		// if the watermark is already past the window fire immediately
		return TriggerResult.FIRE;
	} else {
		ctx.registerEventTimeTimer(window.maxTimestamp());
		return TriggerResult.CONTINUE;
	}
}
 
Example 8
Source File: GlobalWindows.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onElement(Object element, long timestamp, GlobalWindow window, TriggerContext ctx) {
	return TriggerResult.CONTINUE;
}
 
Example 9
Source File: GlobalWindows.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onElement(Object element, long timestamp, GlobalWindow window, TriggerContext ctx) {
	return TriggerResult.CONTINUE;
}
 
Example 10
Source File: DrivingSegments.java    From flink-training-exercises with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onProcessingTime(long time, GlobalWindow window, TriggerContext ctx) {
	return TriggerResult.CONTINUE;
}
 
Example 11
Source File: GlobalWindows.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onProcessingTime(long time, GlobalWindow window, TriggerContext ctx) {
	return TriggerResult.CONTINUE;
}
 
Example 12
Source File: WindowOperatorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onProcessingTime(long time, TimeWindow window, TriggerContext ctx) throws Exception {
	return TriggerResult.CONTINUE;
}
 
Example 13
Source File: WindowOperatorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onEventTime(long time, TimeWindow window, TriggerContext ctx) {
	return time == window.maxTimestamp() || time == window.maxTimestamp() + cleanupTime ?
		TriggerResult.FIRE_AND_PURGE :
		TriggerResult.CONTINUE;
}
 
Example 14
Source File: GlobalWindows.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onProcessingTime(long time, GlobalWindow window, TriggerContext ctx) {
	return TriggerResult.CONTINUE;
}
 
Example 15
Source File: GlobalWindows.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onEventTime(long time, GlobalWindow window, TriggerContext ctx) {
	return TriggerResult.CONTINUE;
}
 
Example 16
Source File: GlobalWindows.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onElement(Object element, long timestamp, GlobalWindow window, TriggerContext ctx) {
	return TriggerResult.CONTINUE;
}
 
Example 17
Source File: WindowOperatorTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onProcessingTime(long time, TimeWindow window, TriggerContext ctx) throws Exception {
	return TriggerResult.CONTINUE;
}
 
Example 18
Source File: WindowOperatorTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onEventTime(long time, TimeWindow window, TriggerContext ctx) {
	return time == window.maxTimestamp() || time == window.maxTimestamp() + cleanupTime ?
		TriggerResult.FIRE_AND_PURGE :
		TriggerResult.CONTINUE;
}
 
Example 19
Source File: GlobalWindows.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onProcessingTime(long time, GlobalWindow window, TriggerContext ctx) {
	return TriggerResult.CONTINUE;
}
 
Example 20
Source File: GlobalWindows.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerResult onEventTime(long time, GlobalWindow window, TriggerContext ctx) {
	return TriggerResult.CONTINUE;
}