public class CdbUpgradeSession extends CdbSession
CdbUpgradeSession
represents a session against
the Cdb database that can be used for accessing data models that are
in the process of being deleted by a cdb upgrade.
The operations supported by an upgrade session are the same as those
of a normal session, the only difference being that keypaths on the
format (fmt, arguments) will be treated as ConfCdbUpgradePaths
rather than ConfPaths.
For information on specific methods, refer to the
CdbSession
documentation.Constructor and Description |
---|
CdbUpgradeSession(Cdb cdb) |
CdbUpgradeSession(Cdb cdb,
CdbDBType dbtype) |
CdbUpgradeSession(Cdb cdb,
CdbDBType dbtype,
EnumSet<CdbLockType> lockflags) |
Modifier and Type | Method and Description |
---|---|
void |
cd(ConfCdbUpgradePath path) |
void |
cd(String fmt,
Object... arguments)
Change working directory to container specified by path string
|
void |
create(ConfCdbUpgradePath path) |
void |
create(String fmt,
Object... arguments)
similar to
CdbSession.create(ConfPath) but specifies element using path
string |
void |
delete(ConfCdbUpgradePath path) |
void |
delete(String fmt,
Object... arguments)
similar to
CdbSession.delete(ConfPath) but specifies element using path
string |
boolean |
exists(ConfCdbUpgradePath path) |
boolean |
exists(String fmt,
Object... arguments)
Checks whether an element exists.
|
ConfObject |
getCase(String choice,
ConfCdbUpgradePath path) |
ConfObject |
getCase(String choice,
String fmt,
Object... arguments)
Retrieve the currently selected case.
|
ConfValue |
getElem(ConfCdbUpgradePath path) |
ConfValue |
getElem(String fmt,
Object... arguments)
similar to
CdbSession.getElem(ConfPath) but specifies element using path
string |
int |
getNumberOfInstances(ConfCdbUpgradePath path) |
int |
getNumberOfInstances(String fmt,
Object... arguments)
similar to
CdbSession.getNumberOfInstances(ConfPath) but specifies element
using path string |
ConfObject[] |
getObject(int numOfObjects,
ConfCdbUpgradePath path) |
ConfObject[] |
getObject(int numOfObjects,
String fmt,
Object... arguments)
In some cases it can be motivated to read multiple values in one request
- this will be more efficient since it only incurs a single round trip to
the server, but usage is a bit more complex.
|
List<ConfObject[]> |
getObjects(int numOfObjects,
int instance,
int numOfInstances,
ConfCdbUpgradePath path) |
List<ConfObject[]> |
getObjects(int numOfObjects,
int instance,
int numOfInstances,
String fmt,
Object... arguments)
Similar to cdb.getObject(), but reads multiple instances of a dynamic
container based on the "instance integer" otherwise given within square
brackets in the path - here the path must specify the dynamic container
without the instance integer.
|
ConfXMLParam[] |
getValues(ConfXMLParam[] params,
ConfCdbUpgradePath path) |
ConfXMLParam[] |
getValues(ConfXMLParam[] params,
String fmt,
Object... arguments)
Read an arbitrary set of sub-elements of a container element.
|
int |
index(ConfCdbUpgradePath path) |
int |
index(String fmt,
Object... arguments)
similar to
CdbSession.index(ConfPath) but specifies element using path
string |
boolean |
isDefault(ConfCdbUpgradePath path) |
boolean |
isDefault(String fmt,
Object... arguments)
similar to
CdbSession.isDefault(ConfPath) but specifies element using path
string |
int |
nextIndex(ConfCdbUpgradePath path) |
int |
nextIndex(String fmt,
Object... arguments)
similar to
CdbSession.nextIndex(ConfPath) but specifies element using path
string |
void |
pushd(ConfCdbUpgradePath path) |
void |
pushd(String fmt,
Object... arguments)
similar to
CdbSession.pushd(ConfPath) but specifies position using path
string |
void |
setCase(String choice,
String scase,
ConfCdbUpgradePath path) |
void |
setCase(String choice,
String scase,
String fmt,
Object... arguments)
When we use the YANG choice construct in the data model, this function
can be used to select the current case.
|
void |
setElem(ConfValue value,
ConfCdbUpgradePath path) |
void |
setElem(ConfValue value,
String fmt,
Object... arguments)
similar to
CdbSession.setElem(ConfValue, ConfPath) but specifies element
using path string |
void |
setObject(ConfValue[] values,
ConfCdbUpgradePath path) |
void |
setObject(ConfValue[] values,
String fmt,
Object... arguments)
similar to
CdbSession.setObject(ConfValue[], ConfPath) but specifies
element using path string |
void |
setValues(ConfXMLParam[] params,
ConfCdbUpgradePath path) |
void |
setValues(ConfXMLParam[] params,
String fmt,
Object... arguments)
similar to
CdbSession.setValues(ConfXMLParam[], ConfPath) but specifies
element using path string |
String |
toString() |
cd, create, delete, endSession, exists, getCase, getCdb, getcwd, getcwdPath, getDbType, getElem, getNumberOfInstances, getObject, getObjects, getValues, index, isDefault, nextIndex, numInstances, numInstances, popd, pushd, setCase, setElem, setNamespace, setObject, setValues, setValues
public CdbUpgradeSession(Cdb cdb) throws IOException, ConfException
IOException
ConfException
public CdbUpgradeSession(Cdb cdb, CdbDBType dbtype) throws ConfException, IOException
ConfException
IOException
public CdbUpgradeSession(Cdb cdb, CdbDBType dbtype, EnumSet<CdbLockType> lockflags) throws ConfException, IOException
ConfException
IOException
public boolean exists(ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public boolean exists(String fmt, Object... arguments) throws ConfException, IOException
CdbSession
exists
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public void cd(ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public void cd(String fmt, Object... arguments) throws ConfException, IOException
CdbSession
cd
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public void pushd(ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public void pushd(String fmt, Object... arguments) throws ConfException, IOException
CdbSession
CdbSession.pushd(ConfPath)
but specifies position using path
stringpushd
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public int getNumberOfInstances(ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public int getNumberOfInstances(String fmt, Object... arguments) throws ConfException, IOException
CdbSession
CdbSession.getNumberOfInstances(ConfPath)
but specifies element
using path stringgetNumberOfInstances
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public int nextIndex(ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public int nextIndex(String fmt, Object... arguments) throws ConfException, IOException
CdbSession
CdbSession.nextIndex(ConfPath)
but specifies element using path
stringnextIndex
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public int index(ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public int index(String fmt, Object... arguments) throws ConfException, IOException
CdbSession
CdbSession.index(ConfPath)
but specifies element using path
stringindex
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public boolean isDefault(ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public boolean isDefault(String fmt, Object... arguments) throws ConfException, IOException
CdbSession
CdbSession.isDefault(ConfPath)
but specifies element using path
stringisDefault
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public ConfValue getElem(ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public ConfValue getElem(String fmt, Object... arguments) throws ConfException, IOException
CdbSession
CdbSession.getElem(ConfPath)
but specifies element using path
stringgetElem
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public void setElem(ConfValue value, ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public void setElem(ConfValue value, String fmt, Object... arguments) throws ConfException, IOException
CdbSession
CdbSession.setElem(ConfValue, ConfPath)
but specifies element
using path stringsetElem
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public void create(ConfCdbUpgradePath path) throws ConfException, IOException
ConfException
IOException
public void create(String fmt, Object... arguments) throws ConfException, IOException
CdbSession
CdbSession.create(ConfPath)
but specifies element using path
stringcreate
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtConfException
IOException
public void delete(ConfCdbUpgradePath path) throws IOException, ConfException
IOException
ConfException
public void delete(String fmt, Object... arguments) throws IOException, ConfException
CdbSession
CdbSession.delete(ConfPath)
but specifies element using path
stringdelete
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtIOException
ConfException
public ConfObject[] getObject(int numOfObjects, ConfCdbUpgradePath path) throws IOException, ConfException
IOException
ConfException
public ConfObject[] getObject(int numOfObjects, String fmt, Object... arguments) throws IOException, ConfException
CdbSession
String path = "/mtest/servers/server{www}/interface{%s}"; ConfObject[] objArr = cdbsess.getObject(4, path, "eth0"); ConfBuf name = (ConfBuf) objArr[0]; ConfInt64 mtu = (ConfInt64) objArr[1];
getObject
in class CdbSession
numOfObjects
- number of objects to retrieveIOException
ConfException
public List<ConfObject[]> getObjects(int numOfObjects, int instance, int numOfInstances, ConfCdbUpgradePath path) throws IOException, ConfException
IOException
ConfException
public List<ConfObject[]> getObjects(int numOfObjects, int instance, int numOfInstances, String fmt, Object... arguments) throws IOException, ConfException
CdbSession
String path = "/mtest/servers/server"; int n = cdbsess.numInstances(path); List<ConfObject[]> objArrList = cdbsess.getObjects(4, 0, n, path); ConfBuf[] name = new ConfBuf[n]; ConfIPv4[] ip = new ConfIPv4[n]; ConfUInt16[] port = new ConfUInt16[n]; for (int i = 0; i < objArrList.size(); i++) { ConfObject[] objArr = objArrList.get(i); name[i] = (ConfBuf) objArr[0]; ip[i] = (ConfIPv4) objArr[1]; port[i] = (ConfUInt16) objArr[2]; }
getObjects
in class CdbSession
numOfObjects
- number of objects to retrieveinstance
- instance integernumOfInstances
- number if instances to retrieveIOException
ConfException
public void setObject(ConfValue[] values, ConfCdbUpgradePath path) throws IOException, ConfException
IOException
ConfException
public void setObject(ConfValue[] values, String fmt, Object... arguments) throws IOException, ConfException
CdbSession
CdbSession.setObject(ConfValue[], ConfPath)
but specifies
element using path stringsetObject
in class CdbSession
fmt
- path stringarguments
- optional parameters for substitution in fmtIOException
ConfException
public void setValues(ConfXMLParam[] params, ConfCdbUpgradePath path) throws IOException, ConfException
IOException
ConfException
public void setValues(ConfXMLParam[] params, String fmt, Object... arguments) throws IOException, ConfException
CdbSession
CdbSession.setValues(ConfXMLParam[], ConfPath)
but specifies
element using path stringsetValues
in class CdbSession
IOException
ConfException
public ConfXMLParam[] getValues(ConfXMLParam[] params, ConfCdbUpgradePath path) throws IOException, ConfException
IOException
ConfException
public ConfXMLParam[] getValues(ConfXMLParam[] params, String fmt, Object... arguments) throws IOException, ConfException
CdbSession
String path = "/mtest/servers/server"; int n = cdbsess.getNumberOfInstances(path); List<ConfObject[]> objArrList = cdbsess.getObjects(4,0,n,path); //when reading ip/port, we need 5 elements per interface: //begin + name (key) + ip + port + end ConfXMLParam[] values = new ConfXMLParam[5*n]; int j = 0; for (int i=0; i<n; i++) { values[j++] = new ConfXMLParamCdbStart(ns, "server", i); values[j++] = new ConfXMLParamLeaf(ns, "name"); values[j++] = new ConfXMLParamLeaf(ns, "ip"); values[j++] = new ConfXMLParamLeaf(ns, "port"); values[j++] = new ConfXMLParamStop(ns, "server"); } path = "/mtest/servers"; ConfXMLParam[] resvalues = cdbsess.getValues(values, path); // extract name for enabled interfaces String name = null; int noOfInterfaces = 0; for (int i = 0; i < n; i++) { ConfIPv4 ip4 = (ConfIPv4) resvalues[i*5+2].getValue(); name = resvalues[i*5+1].getValue().toString(); path = "/mtest/servers/server{%s}/interface"; noOfInterfaces = cdbsess.getNumberOfInstances(path, name); System.out.println("name = "+ name); } int n_if = j; j = 0; values = new ConfXMLParam[noOfInterfaces*4]; for (int i=0; i<noOfInterfaces; i++) { values[j++] = new ConfXMLParamCdbStart(ns.hash(), ns.mtest_interface, i); values[j++] = new ConfXMLParamLeaf(ns.hash(), ns.mtest_name); values[j++] = new ConfXMLParamLeaf(ns.hash(), ns.mtest_mtu); values[j++] = new ConfXMLParamStop(ns.hash(), ns.mtest_interface); } path = "/mtest/servers/server{%s}"; resvalues = cdbsess.getValues(values, path, name); ...
getValues
in class CdbSession
IOException
ConfException
public ConfObject getCase(String choice, ConfCdbUpgradePath path) throws IOException, ConfException
IOException
ConfException
public ConfObject getCase(String choice, String fmt, Object... arguments) throws IOException, ConfException
CdbSession
Retrieve the currently selected case.
When we use the YANG choice construct in the data model, this method
can be used to find the currently selected case, avoiding useless
CdbSession.getElem(ConfPath)
etc requests for elements
that belong to other
cases.
The fmt
give the path to the container where the
choice is defined,
The choice
is the name of the choice.
The case value is returned as type ConfTag
.
If no case is currently selected (i.e. for an optional choice
that does not have a default case), the function will fail with a an
exception with code ConfException.ERR_NOEXISTS
.
getCase
in class CdbSession
choice
- the name of the choicefmt
- format string pointing to the choicearguments
- replacement arguments for fmt stringConfTag
IOException
ConfException
public void setCase(String choice, String scase, ConfCdbUpgradePath path) throws IOException, ConfException
IOException
ConfException
public void setCase(String choice, String scase, String fmt, Object... arguments) throws IOException, ConfException
CdbSession
When we use the YANG choice construct in the data model, this function can be used to select the current case.
When configuration data is modified by northbound agents, the current case is implicitly selected (and elements for other cases potentially deleted) by the setting of elements in a choice.
For operational data in CDB however, this is under direct control of the application, which needs to explicitly set the current case. Setting the case will also automatically delete elements belonging to other cases, but it is up to the application to not set any elements in the "wrong" case. The fmt, ... arguments give the path to the container where the choice is defined, and choice and scase are the choice and case names. For an optional choice, it is possible to have no case at all selected. To indicate that the previously selected case should be deleted without selecting another case, we can pass NULL for the scase argument.
setCase
in class CdbSession
choice
- choice stringscase
- case stringfmt
- format string pointing to the choicearguments
- replacement arguments for fmt stringIOException
ConfException
public String toString()
toString
in class CdbSession