@Beta public final class JdbcSemaphore extends Object implements AutoCloseable, Semaphore
| Constructor and Description |
|---|
JdbcSemaphore(DataSource dataSource,
SemaphoreTablesDesc semTableDesc,
String semaphoreName,
int nrPermits,
int jdbcTimeoutSeconds,
boolean strictReservations) |
JdbcSemaphore(DataSource dataSource,
SemaphoreTablesDesc semTableDesc,
String semaphoreName,
int nrPermits,
int jdbcTimeoutSeconds,
boolean strictReservations,
int acquirePollMillis) |
JdbcSemaphore(DataSource dataSource,
String semaphoreName,
int nrPermits) |
JdbcSemaphore(DataSource dataSource,
String semaphoreName,
int nrPermits,
boolean strict)
create a JDBC Semaphore.
|
| Modifier and Type | Method and Description |
|---|---|
int |
availablePermits() |
void |
close() |
protected void |
finalize() |
List<OwnerPermits> |
getDeadOwnerPermits(int wishPermits) |
int |
getJdbcTimeoutSeconds() |
void |
increasePermits(int nrPermits) |
boolean |
isIsHealthy() |
int |
permitsOwned() |
void |
reducePermits(int nrPermits) |
void |
registerJmx() |
void |
release(int nrReservations)
release a number of permits.
|
void |
releaseAll() |
int |
releaseDeadOwnerPermits(int wishPermits)
Attempts to release permits for this semaphore owned by dead owners.
|
int |
removeDeadHeartBeatAndNotOwnerRows(long timeoutSeconds) |
String |
toString() |
int |
totalPermits() |
boolean |
tryAcquire(int nrPermits,
long deadlineNanos) |
void |
unregisterJmx() |
void |
updatePermits(int nrPermits) |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitrelease, toSemaphoreacquire, acquire, tryAcquire, tryAcquirepublic JdbcSemaphore(DataSource dataSource, String semaphoreName, int nrPermits) throws InterruptedException, SQLException
dataSource - the jdbc data source with the Semaphores table. Please be sensible, no "test on borrow" pools.semaphoreName - number of initial permits, if semaphore already exists the existing nr of permits is kept.nrPermits - the number of initial permits.InterruptedExceptionSQLExceptionpublic JdbcSemaphore(DataSource dataSource, String semaphoreName, int nrPermits, boolean strict) throws InterruptedException, SQLException
dataSource - the data source to use for sync.semaphoreName - the semaphore name.nrPermits - number of initial permits.strict - if true, if semaphore already exists and the total permits is different that param nrPermits an
IllegalArgumentException will be thrown.InterruptedExceptionSQLExceptionpublic JdbcSemaphore(DataSource dataSource, SemaphoreTablesDesc semTableDesc, String semaphoreName, int nrPermits, int jdbcTimeoutSeconds, boolean strictReservations) throws InterruptedException, SQLException
InterruptedExceptionSQLExceptionpublic JdbcSemaphore(DataSource dataSource, SemaphoreTablesDesc semTableDesc, String semaphoreName, int nrPermits, int jdbcTimeoutSeconds, boolean strictReservations, int acquirePollMillis) throws InterruptedException, SQLException
InterruptedExceptionSQLExceptionpublic void registerJmx()
public void unregisterJmx()
@CheckReturnValue public boolean tryAcquire(int nrPermits, long deadlineNanos) throws InterruptedException
tryAcquire in interface PermitSupplierInterruptedExceptionpublic void release(int nrReservations)
Semaphorepublic void releaseAll()
public int availablePermits()
throws SQLException,
InterruptedException
SQLExceptionInterruptedExceptionpublic int permitsOwned()
throws SQLException,
InterruptedException
SQLExceptionInterruptedExceptionpublic int totalPermits()
throws SQLException,
InterruptedException
SQLExceptionInterruptedException@Nonnull public List<OwnerPermits> getDeadOwnerPermits(int wishPermits) throws SQLException, InterruptedException
SQLExceptionInterruptedException@CheckReturnValue public int releaseDeadOwnerPermits(int wishPermits) throws InterruptedException, SQLException
wishPermits - - How many permits we would like to get released.SQLException - - something went wrong with the db.InterruptedException - - thrown if thread is interrupted.public void updatePermits(int nrPermits)
throws SQLException,
InterruptedException
SQLExceptionInterruptedExceptionpublic void reducePermits(int nrPermits)
throws SQLException,
InterruptedException
SQLExceptionInterruptedExceptionpublic void increasePermits(int nrPermits)
throws SQLException,
InterruptedException
SQLExceptionInterruptedExceptionpublic int removeDeadHeartBeatAndNotOwnerRows(long timeoutSeconds)
throws SQLException,
InterruptedException
SQLExceptionInterruptedExceptionpublic void close()
close in interface AutoCloseableprotected void finalize()
throws Throwable
public int getJdbcTimeoutSeconds()
public boolean isIsHealthy()
Copyright © 2018 SPF4J. All rights reserved.