首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode =/ ConnectionLoss /test3_node

org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode =/ ConnectionLoss /test3_node
EN

Stack Overflow用户
提问于 2016-08-31 10:45:02
回答 1查看 8.9K关注 0票数 0

我使用Curator客户端操作zookeeper服务器,但如果我同时启动10个线程来操作zookeeper服务器,总是失败。

如果线程数少于6,它就能正常工作,当连接丢失时,我必须重新启动zookeeper服务器。有人知道如何解决这个问题吗?

代码语言:javascript
复制
curatorClient = CuratorFrameworkFactory.builder().connectString(zkAddress).sessionTimeoutMs(Constant.ZK_SESSION_TIMEOUT).connectionTimeoutMs(Constant.ZK_CONNECTION_TIMEOUT).retryPolicy(retryPolicy).build();
curatorClient.start();

我执行了以下操作: curatorClient.create().inbackground(new callback(){}).forPath();curatorClient.delete().inbackground(new callback(){}).forPath();lock.acquire();..

错误:

代码语言:javascript
复制
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode    
= ConnectionLoss for /lock/test3_node
at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1472)
at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1500)
at  

org.apache.curator.framework.imps.CreateBuilderImpl$12.call(CreateBuilderImpl.java:766)
at org.apache.curator.framework.imps.CreateBuilderImpl$12.call(CreateBuilderImpl.java:758)
at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107)
at org.apache.curator.framework.imps.CreateBuilderImpl.findProtectedNodeInForeground(CreateBuilderImpl.java:754)
at org.apache.curator.framework.imps.CreateBuilderImpl.access$1300(CreateBuilderImpl.java:44)
at org.apache.curator.framework.imps.CreateBuilderImpl$11.call(CreateBuilderImpl.java:713)
at org.apache.curator.framework.imps.CreateBuilderImpl$11.call(CreateBuilderImpl.java:703)
at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107)
at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:699)
at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:477)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:467)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:447)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:44)
at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:216)
at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:232)
at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
at 
$InsertQueueCallBack.processResult(CuratorUtil.java:614)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.sendToBackgroundCallback(CuratorFrameworkImpl.java:743)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.processBackgroundOperation(CuratorFrameworkImpl.java:520)
at org.apache.curator.framework.imps.CreateBuilderImpl.sendBackgroundResponse(CreateBuilderImpl.java:565)
at org.apache.curator.framework.imps.CreateBuilderImpl.access$900(CreateBuilderImpl.java:44)
at org.apache.curator.framework.imps.CreateBuilderImpl$6.processResult(CreateBuilderImpl.java:524)
at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:599)
at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:498)
.....
Connection timed out for connection string (slc03nwh.us.oracle.com:2181) and timeout (15000) / elapsed (5380)
org.apache.curator.CuratorConnectionLossException: KeeperErrorCode = ConnectionLoss
at org.apache.curator.ConnectionState.checkTimeouts(ConnectionState.java:195)
at org.apache.curator.ConnectionState.getZooKeeper(ConnectionState.java:87)
at org.apache.curator.CuratorZookeeperClient.getZooKeeper(CuratorZookeeperClient.java:115)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.performBackgroundOperation(CuratorFrameworkImpl.java:821)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.backgroundOperationsLoop(CuratorFrameworkImpl.java:807)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.access$300(CuratorFrameworkImpl.java:63)
at org.apache.curator.framework.imps.CuratorFrameworkImpl$4.call(CuratorFrameworkImpl.java:267)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

然后添加ConnectionStateListener和UnhandledErrorListener,我得到了以下信息:

代码语言:javascript
复制
 newState.isConnected()false
 SUSPENDED
 newState.isConnected()true
 RECONNECTED
 newState.isConnected()lost
 RECONNECTED

  unhandledErrorListener:Background operation retry gave up
  Background retry gave up
EN

回答 1

Stack Overflow用户

发布于 2016-08-31 12:23:31

我尝试使用单例实例创建客户端,并将连接超时设置得更长。这个问题已经消失了。

但是我没有找到导致连接丢失错误的根本原因。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39239957

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档