Search in sources :

Example 16 with SnmpTableHandler

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

the class JvmThreadInstanceTableMetaImpl method getHandler.

/**
     * Get the SnmpTableHandler that holds the jvmThreadInstanceTable data.
     * First look it up in the request contextual cache, and if it is
     * not found, obtain it from the weak cache.
     * <br>The request contextual cache will be released at the end of the
     * current requests, and is used only to process this request.
     * <br>The weak cache is shared by all requests, and is only
     * recomputed when it is found to be obsolete.
     * <br>Note that the data put in the request contextual cache is
     *     never considered to be obsolete, in order to preserve data
     *     coherency.
     **/
protected SnmpTableHandler getHandler(Object userData) {
    final Map<Object, Object> m;
    if (userData instanceof Map)
        m = Util.cast(userData);
    else
        m = null;
    // Look in the contextual cache.
    if (m != null) {
        final SnmpTableHandler handler = (SnmpTableHandler) m.get("JvmThreadInstanceTable.handler");
        if (handler != null)
            return handler;
    }
    // No handler in contextual cache, make a new one.
    final SnmpTableHandler handler = cache.getTableHandler();
    if (m != null && handler != null)
        m.put("JvmThreadInstanceTable.handler", handler);
    return handler;
}
Also used : SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 17 with SnmpTableHandler

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

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

the class JvmMemMgrPoolRelTableMetaImpl method getHandler.

/**
     * Get the SnmpTableHandler that holds the jvmMemManagerTable data.
     * First look it up in the request contextual cache, and if it is
     * not found, obtain it from the weak cache.
     * <br>The request contextual cache will be released at the end of the
     * current requests, and is used only to process this request.
     * <br>The weak cache is shared by all requests, and is only
     * recomputed when it is found to be obsolete.
     * <br>Note that the data put in the request contextual cache is
     *     never considered to be obsolete, in order to preserve data
     *     coherency.
     **/
protected SnmpTableHandler getHandler(Object userData) {
    final Map<Object, Object> m;
    if (userData instanceof Map)
        m = Util.cast(userData);
    else
        m = null;
    // Look in the contextual cache.
    if (m != null) {
        final SnmpTableHandler handler = (SnmpTableHandler) m.get("JvmMemMgrPoolRelTable.handler");
        if (handler != null)
            return handler;
    }
    // No handler in contextual cache, make a new one.
    final SnmpTableHandler handler = cache.getTableHandler();
    if (m != null && handler != null)
        m.put("JvmMemMgrPoolRelTable.handler", handler);
    return handler;
}
Also used : SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 19 with SnmpTableHandler

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

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

the class JvmRTClassPathTableMetaImpl 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 : ("JvmRTClassPathTable.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 JvmRTClassPathEntryImpl((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)

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