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, setValuespublic CdbUpgradeSession(Cdb cdb) throws IOException, ConfException
IOExceptionConfExceptionpublic CdbUpgradeSession(Cdb cdb, CdbDBType dbtype) throws ConfException, IOException
ConfExceptionIOExceptionpublic CdbUpgradeSession(Cdb cdb, CdbDBType dbtype, EnumSet<CdbLockType> lockflags) throws ConfException, IOException
ConfExceptionIOExceptionpublic boolean exists(ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic boolean exists(String fmt, Object... arguments) throws ConfException, IOException
CdbSessionexists in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void cd(ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic void cd(String fmt, Object... arguments) throws ConfException, IOException
CdbSessioncd in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void pushd(ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic void pushd(String fmt, Object... arguments) throws ConfException, IOException
CdbSessionCdbSession.pushd(ConfPath) but specifies position using path
 stringpushd in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic int getNumberOfInstances(ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic int getNumberOfInstances(String fmt, Object... arguments) throws ConfException, IOException
CdbSessionCdbSession.getNumberOfInstances(ConfPath) but specifies element
  using path stringgetNumberOfInstances in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic int nextIndex(ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic int nextIndex(String fmt, Object... arguments) throws ConfException, IOException
CdbSessionCdbSession.nextIndex(ConfPath) but specifies element using path
 stringnextIndex in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic int index(ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic int index(String fmt, Object... arguments) throws ConfException, IOException
CdbSessionCdbSession.index(ConfPath) but specifies element using path
 stringindex in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic boolean isDefault(ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic boolean isDefault(String fmt, Object... arguments) throws ConfException, IOException
CdbSessionCdbSession.isDefault(ConfPath) but specifies element using path
 stringisDefault in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic ConfValue getElem(ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic ConfValue getElem(String fmt, Object... arguments) throws ConfException, IOException
CdbSessionCdbSession.getElem(ConfPath) but specifies element using path
 stringgetElem in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void setElem(ConfValue value, ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic void setElem(ConfValue value, String fmt, Object... arguments) throws ConfException, IOException
CdbSessionCdbSession.setElem(ConfValue, ConfPath) but specifies element
 using path stringsetElem in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void create(ConfCdbUpgradePath path) throws ConfException, IOException
ConfExceptionIOExceptionpublic void create(String fmt, Object... arguments) throws ConfException, IOException
CdbSessionCdbSession.create(ConfPath) but specifies element using path
 stringcreate in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void delete(ConfCdbUpgradePath path) throws IOException, ConfException
IOExceptionConfExceptionpublic void delete(String fmt, Object... arguments) throws IOException, ConfException
CdbSessionCdbSession.delete(ConfPath) but specifies element using path
 stringdelete in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic ConfObject[] getObject(int numOfObjects, ConfCdbUpgradePath path) throws IOException, ConfException
IOExceptionConfExceptionpublic 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 CdbSessionnumOfObjects - number of objects to retrieveIOExceptionConfExceptionpublic List<ConfObject[]> getObjects(int numOfObjects, int instance, int numOfInstances, ConfCdbUpgradePath path) throws IOException, ConfException
IOExceptionConfExceptionpublic 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 CdbSessionnumOfObjects - number of objects to retrieveinstance - instance integernumOfInstances - number if instances to retrieveIOExceptionConfExceptionpublic void setObject(ConfValue[] values, ConfCdbUpgradePath path) throws IOException, ConfException
IOExceptionConfExceptionpublic void setObject(ConfValue[] values, String fmt, Object... arguments) throws IOException, ConfException
CdbSessionCdbSession.setObject(ConfValue[], ConfPath) but specifies
 element using path stringsetObject in class CdbSessionfmt - path stringarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic void setValues(ConfXMLParam[] params, ConfCdbUpgradePath path) throws IOException, ConfException
IOExceptionConfExceptionpublic void setValues(ConfXMLParam[] params, String fmt, Object... arguments) throws IOException, ConfException
CdbSessionCdbSession.setValues(ConfXMLParam[], ConfPath) but specifies
 element using path stringsetValues in class CdbSessionIOExceptionConfExceptionpublic ConfXMLParam[] getValues(ConfXMLParam[] params, ConfCdbUpgradePath path) throws IOException, ConfException
IOExceptionConfExceptionpublic 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 CdbSessionIOExceptionConfExceptionpublic ConfObject getCase(String choice, ConfCdbUpgradePath path) throws IOException, ConfException
IOExceptionConfExceptionpublic ConfObject getCase(String choice, String fmt, Object... arguments) throws IOException, ConfException
CdbSessionRetrieve 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 CdbSessionchoice - the name of the choicefmt - format string pointing to the choicearguments - replacement arguments for fmt stringConfTagIOExceptionConfExceptionpublic void setCase(String choice, String scase, ConfCdbUpgradePath path) throws IOException, ConfException
IOExceptionConfExceptionpublic void setCase(String choice, String scase, String fmt, Object... arguments) throws IOException, ConfException
CdbSessionWhen 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 CdbSessionchoice - choice stringscase - case stringfmt - format string pointing to the choicearguments - replacement arguments for fmt stringIOExceptionConfExceptionpublic String toString()
toString in class CdbSession