Apache Flink keyBy函数中的java.lang.IndexOutOfBoundsException

时间:2017-11-24 15:29:31

标签: java stream apache-flink

在Apache Flink中获取Exception in thread "main" java.lang.IndexOutOfBoundsException。我试图在here上遵循这个例子,但是我得到了提及的豁免。我在下面有一个主要课程的片段。我将非常感谢指出我做错了什么或如何解决错误。

DataStream<CSBEvent> inputEventStream = env.addSource(
                new FlinkKafkaConsumer09<CSBEvent>("tester03", new EventDeserializationSchema(), properties));

 Pattern<CSBEvent, ?> warningPattern = Pattern.<CSBEvent>begin("first")
                .subtype(CSBEvent.class)
                .where(evt -> evt.getEvent().getStatus().equals("FAILED"))
                .next("second")
                .subtype(CSBEvent.class)
                .where(evt -> evt.getEvent().getStatus().equals("FAILED"))
                .within(Time.seconds(10));

        // Create a pattern stream from our warning pattern
        PatternStream<CSBEvent> tempPatternStream = CEP.pattern(inputEventStream.keyBy("userID"), warningPattern); //   .pattern(

        // Generate temperature warnings for each matched warning pattern
        DataStream<CSBEvent> warnings = tempPatternStream.select(
            (Map<String, CSBEvent> pattern) -> {
                CSBEvent first = (CSBEvent) pattern.get("first");
                CSBEvent second = (CSBEvent) pattern.get("second");

                return new CSBEvent(second.getUserID());
            }
        );

        // Alert pattern: Two consecutive request failure warnings appearing within a time interval of 20 seconds
        Pattern<CSBEvent, ?> alertPattern = Pattern.<CSBEvent>begin("first")
                .next("second")
                .within(Time.seconds(20));

        // Create a pattern stream from our alert pattern
        PatternStream<CSBEvent> alertPatternStream = CEP.pattern(
                warnings.keyBy("userID"),
                alertPattern);

....这里是stacktrace:

Exception in thread "main" java.lang.IndexOutOfBoundsException
at org.apache.flink.api.java.typeutils.PojoTypeInfo.getTypeAt(PojoTypeInfo.java:259)
at org.apache.flink.streaming.util.keys.KeySelectorUtil.getSelectorForKeys(KeySelectorUtil.java:62)
at org.apache.flink.streaming.api.datastream.DataStream.keyBy(DataStream.java:276)
at org.apache.flink.streaming.api.datastream.DataStream.keyBy(DataStream.java:272)
at de.cep.CorrelatorVersion101.main(CorrelatorVersion101.java:61)

1 个答案:

答案 0 :(得分:0)

从你的代码看起来你正在使用Flink 1.2吗?您是否考虑过更新到更新的版本?目前我们即将发布Flink 1.4。

此外,您是否可以发布整个堆栈跟踪以查看抛出异常的位置?