public class DBCallbackProxy extends Object implements DpDbCallback
DpDbCallback
interface and delegates calls to the registered callback POJO with annotated
methodsM_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 and Description |
---|
DBCallbackProxy(Object backupObject)
Constructor for Callback proxys.
|
Modifier and Type | Method and Description |
---|---|
void |
activateCheckpointRunning(DpDbContext dbx)
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 server
|
void |
addActionMethod(String name,
Method method)
Add callback action method to proxy
|
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.
|
Object |
getBackupObject()
Retrieve the callback POJO
|
static DBCallbackProxy[] |
getDBCallbackProxys(Object obj)
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, 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[][]) . |
public DBCallbackProxy(Object backupObject)
backupObject
- registered callback POJOpublic Object getBackupObject()
public void addActionMethod(String name, Method method)
name
- canonical action namemethod
- registered callback methodpublic void addActionCapability(DBCBType dbCBType)
dbCBType
- action typepublic int mask()
DpDbCallback
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
mask
in interface DpDbCallback
public void activateCheckpointRunning(DpDbContext dbx) throws DpCallbackException
DpDbCallback
activateCheckpointRunning
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failed.public void addCheckpointRunning(DpDbContext dbx) throws DpCallbackException
DpDbCallback
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.
addCheckpointRunning
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failed.public void candidateChkNotModified(DpDbContext dbx) throws DpCallbackException
DpDbCallback
DpCallbackException
(error) if any
uncommitted modifications exist.candidateChkNotModified
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failed.public void candidateCommit(DpDbContext dbx, int timeout) throws DpCallbackException
DpDbCallback
candidateCommit
in interface DpDbCallback
dbx
- The database contexttimeout
- Timeout valueDpCallbackException
- Callback method failed.public void candidateConfirmingCommit(DpDbContext dbx) throws DpCallbackException
DpDbCallback
candidateConfirmingCommit
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failed.public void candidateReset(DpDbContext dbx) throws DpCallbackException
DpDbCallback
candidateReset
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failed.public void candidateRollbackRunning(DpDbContext dbx) throws DpCallbackException
DpDbCallback
candidateRollbackRunning
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failed.public void candidateValidate(DpDbContext dbx) throws DpCallbackException
DpDbCallback
candidateValidate
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failed.public void copyRunningToStartup(DpDbContext dbx) throws DpCallbackException
DpDbCallback
copyRunningToStartup
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failed.public void delCheckpointRunning(DpDbContext dbx) throws DpCallbackException
DpDbCallback
delCheckpointRunning
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failed.public void deleteConfig(DpDbContext dbx, int dbname) throws DpCallbackException
DpDbCallback
deleteConfig
in interface DpDbCallback
dbx
- The database contextdbname
- The database typeDpCallbackException
- Callback method failed.public void lock(DpDbContext dbx, int dbname) throws DpCallbackException
DpDbCallback
DpCallbackException
(error) if the lock was already held by
an external entity.
The dbname constants:
lock
in interface DpDbCallback
dbx
- The database contextdbname
- The database typeDpCallbackException
- Callback method failed.public void lockPartial(DpDbContext dbx, int dbname, int lockid, ConfObject[][] paths) throws DpCallbackException
DpDbCallback
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:
lockPartial
in interface DpDbCallback
dbx
- The database contextdbname
- the databaselockid
- The lock referencepaths
- Paths to lockDpCallbackException
- Callback method failedpublic void unlock(DpDbContext dbx, int dbname) throws DpCallbackException
DpDbCallback
unlock
in interface DpDbCallback
dbx
- The database contextdbname
- The database typeDpCallbackException
- Callback method failed.public void unlockPartial(DpDbContext dbx, int dbname, int lockid) throws DpCallbackException
DpDbCallback
DpDbCallback.lockPartial(DpDbContext,int,int,ConfObject[][])
. The dbname
constants:
unlockPartial
in interface DpDbCallback
dbx
- The database contextdbname
- The database typelockid
- The lock referenceDpCallbackException
- Callback method failed.public void runningChkNotModified(DpDbContext dbx) throws DpCallbackException
DpDbCallback
runningChkNotModified
in interface DpDbCallback
dbx
- The database contextDpCallbackException
- Callback method failedpublic static DBCallbackProxy[] getDBCallbackProxys(Object obj) throws DpCallbackException
obj
- registered Callback POJODpCallbackException