Interface DpDataCallback
- All Known Implementing Classes:
DataCallbackProxy
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Bit flag for all flagsstatic final int
Bit flag for thecreate(DpTrans,ConfObject[])
method.static final int
Bit flag for theexistsOptional(DpTrans,ConfObject[])
method.static final int
Bit flag for thegetAttrs(DpTrans, ConfObject[], List)
method.static final int
Bit flag for thegetCase(DpTrans, ConfObject[], ConfObject[])
method.static final int
Bit flag for thegetElem(DpTrans,ConfObject[])
method.static final int
Bit flag for getting the next key for an element using an iterator retrieved from theiterator(DpTrans,ConfObject[])
method, and converting the Java object into a key with thegetIteratorKey(DpTrans, ConfObject[], Object)
method.static final int
Bit flag for getting the next object using an iterator retrieved from theiterator(DpTrans,ConfObject[])
method, and converting the Java object into an array of ConfValues with thegetIteratorObject(DpTrans, ConfObject[], Object)
method.static final int
Bit flag for thegetObject(DpTrans,ConfObject[])
method.static final int
Bit flag for themoveAfter(DpTrans, ConfObject[], ConfKey)
method.static final int
Bit flag for thenumInstances(DpTrans,ConfObject[])
method.static final int
Bit flag for theremove(DpTrans,ConfObject[])
method.static final int
Bit flag for thesetAttr(DpTrans, ConfObject[], ConfAttributeValue)
method.static final int
Bit flag for thesetCase(DpTrans, ConfObject[], ConfObject[], ConfTag)
method.static final int
Bit flag for thesetElem(DpTrans,ConfObject[],ConfValue)
method.static final int
Bit flag for indicating that filters are wanted.static final int
Bit flag for thewriteAll(DpTrans, ConfObject[])
method. -
Method Summary
Modifier and TypeMethodDescriptionThe name of the callpointint
create
(DpTrans trans, ConfObject[] kp) This callback creates a new presence container, list entry or empty leaf.boolean
existsOptional
(DpTrans trans, ConfObject[] kp) If we have presence containers or optional leafs (empty leafs) without a type, we cannot use the getElem() callback to read such a leaf - since the element is typeless.int
getAttrs
(DpTrans trans, ConfObject[] kp, List<ConfAttributeValue> attrList) This callback only needs to be implemented for callpoints specified for configuration data, and only if attributes are enabled in the server configuration (/confdConfig/enableAttributes set to true).getCase
(DpTrans trans, ConfObject[] kp, ConfObject[] choice) This callback method needs to return the currently chosen 'case' for a 'choice' construct.getElem
(DpTrans trans, ConfObject[] kp) This callback method needs to return a specific leaf value.getIteratorKey
(DpTrans trans, ConfObject[] kp, Object obj) The following callback is used with the iterators above.getIteratorObject
(DpTrans trans, ConfObject[] kp, Object obj) The following callback is used with the iterators above.List<ConfObject[]>
getIteratorObjectList
(DpTrans trans, ConfObject[] kp, Object obj, Iterator<? extends Object> iterator) This callback is used in place of getIteratorObject when aList
of objects is requested rather than a single instance.getObject
(DpTrans trans, ConfObject[] kp) The purpose of the callback is to return an array of values, corresponding to a complete list entry in one swoop.iterator
(DpTrans trans, ConfObject[] kp) This callback makes it possible for ConfD/NCS to traverse a set of list entries.iterator
(DpTrans trans, ConfObject[] kp, ConfFindNextType type, ConfKey key) This iterator method is a specialization ofiterator(DpTrans, ConfObject[])
in that it returns an extended iterator i.e.iterator
(DpTrans trans, ConfObject[] kp, ConfFindNextType type, ConfKey key, DpListFilter filter) Variant of the DpDataFindNextIterator-returning iterator above that may receive a DpListFilter instance which can be used to filter the list.iterator
(DpTrans trans, ConfObject[] kp, DpListFilter filter) Variant of iterator that may receive a DpListFilter which can be used to filter the list.int
mask()
Mask of flags for each method that is supported by this callback:M_EXISTS_OPTIONAL
M_GET_ELEM
M_GET_NEXT
M_SET_ELEM
M_CREATE
M_REMOVE
M_NUM_INSTANCES
M_GET_OBJECT
M_GET_NEXT_OBJECT
M_GET_CASE
M_SET_CASE
M_GET_ATTRS
M_SET_ATTR
M_MOVE_AFTER
M_WRITE_ALL
M_WANT_FILTER
int
moveAfter
(DpTrans trans, ConfObject[] kp, ConfKey prevkey) This callback only needs to be implemented if we provide configuration data that has YANG lists with a ordered-by user statement.int
numInstances
(DpTrans trans, ConfObject[] kp) This callback can optionally be implemented.int
remove
(DpTrans trans, ConfObject[] kp) This callback is used to remove a presence container, list entry or empty leaf and all its sub elements.int
setAttr
(DpTrans trans, ConfObject[] kp, ConfAttributeValue attr) This callback also only needs to be implemented for callpoints specified for configuration data, and only if attributes are enabled in the server configuration (/confdConfig/enableAttributes set to true).int
setCase
(DpTrans trans, ConfObject[] kp, ConfObject[] choice, ConfTag caseval) This callback method sets the currently chosen 'case' for a 'choice' construct.int
setElem
(DpTrans trans, ConfObject[] kp, ConfValue newval) This callback writes a data leaf.int
writeAll
(DpTrans trans, ConfObject[] kp) This callback method sets the currently chosen 'case' for a 'choice' construct.
-
Field Details
-
M_EXISTS_OPTIONAL
static final int M_EXISTS_OPTIONALBit flag for theexistsOptional(DpTrans,ConfObject[])
method.- See Also:
-
M_GET_ELEM
static final int M_GET_ELEMBit flag for thegetElem(DpTrans,ConfObject[])
method.- See Also:
-
M_GET_NEXT
static final int M_GET_NEXTBit flag for getting the next key for an element using an iterator retrieved from theiterator(DpTrans,ConfObject[])
method, and converting the Java object into a key with thegetIteratorKey(DpTrans, ConfObject[], Object)
method.- See Also:
-
M_SET_ELEM
static final int M_SET_ELEMBit flag for thesetElem(DpTrans,ConfObject[],ConfValue)
method.- See Also:
-
M_CREATE
static final int M_CREATEBit flag for thecreate(DpTrans,ConfObject[])
method.- See Also:
-
M_REMOVE
static final int M_REMOVEBit flag for theremove(DpTrans,ConfObject[])
method.- See Also:
-
M_NUM_INSTANCES
static final int M_NUM_INSTANCESBit flag for thenumInstances(DpTrans,ConfObject[])
method.- See Also:
-
M_GET_OBJECT
static final int M_GET_OBJECTBit flag for thegetObject(DpTrans,ConfObject[])
method.- See Also:
-
M_GET_NEXT_OBJECT
static final int M_GET_NEXT_OBJECTBit flag for getting the next object using an iterator retrieved from theiterator(DpTrans,ConfObject[])
method, and converting the Java object into an array of ConfValues with thegetIteratorObject(DpTrans, ConfObject[], Object)
method.- See Also:
-
M_GET_CASE
static final int M_GET_CASEBit flag for thegetCase(DpTrans, ConfObject[], ConfObject[])
method.- See Also:
-
M_SET_CASE
static final int M_SET_CASEBit flag for thesetCase(DpTrans, ConfObject[], ConfObject[], ConfTag)
method.- See Also:
-
M_GET_ATTRS
static final int M_GET_ATTRSBit flag for thegetAttrs(DpTrans, ConfObject[], List)
method.- See Also:
-
M_SET_ATTR
static final int M_SET_ATTRBit flag for thesetAttr(DpTrans, ConfObject[], ConfAttributeValue)
method.- See Also:
-
M_MOVE_AFTER
static final int M_MOVE_AFTERBit flag for themoveAfter(DpTrans, ConfObject[], ConfKey)
method.- See Also:
-
M_WRITE_ALL
static final int M_WRITE_ALLBit flag for thewriteAll(DpTrans, ConfObject[])
method.- See Also:
-
M_WANT_FILTER
static final int M_WANT_FILTERBit flag for indicating that filters are wanted.- See Also:
-
M_ALL
static final int M_ALLBit flag for all flags- See Also:
-
-
Method Details
-
callpoint
String callpoint()The name of the callpoint -
mask
int mask()Mask of flags for each method that is supported by this callback: -
getElem
This callback method needs to return a specific leaf value.The callback must return a
ConfValue
on success. The implementation ofgetElem
must be prepared to return all the leafs including the key(s).When ConfD/NCS invokes
getElem
on a key leaf it is an existence test. The application should verify whether the object exists or not. If an object doesn't exists this method must return null.- Parameters:
trans
- Transactionkp
- The keypath structured as a reversed array ofConfTag
and/orConfKey
objects- Returns:
- The value of the element
- Throws:
DpCallbackException
- Callback method failure.
-
iterator
This callback makes it possible for ConfD/NCS to traverse a set of list entries.This method is a specific java construct which is actually not registered on the server side. Instead it is a mandatory tool for the
GET_NEXT/GET_NEXT_OBJECT
functionality to work. If either thegetIteratorKey(DpTrans, ConfObject[], Object)
or thegetIteratorObject(DpTrans, ConfObject[], Object)
is registered this method must also be registered.The Iterator is stored internally by
Dp
and when aGET_NEXT/GET_NEXT_OBJECT
request is issued the iterator is called to get the next element in the list.Note that the iterator is free to return any POJO Object and it is instead the responsibility of the
getIteratorKey
orgetIteratorObject
to render the return values.- Parameters:
trans
- DpTrans object for current transactionkp
- Keypath for the list that is subject for traversal- Returns:
- An Java Iterator for traversing objects in the table.
- Throws:
DpCallbackException
- if Callback method failed.
-
iterator
Iterator<? extends Object> iterator(DpTrans trans, ConfObject[] kp, DpListFilter filter) throws DpCallbackException Variant of iterator that may receive a DpListFilter which can be used to filter the list. Filtering the list is optional, if it is not done by the callback, it will be done server-side. If the callback implementation guarantees that the returned iterator is filtered, it can indicate this to the server by calling honorFilter(true) on the trans object. Note that this iterator will take precedence over its non-filtering counterpart.- Parameters:
trans
- DpTrans object for current transactionkp
- Keypath for the list that is subject for traversalfilter
- DpListFilter instance for filtering elements, or null if no filtering is requested- Returns:
- An Java Iterator for traversing objects in the table.
- Throws:
DpCallbackException
- if Callback method failed.
-
iterator
DpDataFindNextIterator iterator(DpTrans trans, ConfObject[] kp, ConfFindNextType type, ConfKey key) throws DpCallbackException This iterator method is a specialization ofiterator(DpTrans, ConfObject[])
in that it returns an extended iterator i.e. DpFindNextIterator. This iterator does the same job as the normal Java Iterator but it also has aDpDataFindNextIterator.findNext(DpTrans, ConfObject[], ConfFindNextType, ConfKey)
method that is called if FIND_NEXT/FIND_NEXT_OBJECT is called. Note that this iterator is expected to be able to traverse using next()/hasNext() functions after a initial findNext(...) has been called and it will take precedence over the standard iterator method.- Parameters:
trans
- DpTrans object for current transactionkp
- Keypath for the list that is subject for traversaltype
-ConfFindNextType
describing the findNext behaviorkey
- ConfKey which constitutes the search criteria- Returns:
- An Java Iterator subclass DpFindNextIterator.
- Throws:
DpCallbackException
- if Callback method failed.DpCallbackException
-
iterator
DpDataFindNextIterator iterator(DpTrans trans, ConfObject[] kp, ConfFindNextType type, ConfKey key, DpListFilter filter) throws DpCallbackException Variant of the DpDataFindNextIterator-returning iterator above that may receive a DpListFilter instance which can be used to filter the list. Filtering the list is optional, if it is not done by the callback, it will be done server-side. If the callback implementation guarantees that the returned iterator is filtered, it can indicate this to the server by calling honorFilter(true) on the trans object. Note that this iterator will take precedence over all other iterators.- Parameters:
trans
- DpTrans object for current transactionkp
- Keypath for the list that is subject for traversaltype
-ConfFindNextType
describing the findNext behaviorkey
- ConfKey which constitutes the search criteriafilter
- DpListFilter instance for filtering elements, or null if no filtering is requested- Returns:
- An Java Iterator subclass DpFindNextIterator.
- Throws:
DpCallbackException
- if Callback method failed.DpCallbackException
-
getIteratorKey
The following callback is used with the iterators above. For each object returned by the iterator the getKey method will be invoked which must return the ConfKey for the given object.- Parameters:
trans
- Transactionkp
- The keypathobj
- The object returned by the iterator- Returns:
- The configuration key of the provided object.
- Throws:
DpCallbackException
- Callback method failed.
-
getIteratorObject
ConfObject[] getIteratorObject(DpTrans trans, ConfObject[] kp, Object obj) throws DpCallbackException The following callback is used with the iterators above. For each object returned by the iterator, thegetIteratorObject
method will be invoked and it must return either of the following:- An array of
ConfValue
s describing the object - An array of
ConfXMLParam
s describing the object
ConfNoExists
element. Each list contained within the object must also be represented by a single ConfNoExists, regardless of whether it contains any elements or not. If a ConfXMLParam array is used, lists and missing values should simply be omitted from the array.- Parameters:
trans
- Transactionkp
- The keypathobj
- The object returned by the iterator- Returns:
- An array of all values in the object.
- Throws:
DpCallbackException
- Callback method failed.
- An array of
-
getIteratorObjectList
List<ConfObject[]> getIteratorObjectList(DpTrans trans, ConfObject[] kp, Object obj, Iterator<? extends Object> iterator) throws DpCallbackException This callback is used in place of getIteratorObject when a
List
of objects is requested rather than a single instance. This is of interest when lists are big and performance requires larger chunks to be sent at once.The first object from the iterator is already retrieved and delivered in the
obj
parameter. It is mandatory to put this object first in the list. An arbitrary number of additional objects can then be retrieved using the iterator.The returned list should contain either
ConfValue
arrays orConfXMLParam
arrays. SeegetIteratorObject(com.tailf.dp.DpTrans, com.tailf.conf.ConfObject[], java.lang.Object)
for more information on how to format the return values.It is important to return all objects retrieved by the iterator. Any item that is retrieved but not returned will be lost.
To override the global object cache timeout for the response, return an object of the type
NextObjectList
<ConfObject[]>, for example an instance ofNextObjectArrayList
<ConfObject[]> where you have set the desired timeout via theNextObjectArrayList.setTimeout(int)
method.For backwards compatibility reasons, you can return a List<ConfObject[]> instance of a class that doesn't implement the NextObjectList interface, in which case the default object cache timeout will be in effect for the response.
Also for backwards compatibility reasons, it is acceptable for this method to return a List<
ConfValue
[]> instead of a List<ConfObject[]>.- Parameters:
trans
- Transactionkp
- The keypathobj
- The first object returned by the iteratoriterator
- The iterator to optionally retrieve more objects from- Returns:
- A List of objects where each object is represented as an array of ConfValues or ConfXMLParams.
- Throws:
DpCallbackException
- Callback method fails
-
setElem
This callback writes a data leaf. Note that an optional leaf (i.e. a leaf "type empty;" is created by a call to this method.- Parameters:
trans
- Transactionkp
- The keypathnewval
- The new value to be set- Returns:
Conf.REPLY_OK
orConf.REPLY_ACCUMULATE
- Throws:
DpCallbackException
- Callback method failed.
-
create
This callback creates a new presence container, list entry or empty leaf. In the case of the "servers" data model, this function need to create a new "server" list entry.- Parameters:
trans
- Transactionkp
- The keypath- Returns:
Conf.REPLY_OK
orConf.REPLY_ACCUMULATE
- Throws:
DpCallbackException
- Callback method failed.
-
remove
This callback is used to remove a presence container, list entry or empty leaf and all its sub elements.- Parameters:
trans
- Transactionkp
- The keypath- Returns:
Conf.REPLY_OK
orConf.REPLY_ACCUMULATE
- Throws:
DpCallbackException
- Callback method failed.
-
numInstances
This callback can optionally be implemented. The purpose is to return the number of instances of a list. Must return number of list entries on success- Parameters:
trans
- Transactionkp
- The keypath- Returns:
- The number of instances
- Throws:
DpCallbackException
- Callback method failed.
-
getObject
The purpose of the callback is to return an array of values, corresponding to a complete list entry in one swoop. The callback will only be called for list entries (i.e. getElem() is still needed for elements that are not sub-elements of a list entry). If the returned array is also ConfValue[] the complete list of values in there defined order is expected. However, as an option, it is possible to return an array of type ConfXMLParam[] instead. The difference being that the values are tagged with the node names from the data model - this means that non-existing values can simply be omitted from the array. Additionally the key leafs can be omitted, since they are already known by the server. - if the key leafs are included, they will be ignored. Finally, in e.g. the case of a container with both config and non-config data, where the config data is in CDB and only the non-config data provided by the callback, the config elements can be omitted (for the ConfValue[] return type they must be included as ConfNoExists elements). However, although the ConfXMLParam array format can represent nested lists, these must not be passed via this function, since the get_object() callback only pertains to a single entry of one list. Nodes representing sub-lists must thus be omitted from the array, and the server will issue separate get_object() invocations to retrieve the data for those. If the requested entry does not exist this callback should return null.- Parameters:
trans
- Transactionkp
- The keypath- Returns:
- An array of all values.
- Throws:
DpCallbackException
- Callback method failed.
-
existsOptional
If we have presence containers or optional leafs (empty leafs) without a type, we cannot use the getElem() callback to read such a leaf - since the element is typeless.Additionally, the getElem() callback cannot be used as an existence test by requesting a key leaf for entries in operational data lists without keys, or for leaf-list entries, since there are no key leafs in those cases.
In all the above cases, we need to implement the existsOptional() callback method.
- Parameters:
trans
- Transactionkp
- The keypath- Returns:
true
orfalse
- Throws:
DpCallbackException
- Callback method failed.
-
getCase
This callback method needs to return the currently chosen 'case' for a 'choice' construct. The choice construct is an array of ConfTag values. The reason for this when nestled choice in choice definitions are addressed, for the "non-nestled" scenario the array is of length 1. The callback must return either a ConfTag containing the selected case or ConfDefault or ConfNoExist. A null return value is equivalent to ConfNoExist. success.- Parameters:
trans
- Transactionkp
- The keypathchoice
- The choice name(s) as an array of ConfTag- Returns:
- The ConfTag, ConfDefault, ConfNoExist or null.
- Throws:
DpCallbackException
- Callback method failed.
-
setCase
int setCase(DpTrans trans, ConfObject[] kp, ConfObject[] choice, ConfTag caseval) throws DpCallbackException This callback method sets the currently chosen 'case' for a 'choice' construct. The choice construct is an array of ConfTag values. The reason for this when nestled choice in choice definitions are addressed, for the "non-nestled" scenario the array is of length 1.- Parameters:
trans
- Transactionkp
- The keypathchoice
- The choice name(s) as an array of ConfTagcaseval
- The name of the case- Returns:
Conf.REPLY_OK
- Throws:
DpCallbackException
- Callback method failed.
-
getAttrs
int getAttrs(DpTrans trans, ConfObject[] kp, List<ConfAttributeValue> attrList) throws DpCallbackException, IllegalArgumentException This callback only needs to be implemented for callpoints specified for configuration data, and only if attributes are enabled in the server configuration (/confdConfig/enableAttributes set to true). These are the currently supported attributes:ConfAttributeType.TAGS
(values are ConfList of ConfBuf)ConfAttributeType.ANNOTATION
(value is ConfBuf)ConfAttributeType.INACTIVE
(not used)ConfAttributeType.ORIGIN
(value is Confidentityref) The attrs parameter is an list of ConfAttributeValue objects with attributeType set to requested attribute and attributeValue set to null. If the list is empty all attributes are requested. If the node given by kp does not exist, the callback should throw an IllegalArgumentException, otherwise it should set values to the elements of the attrs list, or even add attributes if the list was empty. Must returnConf.REPLY_OK
on success orConf.REPLY_DELAYED_RESPONSE
. On error aDpCallbackException
should be thrown- Parameters:
trans
- current transactionkp
- keypath for node to set attributes onattrList
- list of ConfAttributeValue to populate as result- Returns:
Conf.REPLY_OK
orConf.REPLY_DELAYED_RESPONSE
on successful call- Throws:
DpCallbackException
- on unsuccessful callIllegalArgumentException
-
setAttr
This callback also only needs to be implemented for callpoints specified for configuration data, and only if attributes are enabled in the server configuration (/confdConfig/enableAttributes set to true). See get_attrs() above for the supported attributes. The callback should set the attribute attr for the node given by kp to the value v. If the callback is invoked with NULL for the value argument, it means that the attribute should be deleted. The callback must return Conf.REPLY_OK on success, Conf.REPLY_DELAYED_RESPONSE or Conf.REPLY_ACCUMULATE. On error an DpCallbackException should be thrown.- Parameters:
trans
- current transactionkp
- keypath for node to set attributes onattr
- ConfAttributeValue to set value- Returns:
- int
- Throws:
DpCallbackException
-
moveAfter
This callback only needs to be implemented if we provide configuration data that has YANG lists with a ordered-by user statement. The callback moves the list entry given by kp. If prevkey is NULL, the entry is moved first in the list, otherwise it is moved after the entry given by prevkey. In this case prevkey identifies an entry in the list. The callback must return Conf.REPLY_OK on success, Conf.REPLY_DELAYED_RESPONSE or Conf.REPLY_ACCUMULATE. On error an DpCallbackException should be thrown.- Parameters:
trans
- current transactionkp
- keypath for entry to moveprevkey
- position to entry which should be before the entry to move- Returns:
Conf.REPLY_OK
- Throws:
DpCallbackException
-
writeAll
This callback method sets the currently chosen 'case' for a 'choice' construct.- Parameters:
trans
- Transactionkp
- The keypath- Returns:
Conf.REPLY_OK
- Throws:
DpCallbackException
- Callback method failed.
-