Package java.util.concurrent

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


        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

            // 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

   * 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

            // 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

            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

            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

            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

                        }
                    }
                );

                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

                lockBefore.release();
            } catch (InterruptedException ex) {
                ex.printStackTrace();
                throw new VoltAbortException(ex.getMessage());
            } finally {
                if (notifyBefore != null) notifyBefore.drainPermits();
            }
        }
       
        // Let 'er rip!
        voltQueueSQL(updateSubscriber, marker, s_id);
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.