java.lang.Object
org.tentackle.dbms.PooledDb
Session managed by the session pool.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes a pooled db.protected Db
createSession
(int slotNumber) Creates a new session.long
Get epochal time of first use.Gets the mapped diagnostic context string.getPool()
Gets the session pool.Gets the referenced session.
This is the value of aWeakReference
.Returns the managed session.int
Gets the slot number.long
Gets the last return time.long
Gets the time lent.Gets the lending thread string.
Avoids the references to the thread.long
idleMinutes
(long currentTimeMillis) Returns the number of minutes the session has been unused.boolean
Checks for forgotten puts.toString()
void
Marks a pooled db unused.void
Marks a pooled db used.long
usedMinutes
(long currentTimeMillis) Returns the number of minutes the session has been used at all.
-
Constructor Details
-
PooledDb
Creates a pooled session.- Parameters:
pool
- the session poolslotNumber
- the slot number within the pool
-
-
Method Details
-
getPool
Gets the session pool.- Returns:
- the pool
-
getSlotNumber
public int getSlotNumber()Gets the slot number.- Returns:
- the slot number
-
getSession
Returns the managed session.- Returns:
- the managed session, null if currently lent
-
getReferencedDb
Gets the referenced session.
This is the value of aWeakReference
.- Returns:
- the session, null if no more referenced.
-
getFirstUse
public long getFirstUse()Get epochal time of first use.- Returns:
- the epochal time
-
getUsedSince
public long getUsedSince()Gets the time lent.- Returns:
- the epochal time since in use, 0 if not lent
-
getUnusedSince
public long getUnusedSince()Gets the last return time.- Returns:
- the epochal time last returned, 0 if lent
-
getUsingThreadStr
Gets the lending thread string.
Avoids the references to the thread.- Returns:
- the thread name, null if in pool
-
getMdcStr
Gets the mapped diagnostic context string.- Returns:
- the MDC
-
toString
-
close
public void close()Closes a pooled db. -
use
Marks a pooled db used.- Parameters:
usingThread
- the using thread
-
unUse
Marks a pooled db unused. -
isUnreferenced
public boolean isUnreferenced()Checks for forgotten puts.- Returns:
- true if db has been lent but never returned and is not referenced anymore
-
idleMinutes
public long idleMinutes(long currentTimeMillis) Returns the number of minutes the session has been unused.- Parameters:
currentTimeMillis
- the current time to refer to in epochal milliseconds- Returns:
- the idle minutes, 0 if in use or never used at all
-
usedMinutes
public long usedMinutes(long currentTimeMillis) Returns the number of minutes the session has been used at all.- Parameters:
currentTimeMillis
- the current time to refer to in epochal milliseconds- Returns:
- the usage minutes, 0 if never used at all
-
createSession
Creates a new session.- Parameters:
slotNumber
- the slot number- Returns:
- the open session
-