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 SummaryNested classes/interfaces inherited from class com.tailf.navu.NavuContextBaseNavuContextBase.UnSetCaseInChoice
- 
Field SummaryFields inherited from class com.tailf.navu.NavuContextBaseunsetCaseInChoice
- 
Constructor SummaryConstructorsConstructorDescriptionNavuContext(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_RUNNINGorConf.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 SummaryModifier and TypeMethodDescriptionvoidThis method applies any changes in this transaction (Commit) usingMaapi.applyTrans(int, boolean).voidThis method applies (commit) and finish the transaction usingMaapi.applyTrans(int, boolean)andMaapi.finishTrans(int).voidattachRunningTrans(int th) Attach an existing transaction towards theConf.DB_RUNNINGdatabase to be used in the context.intClears the internal transaction defined bystartRunningTrans(int)orstartOperationalTrans(int)The previous transaction id if any is returned but left unattended.voidFor an context with an attached transaction usingattachRunningTrans(int)this method will detach the transaction from the NavuContext maapi instancevoidFinishes current trans usingMaapi.finishTrans(int)and clears the trans from this NavuContext.voidset(NavuContext context) Set the context attributes using another context object.intstartOperationalTrans(int mode) This method starts a transaction towards theConf.DB_OPERATIONALdatabase to be used in the context.intstartOperationalTrans(int mode, String vendor, String product, String version, String clientId) intThis method starts a transaction towards the PRE_COMMIT_RUNNING datastore.intstartPreCommitRunningTrans(String vendor, String product, String version, String clientId) intstartRunningTrans(int mode) This method starts a transaction towards theConf.DB_RUNNINGdatabase to be used in the context.intstartRunningTrans(int mode, String vendor, String product, String version, String clientId) toString()Methods inherited from class com.tailf.navu.NavuContextBasecurrentCdbSession, 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- 
NavuContextConstructor 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- the- Maapiinstance to be used
- confTh- the transaction handle towards DB_RUNNING used for this- NavuContext
 
- 
NavuContextThis constructor prepares a context to be used with a maapi transaction towards eitherConf.DB_RUNNINGorConf.DB_OPERATIONAL. This transactions has to be started with one ofstartRunningTrans(int)orstartOperationalTrans(int)before the context can be used in NAVU.- Parameters:
- m- the- Maapiinstance to be used
 
- 
NavuContextDeprecated.This constructor has been deprecatedConstructor for running NAVU with the Cdbmode.As this constructor takes a Cdbbut it is never touched i.e no new Cdb sessions are opened on the supplied socket. Instead a newCdbsocket 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 Cdbsocket 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 or- NavuContext
 
- 
NavuContextDeprecated.
- 
NavuContextDeprecated.This constructor has been deprecated CDB Session constructor.- Parameters:
- session-
 
- 
NavuContextDeprecated.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- 
attachRunningTransAttach an existing transaction towards theConf.DB_RUNNINGdatabase 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
 
- 
detachRunningTransFor an context with an attached transaction usingattachRunningTrans(int)this method will detach the transaction from the NavuContext maapi instance- Throws:
- NavuException
 
- 
startRunningTransThis method starts a transaction towards theConf.DB_RUNNINGdatabase 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 of- Conf.MODE_READ_WRITE,- Conf.MODE_READ
- Returns:
- transaction id for the started transaction
- Throws:
- NavuException
 
- 
startRunningTranspublic int startRunningTrans(int mode, String vendor, String product, String version, String clientId) throws NavuException - Throws:
- NavuException
 
- 
startPreCommitRunningTransThis 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_DELETEDand the deleted data values are of interest. This datastore can only be open inConf.MODE_READCalling 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
 
- 
startPreCommitRunningTranspublic int startPreCommitRunningTrans(String vendor, String product, String version, String clientId) throws NavuException - Throws:
- NavuException
 
- 
startOperationalTransThis method starts a transaction towards theConf.DB_OPERATIONALdatabase 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 of- Conf.MODE_READ_WRITE,- Conf.MODE_READ
- Returns:
- transaction id for the started transaction
- Throws:
- NavuException
 
- 
startOperationalTranspublic int startOperationalTrans(int mode, String vendor, String product, String version, String clientId) throws NavuException - Throws:
- NavuException
 
- 
clearTransClears 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
 
- 
finishClearTransFinishes 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
 
- 
applyClearTransThis 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
 
- 
applyReplaceTransThis 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_READorConf.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:
- toStringin class- NavuContextBase
 
- 
getMountIdInterface
 
-