use of com.sun.jmx.snmp.agent.SnmpMibAgent in project jdk8u_jdk by JetBrains.
the class SnmpAdaptorServer method getMibs.
/**
* Returns the names of the MIBs available in this SNMP protocol adaptor.
*
* @return An array of MIB names.
*/
@Override
public String[] getMibs() {
String[] result = new String[mibs.size()];
int i = 0;
for (Enumeration<SnmpMibAgent> e = mibs.elements(); e.hasMoreElements(); ) {
SnmpMibAgent mib = e.nextElement();
result[i++] = mib.getMibName();
}
return result;
}
use of com.sun.jmx.snmp.agent.SnmpMibAgent in project jdk8u_jdk by JetBrains.
the class SnmpSubBulkRequestHandler method findVarBind.
/**
* The method updates find out which element to use at update time. Handle oid overlapping as well
*/
private SnmpVarBind findVarBind(SnmpVarBind element, SnmpVarBind result) {
if (element == null)
return null;
if (result.oid == null) {
return element;
}
if (element.value == SnmpVarBind.endOfMibView)
return result;
if (result.value == SnmpVarBind.endOfMibView)
return element;
final SnmpValue val = result.value;
int comp = element.oid.compareTo(result.oid);
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "findVarBind", "Comparing OID element : " + element.oid + " with result : " + result.oid);
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "findVarBind", "Values element : " + element.value + " result : " + result.value);
}
if (comp < 0) {
//
return element;
} else {
if (comp == 0) {
// Take the deeper within the reply
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "findVarBind", " oid overlapping. Oid : " + element.oid + "value :" + element.value);
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "findVarBind", "Already present varBind : " + result);
}
SnmpOid oid = result.oid;
SnmpMibAgent deeperAgent = server.getAgentMib(oid);
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "findVarBind", "Deeper agent : " + deeperAgent);
}
if (deeperAgent == agent) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "findVarBind", "The current agent is the deeper one. Update the value with the current one");
}
return element;
} else {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "findVarBind", "The current agent is not the deeper one. return the previous one.");
}
return result;
}
/*
Vector v = new Vector();
SnmpMibRequest getReq = createMibRequest(v,
version,
null);
SnmpVarBind realValue = new SnmpVarBind(oid);
getReq.addVarBind(realValue);
try {
deeperAgent.get(getReq);
} catch(SnmpStatusException e) {
e.printStackTrace();
}
if(isDebugOn())
trace("findVarBind", "Biggest priority value is : " +
realValue.value);
return realValue;
*/
} else {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "findVarBind", "The right varBind is the already present one");
}
return result;
}
}
}
use of com.sun.jmx.snmp.agent.SnmpMibAgent in project jdk8u_jdk by JetBrains.
the class SnmpRequestHandler method splitRequest.
/**
* The method takes the incoming requests and split it into subrequests.
*/
private void splitRequest(SnmpPduRequest req) {
int nbAgents = mibs.size();
SnmpMibAgent agent = mibs.firstElement();
if (nbAgents == 1) {
// Take all the oids contained in the request and
//
subs.put(agent, new SnmpSubRequestHandler(agent, req, true));
return;
}
//
if (req.type == pduGetNextRequestPdu) {
for (Enumeration<SnmpMibAgent> e = mibs.elements(); e.hasMoreElements(); ) {
final SnmpMibAgent ag = e.nextElement();
subs.put(ag, new SnmpSubNextRequestHandler(adaptor, ag, req));
}
return;
}
int nbReqs = req.varBindList.length;
SnmpVarBind[] vars = req.varBindList;
SnmpSubRequestHandler sub;
for (int i = 0; i < nbReqs; i++) {
agent = root.getAgentMib(vars[i].oid);
sub = subs.get(agent);
if (sub == null) {
// We need to create the sub request handler and update
// the hashtable
//
sub = new SnmpSubRequestHandler(agent, req);
subs.put(agent, sub);
}
// Update the translation table within the subrequest
//
sub.updateRequest(vars[i], i);
}
}
use of com.sun.jmx.snmp.agent.SnmpMibAgent in project jdk8u_jdk by JetBrains.
the class SnmpSubNextRequestHandler method updateResult.
/**
* The method updates a given var bind list with the result of a
* previsouly invoked operation.
* Prior to calling the method, one must make sure that the operation was
* successful. As such the method getErrorIndex or getErrorStatus should be
* called.
*/
protected void updateResult(SnmpVarBind[] result) {
final int max = varBind.size();
for (int i = 0; i < max; i++) {
// May be we should control the position ...
//
final int index = translation[i];
final SnmpVarBind elmt = (SnmpVarBind) ((NonSyncVector) varBind).elementAtNonSync(i);
final SnmpVarBind vb = result[index];
if (vb == null) {
result[index] = elmt;
/* end of NPCTE fix for bugid 4381195 */
continue;
}
final SnmpValue val = vb.value;
if ((val == null) || (val == SnmpVarBind.endOfMibView)) {
/* NPCTE fix for bugid 4381195 esc 0. <J.C.> < 17-Oct-2000> */
if ((elmt != null) && (elmt.value != SnmpVarBind.endOfMibView))
result[index] = elmt;
// vb.value = SnmpVarBind.endOfMibView;
continue;
/* end of NPCTE fix for bugid 4381195 */
}
/* NPCTE fix for bugid 4381195 esc 0. <J.C.> < 17-Oct-2000> */
if (elmt == null)
continue;
if (elmt.value == SnmpVarBind.endOfMibView)
continue;
// Now we need to take the smallest oid ...
//
int comp = elmt.oid.compareTo(vb.oid);
if (comp < 0) {
// Take the smallest (lexicographically)
//
result[index] = elmt;
} else {
if (comp == 0) {
// Take the deeper within the reply
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "updateResult", " oid overlapping. Oid : " + elmt.oid + "value :" + elmt.value);
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "updateResult", "Already present varBind : " + vb);
}
SnmpOid oid = vb.oid;
SnmpMibAgent deeperAgent = server.getAgentMib(oid);
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "updateResult", "Deeper agent : " + deeperAgent);
}
if (deeperAgent == agent) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "updateResult", "The current agent is the deeper one. Update the value with the current one");
}
result[index].value = elmt.value;
}
/*
Vector v = new Vector();
SnmpMibRequest getReq = createMibRequest(v,
version,
null);
SnmpVarBind realValue = new SnmpVarBind(oid);
getReq.addVarBind(realValue);
try {
deeperAgent.get(getReq);
} catch(SnmpStatusException e) {
e.printStackTrace();
}
if(isDebugOn())
trace("updateResult", "Biggest priority value is : " +
realValue.value);
result[index].value = realValue.value;
*/
}
}
}
}
use of com.sun.jmx.snmp.agent.SnmpMibAgent in project jdk8u_jdk by JetBrains.
the class SnmpRequestHandler method splitBulkRequest.
/**
* The method takes the incoming get bulk requests and split it into
* subrequests.
*/
private void splitBulkRequest(SnmpPduBulk req, int nonRepeaters, int maxRepetitions, int R) {
//
for (Enumeration<SnmpMibAgent> e = mibs.elements(); e.hasMoreElements(); ) {
final SnmpMibAgent agent = e.nextElement();
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "splitBulkRequest", "Create a sub with : " + agent + " " + nonRepeaters + " " + maxRepetitions + " " + R);
}
subs.put(agent, new SnmpSubBulkRequestHandler(adaptor, agent, req, nonRepeaters, maxRepetitions, R));
}
}
Aggregations