@Override protected Lock initialValue() { return new ReentrantDistributedLock(zkClient, IDS_BASEPATH + "/lock"); } };
@Override protected Lock initialValue() { return new ReentrantDistributedLock(zkClient, basePath); } };
public Lock getTenantProvisionerLock() { return new ReentrantDistributedLock(zkClient, Constants.Lock.TENANT_NAMESPACE); } }
public SynchronizedZKMap(ZKClient zkClient, Serializer<T> serializer) { this.zkClient = zkClient; this.serializer = serializer; this.currentView = Maps.newHashMap(); this.currentViewVersion = -1; this.globalLock = new ReentrantDistributedLock(zkClient, LOCK_PATH); }
public Lock getResourceLock(String tenantId, String pluginType, String pluginName, String typeName, String resourceName) { String path = Joiner.on('/') .join(Constants.Lock.PLUGIN_NAMESPACE, "resources", tenantId, pluginType, pluginName, typeName, resourceName); return new ReentrantDistributedLock(zkClient, path); }
public Lock getClusterCreateLock(String tenantId) { String path = Joiner.on('/').join(Constants.Lock.CLUSTER_NAMESPACE, "create", tenantId); return new ReentrantDistributedLock(zkClient, path); }
public Lock getClusterLock(String tenantId, String clusterId) { String path = Joiner.on('/').join(Constants.Lock.CLUSTER_NAMESPACE, "clusters", tenantId, clusterId); return new ReentrantDistributedLock(zkClient, path); }
public Lock getJobLock(String tenantId, String clusterId) { String path = Joiner.on('/').join(Constants.Lock.TASK_NAMESPACE, "jobs", tenantId, clusterId); return new ReentrantDistributedLock(zkClient, path); }
try { final Lock[] locks = new Lock[] { new ReentrantDistributedLock(zkClient1, "/lockrace"), new ReentrantDistributedLock(zkClient2, "/lockrace") };
final ReentrantDistributedLock lock = new ReentrantDistributedLock(zkClient, "/interrupt");
try { final ReentrantDistributedLock lock = new ReentrantDistributedLock(zkClient, "multiThreads"); final CountDownLatch acquired = new CountDownLatch(1); Thread t = new Thread() {
ZKClientService zkClient2 = createZKClient(); try { final ReentrantDistributedLock lock1 = new ReentrantDistributedLock(zkClient1, "/multiInterrupt"); final ReentrantDistributedLock lock2 = new ReentrantDistributedLock(zkClient2, "/multiInterrupt");
try { ReentrantDistributedLock lock1 = new ReentrantDistributedLock(zkClient1, "multiClients"); final ReentrantDistributedLock lock2 = new ReentrantDistributedLock(zkClient2, "multiClients");
ZKClientService zkClient2 = createZKClient(); try { final ReentrantDistributedLock lock1 = new ReentrantDistributedLock(zkClient1, "/multiTrylock"); final ReentrantDistributedLock lock2 = new ReentrantDistributedLock(zkClient2, "/multiTrylock");
final ReentrantDistributedLock lock = new ReentrantDistributedLock(zkClient, "/trylock");
@Test (timeout = 20000) public void testReentrant() { // Test the lock is reentrant from the same thread ZKClientService zkClient = createZKClient(); try { ReentrantDistributedLock lock = new ReentrantDistributedLock(zkClient, "reentrant"); lock.lock(); try { try { lock.lock(); } finally { lock.unlock(); } } finally { lock.unlock(); } } finally { zkClient.stopAndWait(); } }