public class PoolSemaphore extends Semaphore
RiakConnectionPool| Constructor and Description |
|---|
PoolSemaphore(Semaphore clusterSemaphore,
int poolPermits)
Creates a pool
Semaphore with permits permits. |
| Modifier and Type | Method and Description |
|---|---|
void |
release()
Both semaphores are released
|
boolean |
tryAcquire(int permits)
Tries to acquire from the cluster semaphore, and only if that succeeds
does it try the pool semaphore.
|
boolean |
tryAcquire(long timeout,
TimeUnit unit)
Tries to acquire on the cluster semaphore, and only if that succeeds does
it try the pool semaphore.
|
acquire, acquire, acquireUninterruptibly, acquireUninterruptibly, availablePermits, drainPermits, getQueuedThreads, getQueueLength, hasQueuedThreads, isFair, reducePermits, release, toString, tryAcquire, tryAcquirepublic PoolSemaphore(Semaphore clusterSemaphore, int poolPermits)
Semaphore with permits permits.
Calls to tryAcquire(long, TimeUnit),
release() and tryAcquire(int) call both cluster and pool
Semaphorecluster - a Semaphore configured for the total cluster maximum
number of connectionspermits - maximum connections for the poolpublic boolean tryAcquire(long timeout,
TimeUnit unit)
throws InterruptedException
Warning: this means potentially double the timeout
TODO configure option for timeout to be shared (i.e. pool semaphore gets remaining time after cluster acquire)tryAcquire in class SemaphoreInterruptedExceptionSemaphore.tryAcquire(long,
java.util.concurrent.TimeUnit)public boolean tryAcquire(int permits)
tryAcquire in class SemaphoreSemaphore.tryAcquire(int)Copyright © 2014. All Rights Reserved.