Examples of availablePermits()


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

                async.run();
            }
        });

        // drain checkpoint permits
        checkpoint.acquireUninterruptibly(checkpoint.availablePermits());
        // block NodeStore.retrieve()
        retrieve.acquireUninterruptibly();
        t.start();

        // wait until async update called checkpoint
View Full Code Here

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

    @Test
    public void releasesPermit() throws Exception {
        final Semaphore semaphore = new Semaphore(1);
        assertThat("semaphore begins with single permit",
                semaphore.availablePermits(), is(1));
        semaphore.acquire(1);
        assertThat("semaphore has no available permits",
                semaphore.availablePermits(), is(0));
        new PermitReleasingCallback<>(semaphore).call(new Object());
        assertThat("callback releases a permit",
View Full Code Here

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

        final Semaphore semaphore = new Semaphore(1);
        assertThat("semaphore begins with single permit",
                semaphore.availablePermits(), is(1));
        semaphore.acquire(1);
        assertThat("semaphore has no available permits",
                semaphore.availablePermits(), is(0));
        new PermitReleasingCallback<>(semaphore).call(new Object());
        assertThat("callback releases a permit",
                semaphore.availablePermits(), is(1));
    }
}
View Full Code Here

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

        semaphore.acquire(1);
        assertThat("semaphore has no available permits",
                semaphore.availablePermits(), is(0));
        new PermitReleasingCallback<>(semaphore).call(new Object());
        assertThat("callback releases a permit",
                semaphore.availablePermits(), is(1));
    }
}
View Full Code Here

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

    }

    // Wait until all puts are finished.
    if (!outstandingPutSemaphore.tryAcquire(_maxOutstandingWrites, _timeout, _timeoutUnit))
    {
      _log.error("Put timed out with {} outstanding writes", _maxOutstandingWrites - outstandingPutSemaphore.availablePermits());
      throw new TimeoutException();
    }

    FutureCallback<None> shutdownCallback = new FutureCallback<None>();
    _store.shutdown(shutdownCallback);
View Full Code Here

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

                async.run();
            }
        });

        // drain checkpoint permits
        checkpoint.acquireUninterruptibly(checkpoint.availablePermits());
        // block NodeStore.retrieve()
        retrieve.acquireUninterruptibly();
        t.start();

        // wait until async update called checkpoint
View Full Code Here

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

            server.stop();

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

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

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

            server.stop();

            // test background retry
            client.checkExists().inBackground().forPath("/hey");
            Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS), "Remaining leases: " + semaphore.availablePermits());
        }
        finally
        {
            CloseableUtils.closeQuietly(client);
        }
View Full Code Here

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

                                try
                                {
                                    if ( isFirst.compareAndSet(true, false) )
                                    {
                                        semaphore.release(THREAD_QTY - 1);
                                        while ( semaphore.availablePermits() > 0 )
                                        {
                                            Thread.sleep(100);
                                        }
                                    }
                                    else
View Full Code Here

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

              factoryBean.close();
            }

            batchContext.close();

            if(semaphore.availablePermits() == 0) {
              semaphore.release();
            }
          }
        }
      });
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.