org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /cu

java基于curator的zookeeper分布式锁报错信息:

org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /curator/lock/_c_122028e9-b21b-4c19-9378-ce14f34ec3cf-lock-
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:103)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
	at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
	at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:225)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:237)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
	at com.itstyle.seckill.distributedlock.zookeeper.CuratorUtil$1.run(CuratorUtil.java:41)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /curator/lock/_c_4b5ae0b8-aeb1-4928-adb2-a4cfc6db7e7c-lock-
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:103)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
	at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
	at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:225)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:237)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
	at com.itstyle.seckill.distributedlock.zookeeper.CuratorUtil$1.run(CuratorUtil.java:41)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
12:45:35.552 [main-EventThread] INFO org.apache.curator.framework.state.ConnectionStateManager - State change: SUSPENDED
12:45:35.553 [pool-3-thread-2] DEBUG org.apache.curator.RetryLoop - Retry-able exception received
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /curator/lock/_c_2137426e-c0cf-4c5d-845e-1606fc863694-lock-
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
	at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
	at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:225)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:237)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
	at com.itstyle.seckill.distributedlock.zookeeper.CuratorUtil$1.run(CuratorUtil.java:41)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
12:45:35.553 [pool-3-thread-3] DEBUG org.apache.curator.RetryLoop - Retry-able exception received
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /curator/lock/_c_f0ee3b69-a3bf-4cb1-b362-0d3fd5d1879e-lock-
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
	at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
	at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:225)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:237)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
	at com.itstyle.seckill.distributedlock.zookeeper.CuratorUtil$1.run(CuratorUtil.java:41)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
12:45:35.553 [pool-3-thread-5] DEBUG org.apache.curator.RetryLoop - Retry-able exception received
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /curator/lock/_c_124e7134-c83a-4dbf-b1f2-162c9a116f6e-lock-
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
	at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
	at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:225)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:237)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
	at com.itstyle.seckill.distributedlock.zookeeper.CuratorUtil$1.run(CuratorUtil.java:41)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
12:45:36.553 [pool-3-thread-2] DEBUG org.apache.curator.RetryLoop - Retrying operation
12:45:36.558 [pool-3-thread-3] DEBUG org.apache.curator.RetryLoop - Retrying operation
12:45:36.560 [pool-3-thread-5] DEBUG org.apache.curator.RetryLoop - Retrying operation
12:45:36.842 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Opening socket connection to server 172.20.42.10/172.20.42.10:2181. Will not attempt to authenticate using SASL (unknown error)
12:45:36.844 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Socket connection established, initiating session, client: /172.20.10.23:56687, server: 172.20.42.10/172.20.42.10:2181
12:45:36.844 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Session establishment request sent on 172.20.42.10/172.20.42.10:2181
12:45:36.856 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Session establishment complete on server 172.20.42.10/172.20.42.10:2181, sessionid = 0x102f04dff350007, negotiated timeout = 40000
12:45:36.857 [main-EventThread] DEBUG org.apache.curator.ConnectionState - Negotiated session timeout: 40000
12:45:36.857 [main-EventThread] INFO org.apache.curator.framework.state.ConnectionStateManager - State change: RECONNECTED
12:45:36.857 [main-EventThread] DEBUG org.apache.curator.framework.imps.CuratorFrameworkImpl - Clearing sleep for 0 operations
12:45:36.862 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:/zookeeper/config serverPath:/zookeeper/config finished:false header:: 8,4  replyHeader:: 8,12884902044,-101  request:: '/zookeeper/config,T  response::  
12:45:36.873 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:null serverPath:null finished:false header:: 9,8  replyHeader:: 9,12884902044,0  request:: '/curator/lock,F  response:: v{} 
12:45:36.873 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:null serverPath:null finished:false header:: 10,8  replyHeader:: 10,12884902044,0  request:: '/curator/lock,F  response:: v{} 
12:45:36.874 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:null serverPath:null finished:false header:: 11,8  replyHeader:: 11,12884902044,0  request:: '/curator/lock,F  response:: v{} 
org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /curator/lock/_c_124e7134-c83a-4dbf-b1f2-162c9a116f6e-lock-
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:103)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
	at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
	at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:225)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:237)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
	at com.itstyle.seckill.distributedlock.zookeeper.CuratorUtil$1.run(CuratorUtil.java:41)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /curator/lock/_c_f0ee3b69-a3bf-4cb1-b362-0d3fd5d1879e-lock-
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:103)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
	at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
	at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:225)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:237)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
	at com.itstyle.seckill.distributedlock.zookeeper.CuratorUtil$1.run(CuratorUtil.java:41)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
12:45:36.951 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:null serverPath:null finished:false header:: 12,15  replyHeader:: 12,-1,-6  request:: '/curator/lock/_c_124e7134-c83a-4dbf-b1f2-162c9a116f6e-lock-,#3137322e32302e31302e3233,v{s{31,s{'world,'anyone}}},3  response::  
12:45:36.952 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:null serverPath:null finished:false header:: 13,15  replyHeader:: 13,-1,-6  request:: '/curator/lock/_c_f0ee3b69-a3bf-4cb1-b362-0d3fd5d1879e-lock-,#3137322e32302e31302e3233,v{s{31,s{'world,'anyone}}},3  response::  
12:45:36.952 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Unable to read additional data from server sessionid 0x102f04dff350007, likely server has closed socket, closing socket connection and attempting reconnect
12:45:37.053 [main-EventThread] INFO org.apache.curator.framework.state.ConnectionStateManager - State change: SUSPENDED
12:45:37.053 [pool-3-thread-2] DEBUG org.apache.curator.RetryLoop - Retry-able exception received
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /curator/lock/_c_2137426e-c0cf-4c5d-845e-1606fc863694-lock-
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
	at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
	at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:225)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:237)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
	at com.itstyle.seckill.distributedlock.zookeeper.CuratorUtil$1.run(CuratorUtil.java:41)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
12:45:38.330 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Opening socket connection to server 172.20.42.10/172.20.42.10:2181. Will not attempt to authenticate using SASL (unknown error)
12:45:38.335 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Socket connection established, initiating session, client: /172.20.10.23:56688, server: 172.20.42.10/172.20.42.10:2181
12:45:38.335 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Session establishment request sent on 172.20.42.10/172.20.42.10:2181
12:45:38.339 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Session establishment complete on server 172.20.42.10/172.20.42.10:2181, sessionid = 0x102f04dff350007, negotiated timeout = 40000
12:45:38.339 [main-EventThread] DEBUG org.apache.curator.ConnectionState - Negotiated session timeout: 40000
12:45:38.340 [main-EventThread] INFO org.apache.curator.framework.state.ConnectionStateManager - State change: RECONNECTED
12:45:38.340 [main-EventThread] DEBUG org.apache.curator.framework.imps.CuratorFrameworkImpl - Clearing sleep for 0 operations
12:45:38.342 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:/zookeeper/config serverPath:/zookeeper/config finished:false header:: 15,4  replyHeader:: 15,12884902044,-101  request:: '/zookeeper/config,T  response::  
12:45:40.054 [pool-3-thread-2] DEBUG org.apache.curator.RetryLoop - Retrying operation
12:45:40.056 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:null serverPath:null finished:false header:: 16,8  replyHeader:: 16,12884902044,0  request:: '/curator/lock,F  response:: v{} 
12:45:40.075 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:null serverPath:null finished:false header:: 17,15  replyHeader:: 17,-1,-6  request:: '/curator/lock/_c_2137426e-c0cf-4c5d-845e-1606fc863694-lock-,#3137322e32302e31302e3233,v{s{31,s{'world,'anyone}}},3  response::  
12:45:40.076 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Unable to read additional data from server sessionid 0x102f04dff350007, likely server has closed socket, closing socket connection and attempting reconnect
org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /curator/lock/_c_2137426e-c0cf-4c5d-845e-1606fc863694-lock-
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:103)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
	at org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver.createsTheLock(StandardLockInternalsDriver.java:54)
	at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:225)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:237)
	at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:108)
	at com.itstyle.seckill.distributedlock.zookeeper.CuratorUtil$1.run(CuratorUtil.java:41)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
12:45:40.177 [main-EventThread] INFO org.apache.curator.framework.state.ConnectionStateManager - State change: SUSPENDED
12:45:42.068 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Opening socket connection to server 172.20.42.10/172.20.42.10:2181. Will not attempt to authenticate using SASL (unknown error)
12:45:42.072 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Socket connection established, initiating session, client: /172.20.10.23:56689, server: 172.20.42.10/172.20.42.10:2181
12:45:42.073 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Session establishment request sent on 172.20.42.10/172.20.42.10:2181
12:45:42.077 [main-SendThread(172.20.42.10:2181)] INFO org.apache.zookeeper.ClientCnxn - Session establishment complete on server 172.20.42.10/172.20.42.10:2181, sessionid = 0x102f04dff350007, negotiated timeout = 40000
12:45:42.077 [main-EventThread] DEBUG org.apache.curator.ConnectionState - Negotiated session timeout: 40000
12:45:42.077 [main-EventThread] INFO org.apache.curator.framework.state.ConnectionStateManager - State change: RECONNECTED
12:45:42.078 [main-EventThread] DEBUG org.apache.curator.framework.imps.CuratorFrameworkImpl - Clearing sleep for 0 operations
12:45:42.081 [main-SendThread(172.20.42.10:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply sessionid:0x102f04dff350007, packet:: clientPath:/zookeeper/config serverPath:/zookeeper/config finished:false header:: 18,4  replyHeader:: 18,12884902044,-101  request:: '/zookeeper/config,T  response::  

CuratorUtil.java项目源码:

package com.itstyle.seckill.distributedlock.zookeeper;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.curator.retry.ExponentialBackoffRetry;
/**
 * 基于curator的zookeeper分布式锁
 * 这里我们开启5个线程,每个线程获取锁的最大等待时间为5秒,为了模拟具体业务场景,方法中设置4秒等待时间。
 * 开始执行main方法,通过ZooInspector监控/curator/lock下的节点如下图:
 */
public class CuratorUtil {
    private static String address = "172.20.42.10:2181";
	
    public static void main(String[] args) {
		//1、重试策略:初试时间为1s 重试3次
		RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
		//2、通过工厂创建连接
		CuratorFramework client = CuratorFrameworkFactory.newClient(address, retryPolicy);
        //3、开启连接
        client.start();
        //4 分布式锁
        final InterProcessMutex mutex = new InterProcessMutex(client, "/curator/lock"); 
        //读写锁
        //InterProcessReadWriteLock readWriteLock = new InterProcessReadWriteLock(client, "/readwriter");
        
        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5);
        
        for (int i = 0; i < 5; i++) {
            fixedThreadPool.submit(new Runnable() {
                @Override
                public void run() {
                	boolean flag = false;
                	try {
                		//尝试获取锁,最多等待5秒
                		flag = mutex.acquire(5, TimeUnit.SECONDS);
                		Thread currentThread = Thread.currentThread();
                		if(flag){
                			System.out.println("线程"+currentThread.getId()+"获取锁成功");
                		}else{
                			System.out.println("线程"+currentThread.getId()+"获取锁失败");
                		}
                		//模拟业务逻辑,延时4秒
                		Thread.sleep(4000);
					} catch (Exception e) {
						e.printStackTrace();
					} finally{
						if(flag){
							try {
								mutex.release();
							} catch (Exception e) {
								e.printStackTrace();
							}
						}
					}
                }
            });
        }
	}
}

原pom.xml:

		
		 
		    org.apache.curator 
		    curator-recipes
		    4.0.1
		

解决办法
修改pom.xml,从curator中剔除zookeeper依赖,单独引入zookeeper依赖。

		 
		    org.apache.curator 
		    curator-recipes
		    4.0.1
			
				
					org.apache.zookeeper
					zookeeper
				
			
		
	  
		  org.apache.zookeeper
		  zookeeper
		  3.4.13
	  

你可能感兴趣的:(工具类)