版本:
"org.apache.storm" % "storm-kafka-client" % "1.2.1"
"org.apache.storm" % "storm-core" % "1.2.1" % "compile"
Kafka: 0.10.1.0
我从我的kafka喷口收到在localCluster中运行的错误/警告:
2018-06-28 00:00:34,930 AppInfoParser [INFO] Kafka version : 0.10.1.0
2018-06-28 00:00:34,930 AppInfoParser [INFO] Kafka commitId : 3402a74efb23d1d4
2018-06-28 00:00:34,931 WARN NetworkClient [Thread-40-KafkaSpout-executor[12 12]] Bootstrap broker ip1:9092 disconnected
2018-06-28 00:00:35,092 WARN NetworkClient [Thread-40-KafkaSpout-executor[12 12]] Bootstrap broker ip2:9092 disconnected
2018-06-28 00:00:35,251 WARN NetworkClient [Thread-40-KafkaSpout-executor[12 12]] Bootstrap broker ip3:9092 disconnected
2018-06-28 00:00:35,524 WARN NetworkClient [Thread-40-KafkaSpout-executor[12 12]] Bootstrap broker ip4:9092 disconnected
2018-06-28 00:00:35,629 WARN NetworkClient [Thread-40-KafkaSpout-executor[12 12]] Bootstrap broker ip5:9092 disconnected
2018-06-28 00:00:35,822 WARN NetworkClient [Thread-40-KafkaSpout-executor[12 12]] Bootstrap broker ip6:9092 disconnected
2018-06-28 00:00:35,927 WARN NetworkClient [Thread-40-KafkaSpout-executor[12 12]] Bootstrap broker ip7:9092 disconnected
这是Kafka Spout的代码:
private def getKafkaSpoutConfig(source: TopologyConfig) = {
System.clearProperty("java.security.auth.login.config") //tried this after getting error, no impact
KafkaSpoutConfig.builder("ip1:9092,ip2:9092,ip3:9092,.....,ip10:9092", "topicName")
.setProp(ConsumerConfig.GROUP_ID_CONFIG, "myConsumerGroup")
.setProp(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArrayDeserializer")
.setOffsetCommitPeriodMs(100)
.setFirstPollOffsetStrategy(KafkaSpoutConfig.FirstPollOffsetStrategy.UNCOMMITTED_LATEST)
.setMaxUncommittedOffsets(1000000)
.build()
}
def getKafkaSpout(source: TopologyConfig) = new KafkaSpout(getKafkaSpoutConfig(source: TopologyConfig))
在调试时,我看到以下是此错误的堆栈跟踪:
maybeHandleDisconnection:568, NetworkClient$DefaultMetadataUpdater (org.apache.kafka.clients)
processDisconnection:396, NetworkClient (org.apache.kafka.clients)
handleDisconnections:464, NetworkClient (org.apache.kafka.clients)
poll:270, NetworkClient (org.apache.kafka.clients)
poll:232, ConsumerNetworkClient (org.apache.kafka.clients.consumer.internals)
poll:195, ConsumerNetworkClient (org.apache.kafka.clients.consumer.internals)
getTopicMetadata:253, Fetcher (org.apache.kafka.clients.consumer.internals)
partitionsFor:1318, KafkaConsumer (org.apache.kafka.clients.consumer)
getFilteredTopicPartitions:57, NamedTopicFilter (org.apache.storm.kafka.spout)
refreshAssignment:54, ManualPartitionSubscription (org.apache.storm.kafka.spout)
subscribe:49, ManualPartitionSubscription (org.apache.storm.kafka.spout)
subscribeKafkaConsumer:657, KafkaSpout (org.apache.storm.kafka.spout)
activate:648, KafkaSpout (org.apache.storm.kafka.spout)
invoke:484, util$async_loop$fn__557 (org.apache.storm)
run:22, AFn (clojure.lang)
run:748, Thread (java.lang)
相同的代码适用于一个Kafka设置,但是对于相同版本的kafka的另一个设置,它开始出现上述错误。
作为评论,我尝试连接到Kafka的端口9092,我能够这样做:
➜ git:(myBranch) ✗ telnet ipn 9092
Trying ipn...
Connected to my-kafka-app-396433.
Escape character is '^]'.
答案 0 :(得分:0)
发生这种情况是因为kafka的某些版本不匹配。在使用kafka-clients版本0.10.0.1
选择和执行代码时,已安装的kafka版本为0.10.1.0
。
发生这种情况的原因是storm-core
具有kafka-clients
版本的依赖项:0.10.1.0
,可以覆盖它,我这样做了,但是某种程度上在sbt中并没有适当地排除它。经过一些排列后,它开始工作,最终依赖项看起来像这样:
Seq("org.apache.storm" % "storm-core" % "1.2.1" % "compile" excludeAll(
ExclusionRule(organization = "org.apache.logging.log4j"),
ExclusionRule(organization = "org.apache.kafka", artifact = "kafka-clients"),
ExclusionRule(organization = "ring-cors"),
ExclusionRule(organization = "org.slf4j", artifact = "*"),
ExclusionRule(organization = "log4j", artifact = "*"),
ExclusionRule(organization = "javax", artifact = "*"),
ExclusionRule(organization = "javax.servlet", artifact="*")
)),
"org.apache.kafka" % "kafka-clients" % "0.10.0.1" excludeAll(
ExclusionRule(organization = "org.slf4j", name = "slf4j-log4j12"),
ExclusionRule(organization = "log4j"),
ExclusionRule(organization = "javax.servlet", artifact="*")
),
"org.apache.storm" % "storm-kafka-client" % "1.2.1" excludeAll(
ExclusionRule(organization = "org.apache.kafka", artifact = "*"),
ExclusionRule(organization = "org.apache.logging.log4j"),
ExclusionRule(organization = "ring-cors"),
ExclusionRule(organization = "org.apache.logging.log4j", artifact = "*"),
ExclusionRule(organization = "org.slf4j", artifact = "*"),
ExclusionRule(organization = "log4j", artifact = "*")
),