Class NavuContext
All data (config/oper) can be read using a Maapi transaction towards the DB_RUNNING database. If this transaction is opened in MODE_READ_WRITE mode, then configuration data can be written with this same transaction.
Another constructor NavuContext(Maapi)
exists as an option.
This constructor prepares a context and expects a Maapi
instance
with a started user session. Before using this type of context it is
mandatory to call either startRunningTrans(int)
or
startOperationalTrans(int)
to retrieve a maapi
transaction.
The user must manage the transaction which are started using the NavuContext.
This can be done either by the user storing the retrieved transaction id
and calling the low level Maapi methods
Maapi.applyTrans(int, boolean)
and/or
Maapi.finishTrans(int)
to commit and end the transaction.
There are also a set of convenience methods in the NavuContext to handle
the transaction like applyClearTrans()
and
finishClearTrans()
etc.
Using startRunningTrans(int)
is equivalent to using a
context created with the NavuContext(Maapi, int)
constructor which
is kept for backward compatibility.
A typical scenario using the NavuContext(Maapi)
constructor
would be something like.
NavuContext context = new NavuContext(maapi); int th context.startRunningTrans(Conf.MODE_READ_WRITE); // if operational data should be written the above line should be // replaced with: // int th = context.startOperationalTrans(Conf.MODE_READ_WRITE); ... Using Navu .... context.applyClearTrans(); // if nothing has been written to the transaction then nothing should // be applied and and following call should be used instead // context.finishClearTrans();
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tailf.navu.NavuContextBase
NavuContextBase.UnSetCaseInChoice
-
Field Summary
Fields inherited from class com.tailf.navu.NavuContextBase
unsetCaseInChoice
-
Constructor Summary
ConstructorDescriptionNavuContext
(Cdb cdb) Deprecated.NavuContext
(CdbSession session) Deprecated.NavuContext
(CdbSubscription cdbsub) Deprecated.NavuContext
(Maapi m) This constructor prepares a context to be used with a maapi transaction towards eitherConf.DB_RUNNING
orConf.DB_OPERATIONAL
.NavuContext
(Maapi m, int confTh) Constructor for running NAVU with a transaction towards DB_RUNNING.NavuContext
(Maapi readWrite, int readWriteTid, Maapi readOnly, int readOnlyTid) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This method applies any changes in this transaction (Commit) usingMaapi.applyTrans(int, boolean)
.void
This method applies (commit) and finish the transaction usingMaapi.applyTrans(int, boolean)
andMaapi.finishTrans(int)
.void
attachRunningTrans
(int th) Attach an existing transaction towards theConf.DB_RUNNING
database to be used in the context.int
Clears the internal transaction defined bystartRunningTrans(int)
orstartOperationalTrans(int)
The previous transaction id if any is returned but left unattended.void
For an context with an attached transaction usingattachRunningTrans(int)
this method will detach the transaction from the NavuContext maapi instancevoid
Finishes current trans usingMaapi.finishTrans(int)
and clears the trans from this NavuContext.void
set
(NavuContext context) Set the context attributes using another context object.int
startOperationalTrans
(int mode) This method starts a transaction towards theConf.DB_OPERATIONAL
database to be used in the context.int
startOperationalTrans
(int mode, String vendor, String product, String version, String clientId) int
This method starts a transaction towards the PRE_COMMIT_RUNNING datastore.int
startPreCommitRunningTrans
(String vendor, String product, String version, String clientId) int
startRunningTrans
(int mode) This method starts a transaction towards theConf.DB_RUNNING
database to be used in the context.int
startRunningTrans
(int mode, String vendor, String product, String version, String clientId) toString()
Methods inherited from class com.tailf.navu.NavuContextBase
currentCdbSession, getBackingStoreCdb, getBackingStoreCdbSession, getCdb, getCdbOperSession, getCdbOperSession, getCdbSession, getCdbSession, getCdbSubscriber, getMaapi, getMaapiHandle, getMaapiReadOnlyHandle, getNsList, getReadConfSession, getReadOnlyMaapi, getReadOperSession, getWriteOperSession, hasCdbSubscriber, isCdb, isCdbSession, isMaapi, isOnline, removeCdbSessions, set, setLockingMode, setOption, setReadConfLocks, setReadOperLocks, setWriteOperLocks
-
Constructor Details
-
NavuContext
Constructor for running NAVU with a transaction towards DB_RUNNING. If the supplied transaction is opened with MODE_READ, then both config and oper data can be read but no data can be written. If instead the supplied transaction is opened in MODE_READ_WRITE the config data can be both read and written while operational data only can be read.- Parameters:
m
- theMaapi
instance to be usedconfTh
- the transaction handle towards DB_RUNNING used for thisNavuContext
-
NavuContext
This constructor prepares a context to be used with a maapi transaction towards eitherConf.DB_RUNNING
orConf.DB_OPERATIONAL
. This transactions has to be started with one ofstartRunningTrans(int)
orstartOperationalTrans(int)
before the context can be used in NAVU.- Parameters:
m
- theMaapi
instance to be used
-
NavuContext
Deprecated.This constructor has been deprecatedConstructor for running NAVU with the
Cdb
mode.As this constructor takes a
Cdb
but it is never touched i.e no new Cdb sessions are opened on the supplied socket. Instead a newCdb
socket is constructed and used for new sessions.The Cdb sockets will be named "supplied-name"-pool:x where "supplied-name" is the name of the supplied
Cdb
socket name ( cdb.getName() ). The string "-pool:x" is appended where x is a internal integer counter.- Parameters:
cdb
- The Cdb socket used as the template orNavuContext
-
NavuContext
Deprecated. -
NavuContext
Deprecated.This constructor has been deprecated CDB Session constructor.- Parameters:
session
-
-
NavuContext
Deprecated.This constructor is deprecated.This constructor was formerly used to make the context delta-aware This was necessary when retrieving difference between current transaction and the data already committed into the database. Normally, deleted nodes are lost when we're in the scope of a transaction. The second Maapi socket provided ghost copies of deleted data allowing to read all data that has been deleted.
The context created by the
NavuContext(Maapi, int)
orNavuContext(Maapi)
constructor are now implicitly delta-aware. Therefore this constructor has become obsolete.The readOnly Maapi and readOnly transaction is not used and therefore obsolete.
- Parameters:
readWrite
- - a read write socket.readWriteTid
-readOnly
- - a read only on the RUNNING.readOnlyTid
-
-
-
Method Details
-
attachRunningTrans
Attach an existing transaction towards theConf.DB_RUNNING
database to be used in the context. Because the transaction is attached and not started by the NavuContext no finish or apply operations are allowed from the context. For example thefinishClearTrans()
will throw an exception for this type of context.- Parameters:
th
- transaction id- Throws:
NavuException
-
detachRunningTrans
For an context with an attached transaction usingattachRunningTrans(int)
this method will detach the transaction from the NavuContext maapi instance- Throws:
NavuException
-
startRunningTrans
This method starts a transaction towards theConf.DB_RUNNING
database to be used in the context. This method or its counterpartstartOperationalTrans(int)
is mandatory to call for a context created by theNavuContext(Maapi)
constructor before the context is being used in NAVU. Calling this method on contexts that already started an transaction will throw an NavuException. The user will need to manage the started transaction (apply/finish).- Parameters:
mode
- one ofConf.MODE_READ_WRITE
,Conf.MODE_READ
- Returns:
- transaction id for the started transaction
- Throws:
NavuException
-
startRunningTrans
public int startRunningTrans(int mode, String vendor, String product, String version, String clientId) throws NavuException - Throws:
NavuException
-
startPreCommitRunningTrans
This method starts a transaction towards the PRE_COMMIT_RUNNING datastore. This datastore only exists between aCdbSubscription.read()
and the followingCdbSubscription.sync(com.tailf.cdb.CdbSubscriptionSyncType)
. The normal use for this transaction type is to be used in a diffIteration where the operation isDiffIterateOperFlag.MOP_DELETED
and the deleted data values are of interest. This datastore can only be open inConf.MODE_READ
Calling this method on contexts that already started an transaction will throw an NavuException. The user will need to manage the finish of this transaction.- Returns:
- transaction id for the started transaction
- Throws:
NavuException
-
startPreCommitRunningTrans
public int startPreCommitRunningTrans(String vendor, String product, String version, String clientId) throws NavuException - Throws:
NavuException
-
startOperationalTrans
This method starts a transaction towards theConf.DB_OPERATIONAL
database to be used in the context. This method or its counterpartstartRunningTrans(int)
is mandatory to call for a context created by theNavuContext(Maapi)
constructor before the context is being used in NAVU. Calling this method on contexts that already started an transaction will throw an NavuException. The user will need to manage the started transaction (apply/finish).- Parameters:
mode
- one ofConf.MODE_READ_WRITE
,Conf.MODE_READ
- Returns:
- transaction id for the started transaction
- Throws:
NavuException
-
startOperationalTrans
public int startOperationalTrans(int mode, String vendor, String product, String version, String clientId) throws NavuException - Throws:
NavuException
-
clearTrans
Clears the internal transaction defined bystartRunningTrans(int)
orstartOperationalTrans(int)
The previous transaction id if any is returned but left unattended. If the transaction needs to be committed or finished this has to be performed outside of Navu. After clearing the transaction it is possible to start a new transaction usingstartRunningTrans(int)
orstartOperationalTrans(int)
. If no new transaction is started further navigation with this context will not be possible.- Returns:
- the previous transaction id or -1 if no transaction was started
- Throws:
NavuException
-
finishClearTrans
Finishes current trans usingMaapi.finishTrans(int)
and clears the trans from this NavuContext. After finish and clear of the transaction using this method it is possible to start a new transaction usingstartRunningTrans(int)
orstartOperationalTrans(int)
. If no new transaction is started further navigation with this context will not be possible.- Throws:
NavuException
-
applyClearTrans
This method applies any changes in this transaction (Commit) usingMaapi.applyTrans(int, boolean)
. Afterwards the transaction is finished usingMaapi.finishTrans(int)
and cleared form this NavuContext. After apply and clear of the transaction using this method it is possible to start a new transaction usingstartRunningTrans(int)
orstartOperationalTrans(int)
. If no new transaction is started further navigation with this context will not be possible. finishes the transaction. The NavuConn- Throws:
NavuException
-
applyReplaceTrans
This method applies (commit) and finish the transaction usingMaapi.applyTrans(int, boolean)
andMaapi.finishTrans(int)
. Afterwards an new transaction of same type (operational or running) and mode (Conf.MODE_READ
orConf.MODE_READ_WRITE
) is created and replaces the old applied transaction. Hence, navigation using this context can be resumed directly after this method call. Note, however that the depending of the committed transaction the Navu tree migth or migth not be up to date. There is no automatic sync or validation of the present Navu tree against the new transaction.- Throws:
NavuException
-
toString
- Overrides:
toString
in classNavuContextBase
-
getMountIdInterface
-