Package com.tailf.dp.annotations
Class DBCallbackProxy
Object
com.tailf.dp.annotations.DBCallbackProxy
- All Implemented Interfaces:
DpDbCallback
Callback proxy for DB Callbacks. Implements the
DpDbCallback
interface and delegates calls to the registered callback POJO with annotated
methods- Since:
- 3.2.0
-
Field Summary
Fields inherited from interface com.tailf.dp.DpDbCallback
M_ACTIVATE_CHECKPOINT_RUNNING, M_ADD_CHECKPOINT_RUNNING, M_ALL, M_CANDIDATE_CHK_NOT_MODIFIED, M_CANDIDATE_COMMIT, M_CANDIDATE_CONFIRMING_COMMIT, M_CANDIDATE_RESET, M_CANDIDATE_ROLLBACK_RUNNING, M_CANDIDATE_VALIDATE, M_COPY_RUNNING_TO_STARTUP, M_DEL_CHECKPOINT_RUNNING, M_DELETE_CONFIG, M_LOCK, M_LOCK_PARTIAL, M_RUNNING_CHK_NOT_MODIFIED, M_UNLOCK, M_UNLOCK_PARTIAL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method should rollback running to the checkpoint created by addCheckpointRunning().void
addActionCapability
(DBCBType dbCBType) Add action capability from annotated callType used to register capabilities on the servervoid
addActionMethod
(String name, Method method) Add callback action method to proxyvoid
This method should be implemented only when ConfD owns the candidate, and confirmed-commit is enabled.void
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
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
This method is intended to copy the current running configuration into the candidate.void
If for some reason, apart from a timeout, something goes wrong, we get invoked in the candidateRollbackRunning() method.void
This callback is optional.void
Copies the 'running' database to 'startup'.void
This method should delete a checkpoint created by addCheckPointRunning().void
deleteConfig
(DpDbContext dbx, int dbname) Will be called for 'startup' or 'candidate' only.Retrieve the callback POJOstatic DBCallbackProxy[]
Get array of proxy objects from registered POJO callback.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, seeDpDbCallback.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
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 withDpDbCallback.lockPartial(DpDbContext,int,int,ConfObject[][])
.
-
Constructor Details
-
DBCallbackProxy
Constructor for Callback proxys. Used internally.- Parameters:
backupObject
- registered callback POJO
-
-
Method Details
-
getBackupObject
Retrieve the callback POJO- Returns:
- Object registered callback object
-
addActionMethod
Add callback action method to proxy- Parameters:
name
- canonical action namemethod
- registered callback method
-
addActionCapability
Add action capability from annotated callType used to register capabilities on the server- Parameters:
dbCBType
- action type
-
mask
public int mask()Description copied from interface:DpDbCallback
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
- Specified by:
mask
in interfaceDpDbCallback
-
-
activateCheckpointRunning
Description copied from interface:DpDbCallback
This method should rollback running to the checkpoint created by addCheckpointRunning(). It is called by ConfD when the timer expires or if the user session expires.- Specified by:
activateCheckpointRunning
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed.
-
addCheckpointRunning
Description copied from interface:DpDbCallback
This method should be implemented only when ConfD owns the candidate, and confirmed-commit is enabled.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.
- Specified by:
addCheckpointRunning
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed.
-
candidateChkNotModified
Description copied from interface:DpDbCallback
This method should check to see if the candidate has been modified or not. Returns if no modifications has been done since the last commit or reset, and throws aDpCallbackException
(error) if any uncommitted modifications exist.- Specified by:
candidateChkNotModified
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed.
-
candidateCommit
Description copied from interface:DpDbCallback
This method should copy the candidate DB into the running DB. If timeout != 0, we should be prepared to do a rollback or act on a candidateConfirmingCommit(). The timeout parameter can not be used to set a timer for when to rollback; this timer is handled by the ConfD daemon. If we terminate without having acted on the candidateConfirmingCommit(), we MUST restart with a rollback. Thus we must remember that we are waiting for a candidateConfirmingCommit() and we must do so on persistent storage. Must only be implemented when the external database owns the candidate.- Specified by:
candidateCommit
in interfaceDpDbCallback
- Parameters:
dbx
- The database contexttimeout
- Timeout value- Throws:
DpCallbackException
- Callback method failed.
-
candidateConfirmingCommit
Description copied from interface:DpDbCallback
If the timeout in the candidate_commit() method is != 0, we will be either invoked here or in the candidateRollbackRunning() method within timeout seconds. candidateConfirmingCommit() should make the commit persistent, whereas a call to candidateRollbackRunning() would copy back the previous running configuration to running.- Specified by:
candidateConfirmingCommit
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed.
-
candidateReset
Description copied from interface:DpDbCallback
This method is intended to copy the current running configuration into the candidate. It is invoked whenever the NETCONF operation <discard-changes> is executed or when a lock is released without committing.- Specified by:
candidateReset
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed.
-
candidateRollbackRunning
Description copied from interface:DpDbCallback
If for some reason, apart from a timeout, something goes wrong, we get invoked in the candidateRollbackRunning() method. The method should copy back the previous running configuration to running.- Specified by:
candidateRollbackRunning
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed.
-
candidateValidate
Description copied from interface:DpDbCallback
This callback is optional. If implemented, the task of the callback is to validate the candidate configuration. Note that the running database can be validated by the database in the prepare() callback. candidateValidate() is only meaningful when an explicit validate operation is received, e.g. through NETCONF.- Specified by:
candidateValidate
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed.
-
copyRunningToStartup
Description copied from interface:DpDbCallback
Copies the 'running' database to 'startup'.- Specified by:
copyRunningToStartup
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed.
-
delCheckpointRunning
Description copied from interface:DpDbCallback
This method should delete a checkpoint created by addCheckPointRunning(). It is called by ConfD when a confirming commit is received.- Specified by:
delCheckpointRunning
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed.
-
deleteConfig
Description copied from interface:DpDbCallback
Will be called for 'startup' or 'candidate' only. The database is supposed to be set to erased. The dbname constants:- Specified by:
deleteConfig
in interfaceDpDbCallback
- Parameters:
dbx
- The database contextdbname
- The database type- Throws:
DpCallbackException
- Callback method failed.
-
lock
Description copied from interface:DpDbCallback
This should only be implemented if our database supports locking from other sources than through ConfD. If a lock is set through e.g. NETCONF, ConfD will first make sure that no other ConfD transaction has locked the database. Then it will call lock() to make sure that the database is not locked by some other source (such as a CLI). Throws aDpCallbackException
(error) if the lock was already held by an external entity.The dbname constants:
- Specified by:
lock
in interfaceDpDbCallback
- Parameters:
dbx
- The database contextdbname
- The database type- Throws:
DpCallbackException
- Callback method failed.
-
lockPartial
public void lockPartial(DpDbContext dbx, int dbname, int lockid, ConfObject[][] paths) throws DpCallbackException Description copied from interface:DpDbCallback
This should only be implemented if our database supports locking from other sources than through ConfD, seeDpDbCallback.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 aDpCallbackException
(error) if the lock was already held by an external entity.The dbname constants:
- Specified by:
lockPartial
in interfaceDpDbCallback
- Parameters:
dbx
- The database contextdbname
- the databaselockid
- The lock referencepaths
- Paths to lock- Throws:
DpCallbackException
- Callback method failed
-
unlock
Description copied from interface:DpDbCallback
Unlocks the database. The dbname constants:- Specified by:
unlock
in interfaceDpDbCallback
- Parameters:
dbx
- The database contextdbname
- The database type- Throws:
DpCallbackException
- Callback method failed.
-
unlockPartial
Description copied from interface:DpDbCallback
Unlocks the partial locks that where previously locked withDpDbCallback.lockPartial(DpDbContext,int,int,ConfObject[][])
. The dbname constants:- Specified by:
unlockPartial
in interfaceDpDbCallback
- Parameters:
dbx
- The database contextdbname
- The database typelockid
- The lock reference- Throws:
DpCallbackException
- Callback method failed.
-
runningChkNotModified
Description copied from interface:DpDbCallback
This function should check to see if running has been modified or not. It only needs to be implemented if the startup data store is enabled. Return silently if no modifications have been done since the last copy of running to startup, and should throw an DpCallbackException if any modifications exist.- Specified by:
runningChkNotModified
in interfaceDpDbCallback
- Parameters:
dbx
- The database context- Throws:
DpCallbackException
- Callback method failed
-
getDBCallbackProxys
Get array of proxy objects from registered POJO callback. Used internally at callback registration- Parameters:
obj
- registered Callback POJO- Returns:
- array of DBCallbackProxy
- Throws:
DpCallbackException
-