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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method should rollback running to the checkpoint created by addCheckpointRunning().voidaddActionCapability(DBCBType dbCBType) Add action capability from annotated callType used to register capabilities on the servervoidaddActionMethod(String name, Method method) Add callback action method to proxyvoidThis method should be implemented only when ConfD owns the candidate, and confirmed-commit is enabled.voidThis method should check to see if the candidate has been modified or not.voidcandidateCommit(DpDbContext dbx, int timeout) This method should copy the candidate DB into the running DB.voidIf the timeout in the candidate_commit() method is != 0, we will be either invoked here or in the candidateRollbackRunning() method within timeout seconds.voidThis method is intended to copy the current running configuration into the candidate.voidIf for some reason, apart from a timeout, something goes wrong, we get invoked in the candidateRollbackRunning() method.voidThis callback is optional.voidCopies the 'running' database to 'startup'.voidThis method should delete a checkpoint created by addCheckPointRunning().voiddeleteConfig(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.voidlock(DpDbContext dbx, int dbname) This should only be implemented if our database supports locking from other sources than through ConfD.voidlockPartial(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.intmask()Mask of flags for methods that are supported by this callback:DpDbCallback.M_CANDIDATE_COMMITDpDbCallback.M_CANDIDATE_CONFIRMING_COMMITDpDbCallback.M_CANDIDATE_RESETDpDbCallback.M_CANDIDATE_CHK_NOT_MODIFIEDDpDbCallback.M_CANDIDATE_ROLLBACK_RUNNINGDpDbCallback.M_CANDIDATE_VALIDATEDpDbCallback.M_ADD_CHECKPOINT_RUNNINGDpDbCallback.M_DEL_CHECKPOINT_RUNNINGDpDbCallback.M_ACTIVATE_CHECKPOINT_RUNNINGDpDbCallback.M_COPY_RUNNING_TO_STARTUPDpDbCallback.M_LOCKDpDbCallback.M_UNLOCKDpDbCallback.M_DELETE_CONFIGDpDbCallback.M_LOCK_PARTIALDpDbCallback.M_UNLOCK_PARTIALDpDbCallback.M_RUNNING_CHK_NOT_MODIFIEDvoidThis function should check to see if running has been modified or not.voidunlock(DpDbContext dbx, int dbname) Unlocks the database.voidunlockPartial(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:DpDbCallbackMask 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:
maskin interfaceDpDbCallback
-
-
activateCheckpointRunning
Description copied from interface:DpDbCallbackThis 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:
activateCheckpointRunningin interfaceDpDbCallback- Parameters:
dbx- The database context- Throws:
DpCallbackException- Callback method failed.
-
addCheckpointRunning
Description copied from interface:DpDbCallbackThis 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:
addCheckpointRunningin interfaceDpDbCallback- Parameters:
dbx- The database context- Throws:
DpCallbackException- Callback method failed.
-
candidateChkNotModified
Description copied from interface:DpDbCallbackThis 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:
candidateChkNotModifiedin interfaceDpDbCallback- Parameters:
dbx- The database context- Throws:
DpCallbackException- Callback method failed.
-
candidateCommit
Description copied from interface:DpDbCallbackThis 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:
candidateCommitin interfaceDpDbCallback- Parameters:
dbx- The database contexttimeout- Timeout value- Throws:
DpCallbackException- Callback method failed.
-
candidateConfirmingCommit
Description copied from interface:DpDbCallbackIf 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:
candidateConfirmingCommitin interfaceDpDbCallback- Parameters:
dbx- The database context- Throws:
DpCallbackException- Callback method failed.
-
candidateReset
Description copied from interface:DpDbCallbackThis 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:
candidateResetin interfaceDpDbCallback- Parameters:
dbx- The database context- Throws:
DpCallbackException- Callback method failed.
-
candidateRollbackRunning
Description copied from interface:DpDbCallbackIf 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:
candidateRollbackRunningin interfaceDpDbCallback- Parameters:
dbx- The database context- Throws:
DpCallbackException- Callback method failed.
-
candidateValidate
Description copied from interface:DpDbCallbackThis 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:
candidateValidatein interfaceDpDbCallback- Parameters:
dbx- The database context- Throws:
DpCallbackException- Callback method failed.
-
copyRunningToStartup
Description copied from interface:DpDbCallbackCopies the 'running' database to 'startup'.- Specified by:
copyRunningToStartupin interfaceDpDbCallback- Parameters:
dbx- The database context- Throws:
DpCallbackException- Callback method failed.
-
delCheckpointRunning
Description copied from interface:DpDbCallbackThis method should delete a checkpoint created by addCheckPointRunning(). It is called by ConfD when a confirming commit is received.- Specified by:
delCheckpointRunningin interfaceDpDbCallback- Parameters:
dbx- The database context- Throws:
DpCallbackException- Callback method failed.
-
deleteConfig
Description copied from interface:DpDbCallbackWill be called for 'startup' or 'candidate' only. The database is supposed to be set to erased. The dbname constants:- Specified by:
deleteConfigin interfaceDpDbCallback- Parameters:
dbx- The database contextdbname- The database type- Throws:
DpCallbackException- Callback method failed.
-
lock
Description copied from interface:DpDbCallbackThis 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:
lockin 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:DpDbCallbackThis 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:
lockPartialin interfaceDpDbCallback- Parameters:
dbx- The database contextdbname- the databaselockid- The lock referencepaths- Paths to lock- Throws:
DpCallbackException- Callback method failed
-
unlock
Description copied from interface:DpDbCallbackUnlocks the database. The dbname constants:- Specified by:
unlockin interfaceDpDbCallback- Parameters:
dbx- The database contextdbname- The database type- Throws:
DpCallbackException- Callback method failed.
-
unlockPartial
Description copied from interface:DpDbCallbackUnlocks the partial locks that where previously locked withDpDbCallback.lockPartial(DpDbContext,int,int,ConfObject[][]). The dbname constants:- Specified by:
unlockPartialin interfaceDpDbCallback- Parameters:
dbx- The database contextdbname- The database typelockid- The lock reference- Throws:
DpCallbackException- Callback method failed.
-
runningChkNotModified
Description copied from interface:DpDbCallbackThis 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:
runningChkNotModifiedin 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
-