CodisLabs / jodis

A java client for codis based on Jedis and Curator
MIT License
218 stars 97 forks source link

org.apache.curator.CuratorConnectionLossException: KeeperErrorCode = ConnectionLoss #7

Closed rayi27 closed 8 years ago

rayi27 commented 8 years ago

客户端开启多个线程获取多个pool时出现异常,JedisResourcePool jedisPool = RoundRobinJedisPool.create().curatorClient("localhost:2181", 30000) .zkProxyDir("/zk/codis/db_kok/proxy").build(); 异常信息:org.apache.curator.CuratorConnectionLossException: KeeperErrorCode = ConnectionLoss at org.apache.curator.ConnectionState.checkTimeouts(ConnectionState.java:198) [curator-client-2.5.0.jar:na] at org.apache.curator.ConnectionState.getZooKeeper(ConnectionState.java:88) [curator-client-2.5.0.jar:na] at org.apache.curator.CuratorZookeeperClient.getZooKeeper(CuratorZookeeperClient.java:115) [curator-client-2.5.0.jar:na] at org.apache.curator.utils.EnsurePath$InitialHelper$1.call(EnsurePath.java:148) [curator-client-2.5.0.jar:na] at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107) [curator-client-2.5.0.jar:na] at org.apache.curator.utils.EnsurePath$InitialHelper.ensure(EnsurePath.java:140) [curator-client-2.5.0.jar:na] at org.apache.curator.utils.EnsurePath.ensure(EnsurePath.java:99) [curator-client-2.5.0.jar:na] at org.apache.curator.framework.recipes.cache.PathChildrenCache.rebuild(PathChildrenCache.java:320) [curator-recipes-2.5.0.jar:na] at org.apache.curator.framework.recipes.cache.PathChildrenCache.start(PathChildrenCache.java:297) [curator-recipes-2.5.0.jar:na] at com.wandoulabs.jodis.RoundRobinJedisPool.(RoundRobinJedisPool.java:239) [jodis-0.2.2.jar:na] at com.wandoulabs.jodis.RoundRobinJedisPool.(RoundRobinJedisPool.java:64) [jodis-0.2.2.jar:na] at com.wandoulabs.jodis.RoundRobinJedisPool$Builder.build(RoundRobinJedisPool.java:479) [jodis-0.2.2.jar:na] 求解决办法

rayi27 commented 8 years ago

客户端测试的时候开了100个线程。每个线程都会去执行上面代码。然后就会出现以上异常

yangzhe1991 commented 8 years ago

为何需要“客户端开启多个线程获取多个pool”。。。每个pool就是一个线程池了

Apache9 commented 8 years ago

zookeeper默认对单机来的连接总数是有限制的,默认应该是10,你100个线程肯定超了连不上。那个Pool本身是线程安全的,不同线程可以用同一个Pool。

谢谢