public interface DpDbCallback
We may also optionally have a set of callback methods which span over several transactions.
If the system is configured in such a way so that the external database owns the candidate data store we must implement callback methods to do this. If ConfD owns the candidate the candidate callbacks can be skipped. Additionally, the lock() callback should be implemented (see more below).
If ConfD owns the candidate, and ConfD has been configured to support confirmed-commit, then three checkpointing methods must be implemented. When confirmed-commit is enabled, the user can commit the candidate with a timeout. Unless a confirming commit is given by the user before the timer expires, the system must rollback to the previous running configuration. This mechanism is controlled by the checkpoint callbacks. See further below.
An external database may also (optionally) support the lock/unlock and lockPartial/unlockPartial operations. This is only interesting if there exists additional locking mechanisms towards the database - such as an external CLI which can lock the database, or if the external database owns the candidate.
Finally, the external database may optionally validate a configuration. Configuration validation is preferably done through ConfD - however if a system already has implemented extensive configuration validation - the validate() callback can be used.
Dp.registerAnnotatedCallbacks(Object)
Modifier and Type | Method and Description |
---|---|
void |
activateCheckpointRunning(DpDbContext dbx)
This method should rollback running to the checkpoint created by
addCheckpointRunning().
|
void |
addCheckpointRunning(DpDbContext dbx)
This method should be implemented only when ConfD owns the candidate, and
confirmed-commit is enabled.
|
void |
candidateChkNotModified(DpDbContext dbx)
This method should check to see if the candidate has been modified or
not.
|
void |
candidateCommit(DpDbContext dbx,
int timeout)
This method should copy the candidate DB into the running DB.
|
void |
candidateConfirmingCommit(DpDbContext dbx)
If the timeout in the candidate_commit() method is != 0, we will be
either invoked here or in the candidateRollbackRunning() method within
timeout seconds.
|
void |
candidateReset(DpDbContext dbx)
This method is intended to copy the current running configuration into
the candidate.
|
void |
candidateRollbackRunning(DpDbContext dbx)
If for some reason, apart from a timeout, something goes wrong, we get
invoked in the candidateRollbackRunning() method.
|
void |
candidateValidate(DpDbContext dbx)
This callback is optional.
|
void |
copyRunningToStartup(DpDbContext dbx)
Copies the 'running' database to 'startup'.
|
void |
delCheckpointRunning(DpDbContext dbx)
This method should delete a checkpoint created by addCheckPointRunning().
|
void |
deleteConfig(DpDbContext dbx,
int dbname)
Will be called for 'startup' or 'candidate' only.
|
void |
lock(DpDbContext dbx,
int dbname)
This should only be implemented if our database supports locking from
other sources than through ConfD.
|
void |
lockPartial(DpDbContext dbx,
int dbname,
int lockid,
ConfObject[][] paths)
This should only be implemented if our database supports locking from
other sources than through ConfD, see
DpDbCallback.lock(DpDbContext,int)
above. |
int |
mask()
Mask of flags for methods that are supported by this callback:
DpDbCallback.M_CANDIDATE_COMMIT
DpDbCallback.M_CANDIDATE_CONFIRMING_COMMIT
DpDbCallback.M_CANDIDATE_RESET
DpDbCallback.M_CANDIDATE_CHK_NOT_MODIFIED
DpDbCallback.M_CANDIDATE_ROLLBACK_RUNNING
DpDbCallback.M_CANDIDATE_VALIDATE
DpDbCallback.M_ADD_CHECKPOINT_RUNNING
DpDbCallback.M_DEL_CHECKPOINT_RUNNING
DpDbCallback.M_ACTIVATE_CHECKPOINT_RUNNING
DpDbCallback.M_COPY_RUNNING_TO_STARTUP
DpDbCallback.M_LOCK
DpDbCallback.M_UNLOCK
DpDbCallback.M_DELETE_CONFIG
DpDbCallback.M_LOCK_PARTIAL
DpDbCallback.M_UNLOCK_PARTIAL
DpDbCallback.M_RUNNING_CHK_NOT_MODIFIED
|
void |
runningChkNotModified(DpDbContext dbx)
This function should check to see if running has been modified or not.
|
void |
unlock(DpDbContext dbx,
int dbname)
Unlocks the database.
|
void |
unlockPartial(DpDbContext dbx,
int dbname,
int lockid)
Unlocks the partial locks that where previously locked with
DpDbCallback.lockPartial(DpDbContext,int,int,ConfObject[][]) . |
static final int M_CANDIDATE_COMMIT
DpDbCallback.candidateCommit(DpDbContext,int)
method.static final int M_CANDIDATE_CONFIRMING_COMMIT
DpDbCallback.candidateConfirmingCommit(DpDbContext)
method.static final int M_CANDIDATE_RESET
DpDbCallback.candidateReset(DpDbContext)
method.static final int M_CANDIDATE_CHK_NOT_MODIFIED
DpDbCallback.candidateChkNotModified(DpDbContext)
method.static final int M_CANDIDATE_ROLLBACK_RUNNING
DpDbCallback.candidateRollbackRunning(DpDbContext)
method.static final int M_CANDIDATE_VALIDATE
DpDbCallback.candidateValidate(DpDbContext)
method.static final int M_ADD_CHECKPOINT_RUNNING
DpDbCallback.addCheckpointRunning(DpDbContext)
method.static final int M_DEL_CHECKPOINT_RUNNING
DpDbCallback.delCheckpointRunning(DpDbContext)
method.static final int M_ACTIVATE_CHECKPOINT_RUNNING
DpDbCallback.activateCheckpointRunning(DpDbContext)
method.static final int M_COPY_RUNNING_TO_STARTUP
DpDbCallback.copyRunningToStartup(DpDbContext)
method.static final int M_LOCK
DpDbCallback.lock(DpDbContext,int)
method.static final int M_UNLOCK
DpDbCallback.unlock(DpDbContext,int)
method.static final int M_DELETE_CONFIG
DpDbCallback.deleteConfig(DpDbContext,int)
method.static final int M_LOCK_PARTIAL
DpDbCallback.lockPartial(DpDbContext,int,int,ConfObject[][])
method.static final int M_UNLOCK_PARTIAL
DpDbCallback.unlockPartial(DpDbContext,int,int)
method.static final int M_RUNNING_CHK_NOT_MODIFIED
DpDbCallback.runningChkNotModified(DpDbContext)
method.static final int M_ALL
int mask()
DpDbCallback.M_CANDIDATE_COMMIT
DpDbCallback.M_CANDIDATE_CONFIRMING_COMMIT
DpDbCallback.M_CANDIDATE_RESET
DpDbCallback.M_CANDIDATE_CHK_NOT_MODIFIED
DpDbCallback.M_CANDIDATE_ROLLBACK_RUNNING
DpDbCallback.M_CANDIDATE_VALIDATE
DpDbCallback.M_ADD_CHECKPOINT_RUNNING
DpDbCallback.M_DEL_CHECKPOINT_RUNNING
DpDbCallback.M_ACTIVATE_CHECKPOINT_RUNNING
DpDbCallback.M_COPY_RUNNING_TO_STARTUP
DpDbCallback.M_LOCK
DpDbCallback.M_UNLOCK
DpDbCallback.M_DELETE_CONFIG
DpDbCallback.M_LOCK_PARTIAL
DpDbCallback.M_UNLOCK_PARTIAL
DpDbCallback.M_RUNNING_CHK_NOT_MODIFIED
void candidateCommit(DpDbContext dbx, int timeout) throws DpCallbackException
dbx
- The database contexttimeout
- Timeout valueDpCallbackException
- Callback method failed.void candidateConfirmingCommit(DpDbContext dbx) throws DpCallbackException
dbx
- The database contextDpCallbackException
- Callback method failed.void candidateRollbackRunning(DpDbContext dbx) throws DpCallbackException
dbx
- The database contextDpCallbackException
- Callback method failed.void candidateReset(DpDbContext dbx) throws DpCallbackException
dbx
- The database contextDpCallbackException
- Callback method failed.void candidateChkNotModified(DpDbContext dbx) throws DpCallbackException
DpCallbackException
(error) if any
uncommitted modifications exist.dbx
- The database contextDpCallbackException
- Callback method failed.void candidateValidate(DpDbContext dbx) throws DpCallbackException
dbx
- The database contextDpCallbackException
- Callback method failed.void addCheckpointRunning(DpDbContext dbx) throws DpCallbackException
It is responsible for creating a checkpoint of the current running configuration and storing the checkpoint in non-volatile memory. When the system restarts this method should check if there is a checkpoint available, and use the checkpoint instead of running.
dbx
- The database contextDpCallbackException
- Callback method failed.void delCheckpointRunning(DpDbContext dbx) throws DpCallbackException
dbx
- The database contextDpCallbackException
- Callback method failed.void activateCheckpointRunning(DpDbContext dbx) throws DpCallbackException
dbx
- The database contextDpCallbackException
- Callback method failed.void copyRunningToStartup(DpDbContext dbx) throws DpCallbackException
dbx
- The database contextDpCallbackException
- Callback method failed.void lock(DpDbContext dbx, int dbname) throws DpCallbackException
DpCallbackException
(error) if the lock was already held by
an external entity.
The dbname constants:
dbx
- The database contextdbname
- The database typeDpCallbackException
- Callback method failed.void unlock(DpDbContext dbx, int dbname) throws DpCallbackException
dbx
- The database contextdbname
- The database typeDpCallbackException
- Callback method failed.void lockPartial(DpDbContext dbx, int dbname, int lockid, ConfObject[][] paths) throws DpCallbackException
DpDbCallback.lock(DpDbContext,int)
above. This callback is invoked if a northbound agent requests a partial
lock. The paths[] argument is an array of keypaths that identify the
leafs and/or subtrees that are to be locked. The lockid is a reference
that will be used on a subsequent corresponding unlockPartial()
invocation. Throws a DpCallbackException
(error) if the lock
was already held by an external entity.
The dbname constants:
dbx
- The database contextdbname
- the databaselockid
- The lock referencepaths
- Paths to lockDpCallbackException
- Callback method failedvoid unlockPartial(DpDbContext dbx, int dbname, int lockid) throws DpCallbackException
DpDbCallback.lockPartial(DpDbContext,int,int,ConfObject[][])
. The dbname
constants:
dbx
- The database contextdbname
- The database typelockid
- The lock referenceDpCallbackException
- Callback method failed.void deleteConfig(DpDbContext dbx, int dbname) throws DpCallbackException
dbx
- The database contextdbname
- The database typeDpCallbackException
- Callback method failed.void runningChkNotModified(DpDbContext dbx) throws DpCallbackException
dbx
- The database contextDpCallbackException
- Callback method failed