/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// java imports
//
// jmx imports
//
// jdmk imports
//
/**
* The class is used for implementing the "JvmMemMgrPoolRelTable" group.
*/
implements Serializable {
/**
* A concrete implementation of {@link SnmpTableCache}, for the
* jvmMemMgrPoolRelTable.
**/
private static class JvmMemMgrPoolRelTableCache
extends SnmpTableCache {
/**
* Create a weak cache for the jvmMemMgrPoolRelTable.
* @param validity validity of the cached data, in ms.
**/
long validity) {
}
/**
* Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
**/
return getTableDatas(userData);
}
/**
* Builds a map pool-name => pool-index from the SnmpTableHandler
* of the JvmMemPoolTable.
**/
// optimization...
if (handler instanceof SnmpCachedData)
// not optimizable... too bad.
final MemoryPoolMXBean mpm =
}
return m;
}
/**
* Builds a map pool-name => pool-index from the SnmpTableHandler
* of the JvmMemPoolTable.
* Optimized algorithm.
**/
for (int i=0; i<len; i++) {
final MemoryPoolMXBean mpm =
(MemoryPoolMXBean)datas[i];
}
return m;
}
/**
* 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.
**/
// Get the MemoryManager table
final SnmpTableHandler mmHandler =
// Get the MemoryPool table
final SnmpTableHandler mpHandler =
// Time stamp for the cache
// Build a Map poolname -> index
// 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.
}
/**
* Get the list of memory pool associated with the
* given MemoryManagerMXBean.
**/
}
}
}
return result;
}
Map poolIndexMap) {
// The MemoryManager index is an int, so it's the first
// and only subidentifier.
final long mmarc;
try {
} catch (SnmpStatusException x) {
"Bad MemoryManager OID index: "+mmIndex);
return;
}
// Cache this in userData + get it from cache?
// The MemoryPool index is an int, so it's the first
// and only subidentifier.
final long mparc;
try {
} catch (SnmpStatusException x) {
mpIndex);
continue;
}
// The MemoryMgrPoolRel table indexed is composed
// of the MemoryManager index, to which the MemoryPool
// index is appended.
(int)mmarc,
(int)mparc));
}
}
Map poolIndexMap) {
if (mmHandler instanceof SnmpCachedData) {
return;
}
final MemoryManagerMXBean mmm =
}
}
Map poolIndexMap) {
final MemoryManagerMXBean mmm =
(MemoryManagerMXBean)datas[i];
}
}
}
// The weak cache for this table.
/**
* Constructor for the table. Initialize metadata for
* "JvmMemMgrPoolRelTableMeta".
* The reference on the MBean server is updated so the entries
* created through an SNMP SET will be AUTOMATICALLY REGISTERED
* in Java DMK.
*/
this.cache = new
validity());
}
// Returns a pointer to the JvmMemManager meta node - we're going
// to reuse its SnmpTableHandler in order to implement the
// relation table.
}
return managers;
}
// Returns a pointer to the JvmMemPool meta node - we're going
// to reuse its SnmpTableHandler in order to implement the
// relation table.
}
return pools;
}
/**
* Returns the JvmMemManagerTable SnmpTableHandler
**/
}
/**
* Returns the JvmMemPoolTable SnmpTableHandler
**/
}
// See com.sun.jmx.snmp.agent.SnmpMibTable
throws SnmpStatusException {
// null means get the first OID.
}
// See com.sun.jmx.snmp.agent.SnmpMibTable
throws SnmpStatusException {
// Get the data handler.
//
// This should never happen.
// If we get here it's a bug.
//
}
// Get the next oid
//
// if next is null: we reached the end of the table.
//
return next;
}
// See com.sun.jmx.snmp.agent.SnmpMibTable
// Get the handler.
//
// handler should never be null.
//
return false;
}
// See com.sun.jmx.snmp.agent.SnmpMibTable
throws SnmpStatusException {
// Get the request contextual cache (userData).
//
// 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.
//
// the request contextual cache.
//
// Revisit: Probably better programming to put all these strings
// in some interface.
//
("JvmMemMgrPoolRelTable.entry." +
// If the entry is in the cache, simply return it.
//
if (m != null) {
}
// The entry was not in the cache, make a new one.
//
// Get the data hanler.
//
// handler should never be null.
//
// Get the data associated with our entry.
//
// data may be null if the OID we were given is not valid.
//
if (!(data instanceof JvmMemMgrPoolRelEntryImpl))
// make the new entry (transient object that will be kept only
// for the duration of the request.
//
// XXXXX Revisit
// new JvmMemMgrPoolRelEntryImpl((MemoryManagerMXBean)data,
// (int)mgrIndex,(int)poolIndex);
// Put the entry in the cache in case we need it later while processing
// the request.
//
}
return entry;
}
/**
* 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.
**/
else m=null;
// Look in the contextual cache.
if (m != null) {
final SnmpTableHandler handler =
}
// No handler in contextual cache, make a new one.
return handler;
}
new MibLogger(JvmMemMgrPoolRelTableMetaImpl.class);
}