/*
* 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.
*/
/**
* The base classes for the concrete implementations of the HotSpot
* PerfData instrumentation buffer.
*
* @author Brian Doherty
* @since 1.5
* @see AbstractPerfDataBuffer
*/
public abstract class PerfDataBufferImpl {
/**
* The buffer containing the instrumentation data.
*/
/**
* A Map of monitor objects found in the instrumentation buffer.
*/
/**
* The Local Java Virtual Machine Identifier for this buffer.
*/
protected int lvmid;
/**
* A Map of monitor object names to aliases as read in from the alias map
* file.
*/
/**
* A cache of resolved monitor aliases.
*/
/**
* Constructor.
*
* @param buffer the ByteBuffer containing the instrumentation data.
* @param lvmid the Local Java Virtual Machine Identifier for this
* instrumentation buffer.
*/
this.aliasCache = new HashMap();
}
/**
* Get the Local Java Virtual Machine Identifier, or <em>lvmid</em>
* for the target JVM associated with this instrumentation buffer.
*
* @return int - the lvmid
*/
public int getLocalVmId() {
return lvmid;
}
/**
* Get a copy of the raw instrumentation data.
* This method is used to get a copy of the current bytes in the
* instrumentation buffer. It is generally used for transporting
* those bytes over the network.
*
* @return byte[] - a copy of the bytes in the instrumentation buffer.
*/
public byte[] getBytes() {
synchronized (this) {
/*
* this operation is potentially time consuming, and the result
* is unused when the getBytes() interface is used. However, the
* call is necessary in order to synchronize this monitoring
* client with the target jvm, which assures that the receiver
* of the byte[] gets an image that is initialized to a usable
* state. Otherwise, they might only get a snapshot of an
* empty instrumentation buffer immediately after it was created.
*/
try {
}
} catch (MonitorException e) {
/*
* just ignore this here and let the reciever of the
* byte[] detect and handle the problem.
*/
}
}
return bytes;
}
/**
* Get the capacity of the instrumentation buffer.
*
* @return int - the capacity, or size, of the instrumentation buffer.
*/
public int getCapacity() {
}
/**
* Get the ByteBuffer containing the instrumentation data.
*
* @return ByteBuffer - a ByteBuffer object that refers to the
* instrumentation data.
*/
// receiver is responsible for assuring that the buffer's state
// is that of an initialized target.
return buffer;
}
/**
* Build the alias mapping. Uses the default alias map file unless
* the sun.jvmstat.perfdata.aliasmap file indicates some other
* file as the source.
*/
private void buildAliasMap() {
try {
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
} else {
}
try {
} catch (IOException e) {
+ e.getMessage());
} catch (SyntaxException e) {
+ e.getMessage());
}
}
/**
* Find the Monitor object for the named counter by using one of its
* aliases.
*/
if (m == null) {
}
}
}
return m;
}
/**
* Find a named Instrumentation object.
*
* This method will look for the named instrumentation object in the
* instrumentation exported by this Java Virtual Machine. If an
* instrumentation object with the given name exists, a Monitor interface
* to that object will be return. Otherwise, the method returns
* <tt>null</tt>. The method will map requests for instrumention objects
* using old names to their current names, if applicable.
*
*
*
* @param name the name of the Instrumentation object to find.
* @return Monitor - the {@link Monitor} object that can be used to
* monitor the the named instrumentation object, or
* <tt>null</tt> if the named object doesn't exist.
* @throws MonitorException Thrown if an error occurs while communicating
* with the target Java Virtual Machine.
*/
synchronized (this) {
}
// look for the requested monitor
if (m == null) {
// not found - load any new monitors, and try again.
}
if (m == null) {
// still not found, look for aliases
m = findByAlias(name);
}
}
return m;
}
/**
* Find all Instrumentation objects with names matching the given pattern.
*
* This method returns a {@link List} of Monitor objects such that
* the name of each object matches the given pattern.
*
* @param patternString a string containing a pattern as described in
* {@link java.util.regex.Pattern}.
* @return List<Monitor> - a List of {@link Monitor} objects that can be used to
* monitor the instrumentation objects whose names match
* the given pattern. If no instrumentation objects have`
* names matching the given pattern, then an empty List
* is returned.
* @throws MonitorException Thrown if an error occurs while communicating
* with the target Java Virtual Machine.
* @see java.util.regex.Pattern
*/
throws MonitorException, PatternSyntaxException {
synchronized(this) {
} else {
}
}
// apply pattern to monitor item name
// if the pattern matches, then add monitor to list
}
}
return matches;
}
/**
* Get a list of the inserted and removed monitors since last called.
*
* @return MonitorStatus - the status of available Monitors for the
* target Java Virtual Machine.
* @throws MonitorException Thrown if communications errors occur
* while communicating with the target.
*/
synchronized(this) {
}
return getMonitorStatus(monitors);
}
}
// PerfDataBuffer implementation specific classes
/**
* get the list of inserted and removed monitors since last called.
*
* @param m the map of Monitors.
* @throws MonitorException Thrown if communications errors occur
* while communicating with the target.
*/
throws MonitorException;
/**
* build the map of Monitor objects.
*
* @param m the map of Monitors.
* @throws MonitorException Thrown if communications errors occur
* while communicating with the target.
*/
/**
* get the new Monitor objects from the Map of Monitor objects.
*
* @param m the map of Monitors.
* @throws MonitorException Thrown if communications errors occur
* while communicating with the target.
*/
}