本文整理汇总了Java中sun.management.snmp.util.SnmpTableHandler类的典型用法代码示例。如果您正苦于以下问题:Java SnmpTableHandler类的具体用法?Java SnmpTableHandler怎么用?Java SnmpTableHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SnmpTableHandler类属于sun.management.snmp.util包,在下文中一共展示了SnmpTableHandler类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNext
import sun.management.snmp.util.SnmpTableHandler; //导入依赖的package包/类
/**
* 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;
}
示例2: findInCache
import sun.management.snmp.util.SnmpTableHandler; //导入依赖的package包/类
/**
* 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;
}
示例3: contains
import sun.management.snmp.util.SnmpTableHandler; //导入依赖的package包/类
protected boolean contains(SnmpOid oid, Object userData) {
// Get the handler.
//
SnmpTableHandler handler = getHandler(userData);
// handler should never be null.
//
if (handler == null)
return false;
if(!handler.contains(oid))
return false;
JvmThreadInstanceEntryImpl inst = getJvmThreadInstance(userData, oid);
return (inst != null);
}
示例4: buildPoolIndexMap
import sun.management.snmp.util.SnmpTableHandler; //导入依赖的package包/类
/**
* 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;
}
示例5: updateCachedDatas
import sun.management.snmp.util.SnmpTableHandler; //导入依赖的package包/类
/**
* 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);
}
示例6: updateTreeMap
import sun.management.snmp.util.SnmpTableHandler; //导入依赖的package包/类
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);
}
}
示例7: buildPoolIndexMap
import sun.management.snmp.util.SnmpTableHandler; //导入依赖的package包/类
/**
* 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<String, SnmpOid>();
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;
}