小编Cri*_*ran的帖子

kafka:无法建立与节点 1001 的连接。经纪人可能不可用

我在 CentOS 7.9 中使用以下命令启动了 Zookeeper 和 kafka 容器:

docker run -it -d --net=sup-network  --name zookeeper --ip 200.100.0.140 -p 2181:2181  zookeeper:3.7.0

docker run -it --net=sup-network --name kafka -p 9092:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=200.100.0.140:2181 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://200.100.0.141:9092 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-d bitnami/kafka:3.0.0
Run Code Online (Sandbox Code Playgroud)

200.100.0.xxx ips 在 docker swarm 中定义。

但卡夫卡始终给出以下日志:

 WARN [Controller id=1001, targetBrokerId=1001] Connection to node 1001 (/200.100.0.141:9092) 
could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
Run Code Online (Sandbox Code Playgroud)

如何解决?


附加信息:

我删除了-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://200.100.0.141:9092 \,然后kafka没有提供Broker may not be …

apache-kafka docker

5
推荐指数
0
解决办法
6867
查看次数

协程似乎并不比 JVM 线程占用更少的资源

我做了一个基准测试(参考答案来测试线程池中coroutiens和线程之间的内存使用情况:

val COUNT = 4_000

val executor: Executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())// 12 cores on my machine
 fun main(array: Array<String>)  = runBlocking{
     val latch = CountDownLatch(COUNT)
     val start = System.currentTimeMillis()
     repeat(COUNT) {
         launch(Dispatchers.Default) {
             testByCoroutine(latch)
         }
     }
     latch.await()
     println("total: " + (System.currentTimeMillis() - start))


     // testByThreadPool()
 }


fun testByThreadPool() {
    val latch = CountDownLatch(COUNT)
    val start = System.currentTimeMillis()
    for (i in 0..<COUNT) {
        executor.execute {
            val num: Int = request1()
            println(request2(num))
            latch.countDown()
        }
    }
    try {
        latch.await()
    } catch (e: …
Run Code Online (Sandbox Code Playgroud)

java multithreading coroutine kotlin kotlin-coroutines

1
推荐指数
1
解决办法
163
查看次数