Object waiter = new Object();
ZooKeeper zkClient;
try
{
synchronized (waiter) {
final CountDownLatch connectedSignal = new CountDownLatch(1);
zkClient = new ZooKeeper("zk地址"
, 1000, event -> {
if (event.getState() == Watcher.Event.KeeperState.SyncConnected) {
connectedSignal.countDown();
System.out.println( "Hello end!" );
}
});
connectedSignal.await();
}
}
catch(Exception g)
{
g.printStackTrace();
}
再zookeeper回调event的时候收不到,当打开debug的时候爆
[DEBUG] [traceId:] [gcatTraceId:] [main-SendThread(********)] org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:210) - Ignoring exception during shutdown output
java.net.SocketException: Socket is not connected
at java.base/sun.nio.ch.Net.translateToSocketException(Net.java:181)
at java.base/sun.nio.ch.Net.translateException(Net.java:217)
at java.base/sun.nio.ch.Net.translateException(Net.java:223)
at java.base/sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:397)
at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:207)
at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1250)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1174)
Caused by: java.nio.channels.NotYetConnectedException: null
at java.base/sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:1044)
at java.base/sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:395)
... 3 common frames omitted
原文地址:https://blog.csdn.net/u010191034/article/details/127568621
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_28226.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。