Apache flink warnings.print()以相反的顺序打印事件(最后一个事件优先),Apache Flink CEP中的第一个事件除外

Apache flink warnings.print()以相反的顺序打印事件(最后一个事件优先),Apache Flink CEP中的第一个事件除外,apache-flink,flink-streaming,complex-event-processing,flink-cep,Apache Flink,Flink Streaming,Complex Event Processing,Flink Cep,我尝试使用下面的模式过滤Flink中大于10的所有临时事件 Pattern<MonitoringEvent, ?> warningPattern = Pattern.<MonitoringEvent>begin("first") .subtype(TemperatureEvent.class) .where(new FilterFunction<TemperatureEvent>() {

我尝试使用下面的模式过滤Flink中大于10的所有临时事件

Pattern<MonitoringEvent, ?> warningPattern = Pattern.<MonitoringEvent>begin("first")
                .subtype(TemperatureEvent.class)
                .where(new FilterFunction<TemperatureEvent>() {
                    @Override
                    public boolean filter(TemperatureEvent temperatureEvent) throws Exception {
                        return temperatureEvent.getTemperature() > 50;
                    }
                });
这里第一个值是机架id,第二个值是温度

我已经在input stream和WarnigsStream上发布了print(),如下所示

inputEventStream.print();
warnings.print();
08/10/2017 23:43:15 Job execution switched to status RUNNING.
08/10/2017 23:43:15 Source: Custom Source -> Sink: Unnamed(1/1) switched to SCHEDULED 
08/10/2017 23:43:15 Source: Custom Source -> Sink: Unnamed(1/1) switched to DEPLOYING 
08/10/2017 23:43:15 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to SCHEDULED 
08/10/2017 23:43:15 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to DEPLOYING 
08/10/2017 23:43:15 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to RUNNING 
08/10/2017 23:43:15 Source: Custom Source -> Sink: Unnamed(1/1) switched to RUNNING 
Rack id = 1 and temprature = 98.0)
Rack id = 2 and temprature = 33.0)
Rack id = 3 and temprature = 44.0)
Rack id = 4 and temprature = 55.0)
Rack id = 5 and temprature = 66.0)
Rack id = 6 and temprature = 88.0)
Rack id = 7 and temprature = 99.0)
Rack id = 8 and temprature = 76.0)
08/10/2017 23:43:16 Source: Custom Source -> Sink: Unnamed(1/1) switched to FINISHED 
Rack id = 1 and temprature = 98.0)
Rack id = 8 and temprature = 76.0)
Rack id = 7 and temprature = 99.0)
Rack id = 6 and temprature = 88.0)
Rack id = 5 and temprature = 66.0)
Rack id = 4 and temprature = 55.0)
08/10/2017 23:43:16 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to FINISHED 
08/10/2017 23:43:16 Job execution switched to status FINISHED.

Process finished with exit code 0
 08/11/2017 00:45:09    Job execution switched to status RUNNING.
    08/11/2017 00:45:09 Source: Custom Source -> Timestamps/Watermarks(1/1) switched to SCHEDULED 
    08/11/2017 00:45:09 Source: Custom Source -> Timestamps/Watermarks(1/1) switched to DEPLOYING 
    08/11/2017 00:45:09 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to SCHEDULED 
    08/11/2017 00:45:09 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to DEPLOYING 
    08/11/2017 00:45:09 Source: Custom Source -> Timestamps/Watermarks(1/1) switched to RUNNING 
    08/11/2017 00:45:09 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to RUNNING 
    Rack id = 1 and temprature = 98.0)
    Rack id = 4 and temprature = 55.0)
    Rack id = 5 and temprature = 66.0)
    Rack id = 6 and temprature = 88.0)
    Rack id = 7 and temprature = 99.0)
    Rack id = 8 and temprature = 76.0)
    08/11/2017 00:45:10 Source: Custom Source -> Timestamps/Watermarks(1/1) switched to FINISHED 
    08/11/2017 00:45:10 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to FINISHED 
    08/11/2017 00:45:10 Job execution switched to status FINISHED.
现在,问题来了,Flink CEP的输出如下所示

inputEventStream.print();
warnings.print();
08/10/2017 23:43:15 Job execution switched to status RUNNING.
08/10/2017 23:43:15 Source: Custom Source -> Sink: Unnamed(1/1) switched to SCHEDULED 
08/10/2017 23:43:15 Source: Custom Source -> Sink: Unnamed(1/1) switched to DEPLOYING 
08/10/2017 23:43:15 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to SCHEDULED 
08/10/2017 23:43:15 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to DEPLOYING 
08/10/2017 23:43:15 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to RUNNING 
08/10/2017 23:43:15 Source: Custom Source -> Sink: Unnamed(1/1) switched to RUNNING 
Rack id = 1 and temprature = 98.0)
Rack id = 2 and temprature = 33.0)
Rack id = 3 and temprature = 44.0)
Rack id = 4 and temprature = 55.0)
Rack id = 5 and temprature = 66.0)
Rack id = 6 and temprature = 88.0)
Rack id = 7 and temprature = 99.0)
Rack id = 8 and temprature = 76.0)
08/10/2017 23:43:16 Source: Custom Source -> Sink: Unnamed(1/1) switched to FINISHED 
Rack id = 1 and temprature = 98.0)
Rack id = 8 and temprature = 76.0)
Rack id = 7 and temprature = 99.0)
Rack id = 6 and temprature = 88.0)
Rack id = 5 and temprature = 66.0)
Rack id = 4 and temprature = 55.0)
08/10/2017 23:43:16 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to FINISHED 
08/10/2017 23:43:16 Job execution switched to status FINISHED.

Process finished with exit code 0
 08/11/2017 00:45:09    Job execution switched to status RUNNING.
    08/11/2017 00:45:09 Source: Custom Source -> Timestamps/Watermarks(1/1) switched to SCHEDULED 
    08/11/2017 00:45:09 Source: Custom Source -> Timestamps/Watermarks(1/1) switched to DEPLOYING 
    08/11/2017 00:45:09 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to SCHEDULED 
    08/11/2017 00:45:09 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to DEPLOYING 
    08/11/2017 00:45:09 Source: Custom Source -> Timestamps/Watermarks(1/1) switched to RUNNING 
    08/11/2017 00:45:09 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to RUNNING 
    Rack id = 1 and temprature = 98.0)
    Rack id = 4 and temprature = 55.0)
    Rack id = 5 and temprature = 66.0)
    Rack id = 6 and temprature = 88.0)
    Rack id = 7 and temprature = 99.0)
    Rack id = 8 and temprature = 76.0)
    08/11/2017 00:45:10 Source: Custom Source -> Timestamps/Watermarks(1/1) switched to FINISHED 
    08/11/2017 00:45:10 AbstractCEPPatternOperator -> Map -> Sink: Unnamed(1/1) switched to FINISHED 
    08/11/2017 00:45:10 Job execution switched to status FINISHED.
如我们所见,第一个复杂事件(Rack id=1和temperature=98.0))以相同的顺序打印,但在此之后,所有temp>50的其他复杂事件都以与输入流相反的顺序打印

My questions are :-

1. Any idea why events are getting printed in reverse order?
2. Is there a custom way to print values{w/o using warnings.print()} of 
   warning stream, like can I print only temperature, rather than rack-id ?

提前感谢

通过为inputStream分配时间戳和水印解决了此问题,如下所示

// Input stream of monitoring events
        DataStream<MonitoringEvent> inputEventStream = env
                .addSource(new InputStreamAGenerator()).assignTimestampsAndWatermarks(new IngestionTimeExtractor<>());