赞
踩
packagecom.wyh.streamingApi.sinkimportjava.utilimportorg.apache.flink.api.common.functions.RuntimeContextimportorg.apache.flink.streaming.api.scala._importorg.apache.flink.streaming.connectors.elasticsearch.{ElasticsearchSinkFunction, RequestIndexer}importorg.apache.flink.streaming.connectors.elasticsearch6.ElasticsearchSinkimportorg.apache.http.HttpHostimportorg.elasticsearch.client.Requests//温度传感器读数样例类
case classSensorReading(id: String, timestamp: Long, temperature: Double)
object Sink2ES {
def main(args: Array[String]): Unit={
val env=StreamExecutionEnvironment.getExecutionEnvironment
env.setParallelism(1)//Source操作
val inputStream = env.readTextFile("F:\\flink-study\\wyhFlinkSD\\data\\sensor.txt")//Transform操作
val dataStream: DataStream[SensorReading] = inputStream.map(data =>{
val dataArray= data.split(",")</
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。