问题
I've been trying different methods but unable to get right. what's wrong in this code?
def main(args: Array[String]): Unit = {
val TEMPERATURE_THRESHOLD: Double = 50.00
val see: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
val properties = new Properties()
properties.setProperty("bootstrap.servers", "localhost:9092")
properties.setProperty("zookeeper.connect", "localhost:2181")
val src = see.addSource(new FlinkKafkaConsumer010("broadcast",
new JSONKeyValueDeserializationSchema(true), properties))
src.map {
v =>
val key = v.get("locationID").asText
val temperature = v.get("temp").asDouble()
(key, temperature)
}
.keyBy(v => v._2)
src.print()
see.execute()
case class Event(locationID: String, temp: Double)
I want an alert when the flink reads the value above threshold
[{"locationID": "ASK","temp": 35},
{"locationID": "BC","temp": 45},
{"locationID":"CHD","temp": 55},
{"locationID": "RAJ","temp": 65},
{"locationID": "EGY","temp": 55}]
Error I'm getting is:
Job Execution Failed
来源:https://stackoverflow.com/questions/58220391/why-im-not-able-to-make-a-keyed-stream-out-of-this