CDB Session - Unable to Fetch the Existing Element


We are using CDB Session and trying to fetch the Element from the CDB if confPath is present.

For this,

First we have checked if confPath is present or not with below method:

public synchronized boolean exists(ConfPath path)

If above method returns true, then we are trying to fetch the Element with same ConfPath from the CDB.

public synchronized ConfValue getElem(ConfPath path)

We have tried this method - getElem() but as mentioned that the path must lead to a leaf element in the XML data tree. So, how can we get the complete non-leaf Element from the CDB.

Note: [ We have tried the same with Maapi Session and used below method to get the Existing Element and getting the expected results.

MaapiInputStream configIS = maapiSession.saveConfig(tid,
EnumSet.of(MaapiConfigFlag.XML_PRETTY, MaapiConfigFlag.WITH_OPER, MaapiConfigFlag.CONFIG_NO_PARENTS),
Can you please help to get the similar kind of methods with CDB Session.


There is no CDB API method/function similar to maapi.saveConfig() as the CDB API goes straight to CDB as the name indicates. The Management Agent API (MAAPI), just like NETCONF, RESTCONF, CLI, etc, utilizes the transaction manager to for example read the data from CDB and can thus use a read transaction to get anything from a single leaf to the entire content of the datastore in a single call to maapi.saveConfig().

I suggest you use MAAPI when you, for example, cannot specify exactly what data you want from CDB.


To have a better performance, we are replacing Maapi session with CDB Session for operational data. So, can you suggest the methods which we can use to get data from a single leaf to the entire content of the datastore in a single call.

Depends on your use case. If you want performance, and you are writing in lots of small operations, I.e. one leaf here and a few over there, then use the CDB API. But if you are writing larger amounts of data, MAAPI is recommended.
Same thing with reading with the exception of reading from multiple processes/threads in parallel on a multi core CPU, then you want to use MAAPI regardless for reading.
When in doubt, use MAAPI.