sun.management.snmp.util.SnmpCachedData Java Examples

The following examples show how to use sun.management.snmp.util.SnmpCachedData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JvmRTInputArgsTableMetaImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] args = JvmRuntimeImpl.getInputArguments(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    SnmpOid indexes[] = new SnmpOid[args.length];

    for(int i = 0; i < args.length; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, args);
}
 
Example #2
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Builds a map pool-name => pool-index from the SnmpTableHandler
 * of the JvmMemPoolTable.
 * Optimized algorithm.
 **/
private static Map<String, SnmpOid> buildPoolIndexMap(SnmpCachedData cached) {
    if (cached == null) return Collections.emptyMap();
    final SnmpOid[] indexes = cached.indexes;
    final Object[]  datas   = cached.datas;
    final int len = indexes.length;
    final Map<String, SnmpOid> m = new HashMap<>(len);
    for (int i=0; i<len; i++) {
        final SnmpOid index = indexes[i];
        if (index == null) continue;
        final MemoryPoolMXBean mpm =
            (MemoryPoolMXBean)datas[i];
        if (mpm == null) continue;
        final String name = mpm.getName();
        if (name == null) continue;
        m.put(name,index);
    }
    return m;
}
 
Example #3
Source File: JvmRTInputArgsTableMetaImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] args = JvmRuntimeImpl.getInputArguments(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    SnmpOid indexes[] = new SnmpOid[args.length];

    for(int i = 0; i < args.length; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, args);
}
 
Example #4
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler that holds the jvmMemManagerTable table data.
 * This method return the cached table data if it is still
 * valid, recompute it and cache the new value if it's not.
 * If it needs to recompute the cached data, it first
 * try to obtain the list of memory managers from the request
 * contextual cache, and if it is not found, it calls
 * <code>ManagementFactory.getMemoryMBean().getMemoryManagers()</code>
 * and caches the value.
 * This ensures that
 * <code>ManagementFactory.getMemoryMBean().getMemoryManagers()</code>
 * is not called more than once per request, thus ensuring a
 * consistent view of the table.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {
    // Get the MemoryManager     table
    final SnmpTableHandler mmHandler =
        meta.getManagerHandler(userData);

    // Get the MemoryPool        table
    final SnmpTableHandler mpHandler =
        meta.getPoolHandler(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();

    //     Build a Map poolname -> index
    final Map<String,SnmpOid> poolIndexMap = buildPoolIndexMap(mpHandler);

    // For each memory manager, get the list of memory pools
    // For each memory pool, find its index in the memory pool table
    // Create a row in the relation table.
    final TreeMap<SnmpOid, Object> table =
            new TreeMap<>(SnmpCachedData.oidComparator);
    updateTreeMap(table,userData,mmHandler,mpHandler,poolIndexMap);

    return new SnmpCachedData(time,table);
}
 
Example #5
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Builds a map pool-name => pool-index from the SnmpTableHandler
 * of the JvmMemPoolTable.
 * Optimized algorithm.
 **/
private static Map<String, SnmpOid> buildPoolIndexMap(SnmpCachedData cached) {
    if (cached == null) return Collections.emptyMap();
    final SnmpOid[] indexes = cached.indexes;
    final Object[]  datas   = cached.datas;
    final int len = indexes.length;
    final Map<String, SnmpOid> m = new HashMap<>(len);
    for (int i=0; i<len; i++) {
        final SnmpOid index = indexes[i];
        if (index == null) continue;
        final MemoryPoolMXBean mpm =
            (MemoryPoolMXBean)datas[i];
        if (mpm == null) continue;
        final String name = mpm.getName();
        if (name == null) continue;
        m.put(name,index);
    }
    return m;
}
 
Example #6
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Builds a map pool-name => pool-index from the SnmpTableHandler
 * of the JvmMemPoolTable.
 **/
private static Map<String, SnmpOid> buildPoolIndexMap(SnmpTableHandler handler) {
    // optimization...
    if (handler instanceof SnmpCachedData)
        return buildPoolIndexMap((SnmpCachedData)handler);

    // not optimizable... too bad.
    final Map<String, SnmpOid> m = new HashMap<>();
    SnmpOid index=null;
    while ((index = handler.getNext(index))!=null) {
        final MemoryPoolMXBean mpm =
            (MemoryPoolMXBean)handler.getData(index);
        if (mpm == null) continue;
        final String name = mpm.getName();
        if (name == null) continue;
        m.put(name,index);
    }
    return m;
}
 
Example #7
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected void updateTreeMap(TreeMap<SnmpOid, Object> table, Object userData,
                             SnmpTableHandler mmHandler,
                             SnmpTableHandler mpHandler,
                             Map<String, SnmpOid> poolIndexMap) {
    if (mmHandler instanceof SnmpCachedData) {
        updateTreeMap(table,userData,(SnmpCachedData)mmHandler,
                      mpHandler,poolIndexMap);
        return;
    }

    SnmpOid mmIndex=null;
    while ((mmIndex = mmHandler.getNext(mmIndex))!=null) {
        final MemoryManagerMXBean mmm =
            (MemoryManagerMXBean)mmHandler.getData(mmIndex);
        if (mmm == null) continue;
        updateTreeMap(table,userData,mmm,mmIndex,poolIndexMap);
    }
}
 
Example #8
Source File: JvmRTLibraryPathTableMetaImpl.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] path =
        JvmRuntimeImpl.getLibraryPath(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    final int len = path.length;

    SnmpOid indexes[] = new SnmpOid[len];

    for(int i = 0; i < len; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, path);
}
 
Example #9
Source File: JvmThreadInstanceTableMetaImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {

    // We are getting all the thread ids. WARNING.
    // Some of them will be not valid when accessed for data...
    // See getEntry
    long[] id = JvmThreadingImpl.getThreadMXBean().getAllThreadIds();


    // Time stamp for the cache
    final long time = System.currentTimeMillis();

    SnmpOid indexes[] = new SnmpOid[id.length];
    final TreeMap<SnmpOid, Object> table =
            new TreeMap<>(SnmpCachedData.oidComparator);
    for(int i = 0; i < id.length; i++) {
        log.debug("", "Making index for thread id [" + id[i] +"]");
        //indexes[i] = makeOid(id[i]);
        SnmpOid oid = makeOid(id[i]);
        table.put(oid, oid);
    }

    return new SnmpCachedData(time, table);
}
 
Example #10
Source File: JvmRTLibraryPathTableMetaImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] path =
        JvmRuntimeImpl.getLibraryPath(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    final int len = path.length;

    SnmpOid indexes[] = new SnmpOid[len];

    for(int i = 0; i < len; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, path);
}
 
Example #11
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Builds a map pool-name => pool-index from the SnmpTableHandler
 * of the JvmMemPoolTable.
 * Optimized algorithm.
 **/
private static Map<String, SnmpOid> buildPoolIndexMap(SnmpCachedData cached) {
    if (cached == null) return Collections.emptyMap();
    final SnmpOid[] indexes = cached.indexes;
    final Object[]  datas   = cached.datas;
    final int len = indexes.length;
    final Map<String, SnmpOid> m = new HashMap<>(len);
    for (int i=0; i<len; i++) {
        final SnmpOid index = indexes[i];
        if (index == null) continue;
        final MemoryPoolMXBean mpm =
            (MemoryPoolMXBean)datas[i];
        if (mpm == null) continue;
        final String name = mpm.getName();
        if (name == null) continue;
        m.put(name,index);
    }
    return m;
}
 
Example #12
Source File: JvmThreadInstanceTableMetaImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {

    // We are getting all the thread ids. WARNING.
    // Some of them will be not valid when accessed for data...
    // See getEntry
    long[] id = JvmThreadingImpl.getThreadMXBean().getAllThreadIds();


    // Time stamp for the cache
    final long time = System.currentTimeMillis();

    SnmpOid indexes[] = new SnmpOid[id.length];
    final TreeMap<SnmpOid, Object> table =
            new TreeMap<>(SnmpCachedData.oidComparator);
    for(int i = 0; i < id.length; i++) {
        log.debug("", "Making index for thread id [" + id[i] +"]");
        //indexes[i] = makeOid(id[i]);
        SnmpOid oid = makeOid(id[i]);
        table.put(oid, oid);
    }

    return new SnmpCachedData(time, table);
}
 
Example #13
Source File: JvmRTLibraryPathTableMetaImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] path =
        JvmRuntimeImpl.getLibraryPath(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    final int len = path.length;

    SnmpOid indexes[] = new SnmpOid[len];

    for(int i = 0; i < len; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, path);
}
 
Example #14
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler that holds the jvmMemManagerTable table data.
 * This method return the cached table data if it is still
 * valid, recompute it and cache the new value if it's not.
 * If it needs to recompute the cached data, it first
 * try to obtain the list of memory managers from the request
 * contextual cache, and if it is not found, it calls
 * <code>ManagementFactory.getMemoryMBean().getMemoryManagers()</code>
 * and caches the value.
 * This ensures that
 * <code>ManagementFactory.getMemoryMBean().getMemoryManagers()</code>
 * is not called more than once per request, thus ensuring a
 * consistent view of the table.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {
    // Get the MemoryManager     table
    final SnmpTableHandler mmHandler =
        meta.getManagerHandler(userData);

    // Get the MemoryPool        table
    final SnmpTableHandler mpHandler =
        meta.getPoolHandler(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();

    //     Build a Map poolname -> index
    final Map<String,SnmpOid> poolIndexMap = buildPoolIndexMap(mpHandler);

    // For each memory manager, get the list of memory pools
    // For each memory pool, find its index in the memory pool table
    // Create a row in the relation table.
    final TreeMap<SnmpOid, Object> table =
            new TreeMap<>(SnmpCachedData.oidComparator);
    updateTreeMap(table,userData,mmHandler,mpHandler,poolIndexMap);

    return new SnmpCachedData(time,table);
}
 
Example #15
Source File: JvmRTInputArgsTableMetaImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] args = JvmRuntimeImpl.getInputArguments(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    SnmpOid indexes[] = new SnmpOid[args.length];

    for(int i = 0; i < args.length; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, args);
}
 
Example #16
Source File: JvmThreadInstanceTableMetaImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {

    // We are getting all the thread ids. WARNING.
    // Some of them will be not valid when accessed for data...
    // See getEntry
    long[] id = JvmThreadingImpl.getThreadMXBean().getAllThreadIds();


    // Time stamp for the cache
    final long time = System.currentTimeMillis();

    SnmpOid indexes[] = new SnmpOid[id.length];
    final TreeMap<SnmpOid, Object> table =
            new TreeMap<>(SnmpCachedData.oidComparator);
    for(int i = 0; i < id.length; i++) {
        log.debug("", "Making index for thread id [" + id[i] +"]");
        //indexes[i] = makeOid(id[i]);
        SnmpOid oid = makeOid(id[i]);
        table.put(oid, oid);
    }

    return new SnmpCachedData(time, table);
}
 
Example #17
Source File: JvmRTBootClassPathTableMetaImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] path =
        JvmRuntimeImpl.getBootClassPath(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    final int len = path.length;

    SnmpOid indexes[] = new SnmpOid[len];

    for(int i = 0; i < len; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, path);
}
 
Example #18
Source File: JVM_MANAGEMENT_MIB_IMPL.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * WARNING: This should probably be moved to JvmMemPoolTableMetaImpl
 **/
private int findInCache(SnmpTableHandler handler,
                        String poolName) {

    if (!(handler instanceof SnmpCachedData)) {
        if (handler != null) {
            final String err = "Bad class for JvmMemPoolTable datas: " +
                handler.getClass().getName();
            log.error("getJvmMemPoolEntry", err);
        }
        return -1;
    }

    final SnmpCachedData data = (SnmpCachedData)handler;
    final int len = data.datas.length;
    for (int i=0; i < data.datas.length ; i++) {
        final MemoryPoolMXBean pool = (MemoryPoolMXBean) data.datas[i];
        if (poolName.equals(pool.getName())) return i;
    }
    return -1;
}
 
Example #19
Source File: JvmMemGCTableMetaImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the index that immediately follows the given
 * <var>index</var>. The returned index is strictly greater
 * than the given <var>index</var>, and is contained in the table.
 * <br>If the given <var>index</var> is null, returns the first
 * index in the table.
 * <br>If there are no index after the given <var>index</var>,
 * returns null.
 **/
public SnmpOid getNext(SnmpTableHandler handler, SnmpOid index) {

    // try to call the optimized method
    if (handler instanceof SnmpCachedData)
        return getNext((SnmpCachedData)handler, index);

    // too bad - revert to non-optimized generic algorithm
    SnmpOid next = index;
    do {
        next = handler.getNext(next);
        final Object value = handler.getData(next);
        if (value instanceof GarbageCollectorMXBean)
            // That's the next! return it
            return next;
        // skip to next index...
    } while (next != null);
    return null;
}
 
Example #20
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected void updateTreeMap(TreeMap<SnmpOid, Object> table, Object userData,
                             SnmpTableHandler mmHandler,
                             SnmpTableHandler mpHandler,
                             Map<String, SnmpOid> poolIndexMap) {
    if (mmHandler instanceof SnmpCachedData) {
        updateTreeMap(table,userData,(SnmpCachedData)mmHandler,
                      mpHandler,poolIndexMap);
        return;
    }

    SnmpOid mmIndex=null;
    while ((mmIndex = mmHandler.getNext(mmIndex))!=null) {
        final MemoryManagerMXBean mmm =
            (MemoryManagerMXBean)mmHandler.getData(mmIndex);
        if (mmm == null) continue;
        updateTreeMap(table,userData,mmm,mmIndex,poolIndexMap);
    }
}
 
Example #21
Source File: JvmRTInputArgsTableMetaImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] args = JvmRuntimeImpl.getInputArguments(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    SnmpOid indexes[] = new SnmpOid[args.length];

    for(int i = 0; i < args.length; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, args);
}
 
Example #22
Source File: JvmRTBootClassPathTableMetaImpl.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] path =
        JvmRuntimeImpl.getBootClassPath(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    final int len = path.length;

    SnmpOid indexes[] = new SnmpOid[len];

    for(int i = 0; i < len; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, path);
}
 
Example #23
Source File: JvmMemGCTableMetaImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the index that immediately follows the given
 * <var>index</var>. The returned index is strictly greater
 * than the given <var>index</var>, and is contained in the table.
 * <br>If the given <var>index</var> is null, returns the first
 * index in the table.
 * <br>If there are no index after the given <var>index</var>,
 * returns null.
 **/
public SnmpOid getNext(SnmpTableHandler handler, SnmpOid index) {

    // try to call the optimized method
    if (handler instanceof SnmpCachedData)
        return getNext((SnmpCachedData)handler, index);

    // too bad - revert to non-optimized generic algorithm
    SnmpOid next = index;
    do {
        next = handler.getNext(next);
        final Object value = handler.getData(next);
        if (value instanceof GarbageCollectorMXBean)
            // That's the next! return it
            return next;
        // skip to next index...
    } while (next != null);
    return null;
}
 
Example #24
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Builds a map pool-name => pool-index from the SnmpTableHandler
 * of the JvmMemPoolTable.
 * Optimized algorithm.
 **/
private static Map<String, SnmpOid> buildPoolIndexMap(SnmpCachedData cached) {
    if (cached == null) return Collections.emptyMap();
    final SnmpOid[] indexes = cached.indexes;
    final Object[]  datas   = cached.datas;
    final int len = indexes.length;
    final Map<String, SnmpOid> m = new HashMap<>(len);
    for (int i=0; i<len; i++) {
        final SnmpOid index = indexes[i];
        if (index == null) continue;
        final MemoryPoolMXBean mpm =
            (MemoryPoolMXBean)datas[i];
        if (mpm == null) continue;
        final String name = mpm.getName();
        if (name == null) continue;
        m.put(name,index);
    }
    return m;
}
 
Example #25
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler that holds the jvmMemManagerTable table data.
 * This method return the cached table data if it is still
 * valid, recompute it and cache the new value if it's not.
 * If it needs to recompute the cached data, it first
 * try to obtain the list of memory managers from the request
 * contextual cache, and if it is not found, it calls
 * <code>ManagementFactory.getMemoryMBean().getMemoryManagers()</code>
 * and caches the value.
 * This ensures that
 * <code>ManagementFactory.getMemoryMBean().getMemoryManagers()</code>
 * is not called more than once per request, thus ensuring a
 * consistent view of the table.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {
    // Get the MemoryManager     table
    final SnmpTableHandler mmHandler =
        meta.getManagerHandler(userData);

    // Get the MemoryPool        table
    final SnmpTableHandler mpHandler =
        meta.getPoolHandler(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();

    //     Build a Map poolname -> index
    final Map<String,SnmpOid> poolIndexMap = buildPoolIndexMap(mpHandler);

    // For each memory manager, get the list of memory pools
    // For each memory pool, find its index in the memory pool table
    // Create a row in the relation table.
    final TreeMap<SnmpOid, Object> table =
            new TreeMap<>(SnmpCachedData.oidComparator);
    updateTreeMap(table,userData,mmHandler,mpHandler,poolIndexMap);

    return new SnmpCachedData(time,table);
}
 
Example #26
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler that holds the jvmMemManagerTable table data.
 * This method return the cached table data if it is still
 * valid, recompute it and cache the new value if it's not.
 * If it needs to recompute the cached data, it first
 * try to obtain the list of memory managers from the request
 * contextual cache, and if it is not found, it calls
 * <code>ManagementFactory.getMemoryMBean().getMemoryManagers()</code>
 * and caches the value.
 * This ensures that
 * <code>ManagementFactory.getMemoryMBean().getMemoryManagers()</code>
 * is not called more than once per request, thus ensuring a
 * consistent view of the table.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {
    // Get the MemoryManager     table
    final SnmpTableHandler mmHandler =
        meta.getManagerHandler(userData);

    // Get the MemoryPool        table
    final SnmpTableHandler mpHandler =
        meta.getPoolHandler(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();

    //     Build a Map poolname -> index
    final Map<String,SnmpOid> poolIndexMap = buildPoolIndexMap(mpHandler);

    // For each memory manager, get the list of memory pools
    // For each memory pool, find its index in the memory pool table
    // Create a row in the relation table.
    final TreeMap<SnmpOid, Object> table =
            new TreeMap<>(SnmpCachedData.oidComparator);
    updateTreeMap(table,userData,mmHandler,mpHandler,poolIndexMap);

    return new SnmpCachedData(time,table);
}
 
Example #27
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Builds a map pool-name => pool-index from the SnmpTableHandler
 * of the JvmMemPoolTable.
 **/
private static Map<String, SnmpOid> buildPoolIndexMap(SnmpTableHandler handler) {
    // optimization...
    if (handler instanceof SnmpCachedData)
        return buildPoolIndexMap((SnmpCachedData)handler);

    // not optimizable... too bad.
    final Map<String, SnmpOid> m = new HashMap<>();
    SnmpOid index=null;
    while ((index = handler.getNext(index))!=null) {
        final MemoryPoolMXBean mpm =
            (MemoryPoolMXBean)handler.getData(index);
        if (mpm == null) continue;
        final String name = mpm.getName();
        if (name == null) continue;
        m.put(name,index);
    }
    return m;
}
 
Example #28
Source File: JvmThreadInstanceTableMetaImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {

    // We are getting all the thread ids. WARNING.
    // Some of them will be not valid when accessed for data...
    // See getEntry
    long[] id = JvmThreadingImpl.getThreadMXBean().getAllThreadIds();


    // Time stamp for the cache
    final long time = System.currentTimeMillis();

    SnmpOid indexes[] = new SnmpOid[id.length];
    final TreeMap<SnmpOid, Object> table =
            new TreeMap<>(SnmpCachedData.oidComparator);
    for(int i = 0; i < id.length; i++) {
        log.debug("", "Making index for thread id [" + id[i] +"]");
        //indexes[i] = makeOid(id[i]);
        SnmpOid oid = makeOid(id[i]);
        table.put(oid, oid);
    }

    return new SnmpCachedData(time, table);
}
 
Example #29
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Builds a map pool-name => pool-index from the SnmpTableHandler
 * of the JvmMemPoolTable.
 * Optimized algorithm.
 **/
private static Map<String, SnmpOid> buildPoolIndexMap(SnmpCachedData cached) {
    if (cached == null) return Collections.emptyMap();
    final SnmpOid[] indexes = cached.indexes;
    final Object[]  datas   = cached.datas;
    final int len = indexes.length;
    final Map<String, SnmpOid> m = new HashMap<>(len);
    for (int i=0; i<len; i++) {
        final SnmpOid index = indexes[i];
        if (index == null) continue;
        final MemoryPoolMXBean mpm =
            (MemoryPoolMXBean)datas[i];
        if (mpm == null) continue;
        final String name = mpm.getName();
        if (name == null) continue;
        m.put(name,index);
    }
    return m;
}
 
Example #30
Source File: JvmRTBootClassPathTableMetaImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] path =
        JvmRuntimeImpl.getBootClassPath(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    final int len = path.length;

    SnmpOid indexes[] = new SnmpOid[len];

    for(int i = 0; i < len; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, path);
}