public interface NavuCdbSessionPoolable
NavuCdbSessionPoolable
interface should be implemented by
any class whose instance are intended to change the default behavior
of how CdbSession object is created and used in NAVU.
When using NAVU in with Cdb (passing Cdb object to constructor of the NavuContext ) :
Cdb cdb = ..; NavuContext ctx = new NavuContext(cdb);The argument
cdb
object to the constructor of
NavuContext
called the "root Cdb" by default is
not used directly. Which means no sessions are created on the root Cdb.
Instead it acts as a key to a map too look up other Cdb objects that in turn starts sessions towards different datastores.
The default implementation contains a map where the key is the "root Cdb" and the value is in turn another map (inner map).
The "inner map" where its key is of the type CdbDBType
contains
mapping between different datastores and a container that
contains "local Cdb
objects and corresponding
CdbSession
.
Map>Cdb<,Map>CdbDBType,SessionContainer>> map ..
class SessionContainer { CdbSession localSession; Cdb localCdb; ... }When NAVU needs to retrieve a
CdbSession
it calls the static
NavuCdbSessionPool.getCdbSession()
which in turn calls the
current implementation of this interface getSession
method.
The getSession(Cdb,CdbDBType)
or
getSession(Cdb,CdbDBType,EnumSet<CdbLockType>)
method must return a CdbSession
towards the specified the
datastore specified by the second parameter.
The removeCdbSessions(Cdb)
must release
the associated Cdb session for the corresponding Cdb, which is the
corresponding method of getSession(Cdb,CdbDBType)
.
Regardless it is left to the implementation which
Cdb
this CdbSession
is originated from.
The default implementation starts Cdb session from the "local Cdb".
And what a "release" really means in case of
removeCdbSession(Cdb)
.
The specify that a implementation should be used
the parameter com.tailf.navu.cdb.sessionpool
should be set to a binary name ( for example com.foo.NavuCdbSessionPoolImpl)
and should be passed to the jvm at startup:
java -Dcom.tailf.navu.cdb.sessionpool=com.foo.NavuCdbSessionPoolImpl ...It should be noted that the bytecode of the implementation must be available in the system classpath or a exception will be thrown and the default implementation that ships with the library will be used.
Modifier and Type | Method and Description |
---|---|
CdbSession |
getSession(Cdb rootCdb,
CdbDBType dbType,
EnumSet<CdbLockType> locks)
Returns a Cdb session to
dbType datastore with
the locks locks associated with the given Cdb. |
boolean |
poolInUse()
Returns true if the implementation pool is in use.
|
void |
removeAllForCdb(Cdb rootCdb)
Removes or closes all CdbSession associated with the supplied Cdb.
|
void |
removeAllSessions()
Removes all established session held by any Cdb.
|
CdbSession getSession(Cdb rootCdb, CdbDBType dbType, EnumSet<CdbLockType> locks) throws IOException, ConfException
dbType
datastore with
the locks locks
associated with the given Cdb.IOException
- on I/O failureConfException
- on protocol errorvoid removeAllForCdb(Cdb rootCdb) throws IOException, ConfException
IOException
- on I/O failureConfException
- on protocol errorvoid removeAllSessions() throws IOException, ConfException
IOException
- on I/O failureConfException
- on protocol errorboolean poolInUse()