use of com.sun.jmx.snmp.SnmpVarBind in project jdk8u_jdk by JetBrains.
the class SnmpStandardObjectServer method get.
/**
* Generic handling of the <CODE>get</CODE> operation.
* <p> The default implementation of this method is to loop over the
* varbind list associated with the sub-request and to call
* <CODE>get(var.oid.getOidArc(depth), data);</CODE>
* <pre>
* public void get(SnmpStandardMetaServer meta, SnmpMibSubRequest req,
* int depth)
* throws SnmpStatusException {
*
* final Object data = req.getUserData();
*
* for (Enumeration e= req.getElements(); e.hasMoreElements();) {
*
* final SnmpVarBind var= (SnmpVarBind) e.nextElement();
*
* try {
* // This method will generate a SnmpStatusException
* // if `depth' is out of bounds.
* //
* final long id = var.oid.getOidArc(depth);
* var.value = meta.get(id, data);
* } catch(SnmpStatusException x) {
* req.registerGetException(var,x);
* }
* }
* }
* </pre>
* <p> You can override this method if you need to implement some
* specific policies for minimizing the accesses made to some remote
* underlying resources.
* <p>
*
* @param meta A pointer to the generated meta-data object which
* implements the <code>SnmpStandardMetaServer</code>
* interface.
*
* @param req The sub-request that must be handled by this node.
*
* @param depth The depth reached in the OID tree.
*
* @exception SnmpStatusException An error occurred while accessing
* the MIB node.
*/
public void get(SnmpStandardMetaServer meta, SnmpMibSubRequest req, int depth) throws SnmpStatusException {
final Object data = req.getUserData();
for (Enumeration<SnmpVarBind> e = req.getElements(); e.hasMoreElements(); ) {
final SnmpVarBind var = e.nextElement();
try {
final long id = var.oid.getOidArc(depth);
var.value = meta.get(id, data);
} catch (SnmpStatusException x) {
req.registerGetException(var, x);
}
}
}
use of com.sun.jmx.snmp.SnmpVarBind in project jdk8u_jdk by JetBrains.
the class SnmpStandardObjectServer method set.
/**
* Generic handling of the <CODE>set</CODE> operation.
* <p> The default implementation of this method is to loop over the
* varbind list associated with the sub-request and to call
* <CODE>set(var.value, var.oid.getOidArc(depth), data);</CODE>
* <pre>
* public void set(SnmpStandardMetaServer meta, SnmpMibSubRequest req,
* int depth)
* throws SnmpStatusException {
*
* final Object data = req.getUserData();
*
* for (Enumeration e= req.getElements(); e.hasMoreElements();) {
*
* final SnmpVarBind var= (SnmpVarBind) e.nextElement();
*
* try {
* // This method will generate a SnmpStatusException
* // if `depth' is out of bounds.
* //
* final long id = var.oid.getOidArc(depth);
* var.value = meta.set(var.value, id, data);
* } catch(SnmpStatusException x) {
* req.registerSetException(var,x);
* }
* }
* }
* </pre>
* <p> You can override this method if you need to implement some
* specific policies for minimizing the accesses made to some remote
* underlying resources.
* <p>
*
* @param meta A pointer to the generated meta-data object which
* implements the <code>SnmpStandardMetaServer</code>
* interface.
*
* @param req The sub-request that must be handled by this node.
*
* @param depth The depth reached in the OID tree.
*
* @exception SnmpStatusException An error occurred while accessing
* the MIB node.
*/
public void set(SnmpStandardMetaServer meta, SnmpMibSubRequest req, int depth) throws SnmpStatusException {
final Object data = req.getUserData();
for (Enumeration<SnmpVarBind> e = req.getElements(); e.hasMoreElements(); ) {
SnmpVarBind var = e.nextElement();
try {
// This method will generate a SnmpStatusException
// if `depth' is out of bounds.
//
final long id = var.oid.getOidArc(depth);
var.value = meta.set(var.value, id, data);
} catch (SnmpStatusException x) {
req.registerSetException(var, x);
}
}
}
use of com.sun.jmx.snmp.SnmpVarBind in project jdk8u_jdk by JetBrains.
the class SnmpMibTable method getRowAction.
/**
* Return the RowStatus code value specified in this request.
* <p>
* The RowStatus code value should be one of the values defined
* by {@link com.sun.jmx.snmp.EnumRowStatus}. These codes correspond
* to RowStatus codes as defined in RFC 2579, plus the <i>unspecified</i>
* value which is SNMP Runtime specific.
* <p>
*
* @param req The sub-request that must be handled by this node.
*
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param depth The depth reached in the OID tree.
*
* @return The RowStatus code specified in this request, if any:
* <ul>
* <li>If the specified row does not exist and this table do
* not use any variable to control creation/deletion of
* rows, then default creation mechanism is assumed and
* <i>createAndGo</i> is returned</li>
* <li>Otherwise, if the row exists and this table do not use any
* variable to control creation/deletion of rows,
* <i>unspecified</i> is returned.</li>
* <li>Otherwise, if the request does not contain the control variable,
* <i>unspecified</i> is returned.</li>
* <li>Otherwise, mapRowStatus() is called to extract the RowStatus
* code from the SnmpVarBind that contains the control variable.</li>
* </ul>
*
* @exception SnmpStatusException if the value of the control variable
* could not be mapped to a RowStatus code.
*
* @see com.sun.jmx.snmp.EnumRowStatus
**/
protected int getRowAction(SnmpMibSubRequest req, SnmpOid rowOid, int depth) throws SnmpStatusException {
final boolean isnew = req.isNewEntry();
final SnmpVarBind vb = req.getRowStatusVarBind();
if (vb == null) {
if (isnew && !hasRowStatus())
return EnumRowStatus.createAndGo;
else
return EnumRowStatus.unspecified;
}
try {
return mapRowStatus(rowOid, vb, req.getUserData());
} catch (SnmpStatusException x) {
checkRowStatusFail(req, x.getStatus());
}
return EnumRowStatus.unspecified;
}
use of com.sun.jmx.snmp.SnmpVarBind in project jdk8u_jdk by JetBrains.
the class SnmpMibTable method checkRowStatusFail.
// ---------------------------------------------------------------------
//
// Register an exception when checking the RowStatus variable
//
// ---------------------------------------------------------------------
static void checkRowStatusFail(SnmpMibSubRequest req, int errorStatus) throws SnmpStatusException {
final SnmpVarBind statusvb = req.getRowStatusVarBind();
final SnmpStatusException x = new SnmpStatusException(errorStatus);
req.registerCheckException(statusvb, x);
}
use of com.sun.jmx.snmp.SnmpVarBind in project jdk8u_jdk by JetBrains.
the class SnmpMibAgent method splitFrom.
// ---------------------------------------------------------------------
// PRIVATE METHODS
// ---------------------------------------------------------------------
/**
* This method creates a new Vector which does not contain the first
* element up to the specified limit.
*
* @param original The original vector.
* @param limit The limit.
*/
private Vector<SnmpVarBind> splitFrom(Vector<SnmpVarBind> original, int limit) {
int max = original.size();
Vector<SnmpVarBind> result = new Vector<>(max - limit);
int i = limit;
//
for (Enumeration<SnmpVarBind> e = original.elements(); e.hasMoreElements(); --i) {
SnmpVarBind var = e.nextElement();
if (i > 0)
continue;
result.addElement(new SnmpVarBind(var.oid, var.value));
}
return result;
}
Aggregations