org.apache.curator.framework.recipes.shared.SharedCountReader Java Examples
The following examples show how to use
org.apache.curator.framework.recipes.shared.SharedCountReader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SharedCacheCoordinator.java From datawave with Apache License 2.0 | 6 votes |
private void reregisterCounter(String counterName, SharedCountListener listener, int seedValue) throws Exception { ArgumentChecker.notNull(counterName, listener); SharedCount count = new SharedCount(curatorClient, ZKPaths.makePath("/counters", counterName), seedValue); count.start(); sharedCounters.put(counterName, count); sharedCountListeners.put(counterName, listener); localCounters.put(counterName, count.getCount()); count.addListener(new SharedCountListener() { @Override public void countHasChanged(SharedCountReader sharedCountReader, int i) throws Exception {} @Override public void stateChanged(CuratorFramework curatorFramework, ConnectionState connectionState) { if (connectionState == ConnectionState.RECONNECTED) { try { reregisterCounter(counterName, sharedCountListeners.get(counterName), localCounters.get(counterName)); } catch (Exception e) { System.err.println("Unable to re-register counter " + counterName + ": " + e.getMessage()); } } } }); count.addListener(listener); }
Example #2
Source File: SharedCounterExample.java From ZKRecipesByExample with Apache License 2.0 | 4 votes |
@Override public void countHasChanged(SharedCountReader sharedCount, int newCount) throws Exception { System.out.println("Counter's value is changed to " + newCount); }
Example #3
Source File: InterProcessSemaphore.java From xian with Apache License 2.0 | 2 votes |
/** * @param client the client * @param path path for the semaphore * @param count the shared count to use for the max leases */ public InterProcessSemaphore(CuratorFramework client, String path, SharedCountReader count) { this(client, path, 0, count); }
Example #4
Source File: InterProcessSemaphoreV2.java From xian with Apache License 2.0 | 2 votes |
/** * @param client the client * @param path path for the semaphore * @param count the shared count to use for the max leases */ public InterProcessSemaphoreV2(CuratorFramework client, String path, SharedCountReader count) { this(client, path, 0, count); }
Example #5
Source File: InterProcessSemaphore.java From curator with Apache License 2.0 | 2 votes |
/** * @param client the client * @param path path for the semaphore * @param count the shared count to use for the max leases */ public InterProcessSemaphore(CuratorFramework client, String path, SharedCountReader count) { this(client, path, 0, count); }
Example #6
Source File: InterProcessSemaphoreV2.java From curator with Apache License 2.0 | 2 votes |
/** * @param client the client * @param path path for the semaphore * @param count the shared count to use for the max leases */ public InterProcessSemaphoreV2(CuratorFramework client, String path, SharedCountReader count) { this(client, path, 0, count); }