Search in sources :

Example 1 with ThreadContext

use of com.sun.jmx.snmp.ThreadContext in project jdk8u_jdk by JetBrains.

the class SnmpSubRequestHandler method run.

public void run() {
    try {
        final ThreadContext oldContext = ThreadContext.push("SnmpUserData", data);
        try {
            switch(type) {
                case pduGetRequestPdu:
                    //
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "run", "[" + Thread.currentThread() + "]:get operation on " + agent.getMibName());
                    }
                    agent.get(createMibRequest(varBind, version, data));
                    break;
                case pduGetNextRequestPdu:
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "run", "[" + Thread.currentThread() + "]:getNext operation on " + agent.getMibName());
                    }
                    //#ifdef DEBUG
                    agent.getNext(createMibRequest(varBind, version, data));
                    break;
                case pduSetRequestPdu:
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "run", "[" + Thread.currentThread() + "]:set operation on " + agent.getMibName());
                    }
                    agent.set(createMibRequest(varBind, version, data));
                    break;
                case pduWalkRequest:
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "run", "[" + Thread.currentThread() + "]:check operation on " + agent.getMibName());
                    }
                    agent.check(createMibRequest(varBind, version, data));
                    break;
                default:
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(), "run", "[" + Thread.currentThread() + "]:unknown operation (" + type + ") on " + agent.getMibName());
                    }
                    errorStatus = snmpRspGenErr;
                    errorIndex = 1;
                    break;
            }
        // end of switch
        } finally {
            ThreadContext.restore(oldContext);
        }
    } catch (SnmpStatusException x) {
        errorStatus = x.getStatus();
        errorIndex = x.getErrorIndex();
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(), "run", "[" + Thread.currentThread() + "]:an Snmp error occurred during the operation", x);
        }
    } catch (Exception x) {
        errorStatus = SnmpDefinitions.snmpRspGenErr;
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(), "run", "[" + Thread.currentThread() + "]:a generic error occurred during the operation", x);
        }
    }
    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(), "run", "[" + Thread.currentThread() + "]:operation completed");
    }
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) ThreadContext(com.sun.jmx.snmp.ThreadContext) SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException)

Aggregations

SnmpStatusException (com.sun.jmx.snmp.SnmpStatusException)1 ThreadContext (com.sun.jmx.snmp.ThreadContext)1