Why I'm not able to make a keyed stream out of this

故事扮演 提交于 2019-12-11 08:09:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!