Package org.cyclos.impl.sql
Interface DbLockHandler
-
- All Known Implementing Classes:
BaseDbLockHandlerImpl,PostgresqlLockHandlerImpl
public interface DbLockHandlerManages the database lock, via the db_lock table. The database lock avoids 2 independent Cyclos instances from using the same database at the same time, which could lead to data corruption.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidlock(String host, DbLock dbLock)Locks the database, by either inserting or updating the existing row in db_lock table, and schedules a timer to update the table every few secondsvoidprepare()Makes sure the table existsDbLockread()Return the current row, if anyvoidsleepUntilTryingAgain(DbLock dbLock)Sleeps for a few seconds before attempting to check again if the db is lockedvoidthrowAlreadyLocked(DbLock dbLock)Throws an appropriate error indicating the current db is already lockedvoidunlock()Delete the row
-
-
-
Method Detail
-
lock
void lock(String host, @Nullable DbLock dbLock)
Locks the database, by either inserting or updating the existing row in db_lock table, and schedules a timer to update the table every few seconds
-
prepare
void prepare()
Makes sure the table exists
-
read
@Nullable DbLock read()
Return the current row, if any
-
sleepUntilTryingAgain
void sleepUntilTryingAgain(@Nonnull DbLock dbLock)Sleeps for a few seconds before attempting to check again if the db is locked
-
throwAlreadyLocked
void throwAlreadyLocked(@Nullable DbLock dbLock)Throws an appropriate error indicating the current db is already locked
-
unlock
void unlock()
Delete the row
-
-