Search in sources :

Example 1 with SnmpTableHandler

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

the class JvmMemManagerTableMetaImpl 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("JvmMemManagerTable.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("JvmMemManagerTable.handler", handler);
    return handler;
}
Also used : SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 2 with SnmpTableHandler

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

the class JvmMemMgrPoolRelTableMetaImpl method getEntry.

// See com.sun.jmx.snmp.agent.SnmpMibTable
public Object getEntry(SnmpOid oid) throws SnmpStatusException {
    if (oid == null || oid.getLength() < 2)
        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 composed
    // of two integers,
    //  o The MemoryManager is the first  OID arc of the index OID.
    //  o The MemoryPool    is the second OID arc of the index OID.
    //
    final long mgrIndex = oid.getOidArc(0);
    final long poolIndex = oid.getOidArc(1);
    // 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 : ("JvmMemMgrPoolRelTable.entry." + mgrIndex + "." + poolIndex));
    //
    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 instanceof JvmMemMgrPoolRelEntryImpl))
        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 = (JvmMemMgrPoolRelEntryImpl) data;
    //
    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 3 with SnmpTableHandler

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

the class JvmThreadInstanceTableMetaImpl method contains.

// See com.sun.jmx.snmp.agent.SnmpMibTable
protected boolean contains(SnmpOid oid, Object userData) {
    // Get the handler.
    //
    SnmpTableHandler handler = getHandler(userData);
    //
    if (handler == null)
        return false;
    if (!handler.contains(oid))
        return false;
    JvmThreadInstanceEntryImpl inst = getJvmThreadInstance(userData, oid);
    return (inst != null);
}
Also used : SnmpTableHandler(sun.management.snmp.util.SnmpTableHandler)

Example 4 with SnmpTableHandler

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

the class JvmThreadInstanceTableMetaImpl method getNextOid.

// See com.sun.jmx.snmp.agent.SnmpMibTable
protected SnmpOid getNextOid(SnmpOid oid, Object userData) throws SnmpStatusException {
    log.debug("getNextOid", "previous=" + oid);
    // Get the data handler.
    //
    SnmpTableHandler handler = getHandler(userData);
    if (handler == null) {
        // This should never happen.
        // If we get here it's a bug.
        //
        log.debug("getNextOid", "handler is null!");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }
    // Get the next oid
    //
    SnmpOid next = oid;
    while (true) {
        next = handler.getNext(next);
        if (next == null)
            break;
        if (getJvmThreadInstance(userData, next) != null)
            break;
    }
    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 5 with SnmpTableHandler

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

the class JvmRTBootClassPathTableMetaImpl 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

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