use of com.sun.jmx.snmp.SnmpOid in project jdk8u_jdk by JetBrains.
the class SnmpIndex method toString.
/**
* Returns a <CODE>String</CODE> representation of the index.
* The different elements are separated by "//".
*
* @return A string representation of the index.
*/
@Override
public String toString() {
final StringBuilder msg = new StringBuilder();
for (Enumeration<SnmpOid> e = oids.elements(); e.hasMoreElements(); ) {
SnmpOid val = e.nextElement();
msg.append("//").append(val.toString());
}
return msg.toString();
}
use of com.sun.jmx.snmp.SnmpOid in project jdk8u_jdk by JetBrains.
the class SnmpIndex method equals.
/**
* Compares two indexes for equality.
*
* @param index The index to compare <CODE>this</CODE> with.
*
* @return <CODE>true</CODE> if the two indexes are equal, <CODE>false</CODE> otherwise.
*/
public boolean equals(SnmpIndex index) {
if (size != index.getNbComponents())
return false;
// The two vectors have the same length.
// Compare each single element ...
//
SnmpOid oid1;
SnmpOid oid2;
Vector<SnmpOid> components = index.getComponents();
for (int i = 0; i < size; i++) {
oid1 = oids.elementAt(i);
oid2 = components.elementAt(i);
if (oid1.equals(oid2) == false)
return false;
}
return true;
}
use of com.sun.jmx.snmp.SnmpOid in project jdk8u_jdk by JetBrains.
the class SnmpIndex method compareTo.
/**
* Compares two indexes.
*
* @param index The index to compare <CODE>this</CODE> with.
*
* @return The value 0 if the two OID vectors have the same elements, another value otherwise.
*/
public int compareTo(SnmpIndex index) {
int length = index.getNbComponents();
Vector<SnmpOid> components = index.getComponents();
SnmpOid oid1;
SnmpOid oid2;
int comp;
for (int i = 0; i < size; i++) {
if (i > length) {
//
return 1;
}
// Access the element ...
//
oid1 = oids.elementAt(i);
oid2 = components.elementAt(i);
comp = oid1.compareTo(oid2);
if (comp == 0)
continue;
return comp;
}
return 0;
}
use of com.sun.jmx.snmp.SnmpOid in project jdk8u_jdk by JetBrains.
the class SnmpMib method getGetNextHandlers.
/**
* This method builds the temporary request-tree that will be used to
* perform the SNMP GET-NEXT request associated with the given vector
* of varbinds `list'.
*
* @param req The SnmpMibRequest object holding the varbind list
* concerning this MIB.
*
* @return The request-tree where the original varbind list has been
* dispatched to the appropriate nodes, and where the original
* OIDs have been replaced with the correct "next" OID.
*/
private SnmpRequestTree getGetNextHandlers(SnmpMibRequest req) throws SnmpStatusException {
// Creates an empty request tree, no entry creation is allowed (false)
SnmpRequestTree handlers = new SnmpRequestTree(req, false, SnmpDefinitions.pduGetNextRequestPdu);
// Sets the getNext flag: if version=V2, status exception are
// transformed in endOfMibView
handlers.setGetNextFlag();
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(), "getGetNextHandlers", "Received MIB request : " + req);
}
AcmChecker checker = new AcmChecker(req);
int index = 0;
SnmpVarBind var = null;
final int ver = req.getVersion();
SnmpOid original = null;
// follows.
for (Enumeration<SnmpVarBind> e = req.getElements(); e.hasMoreElements(); index++) {
var = e.nextElement();
SnmpOid result;
try {
//ACM loop.
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(), "getGetNextHandlers", " Next OID of : " + var.oid);
}
result = new SnmpOid(root.findNextHandlingNode(var, var.oid.longValue(false), 0, 0, handlers, checker));
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(), "getGetNextHandlers", " is : " + result);
}
// We replace the varbind original OID with the OID of the
// leaf object we have to return.
var.oid = result;
} catch (SnmpStatusException x) {
if (ver == SnmpDefinitions.snmpVersionOne) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(), "getGetNextHandlers", "\tThrowing exception " + x.toString());
}
//
throw new SnmpStatusException(x, index + 1);
}
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(), "getGetNextHandlers", "Exception : " + x.getStatus());
}
var.setSnmpValue(SnmpVarBind.endOfMibView);
}
}
return handlers;
}
use of com.sun.jmx.snmp.SnmpOid in project jdk8u_jdk by JetBrains.
the class SnmpTableSupport method addEntry.
/**
* Add an entry in this table.
*
* This method registers an entry in the table and perform
* synchronization with the associated table metadata object.
*
* This method assumes that the given entry will not be registered,
* or will be registered with its default ObjectName built from the
* associated SnmpIndex.
* <p>
* If the entry is going to be registered, then
* {@link com.sun.jmx.snmp.agent.SnmpTableSupport#addEntry(SnmpIndex, ObjectName, Object)} should be preferred.
* <br> This function is mainly provided for backward compatibility.
*
* @param index The SnmpIndex built from the given entry.
* @param entry The entry that should be added in the table.
*
* @exception SnmpStatusException if the entry cannot be registered with
* the given index.
**/
protected void addEntry(SnmpIndex index, Object entry) throws SnmpStatusException {
SnmpOid oid = buildOidFromIndex(index);
ObjectName name = null;
if (isRegistrationRequired()) {
name = buildNameFromIndex(index);
}
meta.addEntry(oid, name, entry);
}
Aggregations