├── CHANGELOG.md
├── LICENSE.txt
├── NOTICE.txt
├── OSSMETADATA
├── README.md
├── pom.xml
└── src
├── main
└── java
│ └── com
│ └── netflix
│ └── curator
│ └── x
│ └── zkclientbridge
│ └── CuratorZKClientBridge.java
└── test
└── java
└── org
└── I0Itec
└── zkclient
├── AbstractBaseZkClientTest.java
├── AbstractConnectionTest.java
├── ContentWatcherTest.java
├── DeferredGatewayStarter.java
├── DistributedQueueTest.java
├── InMemoryConnectionTest.java
├── MemoryZkClientTest.java
├── ServerZkClientTest.java
├── TestUtil.java
├── ZkClientSerializationTest.java
├── ZkConnectionTest.java
├── testutil
├── ZkPathUtil.java
└── ZkTestSystem.java
└── util
└── ZkPathUtilTest.java
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | END OF LIFE
2 | ===============
3 |
4 | Curator has move to Apache. Please see: http://curator.apache.incubator.org
5 |
6 | The previous Netflix branch is now in a branch named "archive".
7 |
8 | 2.0.0 - June 3, 2013
9 | ====================
10 | * Possible final release - removed code branches that are now in Apache. Added
11 | a version of ZkClient bridge that uses Apache Curator.
12 |
13 | 1.3.4 - xxxxxxxxxxxxx
14 | =====================
15 | * Issue 257: Fixed a race condition in LeaderLatch that cause the recipe to create
16 | two nodes in some edge cases.
17 |
18 | 1.3.3 - March 6, 2013
19 | =====================
20 | * Issue 250: Restore support for passing null to usingWatcher().
21 |
22 | * Issue 251: Allow a custom Executor Service to be used for PathChildrenCache.
23 |
24 | * DistributedDoubleBarrier wasn't handling wait expiration correctly and was sending negative
25 | numbers to wait().
26 |
27 | * Issue 254: Check that executorService isn't null before closing.
28 |
29 | * Pull 258: Fix bad performing use of Guava's transform.
30 |
31 | 1.3.2 - February 6, 2013
32 | ========================
33 | * MAJOR BUG FIX - Issue 232: ZooKeeper guarantees that "A watch object, or function/context pair, will only
34 | be triggered once for a given notification." Curator was breaking this guarantee by internally creating a
35 | new Watcher object each time one was needed. This is now fixed and ZooKeeper's guarantee is restored. Big
36 | thanks to user barkbay for his persistence and help on this.
37 |
38 | * Issue 247: POST_INITIALIZED_EVENT wasn't correctly handling an initially empty node.
39 |
40 | * Issue 245: Auth info specified in the CuratorFrameworkFactory.Builder was not being re-set in cases
41 | where the internal ZooKeeper handle was recreated. i.e. if the cluster has issues auth info would be lost.
42 |
43 | * The default watcher in the ZooKeeper handle is now cleared before the ZooKeeper handle is closed. This avoids
44 | an edge case where events meant for the old ZooKeeper handle get processed.
45 |
46 | 1.3.1 - January 28, 2013
47 | ========================
48 | * Tightened up a possible race deep inside the connection management.
49 |
50 | * PathChildrenCache.rebuild() and PathChildrenCache.rebuildNode() were not handling deleted nodes.
51 |
52 | * Issue 237: New feature. PathChildrenCache now optionally posts an event when the initial cache is
53 | populated. To accommodate this behavior there is a new version of start() that takes an enum. See the
54 | Javadoc for each value. For this new behavior, use StartMode.POST_INITIALIZED_EVENT. Once the cache
55 | is initialized a PathChildrenCacheEvent.Type.INITIALIZED will be posted. Huge thanks to user philflesh
56 | for the idea and co-implementation.
57 |
58 | 1.3.0 - January 10, 2013
59 | ========================
60 | * MAJOR CHANGE (thus a version bump): I'd always thought that if the client is disconnected from the server
61 | long enough then an Expired event would be generated. Testing, however, shows this not to be the case. I believe
62 | it's related to ZOOKEEPER-1159. The behavior associated with this is that if the clients lost connection to the
63 | cluster for longer than the session expiration they would _never_ be able to reconnect. The connection would
64 | be permanently lost. Many users were seeing this as endless log messages indicating "Connection timed out
65 | for connection...". As a workaround, in 1.3.0+ when the Curator state changes to LOST, a flag will be set
66 | so that the next time Curator needs to get the ZooKeeper instance, the current instance will be closed and a new
67 | ZooKeeper instance will be allocated (as if the session had expired).
68 |
69 | * Added checks for illegal namespaces.
70 |
71 | * Issue 232: NodeCache wasn't handling server connection issues well. It would repeatedly execute checkExists()
72 | with a watcher causing the heap to fill with watcher objects.
73 |
74 | * Issue 233: An internal idiom being used to create an EnsurePath instance with the parent of a passed in path
75 | wasn't correct. Due to an unfortunate implementation of ZKPaths.PathAndNode (mea culpa) the root path is specified
76 | differently than non-root paths. To work around this, I added a method to EnsurePath - excludingLast() - that
77 | can be used instead of the idiom.
78 |
79 | * Issue 230: Added a filter to control which IP address are returned by ServiceInstanceBuilder.getAllLocalIPs().
80 | Set the filter via ServiceInstanceBuilder.setLocalIpFilter().
81 |
82 | 1.2.6 - January 1, 2013
83 | =======================
84 | * Issue 214: Added rebuildNode method to PathChildrenCache.
85 |
86 | * Added a NodeCache to compliment the PathChildrenCache. The doc is here:
87 | https://github.com/Netflix/curator/wiki/Node-Cache
88 |
89 | * Creating nodes in background wasn't handling createParentsIfNeeded.
90 |
91 | * Issue 216: Rewrote LeaderLatch to better handle connection/server instability. At the same time, made
92 | most of the calls async which will help concurrency and performance.
93 |
94 | * Issue 217: DistributedAtomicLong (et al) should use ensurePath internally to be consistent with
95 | other recipes.
96 |
97 | * Issue 220: When creating a ServiceCacheImpl, a PathChildrenCache is created. The cache loads all existing services,
98 | but because preloading does not create events, ServiceCacheImpl never notices this. ServiceCacheImpl.getInstances()
99 | will return an empty list.
100 |
101 | * Issue 221: client.getACL().forPath("/") throws a NullPointerException, because the Zookeeper
102 | API expects a Stat, but GetACLBuilderImpl initializes responseStat to null.
103 |
104 | * Issue 222: Counter and log messages reversed in RetryLoop.takeException().
105 |
106 | * New feature: CuratorTempFramework. Temporary CuratorFramework instances are meant for single requests to
107 | ZooKeeper ensembles over a failure prone network such as a WAN. The APIs available from CuratorTempFramework
108 | are limited. Further, the connection will be closed after a period of inactivity. Based on an idea mentioned in a
109 | post by Camille Fournier: http://whilefalse.blogspot.com/2012/12/building-global-highly-available.html - details
110 | here: https://github.com/Netflix/curator/wiki/Temporary-Framework
111 |
112 | * Issue 224: ExponentialBackoffRetry was not protected against edge-cases where a too big maxRetries argument
113 | was used. It now also incorporates a maxSleep value.
114 |
115 | 1.2.5 - November 27, 2012
116 | =========================
117 | * Depend on ZooKeeper 3.4.5
118 |
119 | * Issue 177: PathChildrenCache wasn't shutting down the executor when closed. Also, reworked the event
120 | queue to avoid potential herding of messages in unstable conditions. The herding could result in runaway
121 | memory allocation as reported in the issue. NOTE: due to this change, the PathChildrenCache node
122 | refresh code and the PathChildrenCacheListener notification threads have been merged. Do not block
123 | for very long inside of your PathChildrenCacheListener or you will prevent the cache from getting
124 | updated.
125 |
126 | * Issue 200: Post-creation services registered in ServiceDiscovery via registerService() were
127 | not being treated the same as the service passed in the constructor. Consequently they wouldn't get
128 | re-registered if there were connection problems.
129 |
130 | * Creating nodes withProtection() is now supported in the background. e.g.
131 | client.create().withProtection().inBackground()...
132 |
133 | * Added methods to InterProcessSemaphoreV2: setNodeData() and getParticipantNodes() and, to the Lease
134 | interface, getData().
135 |
136 | * Issue 205 - already started error message was misleading.
137 |
138 | * Pull 209 - Fixed inconsistent API for get() in DiscoveryResource.java - thanks to user dougnukem
139 |
140 | * Issue 211 - Added getState() method to CuratorFramework.
141 |
142 | * Issue 212 - There wasn't a good way to update the data for a Service. I've added a new method
143 | ServiceDiscovery: updateService(). NOTE: this method requires all ServiceDiscovery instances to be using
144 | version 1.2.5 of Curator. Internally, ServiceCache now uses PathChildrenCache.
145 |
146 | * Pull 210 - For convenience, a version of {@link DiscoveryContext} that uses any generic type as the
147 | payload. Thanks to user dougnukem.
148 |
149 | 1.2.4 - November 2, 2012
150 | ========================
151 | * Depend on ZooKeeper 3.4.4
152 |
153 | * Added a new Examples sub project - better late than never.
154 |
155 | * Guaranteed deletes were not working correctly if CuratorFramework.usingNamespace() was used.
156 |
157 | * I can't believe this has been like this for so long. The executor passed to listeners was never used.
158 | Doh!!! Major bug.
159 |
160 | * Issue 188: Display a meaningful message if the value node is corrupted
161 |
162 | * Issue 194: Initial sync() operation should occur immediately - like the change in 1.2.3 for all "background"
163 | operations.
164 |
165 | * Added support for ZK 3.4's read only operation as described here:
166 | http://wiki.apache.org/hadoop/ZooKeeper/GSoCReadOnlyMode - CuratorFrameworkFactory.Builder has a new
167 | method to set canBeReadOnly(). There is a new ConnectionState: READ_ONLY. Note: Your servers need to
168 | see a system property set "readonlymode.enabled" as true. This isn't documented anywhere that I can see.
169 |
170 | * Pull Request: 196 - Fix some issues with NamespaceFacade stemming from inconsistent state. Thanks to
171 | Answashe.
172 |
173 | * Issue 197 - Possible NullPointerException from ConnectionStateManager line 133 that is caused by a race
174 | condition. In CuratorFrameworkImpl, connectionStateManager.start() is called after client.start().
175 |
176 | 1.2.3 - October 6, 2012
177 | =======================
178 | * Previously, all background operations (i.e. when the inBackground() method is used)
179 | were put into a queue and processed in an internal thread. Curator does this to handle retries in
180 | background operations. This can be improved, however. The first time the background operation is
181 | executed the ZooKeeper method can be called directly - without queuing. This will get the operation
182 | into ZooKeeper immediately and will help prevent Curator's internal queue from backing up.
183 |
184 | * Issue 173: The DistributedQueue (and, thus, all the other queue recipes) was unnecessarily
185 | calling getChildren (with a watch) after each group of children was processed. It can just as easily
186 | wait for the internal cache to get its watch notified. This change creates an edge case, though,
187 | for ErrorMode.REQUEUE. Consequently, when in mode ErrorMode.REQUEUE the DistributedQueue now
188 | deletes the bad message and re-creates it. This required the use of ZooKeeper 3.4.x's transactions.
189 | So, if you use ErrorMode.REQUEUE you MUST be running ZooKeeper 3.4+.
190 |
191 | 1.2.2 - September 30, 2012
192 | ==========================
193 | * NOTE: The 1.0.x branch is not being released and has been deprecated. It was advised many versions
194 | ago that this was coming. So, here it is.
195 |
196 | * For ZKClient Bridge: 1. Previous method of sending initial connect event to ZKClient was
197 | unreliable; 2. Added an option to not close the curator instance
198 |
199 | * The default connection timeout has increased to 15 seconds. The default session timeout has
200 | increased to 60 seconds. These both can now be overridden via system properties:
201 | "curator-default-connection-timeout" and "curator-default-session-timeout".
202 |
203 | * Thanks to Ben Bangert: the InterProcessSemaphore waiting semantics weren't ideal. The nth
204 | waiting node has to wait for all nodes in front of it. I've improved this a bit. However, the algorithm
205 | used still suffers from potential out of order acquisition as well as potential starvation if a given client
206 | does not release a lease. Therefore, I'm deprecating InterProcessSemaphore in favor of the new
207 | InterProcessSemaphoreV2 which is based on Ben's algorithm.
208 |
209 | * Issue 164: The PathChildrenCache no longer clears its internal state when there is a connection
210 | issue. Consequently, the PathChildrenCacheEvent.Type values have changed. Instead of a RESET event
211 | there are events that match the ConnectionState events.
212 |
213 | 1.1.18/1.0.20 - September 4, 2012
214 | =================================
215 | * New extension project: "ZKClient Bridge". A bridge between Curator and ZKClient. Useful for
216 | projects that would like to use Curator but don't want to risk porting working code that uses
217 | ZKClient.
218 |
219 | 1.1.17/1.0.18 - August 30, 2012
220 | ===============================
221 | * Issue 132: If namespace is set in builder, getNamespace() does not return it
222 |
223 | * Issue 131: If connection is lost to the server, the ServiceInstance needs to re-register once
224 | there is a re-connection.
225 |
226 | * PathChildrenCache was not sending UPDATE messages when a node's data changed in the case
227 | that false was passed in the constructor for cacheData.
228 |
229 | * Merge 136 from wt: Add eclipse support to gradle.
230 |
231 | * Merge 137 from pbh101: ConnectionState declares IOException, never throws it
232 |
233 | 1.1.16/1.0.17 - August 2, 2012
234 | ==============================
235 | * Merge 114 from amuraru: Make sure internal executor services are not started until startup.
236 |
237 | * Merge 116 from samuelgmartinez: Fix for Issue 115: Wrong behaviour in LeaderLatch when a candidate
238 | loses connection
239 |
240 | * Issue 118: Ignore nonode exceptions when deleting lock path
241 |
242 | * Added a non-reentrant mutex: InterProcessSemaphoreMutex. This mutex doesn't have the threading
243 | restrictions that InterProcessMutex has. This should help with issues 75 and 117.
244 |
245 | * Merge 122 from ithaka that addresses Issue #98 - JsonInstanceSerializer does not deserialize
246 | custom payload types. IMPORTANT! This change introduces a breaking incompatibility with List payloads
247 | that will show up in environments that mix the old code and the new code. The new code will throw a
248 | JsonMappingException when it attempts to read a List payload written by the old code. The old code,
249 | when it reads a List payload generated by the new code, will generate a list with two elements,
250 | the first of which is the class name of the List type, and the second of which is the original list.
251 |
252 | * Issue 121: Apply bytecode rewriting to turn off JMX registrations to TestingServer as well as
253 | TestingCluster.
254 |
255 | * Issue 125: Use ScheduledThreadPoolExecutor instead of blocking threads that have period work.
256 |
257 | * Issue 126: Added getNamespace() method.
258 |
259 | * Issue 120: Additional check for connection loss in DistributedDoubleBarrier.
260 |
261 | 1.1.15/1.0.16 - July 14, 2012
262 | =============================
263 | * Added ChildReaper. This builds on the newly added Reaper. This utility monitors a single node
264 | and reaps empty children of that node.
265 |
266 | * Issue 107: The namespace wrapper was corrupting the path if the EnsurePath handler had an error.
267 | The best thing to do is let the code continue.
268 |
269 | * Issue 109: Make duplicate close() calls in CuratorFrameworkImpl a NOP instead of an error.
270 |
271 | * A more complete solution for background build-ups. The previous implementation did the retry sleep
272 | in the background process which ends up blocking ZooKeeper. During connection problems, this would
273 | cause ZooKeeper packets/watchers to back up. The new implementation uses a DelayQueue to simulate a
274 | sleep in the background. NOTE: this caused a change to the RetryPolicy APIs.
275 |
276 | 1.1.14/1.0.15 - July 6, 2012
277 | ============================
278 | * Merge #100 from bbeck: Added BoundedExponentialBackoffRetry.
279 |
280 | * Merge #102 from artemip: Added REAP_UNTIL_GONE mode to Reaper; Remove items from activePaths once
281 | they are deletes; Tests
282 |
283 | * Issue 99: The Double Barrier should allow more than the max to enter the barrier. I don't see any
284 | harm in this.
285 |
286 | * Issue 103: Important change/fix for ExhibitorEnsembleProvider: the previous implementation wasn't
287 | handling outages very well. The connectionString could get stuck to an old value if the list of
288 | Exhibitors all went down and couldn't be contacted. Now, a backup provider is required and the backup
289 | is used to update the list of Exhibitors should there be connection problems.
290 |
291 | * IMPORTANT NOTE: The 1.0.x branch of Curator is now end of life. There will be a few more releases
292 | but please migrate to the 1.1.x branch.
293 |
294 | 1.1.13/1.0.14 - June 25, 2012
295 | =============================
296 | * New queue features: a) bounded queues: use setMaxItems() in the builder to set an (approx) upper
297 | bound on the queue size; b) the builder now has an option to turn off background puts; c) queues now
298 | default to flushing remaining puts when closed - this can be controlled in the builder via
299 | finalFlushTime().
300 |
301 | * Issue 82: Generalized (and deprecated) nonNamespaceView() by adding the usingNamespace() method
302 | to allow getting a facade of the client that uses a specified namespace.
303 |
304 | * createParentsIfNeeded() should now perform better. Instead of "pre" checking, it now only does the
305 | check if KeeperException.NoNodeException is thrown. LockInternals now uses this method and, so, should
306 | perform a bit better.
307 |
308 | * Added a new utility: Reaper. This can be used to clean up parent lock nodes so that they don't
309 | stay around as garbage. See the Utilities wiki for details: https://github.com/Netflix/curator/wiki/Utilities
310 |
311 | * Unit tests should be a lot less noisy. A system property now turns off most internal error logging.
312 |
313 | * Issue 88: Children processor should wait for all nodes to be processed before fetching more items
314 |
315 | 1.1.12/1.0.13 - June 5, 2012
316 | ============================
317 | * Pull Request 81: Avoid invalid ipv6 localhost addresses
318 |
319 | * Another big bug: guaranteed deletions were not working with namespaces.
320 |
321 | 1.1.11/1.0.12 - June 1, 2012
322 | ============================
323 | * MAJOR BUG FIX!!!! Many of the Curator recipes rely on the internal class LockInternals. It has
324 | a bug that exhibits when the ZooKeeper cluster is unstable. There is an edge case that causes
325 | LockInternals to leak a node in the lock path that it is managing. This results in a deadlock. The
326 | leak occurs when retries are exhausted. NOTE: TestLockCleanlinessWithFaults now tests for this
327 | condition.
328 |
329 | * Added some missing combinations in the backgrounding API
330 |
331 | * Added QueueSharder utility. Due to limitations in ZooKeeper's transport layer, a single queue
332 | will break if it has more than 10K-ish items in it. This class provides a facade over multiple
333 | distributed queues. It monitors the queues and if any one of them goes over a threshold, a new
334 | queue is added. Puts are distributed amongst the queues.
335 |
336 | * Issue 80: Check for null data before decompressing data in getData().
337 |
338 | * Merge from user bbeck - enhanced the testing in-memory ZK server to handle some edge cases. A nice
339 | benefit is that it starts up faster. Thanks Brandon!
340 |
341 | 1.1.10/1.0.11 - May 17, 2012
342 | ============================
343 | * Generalized the ProtectedEphemeralSequential so that it works with any create mode.
344 | withProtectedEphemeralSequential() is deprecated in favor of the new method withProtection().
345 |
346 | * Update all uses of Preconditions to make sure they print a reasonable diagnostic message.
347 |
348 | * Added a new wrapped Watcher type that can throw exceptions as a convenience. The various
349 | usingWatcher() methods now can take CuratorWatcher instances.
350 |
351 | * InterProcessSemaphore and LeaderSelector weren't respecting the default bytes feature.
352 |
353 | * Make the default data for nodes be the local IP address. This helps in debugging and enables
354 | the deadlock analysis in Exhibitor.
355 |
356 | * New recipe added: DistributedDelayQueue
357 |
358 | 1.1.9/1.0.10 - May 10, 2012
359 | ===========================
360 | * Based on suggestion in Issue 67: Added new concept of UriSpec to the ServiceInstance in the
361 | Service Discovery Curator extension.
362 |
363 | * User "Pierre-Luc Bertrand" pointed out a potential race condition that would cause a SysConnected
364 | to get sent before an Expired. So, now I push the event to the parent watcher before resetting
365 | the connection in ConnectionState.process(WatchedEvent)
366 |
367 | * New Feature: SessionFailRetryLoop. Huge thanks to Pierre-Luc Bertrand for his work on this.
368 | SessionFailRetryLoop is a special type of retry loop that causes all Curator methods in a thread to
369 | fail when a session failure is detected. This enables sets of Curator operations that must be tied
370 | to a single ZooKeeper session. See Tech Note 3 for details: https://github.com/Netflix/curator/wiki/Tech-Note-3
371 |
372 | * Several users have expressed dissatisfaction with the LeaderSelector implementation - requiring a
373 | thread, etc. So, LeaderLatch has been added which behaves a lot like a CountDownLatch but for leader
374 | selection.
375 |
376 | 1.1.8/1.0.9 - April 17, 2012
377 | ============================
378 | * Added methods to compress data via create() and setData() and to decompress data via getData(). The
379 | compression is GZIP by default. You can change this via the CuratorFrameworkFactory by specifying
380 | a CompressionProvider.
381 |
382 | * Added ZookeeperFactory to the client as a testing aid.
383 |
384 | * Added ACLProvider to make it easier to use ACLs and recipes. It can be set via the
385 | CuratorFrameworkFactory builder.
386 |
387 | * Several of the recipes were creating new watcher objects each time they were needed when the watcher(s)
388 | can be created once in the constructor.
389 |
390 | * Issue 62: DistributedQueue wasn't handling getting interrupted very well. It was logging an error.
391 |
392 | * Issue 64: wasn't handling SASL events. Any non-SysConnected event was being treated as a disconnection.
393 |
394 | * Issue 65: Accepted a pull request that fixes a bug in RetryUntilElapsed.
395 |
396 | * Issue 66: Bad log string - needed String.format()
397 |
398 | 1.1.7/1.0.8 - April 6, 2012
399 | ===========================
400 | * Accepted a change so that testng is testCompile in Gradle
401 |
402 | * Rewrote TestingServer and TestingCluster based on work by Jeremie BORDIER (ahfeel)
403 |
404 | * Rewrote the log4j property files
405 |
406 | * Moved to ZK 3.4.3
407 |
408 | * More work on the Exhibitor integration
409 |
410 | 1.1.5/1.0.6 - March 23, 2012
411 | ============================
412 | * Moved to Gradle as the build system.
413 |
414 | * Added SimpleDistributedQueue, a drop-in replacement for the DistributedQueue that comes with the
415 | ZK distribution.
416 |
417 | * IMPORTANT CHANGE TO LeaderSelector. Previous versions of Curator overloaded the start() method
418 | to allow re-queueing. THIS IS NO LONGER SUPPORTED. Instead, there is a new method, requeue(), that
419 | does this. Calling start() more than once will now throw an exception.
420 |
421 | * LeaderSelector now supports auto re-queueing. In previous versions, it wasn't trivial to requeue
422 | the instance. Now, make a call to autoRequeue() to put the instance in a mode where it will requeue
423 | itself when the leader selector listener returns.
424 |
425 | * The mechanism that calls any kind of Curator listener wasn't protected against exceptions. Thus,
426 | an exception in a listener could break the listener event thread.
427 |
428 | * deleteDirectoryContents() no longer checks for sym links. This was a major issue in the Guava
429 | version and possibly one of the reasons they removed the method altogether.
430 |
431 | 1.1.4/1.0.5 - March 12, 2012
432 | ============================
433 | * Introduced a parent interface for Queues so that they can have some common methods
434 |
435 | * Added new Recipe: DistributedIdQueue - a version of DistributedQueue that allows IDs to be
436 | associated with queue items. Items can then be removed from the queue if needed.
437 |
438 | * Curator can now be configured to poll a cluster of Exhibitor (https://github.com/Netflix/exhibitor)
439 | instances to get the connection string to use with the ZooKeeper client. Should the connection
440 | string change, any new connections will use the new connection string.
441 |
442 | 1.1.3/1.0.4 - March 7, 2012
443 | ===========================
444 | * Issue 27: This bug exposed major problems with the PathChildrenCache. I ended up completely
445 | rewriting it. The original version was very inefficient and prone to herding. This new version
446 | is as efficient as possible and adds some nice new features. The major new feature is that when
447 | calling start(), you can have the cache load an initial working set of data.
448 |
449 | * Issue 31: It turns out an instance of InterProcessMutex could not be shared in multiple threads. My
450 | assumption was that users would create a new InterProcessMutex per thread. But, this restriction is
451 | arbitrary. For comparison, the JDK Lock doesn't have this requirement. I've fixed this however it
452 | was a significant change internally. I'm counting on my tests to prove correctness.
453 |
454 | * EnsurePath wasn't doing its work in a RetryLoop.
455 |
456 | * Added a new class to the Test module, Timing, that is used to better coordinate timings in tests
457 |
458 | * LockInternals had a retry loop for all failures when it was only needed if the session expired
459 | and the lock node was lost. So, I refined the code to handle this specific case.
460 |
461 | * Issue 34: PathChildrenCache should ensure the path
462 |
463 | * Moved to Guava 11.x
464 |
465 | * Lots of work on the Gradle build. NOTE: Gradle will soon become the build system for Curator
466 |
467 | 1.1.2/1.0.3 - Feb. 8, 2012
468 | ==========================
469 | * Added listener to Queues to listen for put completion
470 |
471 | * Issue 24: If InterProcesMutex.release() failed to delete the node (due to connection errors, etc.)
472 | the instance was left in an inconsistent state that would cause a future call to acquire() to
473 | succeed without actually creating the lock. A new feature (see next bullet) was added to solve this
474 | problem: guaranteed deletes. The various lock-based recipes now use this feature.
475 |
476 | * New feature: guaranteed deletes. The delete builder now has a method that will record failed node
477 | deletions and attempt to delete them in the background until successful. NOTE: you will still get
478 | an exception when the deletion fails. But, you can be assured that as long as the CuratorFramework
479 | instance is open attempts will be made to delete the node:
480 | client.delete().guaranteed() ...
481 |
482 | 1.1.1/1.0.2 - Jan. 21, 2012
483 | ===========================
484 | * Issue 22: Make ServiceCache close itself down properly.
485 |
486 | * Issue 21: Move TestNG to the top-level pom and define its scope as test
487 |
488 | * Issue 17: ConnectionStateManager should use the builder's thread factory if present
489 |
490 | 1.1.0 - Jan. 5, 2012
491 | =====================
492 | * 1.1.x marks a separate branch of Curator:
493 | - 1.0.x will stay compatible with ZooKeeper 3.3.x
494 | - 1.1.x+ will require ZooKeeper 3.4.x+
495 |
496 | * Added support for ZooKeeper 3.4's Transactions:
497 | - CuratorFramework has a new method: inTransaction() that starts a
498 | transaction builder
499 | - See TestTransactions for examples
500 |
501 | 1.0.1 - Jan. 4, 2012
502 | =====================
503 | * Updated and tested against ZooKeeper 3.4.2
504 |
505 | 1.0.0 - Dec. 31, 2011
506 | =====================
507 | * Added a REST server for Service Discovery
508 | * Switched to slf4j for logging
509 | * Moved to 1.0 version
510 | * Curator is now feature complete
511 |
512 | 0.6.4 - Dec. 7, 2011
513 | =====================
514 | * Added Barrier
515 |
516 | * Added Double Barrier
517 |
518 | * Added Read/Write lock
519 |
520 | * Added revocation to InterProcessMutex
521 |
522 | * Fixed (hopefully) intermittent failures with testRetry()
523 |
524 | * Updates/enhancements to Discovery based on suggestions from Eishay Smith
525 |
526 | 0.6.3 - Nov. 30, 2011
527 | =====================
528 | * Added Service Discovery
529 |
530 | 0.6.1 - Nov. 18, 2011
531 | =====================
532 | * Added new methods to LeaderSelector to identify/get all Participants
533 |
534 | * Moved to ZooKeeper 3.3.3
535 |
536 | * Made the TestingCluster not throw an assertion error due to internal JMX registrations
537 | in ZK. This is done with Javaassist ugliness.
538 |
539 | * Refactored listeners in Curator to a common methodology
540 |
541 | * Major changes to error handling. Adding a ConnectionStateManager that allows users to
542 | listen for connection changes. Connection loss is first treated as a recoverable Suspension.
543 | If the connection is not re-established, the state changes to connection loss. Any recipes
544 | that are affected by this have been updated.
545 |
546 | * PathChildrenCache now handles connection state changes much better.
547 |
548 | * All Curator created threads now have a meaningful name.
549 |
550 | 0.5.2 - Nov. 14, 2011
551 | =====================
552 | * Jérémie Bordier posted on the ZK mailing list about a split brain issue with the Leader Selector.
553 | If the Leader is connected to a server that suffers a network partition, it needs to get notified
554 | that it has lost leadership. Curator handled this somewhat but only if the client application
555 | executed periodic ZooKeeper operations. I've enhanced the CuratorFramework implementation to check
556 | for disconnection and executed a background sync (with retries). This will cause any listener's
557 | unhandledError() method to get called when there is a network partition.
558 |
559 | * New utility: TestingCluster. Allows for testing with an in-memory ZK ensemble.
560 |
561 | * Reworked distributed atomic implementations. I was unhappy with the complexity of the previous
562 | one. Now, there's a simpler master implementation DistributedAtomicValue that is the basis for the
563 | others. Adding new versions should be simpler as well.
564 |
565 | 0.5.1 - Nov. 12, 2011
566 | =====================
567 | * Another pass at fixing the semaphore. Went back to the model of the count being merely a
568 | convention. Added a new recipe for a SharedCount that can be used in place of the count convention
569 | with the semaphore. This is the best of both worlds. The semaphore code is a lot simpler and will
570 | perform better. Thanks to Monal Daxini for the idea.
571 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | ====
2 | Copyright 2012 Netflix, Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ====
16 |
17 |
18 | Apache License
19 | Version 2.0, January 2004
20 | http://www.apache.org/licenses/
21 |
22 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
23 |
24 | 1. Definitions.
25 |
26 | "License" shall mean the terms and conditions for use, reproduction,
27 | and distribution as defined by Sections 1 through 9 of this document.
28 |
29 | "Licensor" shall mean the copyright owner or entity authorized by
30 | the copyright owner that is granting the License.
31 |
32 | "Legal Entity" shall mean the union of the acting entity and all
33 | other entities that control, are controlled by, or are under common
34 | control with that entity. For the purposes of this definition,
35 | "control" means (i) the power, direct or indirect, to cause the
36 | direction or management of such entity, whether by contract or
37 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
38 | outstanding shares, or (iii) beneficial ownership of such entity.
39 |
40 | "You" (or "Your") shall mean an individual or Legal Entity
41 | exercising permissions granted by this License.
42 |
43 | "Source" form shall mean the preferred form for making modifications,
44 | including but not limited to software source code, documentation
45 | source, and configuration files.
46 |
47 | "Object" form shall mean any form resulting from mechanical
48 | transformation or translation of a Source form, including but
49 | not limited to compiled object code, generated documentation,
50 | and conversions to other media types.
51 |
52 | "Work" shall mean the work of authorship, whether in Source or
53 | Object form, made available under the License, as indicated by a
54 | copyright notice that is included in or attached to the work
55 | (an example is provided in the Appendix below).
56 |
57 | "Derivative Works" shall mean any work, whether in Source or Object
58 | form, that is based on (or derived from) the Work and for which the
59 | editorial revisions, annotations, elaborations, or other modifications
60 | represent, as a whole, an original work of authorship. For the purposes
61 | of this License, Derivative Works shall not include works that remain
62 | separable from, or merely link (or bind by name) to the interfaces of,
63 | the Work and Derivative Works thereof.
64 |
65 | "Contribution" shall mean any work of authorship, including
66 | the original version of the Work and any modifications or additions
67 | to that Work or Derivative Works thereof, that is intentionally
68 | submitted to Licensor for inclusion in the Work by the copyright owner
69 | or by an individual or Legal Entity authorized to submit on behalf of
70 | the copyright owner. For the purposes of this definition, "submitted"
71 | means any form of electronic, verbal, or written communication sent
72 | to the Licensor or its representatives, including but not limited to
73 | communication on electronic mailing lists, source code control systems,
74 | and issue tracking systems that are managed by, or on behalf of, the
75 | Licensor for the purpose of discussing and improving the Work, but
76 | excluding communication that is conspicuously marked or otherwise
77 | designated in writing by the copyright owner as "Not a Contribution."
78 |
79 | "Contributor" shall mean Licensor and any individual or Legal Entity
80 | on behalf of whom a Contribution has been received by Licensor and
81 | subsequently incorporated within the Work.
82 |
83 | 2. Grant of Copyright License. Subject to the terms and conditions of
84 | this License, each Contributor hereby grants to You a perpetual,
85 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
86 | copyright license to reproduce, prepare Derivative Works of,
87 | publicly display, publicly perform, sublicense, and distribute the
88 | Work and such Derivative Works in Source or Object form.
89 |
90 | 3. Grant of Patent License. Subject to the terms and conditions of
91 | this License, each Contributor hereby grants to You a perpetual,
92 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
93 | (except as stated in this section) patent license to make, have made,
94 | use, offer to sell, sell, import, and otherwise transfer the Work,
95 | where such license applies only to those patent claims licensable
96 | by such Contributor that are necessarily infringed by their
97 | Contribution(s) alone or by combination of their Contribution(s)
98 | with the Work to which such Contribution(s) was submitted. If You
99 | institute patent litigation against any entity (including a
100 | cross-claim or counterclaim in a lawsuit) alleging that the Work
101 | or a Contribution incorporated within the Work constitutes direct
102 | or contributory patent infringement, then any patent licenses
103 | granted to You under this License for that Work shall terminate
104 | as of the date such litigation is filed.
105 |
106 | 4. Redistribution. You may reproduce and distribute copies of the
107 | Work or Derivative Works thereof in any medium, with or without
108 | modifications, and in Source or Object form, provided that You
109 | meet the following conditions:
110 |
111 | (a) You must give any other recipients of the Work or
112 | Derivative Works a copy of this License; and
113 |
114 | (b) You must cause any modified files to carry prominent notices
115 | stating that You changed the files; and
116 |
117 | (c) You must retain, in the Source form of any Derivative Works
118 | that You distribute, all copyright, patent, trademark, and
119 | attribution notices from the Source form of the Work,
120 | excluding those notices that do not pertain to any part of
121 | the Derivative Works; and
122 |
123 | (d) If the Work includes a "NOTICE" text file as part of its
124 | distribution, then any Derivative Works that You distribute must
125 | include a readable copy of the attribution notices contained
126 | within such NOTICE file, excluding those notices that do not
127 | pertain to any part of the Derivative Works, in at least one
128 | of the following places: within a NOTICE text file distributed
129 | as part of the Derivative Works; within the Source form or
130 | documentation, if provided along with the Derivative Works; or,
131 | within a display generated by the Derivative Works, if and
132 | wherever such third-party notices normally appear. The contents
133 | of the NOTICE file are for informational purposes only and
134 | do not modify the License. You may add Your own attribution
135 | notices within Derivative Works that You distribute, alongside
136 | or as an addendum to the NOTICE text from the Work, provided
137 | that such additional attribution notices cannot be construed
138 | as modifying the License.
139 |
140 | You may add Your own copyright statement to Your modifications and
141 | may provide additional or different license terms and conditions
142 | for use, reproduction, or distribution of Your modifications, or
143 | for any such Derivative Works as a whole, provided Your use,
144 | reproduction, and distribution of the Work otherwise complies with
145 | the conditions stated in this License.
146 |
147 | 5. Submission of Contributions. Unless You explicitly state otherwise,
148 | any Contribution intentionally submitted for inclusion in the Work
149 | by You to the Licensor shall be under the terms and conditions of
150 | this License, without any additional terms or conditions.
151 | Notwithstanding the above, nothing herein shall supersede or modify
152 | the terms of any separate license agreement you may have executed
153 | with Licensor regarding such Contributions.
154 |
155 | 6. Trademarks. This License does not grant permission to use the trade
156 | names, trademarks, service marks, or product names of the Licensor,
157 | except as required for reasonable and customary use in describing the
158 | origin of the Work and reproducing the content of the NOTICE file.
159 |
160 | 7. Disclaimer of Warranty. Unless required by applicable law or
161 | agreed to in writing, Licensor provides the Work (and each
162 | Contributor provides its Contributions) on an "AS IS" BASIS,
163 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
164 | implied, including, without limitation, any warranties or conditions
165 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
166 | PARTICULAR PURPOSE. You are solely responsible for determining the
167 | appropriateness of using or redistributing the Work and assume any
168 | risks associated with Your exercise of permissions under this License.
169 |
170 | 8. Limitation of Liability. In no event and under no legal theory,
171 | whether in tort (including negligence), contract, or otherwise,
172 | unless required by applicable law (such as deliberate and grossly
173 | negligent acts) or agreed to in writing, shall any Contributor be
174 | liable to You for damages, including any direct, indirect, special,
175 | incidental, or consequential damages of any character arising as a
176 | result of this License or out of the use or inability to use the
177 | Work (including but not limited to damages for loss of goodwill,
178 | work stoppage, computer failure or malfunction, or any and all
179 | other commercial damages or losses), even if such Contributor
180 | has been advised of the possibility of such damages.
181 |
182 | 9. Accepting Warranty or Additional Liability. While redistributing
183 | the Work or Derivative Works thereof, You may choose to offer,
184 | and charge a fee for, acceptance of support, warranty, indemnity,
185 | or other liability obligations and/or rights consistent with this
186 | License. However, in accepting such obligations, You may act only
187 | on Your own behalf and on Your sole responsibility, not on behalf
188 | of any other Contributor, and only if You agree to indemnify,
189 | defend, and hold each Contributor harmless for any liability
190 | incurred by, or claims asserted against, such Contributor by reason
191 | of your accepting any such warranty or additional liability.
192 |
193 | END OF TERMS AND CONDITIONS
194 |
195 | APPENDIX: How to apply the Apache License to your work.
196 |
197 | To apply the Apache License to your work, attach the following
198 | boilerplate notice, with the fields enclosed by brackets "[]"
199 | replaced with your own identifying information. (Don't include
200 | the brackets!) The text should be enclosed in the appropriate
201 | comment syntax for the file format. We also recommend that a
202 | file or class name and description of purpose be included on the
203 | same "printed page" as the copyright notice for easier
204 | identification within third-party archives.
205 |
206 | Copyright 2011 Netflix
207 |
208 | Licensed under the Apache License, Version 2.0 (the "License");
209 | you may not use this file except in compliance with the License.
210 | You may obtain a copy of the License at
211 |
212 | http://www.apache.org/licenses/LICENSE-2.0
213 |
214 | Unless required by applicable law or agreed to in writing, software
215 | distributed under the License is distributed on an "AS IS" BASIS,
216 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
217 | See the License for the specific language governing permissions and
218 | limitations under the License.
219 |
--------------------------------------------------------------------------------
/NOTICE.txt:
--------------------------------------------------------------------------------
1 | ====
2 | Copyright 2012 Netflix, Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ====
16 |
17 | Curator
18 | Copyright 2011 Netflix, Inc.
19 |
20 | This product includes software developed by The Apache Software
21 | Foundation (http://www.apache.org/).
22 |
23 | Alternative collection types provided by Google Guava from
24 | http://code.google.com/p/guava-libraries/
25 | Copyright (C) 2007 Google Inc.
26 |
--------------------------------------------------------------------------------
/OSSMETADATA:
--------------------------------------------------------------------------------
1 | osslifecycle=active
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | http://netflix.github.com/curator/curator.png
2 |
3 | # IMPORTANT NOTE!!!
4 |
5 | Curator has moved to Apache. The Netflix Curator project will remain to hold Netflix
6 | extensions to Curator.
7 |
8 | http://curator.apache.org
9 |
10 | The previous Netflix branch is now in a branch named "archive".
11 |
12 | # ZKCLIENT BRIDGE
13 |
14 | Please see the doc at https://github.com/Netflix/curator/wiki/ZKClient-Bridge
15 |
16 | Jordan Zimmerman (mailto:jzimmerman@netflix.com)
17 |
18 | # LICENSE
19 |
20 | Copyright 2011 Netflix, Inc.
21 |
22 | Licensed under the Apache License, Version 2.0 (the "License");
23 | you may not use this file except in compliance with the License.
24 | You may obtain a copy of the License at
25 |
26 | http://www.apache.org/licenses/LICENSE-2.0
27 |
28 | Unless required by applicable law or agreed to in writing, software
29 | distributed under the License is distributed on an "AS IS" BASIS,
30 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 | See the License for the specific language governing permissions and
32 | limitations under the License.
33 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.netflix.curator
6 | curator-x-zkclient-bridge
7 | 3.0.1-SNAPSHOT
8 |
9 |
10 | org.sonatype.oss
11 | oss-parent
12 | 7
13 |
14 |
15 |
16 |
17 | The Apache Software License, Version 2.0
18 | http://www.apache.org/licenses/LICENSE-2.0.txt
19 | repo
20 |
21 |
22 |
23 | Apache Curator ZKClient Bridge
24 |
25 | You may be trying to integrate a project that uses ZKClient and would like a way to use Curator with that
26 | project (for example Kafka). The ZKClient Bridge accomplishes that.
27 |
28 | http://curator.apache.org
29 | 2011
30 |
31 |
32 | scm:git:git@github.com:randgalt/curator.git
33 | scm:git:git@github.com:randgalt/curator.git
34 | scm:git:git@github.com:randgalt/curator.git
35 | curator-x-zkclient-bridge-3.0.0
36 |
37 |
38 |
39 | UTF-8
40 | UTF-8
41 | UTF-8
42 |
43 | 1.6
44 |
45 | 1
46 |
47 | 2.9.1
48 | 2.5.1
49 | 3.1
50 | 2.17
51 | 1.0
52 | 2.5
53 | 1.6
54 | 2.4
55 |
56 | 2.7.1
57 | 0.4
58 | 4.12
59 | 1.10.19
60 |
61 |
62 |
63 |
64 | org.apache.curator
65 | curator-framework
66 | ${curator-version}
67 |
68 |
69 |
70 | com.101tec
71 | zkclient
72 | ${zkclient-version}
73 |
74 |
75 |
76 | org.apache.curator
77 | curator-test
78 | ${curator-version}
79 | test
80 |
81 |
82 |
83 | junit
84 | junit
85 | ${junit-version}
86 | test
87 |
88 |
89 |
90 | org.mockito
91 | mockito-core
92 | ${mockito-version}
93 | test
94 |
95 |
96 |
97 |
98 |
99 | oss
100 |
101 |
102 |
103 | maven-gpg-plugin
104 | ${maven-gpg-plugin-version}
105 |
106 | ${gpg.passphrase}
107 | true
108 |
109 |
110 |
111 | gpg
112 |
113 | sign
114 |
115 | verify
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | maven-install-plugin
128 | ${maven-install-plugin-version}
129 |
130 | true
131 |
132 |
133 |
134 |
135 | maven-compiler-plugin
136 | ${maven-compiler-plugin-version}
137 |
138 | ${jdk-version}
139 | ${jdk-version}
140 |
141 |
142 |
143 |
144 | maven-surefire-plugin
145 | ${maven-surefire-plugin-version}
146 |
147 | ${surefire-forkcount}
148 | false
149 | true
150 |
151 |
152 |
153 |
154 | maven-source-plugin
155 | ${maven-source-plugin-version}
156 |
157 |
158 | attach-sources
159 |
160 | jar
161 |
162 |
163 |
164 |
165 |
166 |
167 | maven-javadoc-plugin
168 | ${maven-javadoc-plugin-version}
169 |
170 | true
171 |
172 | -J-Xmx1g
173 |
174 | false
175 |
176 |
177 |
178 | jar
179 |
180 | jar
181 |
182 | package
183 |
184 |
185 |
186 |
187 |
188 | maven-release-plugin
189 | ${maven-release-plugin-version}
190 |
191 | -Dmaven.test.skip=true
192 | forked-path
193 |
194 |
195 |
196 |
197 |
198 |
--------------------------------------------------------------------------------
/src/main/java/com/netflix/curator/x/zkclientbridge/CuratorZKClientBridge.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.curator.x.zkclientbridge;
17 |
18 | import org.I0Itec.zkclient.IZkConnection;
19 | import org.apache.curator.framework.CuratorFramework;
20 | import org.apache.curator.framework.api.BackgroundCallback;
21 | import org.apache.curator.framework.api.CuratorEvent;
22 | import org.apache.curator.framework.api.CuratorListener;
23 | import org.apache.zookeeper.CreateMode;
24 | import org.apache.zookeeper.KeeperException;
25 | import org.apache.zookeeper.WatchedEvent;
26 | import org.apache.zookeeper.Watcher;
27 | import org.apache.zookeeper.ZooKeeper;
28 | import org.apache.zookeeper.data.Stat;
29 | import java.util.List;
30 | import java.util.concurrent.atomic.AtomicReference;
31 |
32 | /**
33 | *
34 | * Bridge between ZKClient and Curator. Accomplished via an implementation for
35 | * {@link IZkConnection} which is the abstraction ZKClient uses to wrap the raw ZooKeeper handle
36 | *
37 | *
38 | *
39 | * Once allocated, bridge to ZKClient via:
40 | *
41 | * ZKClient zkClient = new ZkClient(new CuratorZKClientBridge(curatorInstance, timeout));
42 | *
43 | *