Search in sources :

Example 21 with SnmpTableHandler

use of sun.management.snmp.util.SnmpTableHandler in project jdk8u_jdk by JetBrains.

the class JvmMemManagerTableMetaImpl method getEntry.

// See com.sun.jmx.snmp.agent.SnmpMibTable
public Object getEntry(SnmpOid oid) throws SnmpStatusException {
    if (oid == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    // Get the request contextual cache (userData).
    //
    final Map<Object, Object> m = JvmContextFactory.getUserData();
    // We know in the case of this table that the index is an integer,
    // it is thus the first OID arc of the index OID.
    //
    final long index = oid.getOidArc(0);
    // We're going to use this name to store/retrieve the entry in
    // the request contextual cache.
    //
    // Revisit: Probably better programming to put all these strings
    //          in some interface.
    //
    final String entryTag = ((m == null) ? null : ("JvmMemManagerTable.entry." + index));
    //
    if (m != null) {
        final Object entry = m.get(entryTag);
        if (entry != null)
            return entry;
    }
    // The entry was not in the cache, make a new one.
    //
    // Get the data hanler.
    //
    SnmpTableHandler handler = getHandler(m);
    //
    if (handler == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    // Get the data associated with our entry.
    //
    final Object data = handler.getData(oid);
    //
    if (data == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    // make the new entry (transient object that will be kept only
    // for the duration of the request.
    //
    final Object entry = new JvmMemManagerEntryImpl((MemoryManagerMXBean) data, (int) index);
    //
    if (m != null && entry != null) {
        m.put(entryTag, entry);
    }
    return entry;
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler)

Example 22 with SnmpTableHandler

use of sun.management.snmp.util.SnmpTableHandler 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)

Example 23 with SnmpTableHandler

use of sun.management.snmp.util.SnmpTableHandler in project jdk8u_jdk by JetBrains.

the class JvmRTBootClassPathTableMetaImpl method getEntry.

// See com.sun.jmx.snmp.agent.SnmpMibTable
public Object getEntry(SnmpOid oid) throws SnmpStatusException {
    final boolean dbg = log.isDebugOn();
    if (dbg)
        log.debug("getEntry", "oid [" + oid + "]");
    if (oid == null || oid.getLength() != 1) {
        if (dbg)
            log.debug("getEntry", "Invalid oid [" + oid + "]");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }
    // Get the request contextual cache (userData).
    //
    final Map<Object, Object> m = JvmContextFactory.getUserData();
    // We're going to use this name to store/retrieve the entry in
    // the request contextual cache.
    //
    // Revisit: Probably better programming to put all these strings
    //          in some interface.
    //
    final String entryTag = ((m == null) ? null : ("JvmRTBootClassPathTable.entry." + oid.toString()));
    //
    if (m != null) {
        final Object entry = m.get(entryTag);
        if (entry != null) {
            if (dbg)
                log.debug("getEntry", "Entry is already in the cache");
            return entry;
        } else if (dbg)
            log.debug("getEntry", "Entry is not in the cache");
    }
    // The entry was not in the cache, make a new one.
    //
    // Get the data hanler.
    //
    SnmpTableHandler handler = getHandler(m);
    //
    if (handler == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    // Get the data associated with our entry.
    //
    final Object data = handler.getData(oid);
    //
    if (data == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    //
    if (dbg)
        log.debug("getEntry", "data is a: " + data.getClass().getName());
    final Object entry = new JvmRTBootClassPathEntryImpl((String) data, (int) oid.getOidArc(0));
    //
    if (m != null && entry != null) {
        m.put(entryTag, entry);
    }
    return entry;
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler) SnmpString(com.sun.jmx.snmp.SnmpString)

Example 24 with SnmpTableHandler

use of sun.management.snmp.util.SnmpTableHandler in project jdk8u_jdk by JetBrains.

the class JvmMemPoolTableMetaImpl method getEntry.

// See com.sun.jmx.snmp.agent.SnmpMibTable
public Object getEntry(SnmpOid oid) throws SnmpStatusException {
    if (oid == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    // Get the request contextual cache (userData).
    //
    final Map<Object, Object> m = Util.cast(JvmContextFactory.getUserData());
    // We know in the case of this table that the index is an integer,
    // it is thus the first OID arc of the index OID.
    //
    final long index = oid.getOidArc(0);
    // We're going to use this name to store/retrieve the entry in
    // the request contextual cache.
    //
    // Revisit: Probably better programming to put all these strings
    //          in some interface.
    //
    final String entryTag = ((m == null) ? null : ("JvmMemPoolTable.entry." + index));
    //
    if (m != null) {
        final Object entry = m.get(entryTag);
        if (entry != null)
            return entry;
    }
    // The entry was not in the cache, make a new one.
    //
    // Get the data hanler.
    //
    SnmpTableHandler handler = getHandler(m);
    //
    if (handler == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    // Get the data associated with our entry.
    //
    final Object data = handler.getData(oid);
    //
    if (data == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    //
    if (log.isDebugOn())
        log.debug("getEntry", "data is a: " + data.getClass().getName());
    final Object entry = new JvmMemPoolEntryImpl((MemoryPoolMXBean) data, (int) index);
    //
    if (m != null && entry != null) {
        m.put(entryTag, entry);
    }
    return entry;
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler)

Example 25 with SnmpTableHandler

use of sun.management.snmp.util.SnmpTableHandler in project jdk8u_jdk by JetBrains.

the class JvmMemPoolTableMetaImpl method getNextOid.

// See com.sun.jmx.snmp.agent.SnmpMibTable
protected SnmpOid getNextOid(SnmpOid oid, Object userData) throws SnmpStatusException {
    final boolean dbg = log.isDebugOn();
    try {
        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;
    } catch (SnmpStatusException x) {
        if (dbg)
            log.debug("getNextOid", "End of MIB View: " + x);
        throw x;
    } catch (RuntimeException r) {
        if (dbg)
            log.debug("getNextOid", "Unexpected exception: " + r);
        if (dbg)
            log.debug("getNextOid", r);
        throw r;
    }
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) SnmpOid(com.sun.jmx.snmp.SnmpOid) SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler)

Aggregations

SnmpTableHandler (sun.management.snmp.util.SnmpTableHandler)27 SnmpStatusException (com.sun.jmx.snmp.SnmpStatusException)18 SnmpOid (com.sun.jmx.snmp.SnmpOid)9 Map (java.util.Map)8 SnmpString (com.sun.jmx.snmp.SnmpString)4 TreeMap (java.util.TreeMap)4 HashMap (java.util.HashMap)1