Class LockingDatabase
java.lang.Object
com.zenith.database.Database
com.zenith.database.LockingDatabase
- Direct Known Subclasses:
LiveDatabase,PlayerCountDatabase,PlaytimeDatabase,QueueLengthDatabase,RestartsDatabase,TablistDatabase,TimeDatabase
Base class for databases that require a lock to be acquired before writing
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Queue<LockingDatabase.InsertInstance> protected final AtomicBooleanprotected ScheduledExecutorServiceprotected final RedisClientFields inherited from class com.zenith.database.Database
queryExecutor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract InstantQuery the database, get latest entry Then drop all records later than that in our queueabstract StringintbooleanhasLock()These lock methods must be executed within the lock threadprotected voidvoidvoidvoidprotected voidvoidvoidstart()voidstop()voidSync the current insert queue with what is in the remote database intended as a deduping mechanismbooleantryLock()voidMethods inherited from class com.zenith.database.Database
subscribeEvents
-
Field Details
-
insertQueue
-
lockAcquired
-
redisClient
-
lockExecutorService
-
-
Constructor Details
-
LockingDatabase
-
-
Method Details
-
getLockKey
-
getLastEntryTime
Query the database, get latest entry Then drop all records later than that in our queue -
getMaxQueueLength
public int getMaxQueueLength() -
syncQueue
public void syncQueue()Sync the current insert queue with what is in the remote database intended as a deduping mechanism -
start
-
stop
-
onLockAcquired
public void onLockAcquired() -
onLockReleased
public void onLockReleased() -
hasLock
public boolean hasLock()These lock methods must be executed within the lock thread -
tryLock
public boolean tryLock() -
releaseLock
public void releaseLock() -
tryLockProcess
public void tryLockProcess() -
insert
-
insert
-
processQueue
protected void processQueue()
-