Examples of drainPermits()


Examples of java.util.concurrent.Semaphore.drainPermits()

      // Create a semaphore to track task completion, and acquire all its
      // permits initially. Each URLProcessor object releases one permit
      // when
      // it finishes.
      final Semaphore sem = new Semaphore(fileUrls.size());
      sem.drainPermits();
      for (IProgress progress : progresses) {
        progress.setRange(0, fileUrls.size());
      }
      for (URL url : fileUrls) {
        service.execute(new URLResourceProcessor(url, sem, map,
View Full Code Here

Examples of java.util.concurrent.Semaphore.drainPermits()

            // make sure we're reconnected
            client.getZookeeperClient().setRetryPolicy(new RetryOneTime(100));
            client.checkExists().forPath("/hey");

            client.getZookeeperClient().setRetryPolicy(policy);
            semaphore.drainPermits();
            retries.set(0);

            server.stop();

            // test background retry
View Full Code Here

Examples of java.util.concurrent.Semaphore.drainPermits()

            provider.start();

            Assert.assertEquals(provider.getConnectionString(), "localhost:2");

            connectionString.set(null);
            semaphore.drainPermits();
            semaphore.acquire();    // wait for next poll
            Assert.assertEquals(provider.getConnectionString(), "backup1:1");

            backupConnectionString.set("backup2:2");
            semaphore.drainPermits();
View Full Code Here

Examples of java.util.concurrent.Semaphore.drainPermits()

            semaphore.drainPermits();
            semaphore.acquire();    // wait for next poll
            Assert.assertEquals(provider.getConnectionString(), "backup1:1");

            backupConnectionString.set("backup2:2");
            semaphore.drainPermits();
            semaphore.acquire();    // wait for next poll
            Assert.assertEquals(provider.getConnectionString(), "backup2:2");

            connectionString.set("count=1&port=3&server0=localhost3");
            semaphore.drainPermits();
View Full Code Here

Examples of java.util.concurrent.Semaphore.drainPermits()

            semaphore.drainPermits();
            semaphore.acquire();    // wait for next poll
            Assert.assertEquals(provider.getConnectionString(), "backup2:2");

            connectionString.set("count=1&port=3&server0=localhost3");
            semaphore.drainPermits();
            semaphore.acquire();    // wait for next poll
            Assert.assertEquals(provider.getConnectionString(), "localhost3:3");
        }
        finally
        {
View Full Code Here

Examples of java.util.concurrent.Semaphore.drainPermits()

                        }
                    }
                );

                connectionString.set(secondConnectionString);
                semaphore.drainPermits();
                semaphore.acquire();

                server.stop()// create situation where the current zookeeper gets a sys-disconnected

                Stat        stat = RetryLoop.callWithRetry
View Full Code Here

Examples of java.util.concurrent.Semaphore.drainPermits()

        public void waitForEvent(long timeout) {
            Thread thread = Thread.currentThread();
            Semaphore semaphore = _semaphores.get(thread);
            if (semaphore == null) {
                semaphore = new Semaphore(1, true);
                semaphore.drainPermits();
                _semaphores.putIfAbsent(thread, semaphore);
            }
            semaphore = _semaphores.get(thread);
            try {
                semaphore.tryAcquire(timeout, TimeUnit.MILLISECONDS);
View Full Code Here

Examples of java.util.concurrent.Semaphore.drainPermits()

    public void resetPermits() {
        for (Entry<Integer, Semaphore> e : m_permits.entrySet()) {
            int type = e.getKey();
            Semaphore permits = e.getValue();

            permits.drainPermits();
            permits.release(m_initialPermits.get(type));
        }
    }

    /**
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.