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, tryAcquire
public PoolSemaphore(Semaphore clusterSemaphore, int poolPermits)
Semaphore
with permits
permits.
Calls to tryAcquire(long, TimeUnit),
release() and tryAcquire(int) call both cluster
and pool
Semaphore
cluster
- 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 Semaphore
InterruptedException
Semaphore.tryAcquire(long,
java.util.concurrent.TimeUnit)
public boolean tryAcquire(int permits)
tryAcquire
in class Semaphore
Semaphore.tryAcquire(int)
Copyright © 2013. All Rights Reserved.