Examples of drainPermits()


Examples of com.hazelcast.core.ISemaphore.drainPermits()

        final ISemaphore semaphore = hz.getSemaphore(randomString());
        int numberOfPermits = 20;

        assertTrue(semaphore.init(numberOfPermits));
        semaphore.acquire(5);
        int drainedPermits = semaphore.drainPermits();
        assertEquals(drainedPermits, numberOfPermits - 5);
        assertEquals(semaphore.availablePermits(), 0);
    }

    @Test(timeout = 30000)
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.drainPermits()

    @Test(timeout = 30000)
    public void testDrain_whenNoPermits() throws InterruptedException {
        final ISemaphore semaphore = hz.getSemaphore(randomString());
        semaphore.init(0);
        assertEquals(0, semaphore.drainPermits());
    }

    @Test(timeout = 30000)
    public void testReduce() {
        final ISemaphore semaphore = hz.getSemaphore(randomString());
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.drainPermits()

    @Test
    public void testdrainPermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(10);
        assertEquals(10, semaphore.drainPermits());
    }

    @Test
    public void testAvailablePermits_AfterDrainPermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.drainPermits()

    @Test
    public void testAvailablePermits_AfterDrainPermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(10);
        semaphore.drainPermits();
        assertEquals(0, semaphore.availablePermits());
    }

    @Test
    public void testTryAcquire_whenDrainPermits() throws Exception {
View Full Code Here

Examples of com.hazelcast.core.ISemaphore.drainPermits()

    @Test
    public void testTryAcquire_whenDrainPermits() throws Exception {
        final ISemaphore semaphore = client.getSemaphore(randomString());
        semaphore.init(10);
        semaphore.drainPermits();
        assertFalse(semaphore.tryAcquire());
    }

    @Test
    public void testAvailablePermits() throws Exception {
View Full Code Here

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

            // test foreground retry
            client.checkExists().forPath("/hey");
            Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, 10, TimeUnit.SECONDS));

            semaphore.drainPermits();
            retries.set(0);

            server.stop();

            // test background retry
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()

            // test foreground retry
            client.checkExists().forPath("/hey");
            Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS));

            semaphore.drainPermits();
            retries.set(0);

            server.stop();

            // test background retry
View Full Code Here

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

   * http://wiki.developers.facebook.com/index.php/Authorization_and_Authentication_for_Desktop_Applications
   */
  public static JSONObject attainSessionRaw2( String apikey, String secret, int port ) throws Exception {
    Server server = null;
    Semaphore semaphore = new Semaphore( 1 );
    semaphore.drainPermits();
    CaptureSessionHandler handler = new CaptureSessionHandler( apikey, secret, semaphore );
    try {
      {
        // start jetty to capture return value from connect login
        server = new Server( port );
View Full Code Here

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

            // test foreground retry
            client.checkExists().forPath("/hey");
            Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, 10, TimeUnit.SECONDS));

            semaphore.drainPermits();
            retries.set(0);

            server.stop();

            // test background retry
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.