I'm trying to implement a very simple Apache Flink CEP for a Kafka InputStream. The Kafka Producer generates a simple Double Value and send them via a Kafka Topic as String towards the Consumers. At the moment i'm coding a CEP Consumer with Flink. So far this is my written code:
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.getConfig().disableSysoutLogging();
env.getConfig().setRestartStrategy(RestartStrategies.fixedDelayRestart(4, 10000));
env.setParallelism(3);
Properties properties = new Properties();
properties.setProperty("bootstrap.servers", "localhost:9092");
properties.setProperty("group.id", "flink_consumer");
DataStream<String> stream = env
.addSource(new FlinkKafkaConsumer09<>("temp", new SimpleStringSchema(), properties));
Pattern<String, ?> warning= Pattern.<String>begin("first")
.where(new IterativeCondition<String>() {
private static final long serialVersionUID = 1L;
@Override
public boolean filter(String value, Context<String> ctx) throws Exception {
return Double.parseDouble(value) >= 89.0;
}
})
.next("second")
.where(new IterativeCondition<String>() {
private static final long serialVersionUID = 1L;
@Override
public boolean filter(String value, Context<String> ctx) throws Exception {
return Double.parseDouble(value) >= 89.0;
}
})
.within(Time.seconds(10));
DataStream<String> temp = CEP.pattern(stream, warning).select(new PatternSelectFunction<String, String>() {
private static final long serialVersionUID = 1L;
@Override
public String select(Map<String, List<String>> pattern) throws Exception {
List warnung1 = pattern.get("first");
String first = (String) warnung1.get(1);
return first;
}
});
temp.print();
env.execute();
}
if I'm trying to execute this Code this is the error message:
Exception in thread "main" java.lang.NoSuchFieldError: NO_INDEX at org.apache.flink.cep.PatternStream.select(PatternStream.java:102) at CEPTest.main(CEPTest.java:50)
So it looks like my generated DataStream with the CEP Pattern is wrong, but i don't know whats wrong with that method. Every help would be great!
Edit: I tried some other example and at every execution I'm getting the same error. So I think something with my packages is wrong?