private static class DatabaseManager.AutoConnected
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicBoolean |
activated
Flag indicating that the database has been deactivated
|
private java.util.Set<java.lang.Integer> |
connected
Connected sessions' ids
|
private Database |
db
Database
|
private java.util.concurrent.locks.ReentrantReadWriteLock |
lock
Data guard
|
private java.util.concurrent.atomic.AtomicReference<java.util.Date> |
notActiveSince
The timestamp of the most recent database deactivation
|
Constructor and Description |
---|
AutoConnected(Database db)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
activated()
Mark the database as activated
|
boolean |
add(java.lang.Integer sessionId)
Add the user session which uses the database.
|
void |
deactivated()
Mark the database as deactivated
|
boolean |
isActivated()
Check if the database is activated.
|
java.util.Date |
notActiveSince()
Get the timestamp of the most recent database deactivation.
|
java.util.concurrent.locks.Lock |
readLock()
Get the read lock.
|
boolean |
remove(java.lang.Integer sessionId)
Remove the user session which has used the database.
|
java.util.concurrent.locks.Lock |
writeLock()
Get the write lock.
|
private final Database db
private final java.util.concurrent.locks.ReentrantReadWriteLock lock
private final java.util.Set<java.lang.Integer> connected
private final java.util.concurrent.atomic.AtomicReference<java.util.Date> notActiveSince
private final java.util.concurrent.atomic.AtomicBoolean activated
public AutoConnected(Database db)
db
- Database.public java.util.concurrent.locks.Lock readLock()
public java.util.concurrent.locks.Lock writeLock()
public boolean isActivated()
true
if the database is activated.public void activated()
public void deactivated()
public boolean add(java.lang.Integer sessionId)
sessionId
- The session id which uses the database.true
if the session was not registered before.public boolean remove(java.lang.Integer sessionId)
sessionId
- The session id which has used the database.true
if the session was registered.public java.util.Date notActiveSince()