flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiecxy <253441...@qq.com>
Subject How to assign timestamp for event time in a stream?
Date Wed, 07 Sep 2016 10:15:39 GMT
The program is to read the unordered records from a log file, and to print
the record in order. But it doesn't change the  order, is there anything
wrong in my code?  Can anyone give me an example?

This is my program:

Note: the class Tokenizer is to transfer the log to four parts. Like this: 
   Sep  6 09:28:01 master systemd: Stopping user-988.slice. 
  Tuple4<time, master, systemd,  Stopping user-988.slice.>

        // set up the execution environment
        final StreamExecutionEnvironment env =

        StreamTableEnvironment tableEnv =

        DataStream<String> text = env.addSource(new
FlinkKafkaConsumer08<String>("test", new SimpleStringSchema(), properties));
        DataStream<Tuple4&lt;Long, String, String, String>> messages =
                text.flatMap(new Tokenizer())
AscendingTimestampExtractor<Tuple4&lt;Long, String, String, String>>() {
                            public long
extractAscendingTimestamp(Tuple4<Long, String, String, String> tuple4) {
                                return tuple4.f0;

The inputs like this:
Sep  6 09:28:01 master systemd: Stopping user-988.slice1.
Sep  6 09:28:04 master systemd: Stopping user-988.slice4.
Sep  6 09:28:03 master systemd: Stopping user-988.slice3.
Sep  6 09:28:02 master systemd: Stopping user-988.slice2.

But the outputs are same with input, it doesn't change them to 1 - 2 - 3 - 4
(order by the time)...

View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/How-to-assign-timestamp-for-event-time-in-a-stream-tp8944.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.

View raw message