gpt4 book ai didi

scala - flink 1.3.1 elasticsearch 5.5.1。 ElasticsearchSinkFunction失败,并出现java.lang.NoSuchMethodError

转载 作者:行者123 更新时间:2023-12-03 00:05:21 24 4
gpt4 key购买 nike

我正在使用Scala / sbt进行以下示例:

flink / elasticsearch / kibana
flink tutorial

我的built.sbt包含以下版本:

libraryDependencies ++= Seq(
"org.apache.flink" %% "flink-scala" % "1.3.1" % "provided",
"org.apache.flink" %% "flink-streaming-scala" % "1.3.1" % "provided",
"org.apache.flink" %% "flink-clients" % "1.3.1" % "provided",
"joda-time" % "joda-time" % "2.9.9",
"com.google.guava" % "guava" % "22.0",
"com.typesafe" % "config" % "1.3.0",
"org.apache.flink" % "flink-connector-kafka-0.10_2.10" % "1.2.0",
"org.elasticsearch" % "elasticsearch" % "5.5.1",
"org.elasticsearch.client" % "transport" % "5.5.1",
"org.apache.flink" % "flink-connector-elasticsearch5_2.10" % "1.3.1"
)

程序失败,出现以下异常(减号):
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.NoSuchMethodError: org.elasticsearch.action.bulk.BulkProcessor.add(Lorg/elasticsearch/action/ActionRequest;)Lorg/elasticsearch/action/bulk/BulkProcessor;
at org.apache.flink.streaming.connectors.elasticsearch.BulkProcessorIndexer.add(BulkProcessorIndexer.java:52)
at org.aj.flink.stream.TaxiDashboard$MyElasticsearchInserter.process(TaxiDashboard.scala:157)
at org.aj.flink.stream.TaxiDashboard$MyElasticsearchInserter.process(TaxiDashboard.scala:137)
at org.apache.flink.streaming.connectors.elasticsearch.ElasticsearchSinkBase.invoke(ElasticsearchSinkBase.java:282)
at org.apache.flink.streaming.api.operators.StreamSink.processElement(StreamSink.java:41)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.pushToOperator(OperatorChain.java:528)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:503)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:483)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$BroadcastingOutputCollector.collect(OperatorChain.java:575)

这是我相关的进口商品:
import org.apache.flink.streaming.connectors.elasticsearch5.ElasticsearchSink
import org.apache.flink.streaming.connectors.elasticsearch.{ElasticsearchSinkFunction, RequestIndexer}
import org.elasticsearch.action.index.IndexRequest
import org.elasticsearch.client.Requests

这是 MyElasticsearchInserter的代码:
  final class MyElasticsearchInserter(index: String, mappingType: String)
extends ElasticsearchSinkFunction[(Int, Long, (Float, Float), Short)] {

def process(element: (Int, Long, (Float, Float), Short),
ctx: RuntimeContext,
indexer: RequestIndexer): Unit = {

// construct JSON document to index
val json = Map(
"time" -> element._2.toString,
"location" -> (element._3._1 + "," + element._3._2),
"cnt" -> element._4.toString
)

val rqst: IndexRequest = Requests.indexRequest
.index(index)
.`type`(mappingType)
.source(json.asJava)
indexer.add(rqst)
}
}

这是添加接收器的代码:
if (writeToElasticsearch) {
// write to Elasticsearch
nycRides.addSink(new ElasticsearchSink(esConfig,
esTransport, new MyElasticsearchInserter("nyc-idx", "popular-locations")))

}

看起来问题在于,是否可以将 flink 1.3.1elasticsearch 5.5.1一起使用?找不到以下方法?
Caused by: java.lang.NoSuchMethodError: org.elasticsearch.action.bulk.BulkProcessor.add(Lorg/elasticsearch/action/ActionRequest;)Lorg/elasticsearch/action/bulk/BulkProcessor;
at org.apache.flink.streaming.connectors.elasticsearch.BulkProcessorIndexer.add(BulkProcessorIndexer.java:52)
at org.aj.flink.stream.TaxiDashboard$MyElasticsearchInserter.process(TaxiDashboard.scala:157)

非常感谢

最佳答案

快速浏览ES代码库后,我认为他们在BulkProcessor#add(ActionRequest)中删除了该方法(5.2.0)。

Flink在内部使用该方法。不幸的是,我担心Flink连接器现在无法与ES 5.3+连接器一起使用。

关于scala - flink 1.3.1 elasticsearch 5.5.1。 ElasticsearchSinkFunction失败,并出现java.lang.NoSuchMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45555420/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com