2362N/A * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * The class is used for implementing the "JvmMemGCTable" table. 0N/A * This class acts as a filter over the SnmpTableHandler 0N/A * used for the JvmMemoryManagerTable. It filters out 0N/A * (skip) all MemoryManagerMXBean that are not instances of 0N/A * GarbageCollectorMXBean so that only Garbage Collectors are 0N/A * seen. This is a better solution than relying on 0N/A * ManagementFactory.getGarbageCollectorMXBeans() because it makes it 0N/A * possible to guarantee the consistency betwen the MemoryManager table 0N/A * and the GCTable since both will be sharing the same cache. 0N/A * Returns the index that immediately follows the given 0N/A * <var>index</var>. The returned index is strictly greater 0N/A * than the given <var>index</var>, and is contained in the table. 0N/A * <br>If the given <var>index</var> is null, returns the first 0N/A * index in the table. 0N/A * <br>If there are no index after the given <var>index</var>, 0N/A * This method is an optimization for the case where the 0N/A * SnmpTableHandler is in fact an instance of SnmpCachedData. 0N/A // We're going to loop until we find an instance of 0N/A // GarbageCollectorMXBean. First we attempt to find 0N/A // the next element whose OID follows the given index. 0N/A // If `index' is null, the insertion point is -1 0N/A // (the next is 0 = -insertion - 1) 0N/A // Now `next' points to the element that imediately 0N/A // follows the given `index'. We're going to loop 0N/A // through the table, starting at `next' (included), 0N/A // and return the first element which is an instance 0N/A // of GarbageCollectorMXBean. 0N/A // That's the next: return it. 0N/A " is a GarbageCollectorMXBean.");
0N/A " is not a GarbageCollectorMXBean: " +
0N/A // skip to next index... 0N/A * Returns the index that immediately follows the given 0N/A * <var>index</var>. The returned index is strictly greater 0N/A * than the given <var>index</var>, and is contained in the table. 0N/A * <br>If the given <var>index</var> is null, returns the first 0N/A * index in the table. 0N/A * <br>If there are no index after the given <var>index</var>, 0N/A // try to call the optimized method 0N/A // too bad - revert to non-optimized generic algorithm 0N/A // That's the next! return it 0N/A // skip to next index... 0N/A * Returns the data associated with the given index. 0N/A * If the given index is not found, null is returned. 0N/A * Note that returning null does not necessarily means that 0N/A * the index was not found. 0N/A // Behaves as if there was nothing at this index... 0N/A * Returns true if the given <var>index</var> is present. 0N/A // Behaves as if there was nothing at this index... 0N/A * Constructor for the table. Initialize metadata for "JvmMemGCTableMeta". 0N/A // Returns a pointer to the JvmMemManager meta node - we're going 0N/A // to reuse its SnmpTableHandler by filtering out all that is 0N/A // not a GarbageCollectorMXBean. 0N/A * Returns the JvmMemManagerTable SnmpTableHandler 0N/A // See com.sun.jmx.snmp.agent.SnmpMibTable 0N/A // null means get the first OID. 0N/A // See com.sun.jmx.snmp.agent.SnmpMibTable 0N/A // Get the data handler. 0N/A // This should never happen. 0N/A // If we get here it's a bug. 0N/A // Get the next oid, using the GC filter. 0N/A // if next is null: we reached the end of the table. 0N/A // debug. This should never happen. 0N/A // See com.sun.jmx.snmp.agent.SnmpMibTable 0N/A // handler should never be null. 0N/A // See com.sun.jmx.snmp.agent.SnmpMibTable 0N/A // Get the request contextual cache (userData). 0N/A // First look in the request contextual cache: maybe we've already 0N/A // created this entry... 0N/A // We know in the case of this table that the index is an integer, 0N/A // it is thus the first OID arc of the index OID. 0N/A // the request contextual cache. 0N/A // Revisit: Probably better programming to put all these strings 0N/A // in some interface. 0N/A // If the entry is in the cache, simply return it. 0N/A // Entry was not in request cache. Make a new one. 0N/A // Get the data hanler. 0N/A // handler should never be null. 0N/A // Use the filter to retrieve only GarabageCollectorMBean data. 0N/A // data may be null if the OID we were given is not valid. 0N/A // (e.g. it identifies a MemoryManager which is not a 0N/A // GarbageCollector) 0N/A // Make a new entryy (transient object that will be kept only 0N/A // for the duration of the request. 0N/A // Put the entry in the request cache in case we need it later 0N/A // in the processing of the request. Note that we could have 0N/A // optimized this by making JvmMemGCEntryImpl extend 0N/A // JvmMemManagerEntryImpl, and then make sure that 0N/A // JvmMemManagerTableMetaImpl creates an instance of JvmMemGCEntryImpl 0N/A // instead of JvmMemManagerEntryImpl when the associated data is 0N/A // an instance of GarbageCollectorMXBean. This would have made it 0N/A // possible to share the transient entry object. 0N/A // As it is, we may have two transient objects that points to 0N/A // the same underlying MemoryManagerMXBean (which is definitely 0N/A // not a problem - but is only a small dysatisfaction)