Search in sources :

Example 31 with SnmpOid

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

the class SnmpMibTable method set.

// ---------------------------------------------------------------------
//
// Implements the method defined in SnmpMibNode.
//
// ---------------------------------------------------------------------
/**
     * Generic handling of the <CODE>set</CODE> operation.
     * <p> The default implementation of this method is to
     * call the generated
     * <CODE>set(req,oid,depth+1)</CODE> method.
     * <p>
     * <pre>
     * public void set(SnmpMibSubRequest req, int depth)
     *    throws SnmpStatusException {
     *    final SnmpOid oid = req.getEntryOid();
     *    final int  action = getRowAction(req,oid,depth+1);
     *
     *    set(req,oid,depth+1);
     *    endRowAction(req,oid,depth+1,action);
     * }
     * </pre>
     * <p> You should not need to override this method in any cases, because
     * it will eventually call
     * <CODE>set(SnmpMibSubRequest req, int depth)</CODE> on the generated
     * derivative of <CODE>SnmpMibEntry</CODE>. If you need to implement
     * specific policies for minimizing the accesses made to some remote
     * underlying resources, or if you need to implement some consistency
     * checks between the different values provided in the varbind list,
     * you should then rather override
     * <CODE>set(SnmpMibSubRequest req, int depth)</CODE> on the generated
     * derivative of <CODE>SnmpMibEntry</CODE>.
     * <p>
     *
     */
@Override
public void set(SnmpMibSubRequest req, int depth) throws SnmpStatusException {
    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMibTable.class.getName(), "set", "Entering set");
    }
    final SnmpOid oid = req.getEntryOid();
    final int action = getRowAction(req, oid, depth + 1);
    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMibTable.class.getName(), "set", "Calling set for " + req.getSize() + " varbinds");
    }
    set(req, oid, depth + 1);
    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMibTable.class.getName(), "set", "Calling endRowAction");
    }
    endRowAction(req, oid, depth + 1, action);
    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMibTable.class.getName(), "set", "RowAction finished");
    }
}
Also used : SnmpOid(com.sun.jmx.snmp.SnmpOid)

Example 32 with SnmpOid

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

the class SnmpRequestTree method findOid.

//-------------------------------------------------------------------
// Search for the given oid in `oids'. If none is found, returns -1
// otherwise, returns the index at which the oid is located.
//-------------------------------------------------------------------
private static int findOid(SnmpOid[] oids, int count, SnmpOid oid) {
    final int size = count;
    int low = 0;
    int max = size - 1;
    int curr = low + (max - low) / 2;
    //System.out.println("Try to retrieve: " + oid.toString());
    while (low <= max) {
        final SnmpOid pos = oids[curr];
        //System.out.println("Compare with" + pos.toString());
        // never know ...we might find something ...
        //
        final int comp = oid.compareTo(pos);
        if (comp == 0)
            return curr;
        if (oid.equals(pos)) {
            return curr;
        }
        if (comp > 0) {
            low = curr + 1;
        } else {
            max = curr - 1;
        }
        curr = low + (max - low) / 2;
    }
    return -1;
}
Also used : SnmpOid(com.sun.jmx.snmp.SnmpOid)

Example 33 with SnmpOid

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

the class JvmMemMgrPoolRelTableMetaImpl method getNextOid.

// See com.sun.jmx.snmp.agent.SnmpMibTable
protected SnmpOid getNextOid(SnmpOid oid, Object userData) throws SnmpStatusException {
    final boolean dbg = log.isDebugOn();
    if (dbg)
        log.debug("getNextOid", "previous=" + oid);
    // Get the data handler.
    //
    SnmpTableHandler handler = getHandler(userData);
    if (handler == null) {
        //
        if (dbg)
            log.debug("getNextOid", "handler is null!");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }
    // Get the next oid
    //
    final SnmpOid next = handler.getNext(oid);
    if (dbg)
        log.debug("getNextOid", "next=" + next);
    //
    if (next == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    return next;
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) SnmpOid(com.sun.jmx.snmp.SnmpOid) SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler)

Example 34 with SnmpOid

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

the class JvmRTClassPathTableMetaImpl method getNextOid.

// See com.sun.jmx.snmp.agent.SnmpMibTable
protected SnmpOid getNextOid(SnmpOid oid, Object userData) throws SnmpStatusException {
    final boolean dbg = log.isDebugOn();
    if (dbg)
        log.debug("getNextOid", "previous=" + oid);
    // Get the data handler.
    //
    SnmpTableHandler handler = getHandler(userData);
    if (handler == null) {
        //
        if (dbg)
            log.debug("getNextOid", "handler is null!");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }
    // Get the next oid
    //
    final SnmpOid next = handler.getNext(oid);
    if (dbg)
        log.debug("*** **** **** **** getNextOid", "next=" + next);
    //
    if (next == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    return next;
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) SnmpOid(com.sun.jmx.snmp.SnmpOid) SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler)

Example 35 with SnmpOid

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

the class JvmMemManagerTableMetaImpl method getNextOid.

// See com.sun.jmx.snmp.agent.SnmpMibTable
protected SnmpOid getNextOid(SnmpOid oid, Object userData) throws SnmpStatusException {
    final boolean dbg = log.isDebugOn();
    if (dbg)
        log.debug("getNextOid", "previous=" + oid);
    // Get the data handler.
    //
    SnmpTableHandler handler = getHandler(userData);
    if (handler == null) {
        //
        if (dbg)
            log.debug("getNextOid", "handler is null!");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }
    // Get the next oid
    //
    final SnmpOid next = handler.getNext(oid);
    if (dbg)
        log.debug("getNextOid", "next=" + next);
    //
    if (next == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    return next;
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) SnmpOid(com.sun.jmx.snmp.SnmpOid) SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler)

Aggregations

SnmpOid (com.sun.jmx.snmp.SnmpOid)37 SnmpStatusException (com.sun.jmx.snmp.SnmpStatusException)15 SnmpTableHandler (sun.management.snmp.util.SnmpTableHandler)9 SnmpVarBind (com.sun.jmx.snmp.SnmpVarBind)4 SnmpValue (com.sun.jmx.snmp.SnmpValue)3 SnmpMibAgent (com.sun.jmx.snmp.agent.SnmpMibAgent)2 TreeMap (java.util.TreeMap)2 ObjectName (javax.management.ObjectName)2 Date (java.util.Date)1 Map (java.util.Map)1