feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
565
jdkSrc/jdk8/sun/management/Agent.java
Normal file
565
jdkSrc/jdk8/sun/management/Agent.java
Normal file
@@ -0,0 +1,565 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.management.remote.JMXConnectorServer;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
|
||||
import static sun.management.AgentConfigurationError.*;
|
||||
import sun.management.jmxremote.ConnectorBootstrap;
|
||||
import sun.management.jdp.JdpController;
|
||||
import sun.management.jdp.JdpException;
|
||||
import sun.misc.VMSupport;
|
||||
|
||||
/**
|
||||
* This Agent is started by the VM when -Dcom.sun.management.snmp or
|
||||
* -Dcom.sun.management.jmxremote is set. This class will be loaded by the
|
||||
* system class loader. Also jmx framework could be started by jcmd
|
||||
*/
|
||||
public class Agent {
|
||||
// management properties
|
||||
|
||||
private static Properties mgmtProps;
|
||||
private static ResourceBundle messageRB;
|
||||
private static final String CONFIG_FILE =
|
||||
"com.sun.management.config.file";
|
||||
private static final String SNMP_PORT =
|
||||
"com.sun.management.snmp.port";
|
||||
private static final String JMXREMOTE =
|
||||
"com.sun.management.jmxremote";
|
||||
private static final String JMXREMOTE_PORT =
|
||||
"com.sun.management.jmxremote.port";
|
||||
private static final String RMI_PORT =
|
||||
"com.sun.management.jmxremote.rmi.port";
|
||||
private static final String ENABLE_THREAD_CONTENTION_MONITORING =
|
||||
"com.sun.management.enableThreadContentionMonitoring";
|
||||
private static final String LOCAL_CONNECTOR_ADDRESS_PROP =
|
||||
"com.sun.management.jmxremote.localConnectorAddress";
|
||||
private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME =
|
||||
"sun.management.snmp.AdaptorBootstrap";
|
||||
|
||||
private static final String JDP_DEFAULT_ADDRESS = "224.0.23.178";
|
||||
private static final int JDP_DEFAULT_PORT = 7095;
|
||||
|
||||
// The only active agent allowed
|
||||
private static JMXConnectorServer jmxServer = null;
|
||||
|
||||
// Parse string com.sun.management.prop=xxx,com.sun.management.prop=yyyy
|
||||
// and return property set if args is null or empty
|
||||
// return empty property set
|
||||
private static Properties parseString(String args) {
|
||||
Properties argProps = new Properties();
|
||||
if (args != null && !args.trim().equals("")) {
|
||||
for (String option : args.split(",")) {
|
||||
String s[] = option.split("=", 2);
|
||||
String name = s[0].trim();
|
||||
String value = (s.length > 1) ? s[1].trim() : "";
|
||||
|
||||
if (!name.startsWith("com.sun.management.")) {
|
||||
error(INVALID_OPTION, name);
|
||||
}
|
||||
|
||||
argProps.setProperty(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
return argProps;
|
||||
}
|
||||
|
||||
// invoked by -javaagent or -Dcom.sun.management.agent.class
|
||||
public static void premain(String args) throws Exception {
|
||||
agentmain(args);
|
||||
}
|
||||
|
||||
// invoked by attach mechanism
|
||||
public static void agentmain(String args) throws Exception {
|
||||
if (args == null || args.length() == 0) {
|
||||
args = JMXREMOTE; // default to local management
|
||||
}
|
||||
|
||||
Properties arg_props = parseString(args);
|
||||
|
||||
// Read properties from the config file
|
||||
Properties config_props = new Properties();
|
||||
String fname = arg_props.getProperty(CONFIG_FILE);
|
||||
readConfiguration(fname, config_props);
|
||||
|
||||
// Arguments override config file
|
||||
config_props.putAll(arg_props);
|
||||
startAgent(config_props);
|
||||
}
|
||||
|
||||
// jcmd ManagementAgent.start_local entry point
|
||||
// Also called due to command-line via startAgent()
|
||||
private static synchronized void startLocalManagementAgent() {
|
||||
Properties agentProps = VMSupport.getAgentProperties();
|
||||
|
||||
// start local connector if not started
|
||||
if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
|
||||
JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
|
||||
String address = cs.getAddress().toString();
|
||||
// Add the local connector address to the agent properties
|
||||
agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);
|
||||
|
||||
try {
|
||||
// export the address to the instrumentation buffer
|
||||
ConnectorAddressLink.export(address);
|
||||
} catch (Exception x) {
|
||||
// Connector server started but unable to export address
|
||||
// to instrumentation buffer - non-fatal error.
|
||||
warning(EXPORT_ADDRESS_FAILED, x.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// jcmd ManagementAgent.start entry point
|
||||
// This method starts the remote JMX agent and starts neither
|
||||
// the local JMX agent nor the SNMP agent
|
||||
// @see #startLocalManagementAgent and also @see #startAgent.
|
||||
private static synchronized void startRemoteManagementAgent(String args) throws Exception {
|
||||
if (jmxServer != null) {
|
||||
throw new RuntimeException(getText(INVALID_STATE, "Agent already started"));
|
||||
}
|
||||
|
||||
try {
|
||||
Properties argProps = parseString(args);
|
||||
Properties configProps = new Properties();
|
||||
|
||||
// Load the management properties from the config file
|
||||
// if config file is not specified readConfiguration implicitly
|
||||
// reads <java.home>/lib/management/management.properties
|
||||
|
||||
String fname = System.getProperty(CONFIG_FILE);
|
||||
readConfiguration(fname, configProps);
|
||||
|
||||
// management properties can be overridden by system properties
|
||||
// which take precedence
|
||||
Properties sysProps = System.getProperties();
|
||||
synchronized (sysProps) {
|
||||
configProps.putAll(sysProps);
|
||||
}
|
||||
|
||||
// if user specifies config file into command line for either
|
||||
// jcmd utilities or attach command it overrides properties set in
|
||||
// command line at the time of VM start
|
||||
String fnameUser = argProps.getProperty(CONFIG_FILE);
|
||||
if (fnameUser != null) {
|
||||
readConfiguration(fnameUser, configProps);
|
||||
}
|
||||
|
||||
// arguments specified in command line of jcmd utilities
|
||||
// override both system properties and one set by config file
|
||||
// specified in jcmd command line
|
||||
configProps.putAll(argProps);
|
||||
|
||||
// jcmd doesn't allow to change ThreadContentionMonitoring, but user
|
||||
// can specify this property inside config file, so enable optional
|
||||
// monitoring functionality if this property is set
|
||||
final String enableThreadContentionMonitoring =
|
||||
configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING);
|
||||
|
||||
if (enableThreadContentionMonitoring != null) {
|
||||
ManagementFactory.getThreadMXBean().
|
||||
setThreadContentionMonitoringEnabled(true);
|
||||
}
|
||||
|
||||
String jmxremotePort = configProps.getProperty(JMXREMOTE_PORT);
|
||||
if (jmxremotePort != null) {
|
||||
jmxServer = ConnectorBootstrap.
|
||||
startRemoteConnectorServer(jmxremotePort, configProps);
|
||||
|
||||
startDiscoveryService(configProps);
|
||||
} else {
|
||||
throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, "No port specified");
|
||||
}
|
||||
} catch (AgentConfigurationError err) {
|
||||
error(err);
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized void stopRemoteManagementAgent() throws Exception {
|
||||
|
||||
JdpController.stopDiscoveryService();
|
||||
|
||||
if (jmxServer != null) {
|
||||
ConnectorBootstrap.unexportRegistry();
|
||||
|
||||
// Attempt to stop already stopped agent
|
||||
// Don't cause any errors.
|
||||
jmxServer.stop();
|
||||
jmxServer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void startAgent(Properties props) throws Exception {
|
||||
String snmpPort = props.getProperty(SNMP_PORT);
|
||||
String jmxremote = props.getProperty(JMXREMOTE);
|
||||
String jmxremotePort = props.getProperty(JMXREMOTE_PORT);
|
||||
|
||||
// Enable optional monitoring functionality if requested
|
||||
final String enableThreadContentionMonitoring =
|
||||
props.getProperty(ENABLE_THREAD_CONTENTION_MONITORING);
|
||||
if (enableThreadContentionMonitoring != null) {
|
||||
ManagementFactory.getThreadMXBean().
|
||||
setThreadContentionMonitoringEnabled(true);
|
||||
}
|
||||
|
||||
try {
|
||||
if (snmpPort != null) {
|
||||
loadSnmpAgent(snmpPort, props);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the jmxremote.port property is set then we start the
|
||||
* RMIConnectorServer for remote M&M.
|
||||
*
|
||||
* If the jmxremote or jmxremote.port properties are set then
|
||||
* we start a RMIConnectorServer for local M&M. The address
|
||||
* of this "local" server is exported as a counter to the jstat
|
||||
* instrumentation buffer.
|
||||
*/
|
||||
if (jmxremote != null || jmxremotePort != null) {
|
||||
if (jmxremotePort != null) {
|
||||
jmxServer = ConnectorBootstrap.
|
||||
startRemoteConnectorServer(jmxremotePort, props);
|
||||
startDiscoveryService(props);
|
||||
}
|
||||
startLocalManagementAgent();
|
||||
}
|
||||
|
||||
} catch (AgentConfigurationError e) {
|
||||
error(e);
|
||||
} catch (Exception e) {
|
||||
error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void startDiscoveryService(Properties props)
|
||||
throws IOException {
|
||||
// Start discovery service if requested
|
||||
String discoveryPort = props.getProperty("com.sun.management.jdp.port");
|
||||
String discoveryAddress = props.getProperty("com.sun.management.jdp.address");
|
||||
String discoveryShouldStart = props.getProperty("com.sun.management.jmxremote.autodiscovery");
|
||||
|
||||
// Decide whether we should start autodicovery service.
|
||||
// To start autodiscovery following conditions should be met:
|
||||
// autodiscovery==true OR (autodicovery==null AND jdp.port != NULL)
|
||||
|
||||
boolean shouldStart = false;
|
||||
if (discoveryShouldStart == null){
|
||||
shouldStart = (discoveryPort != null);
|
||||
}
|
||||
else{
|
||||
try{
|
||||
shouldStart = Boolean.parseBoolean(discoveryShouldStart);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AgentConfigurationError("Couldn't parse autodiscovery argument");
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldStart) {
|
||||
// port and address are required arguments and have no default values
|
||||
InetAddress address;
|
||||
try {
|
||||
address = (discoveryAddress == null) ?
|
||||
InetAddress.getByName(JDP_DEFAULT_ADDRESS) : InetAddress.getByName(discoveryAddress);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new AgentConfigurationError("Unable to broadcast to requested address", e);
|
||||
}
|
||||
|
||||
int port = JDP_DEFAULT_PORT;
|
||||
if (discoveryPort != null) {
|
||||
try {
|
||||
port = Integer.parseInt(discoveryPort);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AgentConfigurationError("Couldn't parse JDP port argument");
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuilding service URL to broadcast it
|
||||
String jmxremotePort = props.getProperty(JMXREMOTE_PORT);
|
||||
String rmiPort = props.getProperty(RMI_PORT);
|
||||
|
||||
JMXServiceURL url = jmxServer.getAddress();
|
||||
String hostname = url.getHost();
|
||||
|
||||
String jmxUrlStr = (rmiPort != null)
|
||||
? String.format(
|
||||
"service:jmx:rmi://%s:%s/jndi/rmi://%s:%s/jmxrmi",
|
||||
hostname, rmiPort, hostname, jmxremotePort)
|
||||
: String.format(
|
||||
"service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi", hostname, jmxremotePort);
|
||||
|
||||
String instanceName = props.getProperty("com.sun.management.jdp.name");
|
||||
|
||||
try{
|
||||
JdpController.startDiscoveryService(address, port, instanceName, jmxUrlStr);
|
||||
}
|
||||
catch(JdpException e){
|
||||
throw new AgentConfigurationError("Couldn't start JDP service", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Properties loadManagementProperties() {
|
||||
Properties props = new Properties();
|
||||
|
||||
// Load the management properties from the config file
|
||||
|
||||
String fname = System.getProperty(CONFIG_FILE);
|
||||
readConfiguration(fname, props);
|
||||
|
||||
// management properties can be overridden by system properties
|
||||
// which take precedence
|
||||
Properties sysProps = System.getProperties();
|
||||
synchronized (sysProps) {
|
||||
props.putAll(sysProps);
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
public static synchronized Properties getManagementProperties() {
|
||||
if (mgmtProps == null) {
|
||||
String configFile = System.getProperty(CONFIG_FILE);
|
||||
String snmpPort = System.getProperty(SNMP_PORT);
|
||||
String jmxremote = System.getProperty(JMXREMOTE);
|
||||
String jmxremotePort = System.getProperty(JMXREMOTE_PORT);
|
||||
|
||||
if (configFile == null && snmpPort == null
|
||||
&& jmxremote == null && jmxremotePort == null) {
|
||||
// return if out-of-the-management option is not specified
|
||||
return null;
|
||||
}
|
||||
mgmtProps = loadManagementProperties();
|
||||
}
|
||||
return mgmtProps;
|
||||
}
|
||||
|
||||
private static void loadSnmpAgent(String snmpPort, Properties props) {
|
||||
try {
|
||||
// invoke the following through reflection:
|
||||
// AdaptorBootstrap.initialize(snmpPort, props);
|
||||
final Class<?> adaptorClass =
|
||||
Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME, true, null);
|
||||
final Method initializeMethod =
|
||||
adaptorClass.getMethod("initialize",
|
||||
String.class, Properties.class);
|
||||
initializeMethod.invoke(null, snmpPort, props);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException x) {
|
||||
// snmp runtime doesn't exist - initialization fails
|
||||
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT, x);
|
||||
} catch (InvocationTargetException x) {
|
||||
final Throwable cause = x.getCause();
|
||||
if (cause instanceof RuntimeException) {
|
||||
throw (RuntimeException) cause;
|
||||
} else if (cause instanceof Error) {
|
||||
throw (Error) cause;
|
||||
}
|
||||
// should not happen...
|
||||
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT, cause);
|
||||
}
|
||||
}
|
||||
|
||||
// read config file and initialize the properties
|
||||
private static void readConfiguration(String fname, Properties p) {
|
||||
if (fname == null) {
|
||||
String home = System.getProperty("java.home");
|
||||
if (home == null) {
|
||||
throw new Error("Can't find java.home ??");
|
||||
}
|
||||
StringBuffer defaultFileName = new StringBuffer(home);
|
||||
defaultFileName.append(File.separator).append("lib");
|
||||
defaultFileName.append(File.separator).append("management");
|
||||
defaultFileName.append(File.separator).append("management.properties");
|
||||
// Set file name
|
||||
fname = defaultFileName.toString();
|
||||
}
|
||||
final File configFile = new File(fname);
|
||||
if (!configFile.exists()) {
|
||||
error(CONFIG_FILE_NOT_FOUND, fname);
|
||||
}
|
||||
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = new FileInputStream(configFile);
|
||||
BufferedInputStream bin = new BufferedInputStream(in);
|
||||
p.load(bin);
|
||||
} catch (FileNotFoundException e) {
|
||||
error(CONFIG_FILE_OPEN_FAILED, e.getMessage());
|
||||
} catch (IOException e) {
|
||||
error(CONFIG_FILE_OPEN_FAILED, e.getMessage());
|
||||
} catch (SecurityException e) {
|
||||
error(CONFIG_FILE_ACCESS_DENIED, fname);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
error(CONFIG_FILE_CLOSE_FAILED, fname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void startAgent() throws Exception {
|
||||
String prop = System.getProperty("com.sun.management.agent.class");
|
||||
|
||||
// -Dcom.sun.management.agent.class not set so read management
|
||||
// properties and start agent
|
||||
if (prop == null) {
|
||||
// initialize management properties
|
||||
Properties props = getManagementProperties();
|
||||
if (props != null) {
|
||||
startAgent(props);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// -Dcom.sun.management.agent.class=<agent classname>:<agent args>
|
||||
String[] values = prop.split(":");
|
||||
if (values.length < 1 || values.length > 2) {
|
||||
error(AGENT_CLASS_INVALID, "\"" + prop + "\"");
|
||||
}
|
||||
String cname = values[0];
|
||||
String args = (values.length == 2 ? values[1] : null);
|
||||
|
||||
if (cname == null || cname.length() == 0) {
|
||||
error(AGENT_CLASS_INVALID, "\"" + prop + "\"");
|
||||
}
|
||||
|
||||
if (cname != null) {
|
||||
try {
|
||||
// Instantiate the named class.
|
||||
// invoke the premain(String args) method
|
||||
Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cname);
|
||||
Method premain = clz.getMethod("premain",
|
||||
new Class<?>[]{String.class});
|
||||
premain.invoke(null, /* static */
|
||||
new Object[]{args});
|
||||
} catch (ClassNotFoundException ex) {
|
||||
error(AGENT_CLASS_NOT_FOUND, "\"" + cname + "\"");
|
||||
} catch (NoSuchMethodException ex) {
|
||||
error(AGENT_CLASS_PREMAIN_NOT_FOUND, "\"" + cname + "\"");
|
||||
} catch (SecurityException ex) {
|
||||
error(AGENT_CLASS_ACCESS_DENIED);
|
||||
} catch (Exception ex) {
|
||||
String msg = (ex.getCause() == null
|
||||
? ex.getMessage()
|
||||
: ex.getCause().getMessage());
|
||||
error(AGENT_CLASS_FAILED, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void error(String key) {
|
||||
String keyText = getText(key);
|
||||
System.err.print(getText("agent.err.error") + ": " + keyText);
|
||||
throw new RuntimeException(keyText);
|
||||
}
|
||||
|
||||
public static void error(String key, String message) {
|
||||
String keyText = getText(key);
|
||||
System.err.print(getText("agent.err.error") + ": " + keyText);
|
||||
System.err.println(": " + message);
|
||||
throw new RuntimeException(keyText + ": " + message);
|
||||
}
|
||||
|
||||
public static void error(Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println(getText(AGENT_EXCEPTION) + ": " + e.toString());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
public static void error(AgentConfigurationError e) {
|
||||
String keyText = getText(e.getError());
|
||||
String[] params = e.getParams();
|
||||
|
||||
System.err.print(getText("agent.err.error") + ": " + keyText);
|
||||
|
||||
if (params != null && params.length != 0) {
|
||||
StringBuffer message = new StringBuffer(params[0]);
|
||||
for (int i = 1; i < params.length; i++) {
|
||||
message.append(" " + params[i]);
|
||||
}
|
||||
System.err.println(": " + message);
|
||||
}
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
public static void warning(String key, String message) {
|
||||
System.err.print(getText("agent.err.warning") + ": " + getText(key));
|
||||
System.err.println(": " + message);
|
||||
}
|
||||
|
||||
private static void initResource() {
|
||||
try {
|
||||
messageRB =
|
||||
ResourceBundle.getBundle("sun.management.resources.agent");
|
||||
} catch (MissingResourceException e) {
|
||||
throw new Error("Fatal: Resource for management agent is missing");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getText(String key) {
|
||||
if (messageRB == null) {
|
||||
initResource();
|
||||
}
|
||||
try {
|
||||
return messageRB.getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
return "Missing management agent resource bundle: key = \"" + key + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getText(String key, String... args) {
|
||||
if (messageRB == null) {
|
||||
initResource();
|
||||
}
|
||||
String format = messageRB.getString(key);
|
||||
if (format == null) {
|
||||
format = "missing resource key: key = \"" + key + "\", "
|
||||
+ "arguments = \"{0}\", \"{1}\", \"{2}\"";
|
||||
}
|
||||
return MessageFormat.format(format, (Object[]) args);
|
||||
}
|
||||
}
|
||||
151
jdkSrc/jdk8/sun/management/AgentConfigurationError.java
Normal file
151
jdkSrc/jdk8/sun/management/AgentConfigurationError.java
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
/**
|
||||
* Configuration Error thrown by a management agent.
|
||||
*/
|
||||
public class AgentConfigurationError extends Error {
|
||||
public static final String AGENT_EXCEPTION =
|
||||
"agent.err.exception";
|
||||
public static final String CONFIG_FILE_NOT_FOUND =
|
||||
"agent.err.configfile.notfound";
|
||||
public static final String CONFIG_FILE_OPEN_FAILED =
|
||||
"agent.err.configfile.failed";
|
||||
public static final String CONFIG_FILE_CLOSE_FAILED =
|
||||
"agent.err.configfile.closed.failed";
|
||||
public static final String CONFIG_FILE_ACCESS_DENIED =
|
||||
"agent.err.configfile.access.denied";
|
||||
public static final String EXPORT_ADDRESS_FAILED =
|
||||
"agent.err.exportaddress.failed";
|
||||
public static final String AGENT_CLASS_NOT_FOUND =
|
||||
"agent.err.agentclass.notfound";
|
||||
public static final String AGENT_CLASS_FAILED =
|
||||
"agent.err.agentclass.failed";
|
||||
public static final String AGENT_CLASS_PREMAIN_NOT_FOUND =
|
||||
"agent.err.premain.notfound";
|
||||
public static final String AGENT_CLASS_ACCESS_DENIED =
|
||||
"agent.err.agentclass.access.denied";
|
||||
public static final String AGENT_CLASS_INVALID =
|
||||
"agent.err.invalid.agentclass";
|
||||
public static final String INVALID_JMXREMOTE_PORT =
|
||||
"agent.err.invalid.jmxremote.port";
|
||||
public static final String INVALID_JMXREMOTE_RMI_PORT =
|
||||
"agent.err.invalid.jmxremote.rmi.port";
|
||||
public static final String INVALID_JMXREMOTE_LOCAL_PORT =
|
||||
"agent.err.invalid.jmxremote.local.port";
|
||||
public static final String PASSWORD_FILE_NOT_SET =
|
||||
"agent.err.password.file.notset";
|
||||
public static final String PASSWORD_FILE_NOT_READABLE =
|
||||
"agent.err.password.file.not.readable";
|
||||
public static final String PASSWORD_FILE_READ_FAILED =
|
||||
"agent.err.password.file.read.failed";
|
||||
public static final String PASSWORD_FILE_NOT_FOUND =
|
||||
"agent.err.password.file.notfound";
|
||||
public static final String ACCESS_FILE_NOT_SET =
|
||||
"agent.err.access.file.notset";
|
||||
public static final String ACCESS_FILE_NOT_READABLE =
|
||||
"agent.err.access.file.not.readable";
|
||||
public static final String ACCESS_FILE_READ_FAILED =
|
||||
"agent.err.access.file.read.failed";
|
||||
public static final String ACCESS_FILE_NOT_FOUND =
|
||||
"agent.err.access.file.notfound";
|
||||
public static final String PASSWORD_FILE_ACCESS_NOT_RESTRICTED =
|
||||
"agent.err.password.file.access.notrestricted";
|
||||
public static final String FILE_ACCESS_NOT_RESTRICTED =
|
||||
"agent.err.file.access.not.restricted";
|
||||
public static final String FILE_NOT_FOUND =
|
||||
"agent.err.file.not.found";
|
||||
public static final String FILE_NOT_READABLE =
|
||||
"agent.err.file.not.readable";
|
||||
public static final String FILE_NOT_SET =
|
||||
"agent.err.file.not.set";
|
||||
public static final String FILE_READ_FAILED =
|
||||
"agent.err.file.read.failed";
|
||||
public static final String CONNECTOR_SERVER_IO_ERROR =
|
||||
"agent.err.connector.server.io.error";
|
||||
public static final String INVALID_OPTION =
|
||||
"agent.err.invalid.option";
|
||||
public static final String INVALID_SNMP_PORT =
|
||||
"agent.err.invalid.snmp.port";
|
||||
public static final String INVALID_SNMP_TRAP_PORT =
|
||||
"agent.err.invalid.snmp.trap.port";
|
||||
public static final String UNKNOWN_SNMP_INTERFACE =
|
||||
"agent.err.unknown.snmp.interface";
|
||||
public static final String SNMP_ACL_FILE_NOT_SET =
|
||||
"agent.err.acl.file.notset";
|
||||
public static final String SNMP_ACL_FILE_NOT_FOUND =
|
||||
"agent.err.acl.file.notfound";
|
||||
public static final String SNMP_ACL_FILE_NOT_READABLE =
|
||||
"agent.err.acl.file.not.readable";
|
||||
public static final String SNMP_ACL_FILE_READ_FAILED =
|
||||
"agent.err.acl.file.read.failed";
|
||||
public static final String SNMP_ACL_FILE_ACCESS_NOT_RESTRICTED =
|
||||
"agent.err.acl.file.access.notrestricted";
|
||||
public static final String SNMP_ADAPTOR_START_FAILED =
|
||||
"agent.err.snmp.adaptor.start.failed";
|
||||
public static final String SNMP_MIB_INIT_FAILED =
|
||||
"agent.err.snmp.mib.init.failed";
|
||||
public static final String INVALID_STATE =
|
||||
"agent.err.invalid.state";
|
||||
|
||||
private final String error;
|
||||
private final String[] params;
|
||||
|
||||
public AgentConfigurationError(String error) {
|
||||
super();
|
||||
this.error = error;
|
||||
this.params = null;
|
||||
}
|
||||
|
||||
public AgentConfigurationError(String error, Throwable cause) {
|
||||
super(cause);
|
||||
this.error = error;
|
||||
this.params = null;
|
||||
}
|
||||
|
||||
public AgentConfigurationError(String error, String... params) {
|
||||
super();
|
||||
this.error = error;
|
||||
this.params = params.clone();
|
||||
}
|
||||
|
||||
public AgentConfigurationError(String error, Throwable cause, String... params) {
|
||||
super(cause);
|
||||
this.error = error;
|
||||
this.params = params.clone();
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public String[] getParams() {
|
||||
return params.clone();
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1211605593516195475L;
|
||||
}
|
||||
80
jdkSrc/jdk8/sun/management/BaseOperatingSystemImpl.java
Normal file
80
jdkSrc/jdk8/sun/management/BaseOperatingSystemImpl.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import javax.management.ObjectName;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
/**
|
||||
* Implementation class for the operating system.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getOperatingSystemMXBean() returns an instance
|
||||
* of this class.
|
||||
*/
|
||||
public class BaseOperatingSystemImpl implements OperatingSystemMXBean {
|
||||
|
||||
private final VMManagement jvm;
|
||||
|
||||
/**
|
||||
* Constructor of BaseOperatingSystemImpl class.
|
||||
*/
|
||||
protected BaseOperatingSystemImpl(VMManagement vm) {
|
||||
this.jvm = vm;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return jvm.getOsName();
|
||||
}
|
||||
|
||||
public String getArch() {
|
||||
return jvm.getOsArch();
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return jvm.getOsVersion();
|
||||
}
|
||||
|
||||
public int getAvailableProcessors() {
|
||||
return jvm.getAvailableProcessors();
|
||||
}
|
||||
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private double[] loadavg = new double[1];
|
||||
public double getSystemLoadAverage() {
|
||||
if (unsafe.getLoadAverage(loadavg, 1) == 1) {
|
||||
return loadavg[0];
|
||||
} else {
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
76
jdkSrc/jdk8/sun/management/ClassLoadingImpl.java
Normal file
76
jdkSrc/jdk8/sun/management/ClassLoadingImpl.java
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.ClassLoadingMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* Implementation class for the class loading subsystem.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getClassLoadingMXBean() returns an instance
|
||||
* of this class.
|
||||
*/
|
||||
class ClassLoadingImpl implements ClassLoadingMXBean {
|
||||
|
||||
private final VMManagement jvm;
|
||||
|
||||
/**
|
||||
* Constructor of ClassLoadingImpl class.
|
||||
*/
|
||||
ClassLoadingImpl(VMManagement vm) {
|
||||
this.jvm = vm;
|
||||
}
|
||||
|
||||
public long getTotalLoadedClassCount() {
|
||||
return jvm.getTotalClassCount();
|
||||
}
|
||||
|
||||
public int getLoadedClassCount() {
|
||||
return jvm.getLoadedClassCount();
|
||||
}
|
||||
|
||||
public long getUnloadedClassCount() {
|
||||
return jvm.getUnloadedClassCount();
|
||||
}
|
||||
|
||||
public boolean isVerbose() {
|
||||
return jvm.getVerboseClass();
|
||||
}
|
||||
|
||||
public void setVerbose(boolean value) {
|
||||
Util.checkControlAccess();
|
||||
|
||||
setVerboseClass(value);
|
||||
}
|
||||
native static void setVerboseClass(boolean value);
|
||||
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
|
||||
}
|
||||
}
|
||||
77
jdkSrc/jdk8/sun/management/CompilationImpl.java
Normal file
77
jdkSrc/jdk8/sun/management/CompilationImpl.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.CompilationMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* Implementation class for the compilation subsystem.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getCompilationMXBean() returns an instance
|
||||
* of this class.
|
||||
*/
|
||||
class CompilationImpl implements CompilationMXBean {
|
||||
|
||||
private final VMManagement jvm;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Constructor of CompilationImpl class.
|
||||
*/
|
||||
CompilationImpl(VMManagement vm) {
|
||||
this.jvm = vm;
|
||||
this.name = jvm.getCompilerName();
|
||||
if (name == null) {
|
||||
throw new AssertionError("Null compiler name");
|
||||
}
|
||||
}
|
||||
|
||||
public java.lang.String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isCompilationTimeMonitoringSupported() {
|
||||
return jvm.isCompilationTimeMonitoringSupported();
|
||||
}
|
||||
|
||||
public long getTotalCompilationTime() {
|
||||
if (!isCompilationTimeMonitoringSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Compilation time monitoring is not supported.");
|
||||
}
|
||||
|
||||
return jvm.getTotalCompileTime();
|
||||
}
|
||||
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
91
jdkSrc/jdk8/sun/management/CompilerThreadStat.java
Normal file
91
jdkSrc/jdk8/sun/management/CompilerThreadStat.java
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CompilerThreadStat implements java.io.Serializable {
|
||||
private String name;
|
||||
private long taskCount;
|
||||
private long compileTime;
|
||||
private MethodInfo lastMethod;
|
||||
|
||||
CompilerThreadStat(String name, long taskCount, long time, MethodInfo lastMethod) {
|
||||
this.name = name;
|
||||
this.taskCount = taskCount;
|
||||
this.compileTime = time;
|
||||
this.lastMethod = lastMethod;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the name of the compiler thread associated with
|
||||
* this compiler thread statistic.
|
||||
*
|
||||
* @return the name of the compiler thread.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of compile tasks performed by the compiler thread
|
||||
* associated with this compiler thread statistic.
|
||||
*
|
||||
* @return the number of compile tasks performed by the compiler thread.
|
||||
*/
|
||||
public long getCompileTaskCount() {
|
||||
return taskCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the accumulated elapsed time spent by the compiler thread
|
||||
* associated with this compiler thread statistic.
|
||||
*
|
||||
* @return the accumulated elapsed time spent by the compiler thread.
|
||||
*/
|
||||
public long getCompileTime() {
|
||||
return compileTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the information about the last method compiled by
|
||||
* the compiler thread associated with this compiler thread statistic.
|
||||
*
|
||||
* @return a {@link MethodInfo} object for the last method
|
||||
* compiled by the compiler thread.
|
||||
*/
|
||||
public MethodInfo getLastCompiledMethodInfo() {
|
||||
return lastMethod;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getName() + " compileTasks = " + getCompileTaskCount()
|
||||
+ " compileTime = " + getCompileTime();
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 6992337162326171013L;
|
||||
|
||||
}
|
||||
181
jdkSrc/jdk8/sun/management/ConnectorAddressLink.java
Normal file
181
jdkSrc/jdk8/sun/management/ConnectorAddressLink.java
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import sun.misc.Perf;
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Counter;
|
||||
import sun.management.counter.perf.PerfInstrumentation;
|
||||
|
||||
/**
|
||||
* A utility class to support the exporting and importing of the address
|
||||
* of a connector server using the instrumentation buffer.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public class ConnectorAddressLink {
|
||||
|
||||
private static final String CONNECTOR_ADDRESS_COUNTER =
|
||||
"sun.management.JMXConnectorServer.address";
|
||||
|
||||
/*
|
||||
* The format of the jvmstat counters representing the properties of
|
||||
* a given out-of-the-box JMX remote connector will be as follows:
|
||||
*
|
||||
* sun.management.JMXConnectorServer.<counter>.<key>=<value>
|
||||
*
|
||||
* where:
|
||||
*
|
||||
* counter = index computed by this class which uniquely identifies
|
||||
* an out-of-the-box JMX remote connector running in this
|
||||
* Java virtual machine.
|
||||
* key/value = a given key/value pair in the map supplied to the
|
||||
* exportRemote() method.
|
||||
*
|
||||
* For example,
|
||||
*
|
||||
* sun.management.JMXConnectorServer.0.remoteAddress=service:jmx:rmi:///jndi/rmi://myhost:5000/jmxrmi
|
||||
* sun.management.JMXConnectorServer.0.authenticate=false
|
||||
* sun.management.JMXConnectorServer.0.ssl=false
|
||||
* sun.management.JMXConnectorServer.0.sslRegistry=false
|
||||
* sun.management.JMXConnectorServer.0.sslNeedClientAuth=false
|
||||
*/
|
||||
private static final String REMOTE_CONNECTOR_COUNTER_PREFIX =
|
||||
"sun.management.JMXConnectorServer.";
|
||||
|
||||
/*
|
||||
* JMX remote connector counter (it will be incremented every
|
||||
* time a new out-of-the-box JMX remote connector is created).
|
||||
*/
|
||||
private static AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
/**
|
||||
* Exports the specified connector address to the instrumentation buffer
|
||||
* so that it can be read by this or other Java virtual machines running
|
||||
* on the same system.
|
||||
*
|
||||
* @param address The connector address.
|
||||
*/
|
||||
public static void export(String address) {
|
||||
if (address == null || address.length() == 0) {
|
||||
throw new IllegalArgumentException("address not specified");
|
||||
}
|
||||
Perf perf = Perf.getPerf();
|
||||
perf.createString(
|
||||
CONNECTOR_ADDRESS_COUNTER, 1, Units.STRING.intValue(), address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports the connector address from the instrument buffer
|
||||
* of the specified Java virtual machine.
|
||||
*
|
||||
* @param vmid an identifier that uniquely identifies a local Java virtual
|
||||
* machine, or <code>0</code> to indicate the current Java virtual machine.
|
||||
*
|
||||
* @return the value of the connector address, or <code>null</code> if the
|
||||
* target VM has not exported a connector address.
|
||||
*
|
||||
* @throws IOException An I/O error occurred while trying to acquire the
|
||||
* instrumentation buffer.
|
||||
*/
|
||||
public static String importFrom(int vmid) throws IOException {
|
||||
Perf perf = Perf.getPerf();
|
||||
ByteBuffer bb;
|
||||
try {
|
||||
bb = perf.attach(vmid, "r");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
throw new IOException(iae.getMessage());
|
||||
}
|
||||
List<Counter> counters =
|
||||
new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
|
||||
Iterator<Counter> i = counters.iterator();
|
||||
if (i.hasNext()) {
|
||||
Counter c = i.next();
|
||||
return (String) c.getValue();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the specified remote connector address and associated
|
||||
* configuration properties to the instrumentation buffer so that
|
||||
* it can be read by this or other Java virtual machines running
|
||||
* on the same system.
|
||||
*
|
||||
* @param properties The remote connector address properties.
|
||||
*/
|
||||
public static void exportRemote(Map<String, String> properties) {
|
||||
final int index = counter.getAndIncrement();
|
||||
Perf perf = Perf.getPerf();
|
||||
for (Map.Entry<String, String> entry : properties.entrySet()) {
|
||||
perf.createString(REMOTE_CONNECTOR_COUNTER_PREFIX + index + "." +
|
||||
entry.getKey(), 1, Units.STRING.intValue(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports the remote connector address and associated
|
||||
* configuration properties from the instrument buffer
|
||||
* of the specified Java virtual machine.
|
||||
*
|
||||
* @param vmid an identifier that uniquely identifies a local Java virtual
|
||||
* machine, or <code>0</code> to indicate the current Java virtual machine.
|
||||
*
|
||||
* @return a map containing the remote connector's properties, or an empty
|
||||
* map if the target VM has not exported the remote connector's properties.
|
||||
*
|
||||
* @throws IOException An I/O error occurred while trying to acquire the
|
||||
* instrumentation buffer.
|
||||
*/
|
||||
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
|
||||
Perf perf = Perf.getPerf();
|
||||
ByteBuffer bb;
|
||||
try {
|
||||
bb = perf.attach(vmid, "r");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
throw new IOException(iae.getMessage());
|
||||
}
|
||||
List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
for (Counter c : counters) {
|
||||
String name = c.getName();
|
||||
if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
|
||||
!name.equals(CONNECTOR_ADDRESS_COUNTER)) {
|
||||
properties.put(name, c.getValue().toString());
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
159
jdkSrc/jdk8/sun/management/DiagnosticCommandArgumentInfo.java
Normal file
159
jdkSrc/jdk8/sun/management/DiagnosticCommandArgumentInfo.java
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
/**
|
||||
* Diagnostic Command Argument information. It contains the description
|
||||
* of one parameter of the diagnostic command. A parameter can either be an
|
||||
* option or an argument. Options are identified by the option name while
|
||||
* arguments are identified by their position in the command line. The generic
|
||||
* syntax of a diagnostic command is:
|
||||
* <blockquote>
|
||||
* <command name> [<option>=<value>] [<argument_value>]
|
||||
* </blockquote>
|
||||
* Example:
|
||||
* <blockquote>
|
||||
* command_name option1=value1 option2=value argumentA argumentB argumentC
|
||||
* </blockquote>
|
||||
* In this command line, the diagnostic command receives five parameters, two
|
||||
* options named {@code option1} and {@code option2}, and three arguments.
|
||||
* argumentA's position is 0, argumentB's position is 1 and argumentC's
|
||||
* position is 2.
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
|
||||
class DiagnosticCommandArgumentInfo {
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String type;
|
||||
private final String defaultValue;
|
||||
private final boolean mandatory;
|
||||
private final boolean option;
|
||||
private final boolean multiple;
|
||||
private final int position;
|
||||
|
||||
/**
|
||||
* Returns the argument name.
|
||||
*
|
||||
* @return the argument name
|
||||
*/
|
||||
String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the argument description.
|
||||
*
|
||||
* @return the argument description
|
||||
*/
|
||||
String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the argument type.
|
||||
*
|
||||
* @return the argument type
|
||||
*/
|
||||
String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default value as a String if a default value
|
||||
* is defined, null otherwise.
|
||||
*
|
||||
* @return the default value as a String if a default value
|
||||
* is defined, null otherwise.
|
||||
*/
|
||||
String getDefault() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the argument is mandatory,
|
||||
* {@code false} otherwise.
|
||||
*
|
||||
* @return {@code true} if the argument is mandatory,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
boolean isMandatory() {
|
||||
return mandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the argument is an option,
|
||||
* {@code false} otherwise. Options have to be specified using the
|
||||
* <key>=<value> syntax on the command line, while other
|
||||
* arguments are specified with a single <value> field and are
|
||||
* identified by their position on command line.
|
||||
*
|
||||
* @return {@code true} if the argument is an option,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
boolean isOption() {
|
||||
return option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the argument can be specified multiple times,
|
||||
* {@code false} otherwise.
|
||||
*
|
||||
* @return {@code true} if the argument can be specified multiple times,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
boolean isMultiple() {
|
||||
return multiple;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expected position of this argument if it is not an option,
|
||||
* -1 otherwise. Argument position if defined from left to right,
|
||||
* starting at zero and ignoring the diagnostic command name and
|
||||
* options.
|
||||
*
|
||||
* @return the expected position of this argument if it is not an option,
|
||||
* -1 otherwise.
|
||||
*/
|
||||
int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
DiagnosticCommandArgumentInfo(String name, String description,
|
||||
String type, String defaultValue,
|
||||
boolean mandatory, boolean option,
|
||||
boolean multiple, int position) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.type = type;
|
||||
this.defaultValue = defaultValue;
|
||||
this.mandatory = mandatory;
|
||||
this.option = option;
|
||||
this.multiple = multiple;
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
380
jdkSrc/jdk8/sun/management/DiagnosticCommandImpl.java
Normal file
380
jdkSrc/jdk8/sun/management/DiagnosticCommandImpl.java
Normal file
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import com.sun.management.DiagnosticCommandMBean;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.Permission;
|
||||
import java.util.*;
|
||||
import javax.management.*;
|
||||
|
||||
/**
|
||||
* Implementation class for the diagnostic commands subsystem.
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
class DiagnosticCommandImpl extends NotificationEmitterSupport
|
||||
implements DiagnosticCommandMBean {
|
||||
|
||||
private final VMManagement jvm;
|
||||
private volatile Map<String, Wrapper> wrappers = null;
|
||||
private static final String strClassName = "".getClass().getName();
|
||||
private static final String strArrayClassName = String[].class.getName();
|
||||
private final boolean isSupported;
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String attribute) throws AttributeNotFoundException,
|
||||
MBeanException, ReflectionException {
|
||||
throw new AttributeNotFoundException(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(Attribute attribute) throws AttributeNotFoundException,
|
||||
InvalidAttributeValueException, MBeanException, ReflectionException {
|
||||
throw new AttributeNotFoundException(attribute.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeList getAttributes(String[] attributes) {
|
||||
return new AttributeList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeList setAttributes(AttributeList attributes) {
|
||||
return new AttributeList();
|
||||
}
|
||||
|
||||
private class Wrapper {
|
||||
|
||||
String name;
|
||||
String cmd;
|
||||
DiagnosticCommandInfo info;
|
||||
Permission permission;
|
||||
|
||||
Wrapper(String name, String cmd, DiagnosticCommandInfo info)
|
||||
throws InstantiationException {
|
||||
this.name = name;
|
||||
this.cmd = cmd;
|
||||
this.info = info;
|
||||
this.permission = null;
|
||||
Exception cause = null;
|
||||
if (info.getPermissionClass() != null) {
|
||||
try {
|
||||
Class c = Class.forName(info.getPermissionClass());
|
||||
if (info.getPermissionAction() == null) {
|
||||
try {
|
||||
Constructor constructor = c.getConstructor(String.class);
|
||||
permission = (Permission) constructor.newInstance(info.getPermissionName());
|
||||
|
||||
} catch (InstantiationException | IllegalAccessException
|
||||
| IllegalArgumentException | InvocationTargetException
|
||||
| NoSuchMethodException | SecurityException ex) {
|
||||
cause = ex;
|
||||
}
|
||||
}
|
||||
if (permission == null) {
|
||||
try {
|
||||
Constructor constructor = c.getConstructor(String.class, String.class);
|
||||
permission = (Permission) constructor.newInstance(
|
||||
info.getPermissionName(),
|
||||
info.getPermissionAction());
|
||||
} catch (InstantiationException | IllegalAccessException
|
||||
| IllegalArgumentException | InvocationTargetException
|
||||
| NoSuchMethodException | SecurityException ex) {
|
||||
cause = ex;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) { }
|
||||
if (permission == null) {
|
||||
InstantiationException iex =
|
||||
new InstantiationException("Unable to instantiate required permission");
|
||||
iex.initCause(cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String execute(String[] args) {
|
||||
if (permission != null) {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(permission);
|
||||
}
|
||||
}
|
||||
if(args == null) {
|
||||
return executeDiagnosticCommand(cmd);
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(cmd);
|
||||
for(int i=0; i<args.length; i++) {
|
||||
if(args[i] == null) {
|
||||
throw new IllegalArgumentException("Invalid null argument");
|
||||
}
|
||||
sb.append(" ");
|
||||
sb.append(args[i]);
|
||||
}
|
||||
return executeDiagnosticCommand(sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DiagnosticCommandImpl(VMManagement jvm) {
|
||||
this.jvm = jvm;
|
||||
isSupported = jvm.isRemoteDiagnosticCommandsSupported();
|
||||
}
|
||||
|
||||
private static class OperationInfoComparator implements Comparator<MBeanOperationInfo> {
|
||||
@Override
|
||||
public int compare(MBeanOperationInfo o1, MBeanOperationInfo o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MBeanInfo getMBeanInfo() {
|
||||
SortedSet<MBeanOperationInfo> operations = new TreeSet<>(new OperationInfoComparator());
|
||||
Map<String, Wrapper> wrappersmap;
|
||||
if (!isSupported) {
|
||||
wrappersmap = (Map<String, Wrapper>) Collections.EMPTY_MAP;
|
||||
} else {
|
||||
try {
|
||||
String[] command = getDiagnosticCommands();
|
||||
DiagnosticCommandInfo[] info = getDiagnosticCommandInfo(command);
|
||||
MBeanParameterInfo stringArgInfo[] = new MBeanParameterInfo[]{
|
||||
new MBeanParameterInfo("arguments", strArrayClassName,
|
||||
"Array of Diagnostic Commands Arguments and Options")
|
||||
};
|
||||
wrappersmap = new HashMap<>();
|
||||
for (int i = 0; i < command.length; i++) {
|
||||
String name = transform(command[i]);
|
||||
try {
|
||||
Wrapper w = new Wrapper(name, command[i], info[i]);
|
||||
wrappersmap.put(name, w);
|
||||
operations.add(new MBeanOperationInfo(
|
||||
w.name,
|
||||
w.info.getDescription(),
|
||||
(w.info.getArgumentsInfo() == null
|
||||
|| w.info.getArgumentsInfo().isEmpty())
|
||||
? null : stringArgInfo,
|
||||
strClassName,
|
||||
MBeanOperationInfo.ACTION_INFO,
|
||||
commandDescriptor(w)));
|
||||
} catch (InstantiationException ex) {
|
||||
// If for some reasons the creation of a diagnostic command
|
||||
// wrappers fails, the diagnostic command is just ignored
|
||||
// and won't appear in the DynamicMBean
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException | UnsupportedOperationException e) {
|
||||
wrappersmap = (Map<String, Wrapper>) Collections.EMPTY_MAP;
|
||||
}
|
||||
}
|
||||
wrappers = Collections.unmodifiableMap(wrappersmap);
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("immutableInfo", "false");
|
||||
map.put("interfaceClassName","com.sun.management.DiagnosticCommandMBean");
|
||||
map.put("mxbean", "false");
|
||||
Descriptor desc = new ImmutableDescriptor(map);
|
||||
return new MBeanInfo(
|
||||
this.getClass().getName(),
|
||||
"Diagnostic Commands",
|
||||
null, // attributes
|
||||
null, // constructors
|
||||
operations.toArray(new MBeanOperationInfo[operations.size()]), // operations
|
||||
getNotificationInfo(), // notifications
|
||||
desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(String actionName, Object[] params, String[] signature)
|
||||
throws MBeanException, ReflectionException {
|
||||
if (!isSupported) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
if (wrappers == null) {
|
||||
getMBeanInfo();
|
||||
}
|
||||
Wrapper w = wrappers.get(actionName);
|
||||
if (w != null) {
|
||||
if (w.info.getArgumentsInfo().isEmpty()
|
||||
&& (params == null || params.length == 0)
|
||||
&& (signature == null || signature.length == 0)) {
|
||||
return w.execute(null);
|
||||
} else if((params != null && params.length == 1)
|
||||
&& (signature != null && signature.length == 1
|
||||
&& signature[0] != null
|
||||
&& signature[0].compareTo(strArrayClassName) == 0)) {
|
||||
return w.execute((String[]) params[0]);
|
||||
}
|
||||
}
|
||||
throw new ReflectionException(new NoSuchMethodException(actionName));
|
||||
}
|
||||
|
||||
private static String transform(String name) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean toLower = true;
|
||||
boolean toUpper = false;
|
||||
for (int i = 0; i < name.length(); i++) {
|
||||
char c = name.charAt(i);
|
||||
if (c == '.' || c == '_') {
|
||||
toLower = false;
|
||||
toUpper = true;
|
||||
} else {
|
||||
if (toUpper) {
|
||||
toUpper = false;
|
||||
sb.append(Character.toUpperCase(c));
|
||||
} else if(toLower) {
|
||||
sb.append(Character.toLowerCase(c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private Descriptor commandDescriptor(Wrapper w) throws IllegalArgumentException {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("dcmd.name", w.info.getName());
|
||||
map.put("dcmd.description", w.info.getDescription());
|
||||
map.put("dcmd.vmImpact", w.info.getImpact());
|
||||
map.put("dcmd.permissionClass", w.info.getPermissionClass());
|
||||
map.put("dcmd.permissionName", w.info.getPermissionName());
|
||||
map.put("dcmd.permissionAction", w.info.getPermissionAction());
|
||||
map.put("dcmd.enabled", w.info.isEnabled());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("help ");
|
||||
sb.append(w.info.getName());
|
||||
map.put("dcmd.help", executeDiagnosticCommand(sb.toString()));
|
||||
if (w.info.getArgumentsInfo() != null && !w.info.getArgumentsInfo().isEmpty()) {
|
||||
HashMap<String, Object> allargmap = new HashMap<>();
|
||||
for (DiagnosticCommandArgumentInfo arginfo : w.info.getArgumentsInfo()) {
|
||||
HashMap<String, Object> argmap = new HashMap<>();
|
||||
argmap.put("dcmd.arg.name", arginfo.getName());
|
||||
argmap.put("dcmd.arg.type", arginfo.getType());
|
||||
argmap.put("dcmd.arg.description", arginfo.getDescription());
|
||||
argmap.put("dcmd.arg.isMandatory", arginfo.isMandatory());
|
||||
argmap.put("dcmd.arg.isMultiple", arginfo.isMultiple());
|
||||
boolean isOption = arginfo.isOption();
|
||||
argmap.put("dcmd.arg.isOption", isOption);
|
||||
if(!isOption) {
|
||||
argmap.put("dcmd.arg.position", arginfo.getPosition());
|
||||
} else {
|
||||
argmap.put("dcmd.arg.position", -1);
|
||||
}
|
||||
allargmap.put(arginfo.getName(), new ImmutableDescriptor(argmap));
|
||||
}
|
||||
map.put("dcmd.arguments", new ImmutableDescriptor(allargmap));
|
||||
}
|
||||
return new ImmutableDescriptor(map);
|
||||
}
|
||||
|
||||
private final static String notifName =
|
||||
"javax.management.Notification";
|
||||
|
||||
private final static String[] diagFramNotifTypes = {
|
||||
"jmx.mbean.info.changed"
|
||||
};
|
||||
|
||||
private MBeanNotificationInfo[] notifInfo = null;
|
||||
|
||||
@Override
|
||||
public MBeanNotificationInfo[] getNotificationInfo() {
|
||||
synchronized (this) {
|
||||
if (notifInfo == null) {
|
||||
notifInfo = new MBeanNotificationInfo[1];
|
||||
notifInfo[0] =
|
||||
new MBeanNotificationInfo(diagFramNotifTypes,
|
||||
notifName,
|
||||
"Diagnostic Framework Notification");
|
||||
}
|
||||
}
|
||||
return notifInfo.clone();
|
||||
}
|
||||
|
||||
private static long seqNumber = 0;
|
||||
private static long getNextSeqNumber() {
|
||||
return ++seqNumber;
|
||||
}
|
||||
|
||||
private void createDiagnosticFrameworkNotification() {
|
||||
|
||||
if (!hasListeners()) {
|
||||
return;
|
||||
}
|
||||
ObjectName on = null;
|
||||
try {
|
||||
on = ObjectName.getInstance(ManagementFactoryHelper.HOTSPOT_DIAGNOSTIC_COMMAND_MBEAN_NAME);
|
||||
} catch (MalformedObjectNameException e) { }
|
||||
Notification notif = new Notification("jmx.mbean.info.changed",
|
||||
on,
|
||||
getNextSeqNumber());
|
||||
notif.setUserData(getMBeanInfo());
|
||||
sendNotification(notif);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addNotificationListener(NotificationListener listener,
|
||||
NotificationFilter filter,
|
||||
Object handback) {
|
||||
boolean before = hasListeners();
|
||||
super.addNotificationListener(listener, filter, handback);
|
||||
boolean after = hasListeners();
|
||||
if (!before && after) {
|
||||
setNotificationEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeNotificationListener(NotificationListener listener)
|
||||
throws ListenerNotFoundException {
|
||||
boolean before = hasListeners();
|
||||
super.removeNotificationListener(listener);
|
||||
boolean after = hasListeners();
|
||||
if (before && !after) {
|
||||
setNotificationEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeNotificationListener(NotificationListener listener,
|
||||
NotificationFilter filter,
|
||||
Object handback)
|
||||
throws ListenerNotFoundException {
|
||||
boolean before = hasListeners();
|
||||
super.removeNotificationListener(listener, filter, handback);
|
||||
boolean after = hasListeners();
|
||||
if (before && !after) {
|
||||
setNotificationEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private native void setNotificationEnabled(boolean enabled);
|
||||
private native String[] getDiagnosticCommands();
|
||||
private native DiagnosticCommandInfo[] getDiagnosticCommandInfo(String[] commands);
|
||||
private native String executeDiagnosticCommand(String command);
|
||||
|
||||
}
|
||||
151
jdkSrc/jdk8/sun/management/DiagnosticCommandInfo.java
Normal file
151
jdkSrc/jdk8/sun/management/DiagnosticCommandInfo.java
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Diagnostic command information. It contains the description of a
|
||||
* diagnostic command.
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
|
||||
class DiagnosticCommandInfo {
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String impact;
|
||||
private final String permissionClass;
|
||||
private final String permissionName;
|
||||
private final String permissionAction;
|
||||
private final boolean enabled;
|
||||
private final List<DiagnosticCommandArgumentInfo> arguments;
|
||||
|
||||
/**
|
||||
* Returns the diagnostic command name.
|
||||
*
|
||||
* @return the diagnostic command name
|
||||
*/
|
||||
String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the diagnostic command description.
|
||||
*
|
||||
* @return the diagnostic command description
|
||||
*/
|
||||
String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the potential impact of the diagnostic command execution
|
||||
* on the Java virtual machine behavior.
|
||||
*
|
||||
* @return the potential impact of the diagnostic command execution
|
||||
* on the Java virtual machine behavior
|
||||
*/
|
||||
String getImpact() {
|
||||
return impact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the permission class required to be allowed
|
||||
* to invoke the diagnostic command, or null if no permission
|
||||
* is required.
|
||||
*
|
||||
* @return the name of the permission class name required to be allowed
|
||||
* to invoke the diagnostic command, or null if no permission
|
||||
* is required
|
||||
*/
|
||||
String getPermissionClass() {
|
||||
return permissionClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the permission name required to be allowed to invoke the
|
||||
* diagnostic command, or null if no permission is required.
|
||||
*
|
||||
* @return the permission name required to be allowed to invoke the
|
||||
* diagnostic command, or null if no permission is required
|
||||
*/
|
||||
String getPermissionName() {
|
||||
return permissionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the permission action required to be allowed to invoke the
|
||||
* diagnostic command, or null if no permission is required or
|
||||
* if the permission has no action specified.
|
||||
*
|
||||
* @return the permission action required to be allowed to invoke the
|
||||
* diagnostic command, or null if no permission is required or
|
||||
* if the permission has no action specified
|
||||
*/
|
||||
String getPermissionAction() {
|
||||
return permissionAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the diagnostic command is enabled,
|
||||
* {@code false} otherwise. The enabled/disabled
|
||||
* status of a diagnostic command can evolve during
|
||||
* the lifetime of the Java virtual machine.
|
||||
*
|
||||
* @return {@code true} if the diagnostic command is enabled,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of the diagnostic command arguments description.
|
||||
* If the diagnostic command has no arguments, it returns an empty list.
|
||||
*
|
||||
* @return a list of the diagnostic command arguments description
|
||||
*/
|
||||
List<DiagnosticCommandArgumentInfo> getArgumentsInfo() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
DiagnosticCommandInfo(String name, String description,
|
||||
String impact, String permissionClass,
|
||||
String permissionName, String permissionAction,
|
||||
boolean enabled,
|
||||
List<DiagnosticCommandArgumentInfo> arguments)
|
||||
{
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.impact = impact;
|
||||
this.permissionClass = permissionClass;
|
||||
this.permissionName = permissionName;
|
||||
this.permissionAction = permissionAction;
|
||||
this.enabled = enabled;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
}
|
||||
79
jdkSrc/jdk8/sun/management/ExtendedPlatformComponent.java
Normal file
79
jdkSrc/jdk8/sun/management/ExtendedPlatformComponent.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.lang.management.PlatformManagedObject;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Class to allow for an extended set of platform MXBeans
|
||||
*/
|
||||
public final class ExtendedPlatformComponent {
|
||||
private ExtendedPlatformComponent() {} // Don't create any instances
|
||||
|
||||
/**
|
||||
* Get the extended set of platform MXBeans that should be registered in the
|
||||
* platform MBeanServer, or an empty list if there are no such MXBeans.
|
||||
*/
|
||||
public static List<? extends PlatformManagedObject> getMXBeans() {
|
||||
PlatformManagedObject o = getFlightRecorderBean();
|
||||
if (o != null) {
|
||||
return Collections.singletonList(o);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extended platform MXBean implementing the given
|
||||
* mxbeanInterface, or null if there is no such MXBean.
|
||||
*/
|
||||
public static <T extends PlatformManagedObject>
|
||||
T getMXBean(Class<T> mxbeanInterface) {
|
||||
|
||||
if ("jdk.management.jfr.FlightRecorderMXBean".equals(mxbeanInterface.getName())) {
|
||||
return (T)getFlightRecorderBean();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PlatformManagedObject getFlightRecorderBean() {
|
||||
PlatformManagedObject object = null;
|
||||
try {
|
||||
Class provider = Class.forName("jdk.management.jfr.internal.FlightRecorderMXBeanProvider");
|
||||
Method m = provider.getDeclaredMethod("getFlightRecorderMXBean");
|
||||
|
||||
object = (PlatformManagedObject)m.invoke(null);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
// no jfr?
|
||||
}
|
||||
return object;
|
||||
}
|
||||
}
|
||||
74
jdkSrc/jdk8/sun/management/FileSystem.java
Normal file
74
jdkSrc/jdk8/sun/management/FileSystem.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
* Utility class to support file system operations
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public abstract class FileSystem {
|
||||
|
||||
private static final Object lock = new Object();
|
||||
private static FileSystem fs;
|
||||
|
||||
protected FileSystem() { }
|
||||
|
||||
/**
|
||||
* Opens the file system
|
||||
*/
|
||||
public static FileSystem open() {
|
||||
synchronized (lock) {
|
||||
if (fs == null) {
|
||||
fs = new FileSystemImpl();
|
||||
}
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not the specified file is located on a
|
||||
* file system that supports file security or not.
|
||||
*
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
public abstract boolean supportsFileSecurity(File f) throws IOException;
|
||||
|
||||
/**
|
||||
* Tell whether or not the specified file is accessible
|
||||
* by anything other than the file owner.
|
||||
*
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* If file is located on a file system that doesn't support
|
||||
* file security.
|
||||
*/
|
||||
public abstract boolean isAccessUserOnly(File f) throws IOException;
|
||||
}
|
||||
75
jdkSrc/jdk8/sun/management/FileSystemImpl.java
Normal file
75
jdkSrc/jdk8/sun/management/FileSystemImpl.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
* Windows implementation of sun.management.FileSystem
|
||||
*/
|
||||
public class FileSystemImpl extends FileSystem {
|
||||
|
||||
public boolean supportsFileSecurity(File f) throws IOException {
|
||||
String path = f.getAbsolutePath();
|
||||
if (path.indexOf(0) >= 0) {
|
||||
throw new IOException("illegal filename");
|
||||
}
|
||||
return isSecuritySupported0(f.getAbsolutePath());
|
||||
}
|
||||
|
||||
public boolean isAccessUserOnly(File f) throws IOException {
|
||||
String path = f.getAbsolutePath();
|
||||
if (path.indexOf(0) >= 0) {
|
||||
throw new IOException("illegal filename");
|
||||
}
|
||||
if (!isSecuritySupported0(path)) {
|
||||
throw new UnsupportedOperationException("File system does not support file security");
|
||||
}
|
||||
return isAccessUserOnly0(path);
|
||||
}
|
||||
|
||||
// Native methods
|
||||
|
||||
static native void init0();
|
||||
|
||||
static native boolean isSecuritySupported0(String path) throws IOException;
|
||||
|
||||
static native boolean isAccessUserOnly0(String path) throws IOException;
|
||||
|
||||
// Initialization
|
||||
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("management");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
init0();
|
||||
}
|
||||
}
|
||||
129
jdkSrc/jdk8/sun/management/Flag.java
Normal file
129
jdkSrc/jdk8/sun/management/Flag.java
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.util.*;
|
||||
import com.sun.management.VMOption;
|
||||
import com.sun.management.VMOption.Origin;
|
||||
import java.security.AccessController;
|
||||
|
||||
/**
|
||||
* Flag class is a helper class for constructing a VMOption.
|
||||
* It has the static methods for getting the Flag objects, each
|
||||
* corresponds to one VMOption.
|
||||
*
|
||||
*/
|
||||
class Flag {
|
||||
private String name;
|
||||
private Object value;
|
||||
private Origin origin;
|
||||
private boolean writeable;
|
||||
private boolean external;
|
||||
|
||||
Flag(String name, Object value, boolean writeable,
|
||||
boolean external, Origin origin) {
|
||||
this.name = name;
|
||||
this.value = value == null ? "" : value ;
|
||||
this.origin = origin;
|
||||
this.writeable = writeable;
|
||||
this.external = external;
|
||||
}
|
||||
|
||||
Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
boolean isWriteable() {
|
||||
return writeable;
|
||||
}
|
||||
|
||||
boolean isExternal() {
|
||||
return external;
|
||||
}
|
||||
|
||||
VMOption getVMOption() {
|
||||
return new VMOption(name, value.toString(), writeable, origin);
|
||||
}
|
||||
|
||||
static Flag getFlag(String name) {
|
||||
String[] names = new String[1];
|
||||
names[0] = name;
|
||||
|
||||
List<Flag> flags = getFlags(names, 1);
|
||||
if (flags.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
// flags should have only one element
|
||||
return flags.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
static List<Flag> getAllFlags() {
|
||||
int numFlags = getInternalFlagCount();
|
||||
|
||||
// Get all internal flags with names = null
|
||||
return getFlags(null, numFlags);
|
||||
}
|
||||
|
||||
private static List<Flag> getFlags(String[] names, int numFlags) {
|
||||
Flag[] flags = new Flag[numFlags];
|
||||
int count = getFlags(names, flags, numFlags);
|
||||
|
||||
List<Flag> result = new ArrayList<>();
|
||||
for (Flag f : flags) {
|
||||
if (f != null) {
|
||||
result.add(f);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static native String[] getAllFlagNames();
|
||||
// getFlags sets each element in the given flags array
|
||||
// with a Flag object only if the name is valid and the
|
||||
// type is supported. The flags array may contain null elements.
|
||||
private static native int getFlags(String[] names, Flag[] flags, int count);
|
||||
private static native int getInternalFlagCount();
|
||||
|
||||
// These set* methods are synchronized on the class object
|
||||
// to avoid multiple threads updating the same flag at the same time.
|
||||
static synchronized native void setLongValue(String name, long value);
|
||||
static synchronized native void setDoubleValue(String name, double value);
|
||||
static synchronized native void setBooleanValue(String name, boolean value);
|
||||
static synchronized native void setStringValue(String name, String value);
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("management");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
initialize();
|
||||
}
|
||||
private static native void initialize();
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import com.sun.management.GarbageCollectionNotificationInfo;
|
||||
import com.sun.management.GcInfo;
|
||||
import java.lang.reflect.Method;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.SimpleType;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* A CompositeData for GarbageCollectionNotificationInfo for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class GarbageCollectionNotifInfoCompositeData extends LazyCompositeData {
|
||||
private final GarbageCollectionNotificationInfo gcNotifInfo;
|
||||
|
||||
public GarbageCollectionNotifInfoCompositeData(GarbageCollectionNotificationInfo info) {
|
||||
this.gcNotifInfo = info;
|
||||
}
|
||||
|
||||
public GarbageCollectionNotificationInfo getGarbageCollectionNotifInfo() {
|
||||
return gcNotifInfo;
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(GarbageCollectionNotificationInfo info) {
|
||||
GarbageCollectionNotifInfoCompositeData gcnicd =
|
||||
new GarbageCollectionNotifInfoCompositeData(info);
|
||||
return gcnicd.getCompositeData();
|
||||
}
|
||||
|
||||
private CompositeType getCompositeTypeByBuilder() {
|
||||
final GcInfoBuilder builder = AccessController.doPrivileged (new PrivilegedAction<GcInfoBuilder>() {
|
||||
public GcInfoBuilder run() {
|
||||
try {
|
||||
Class cl = Class.forName("com.sun.management.GcInfo");
|
||||
Field f = cl.getDeclaredField("builder");
|
||||
f.setAccessible(true);
|
||||
return (GcInfoBuilder)f.get(gcNotifInfo.getGcInfo());
|
||||
} catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
CompositeType gict = null;
|
||||
synchronized(compositeTypeByBuilder) {
|
||||
gict = compositeTypeByBuilder.get(builder);
|
||||
if(gict == null) {
|
||||
OpenType<?>[] gcNotifInfoItemTypes = new OpenType<?>[] {
|
||||
SimpleType.STRING,
|
||||
SimpleType.STRING,
|
||||
SimpleType.STRING,
|
||||
builder.getGcInfoCompositeType(),
|
||||
};
|
||||
try {
|
||||
final String typeName =
|
||||
"sun.management.GarbageCollectionNotifInfoCompositeType";
|
||||
gict = new CompositeType(typeName,
|
||||
"CompositeType for GC notification info",
|
||||
gcNotifInfoItemNames,
|
||||
gcNotifInfoItemNames,
|
||||
gcNotifInfoItemTypes);
|
||||
compositeTypeByBuilder.put(builder,gict);
|
||||
} catch (OpenDataException e) {
|
||||
// shouldn't reach here
|
||||
throw Util.newException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return gict;
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// gcNotifInfoItemNames!
|
||||
final Object[] gcNotifInfoItemValues;
|
||||
gcNotifInfoItemValues = new Object[] {
|
||||
gcNotifInfo.getGcName(),
|
||||
gcNotifInfo.getGcAction(),
|
||||
gcNotifInfo.getGcCause(),
|
||||
GcInfoCompositeData.toCompositeData(gcNotifInfo.getGcInfo())
|
||||
};
|
||||
|
||||
CompositeType gict = getCompositeTypeByBuilder();
|
||||
|
||||
try {
|
||||
return new CompositeDataSupport(gict,
|
||||
gcNotifInfoItemNames,
|
||||
gcNotifInfoItemValues);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
// private static MappedMXBeanType gcInfoMapType;
|
||||
private static final String GC_NAME = "gcName";
|
||||
private static final String GC_ACTION = "gcAction";
|
||||
private static final String GC_CAUSE = "gcCause";
|
||||
private static final String GC_INFO = "gcInfo";
|
||||
private static final String[] gcNotifInfoItemNames = {
|
||||
GC_NAME,
|
||||
GC_ACTION,
|
||||
GC_CAUSE,
|
||||
GC_INFO
|
||||
};
|
||||
private static HashMap<GcInfoBuilder,CompositeType> compositeTypeByBuilder =
|
||||
new HashMap<>();
|
||||
|
||||
public static String getGcName(CompositeData cd) {
|
||||
String gcname = getString(cd, GC_NAME);
|
||||
if (gcname == null) {
|
||||
throw new IllegalArgumentException("Invalid composite data: " +
|
||||
"Attribute " + GC_NAME + " has null value");
|
||||
}
|
||||
return gcname;
|
||||
}
|
||||
|
||||
public static String getGcAction(CompositeData cd) {
|
||||
String gcaction = getString(cd, GC_ACTION);
|
||||
if (gcaction == null) {
|
||||
throw new IllegalArgumentException("Invalid composite data: " +
|
||||
"Attribute " + GC_ACTION + " has null value");
|
||||
}
|
||||
return gcaction;
|
||||
}
|
||||
|
||||
public static String getGcCause(CompositeData cd) {
|
||||
String gccause = getString(cd, GC_CAUSE);
|
||||
if (gccause == null) {
|
||||
throw new IllegalArgumentException("Invalid composite data: " +
|
||||
"Attribute " + GC_CAUSE + " has null value");
|
||||
}
|
||||
return gccause;
|
||||
}
|
||||
|
||||
public static GcInfo getGcInfo(CompositeData cd) {
|
||||
CompositeData gcInfoData = (CompositeData) cd.get(GC_INFO);
|
||||
return GcInfo.from(gcInfoData);
|
||||
}
|
||||
|
||||
/** Validate if the input CompositeData has the expected
|
||||
* CompositeType (i.e. contain all attributes with expected
|
||||
* names and types).
|
||||
*/
|
||||
public static void validateCompositeData(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
if (!isTypeMatched( getBaseGcNotifInfoCompositeType(), cd.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for GarbageCollectionNotificationInfo");
|
||||
}
|
||||
}
|
||||
|
||||
// This is only used for validation.
|
||||
private static CompositeType baseGcNotifInfoCompositeType = null;
|
||||
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
|
||||
if (baseGcNotifInfoCompositeType == null) {
|
||||
try {
|
||||
OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
|
||||
SimpleType.STRING,
|
||||
SimpleType.STRING,
|
||||
SimpleType.STRING,
|
||||
GcInfoCompositeData.getBaseGcInfoCompositeType()
|
||||
};
|
||||
baseGcNotifInfoCompositeType =
|
||||
new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
|
||||
"CompositeType for Base GarbageCollectionNotificationInfo",
|
||||
gcNotifInfoItemNames,
|
||||
gcNotifInfoItemNames,
|
||||
baseGcNotifInfoItemTypes);
|
||||
} catch (OpenDataException e) {
|
||||
// shouldn't reach here
|
||||
throw Util.newException(e);
|
||||
}
|
||||
}
|
||||
return baseGcNotifInfoCompositeType;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -1805123446483771292L;
|
||||
}
|
||||
188
jdkSrc/jdk8/sun/management/GarbageCollectorImpl.java
Normal file
188
jdkSrc/jdk8/sun/management/GarbageCollectorImpl.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import com.sun.management.GarbageCollectorMXBean;
|
||||
import com.sun.management.GarbageCollectionNotificationInfo;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
|
||||
import com.sun.management.GcInfo;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.MBeanAttributeInfo;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.MBeanNotificationInfo;
|
||||
import javax.management.Notification;
|
||||
import javax.management.NotificationFilter;
|
||||
import javax.management.NotificationListener;
|
||||
import javax.management.ListenerNotFoundException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Implementation class for the garbage collector.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getGarbageCollectorMXBeans() returns a list
|
||||
* of instances of this class.
|
||||
*/
|
||||
class GarbageCollectorImpl extends MemoryManagerImpl
|
||||
implements GarbageCollectorMXBean {
|
||||
|
||||
GarbageCollectorImpl(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public native long getCollectionCount();
|
||||
public native long getCollectionTime();
|
||||
|
||||
|
||||
// The memory pools are static and won't be changed.
|
||||
// TODO: If the hotspot implementation begins to have pools
|
||||
// dynamically created and removed, this needs to be modified.
|
||||
private String[] poolNames = null;
|
||||
synchronized String[] getAllPoolNames() {
|
||||
if (poolNames == null) {
|
||||
List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
|
||||
poolNames = new String[pools.size()];
|
||||
int i = 0;
|
||||
for (MemoryPoolMXBean m : pools) {
|
||||
poolNames[i++] = m.getName();
|
||||
}
|
||||
}
|
||||
return poolNames;
|
||||
}
|
||||
|
||||
// Sun JDK extension
|
||||
private GcInfoBuilder gcInfoBuilder;
|
||||
|
||||
private synchronized GcInfoBuilder getGcInfoBuilder() {
|
||||
if(gcInfoBuilder == null) {
|
||||
gcInfoBuilder = new GcInfoBuilder(this, getAllPoolNames());
|
||||
}
|
||||
return gcInfoBuilder;
|
||||
}
|
||||
|
||||
public GcInfo getLastGcInfo() {
|
||||
GcInfo info = getGcInfoBuilder().getLastGcInfo();
|
||||
return info;
|
||||
}
|
||||
|
||||
private final static String notifName =
|
||||
"javax.management.Notification";
|
||||
|
||||
private final static String[] gcNotifTypes = {
|
||||
GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION
|
||||
};
|
||||
|
||||
@Override
|
||||
public MBeanNotificationInfo[] getNotificationInfo() {
|
||||
return new MBeanNotificationInfo[]{
|
||||
new MBeanNotificationInfo(gcNotifTypes,
|
||||
notifName,
|
||||
"GC Notification")
|
||||
};
|
||||
}
|
||||
|
||||
private static long seqNumber = 0;
|
||||
private static long getNextSeqNumber() {
|
||||
return ++seqNumber;
|
||||
}
|
||||
|
||||
void createGCNotification(long timestamp,
|
||||
String gcName,
|
||||
String gcAction,
|
||||
String gcCause,
|
||||
GcInfo gcInfo) {
|
||||
|
||||
if (!hasListeners()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION,
|
||||
getObjectName(),
|
||||
getNextSeqNumber(),
|
||||
timestamp,
|
||||
gcName);
|
||||
GarbageCollectionNotificationInfo info =
|
||||
new GarbageCollectionNotificationInfo(gcName,
|
||||
gcAction,
|
||||
gcCause,
|
||||
gcInfo);
|
||||
|
||||
CompositeData cd =
|
||||
GarbageCollectionNotifInfoCompositeData.toCompositeData(info);
|
||||
notif.setUserData(cd);
|
||||
sendNotification(notif);
|
||||
}
|
||||
|
||||
public synchronized void addNotificationListener(NotificationListener listener,
|
||||
NotificationFilter filter,
|
||||
Object handback)
|
||||
{
|
||||
boolean before = hasListeners();
|
||||
super.addNotificationListener(listener, filter, handback);
|
||||
boolean after = hasListeners();
|
||||
if (!before && after) {
|
||||
setNotificationEnabled(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void removeNotificationListener(NotificationListener listener)
|
||||
throws ListenerNotFoundException {
|
||||
boolean before = hasListeners();
|
||||
super.removeNotificationListener(listener);
|
||||
boolean after = hasListeners();
|
||||
if (before && !after) {
|
||||
setNotificationEnabled(this,false);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void removeNotificationListener(NotificationListener listener,
|
||||
NotificationFilter filter,
|
||||
Object handback)
|
||||
throws ListenerNotFoundException
|
||||
{
|
||||
boolean before = hasListeners();
|
||||
super.removeNotificationListener(listener,filter,handback);
|
||||
boolean after = hasListeners();
|
||||
if (before && !after) {
|
||||
setNotificationEnabled(this,false);
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE, getName());
|
||||
}
|
||||
|
||||
native void setNotificationEnabled(GarbageCollectorMXBean gc,
|
||||
boolean enabled);
|
||||
|
||||
}
|
||||
205
jdkSrc/jdk8/sun/management/GcInfoBuilder.java
Normal file
205
jdkSrc/jdk8/sun/management/GcInfoBuilder.java
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.SimpleType;
|
||||
import javax.management.openmbean.TabularType;
|
||||
import javax.management.openmbean.TabularData;
|
||||
import javax.management.openmbean.TabularDataSupport;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import com.sun.management.GcInfo;
|
||||
|
||||
/**
|
||||
* Helper class to build composite data.
|
||||
*/
|
||||
public class GcInfoBuilder {
|
||||
private final GarbageCollectorMXBean gc;
|
||||
private final String[] poolNames;
|
||||
private String[] allItemNames;
|
||||
|
||||
// GC-specific composite type:
|
||||
// Each GarbageCollectorMXBean may have different GC-specific attributes
|
||||
// the CompositeType for the GcInfo could be different.
|
||||
private CompositeType gcInfoCompositeType;
|
||||
|
||||
// GC-specific items
|
||||
private final int gcExtItemCount;
|
||||
private final String[] gcExtItemNames;
|
||||
private final String[] gcExtItemDescs;
|
||||
private final char[] gcExtItemTypes;
|
||||
|
||||
GcInfoBuilder(GarbageCollectorMXBean gc, String[] poolNames) {
|
||||
this.gc = gc;
|
||||
this.poolNames = poolNames;
|
||||
this.gcExtItemCount = getNumGcExtAttributes(gc);
|
||||
this.gcExtItemNames = new String[gcExtItemCount];
|
||||
this.gcExtItemDescs = new String[gcExtItemCount];
|
||||
this.gcExtItemTypes = new char[gcExtItemCount];
|
||||
|
||||
// Fill the information about extension attributes
|
||||
fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames,
|
||||
gcExtItemTypes, gcExtItemDescs);
|
||||
|
||||
// lazily build the CompositeType for the GcInfo
|
||||
// including the GC-specific extension attributes
|
||||
this.gcInfoCompositeType = null;
|
||||
}
|
||||
|
||||
GcInfo getLastGcInfo() {
|
||||
MemoryUsage[] usageBeforeGC = new MemoryUsage[poolNames.length];
|
||||
MemoryUsage[] usageAfterGC = new MemoryUsage[poolNames.length];
|
||||
Object[] values = new Object[gcExtItemCount];
|
||||
|
||||
return getLastGcInfo0(gc, gcExtItemCount, values, gcExtItemTypes,
|
||||
usageBeforeGC, usageAfterGC);
|
||||
}
|
||||
|
||||
public String[] getPoolNames() {
|
||||
return poolNames;
|
||||
}
|
||||
|
||||
int getGcExtItemCount() {
|
||||
return gcExtItemCount;
|
||||
}
|
||||
|
||||
// Returns the CompositeType for the GcInfo including
|
||||
// the extension attributes
|
||||
synchronized CompositeType getGcInfoCompositeType() {
|
||||
if (gcInfoCompositeType != null)
|
||||
return gcInfoCompositeType;
|
||||
|
||||
// First, fill with the attributes in the GcInfo
|
||||
String[] gcInfoItemNames = GcInfoCompositeData.getBaseGcInfoItemNames();
|
||||
OpenType[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes();
|
||||
int numGcInfoItems = gcInfoItemNames.length;
|
||||
|
||||
int itemCount = numGcInfoItems + gcExtItemCount;
|
||||
allItemNames = new String[itemCount];
|
||||
String[] allItemDescs = new String[itemCount];
|
||||
OpenType<?>[] allItemTypes = new OpenType<?>[itemCount];
|
||||
|
||||
System.arraycopy(gcInfoItemNames, 0, allItemNames, 0, numGcInfoItems);
|
||||
System.arraycopy(gcInfoItemNames, 0, allItemDescs, 0, numGcInfoItems);
|
||||
System.arraycopy(gcInfoItemTypes, 0, allItemTypes, 0, numGcInfoItems);
|
||||
|
||||
// Then fill with the extension GC-specific attributes, if any.
|
||||
if (gcExtItemCount > 0) {
|
||||
fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames,
|
||||
gcExtItemTypes, gcExtItemDescs);
|
||||
System.arraycopy(gcExtItemNames, 0, allItemNames,
|
||||
numGcInfoItems, gcExtItemCount);
|
||||
System.arraycopy(gcExtItemDescs, 0, allItemDescs,
|
||||
numGcInfoItems, gcExtItemCount);
|
||||
for (int i = numGcInfoItems, j = 0; j < gcExtItemCount; i++, j++) {
|
||||
switch (gcExtItemTypes[j]) {
|
||||
case 'Z':
|
||||
allItemTypes[i] = SimpleType.BOOLEAN;
|
||||
break;
|
||||
case 'B':
|
||||
allItemTypes[i] = SimpleType.BYTE;
|
||||
break;
|
||||
case 'C':
|
||||
allItemTypes[i] = SimpleType.CHARACTER;
|
||||
break;
|
||||
case 'S':
|
||||
allItemTypes[i] = SimpleType.SHORT;
|
||||
break;
|
||||
case 'I':
|
||||
allItemTypes[i] = SimpleType.INTEGER;
|
||||
break;
|
||||
case 'J':
|
||||
allItemTypes[i] = SimpleType.LONG;
|
||||
break;
|
||||
case 'F':
|
||||
allItemTypes[i] = SimpleType.FLOAT;
|
||||
break;
|
||||
case 'D':
|
||||
allItemTypes[i] = SimpleType.DOUBLE;
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError(
|
||||
"Unsupported type [" + gcExtItemTypes[i] + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CompositeType gict = null;
|
||||
try {
|
||||
final String typeName =
|
||||
"sun.management." + gc.getName() + ".GcInfoCompositeType";
|
||||
|
||||
gict = new CompositeType(typeName,
|
||||
"CompositeType for GC info for " +
|
||||
gc.getName(),
|
||||
allItemNames,
|
||||
allItemDescs,
|
||||
allItemTypes);
|
||||
} catch (OpenDataException e) {
|
||||
// shouldn't reach here
|
||||
throw Util.newException(e);
|
||||
}
|
||||
gcInfoCompositeType = gict;
|
||||
|
||||
return gcInfoCompositeType;
|
||||
}
|
||||
|
||||
synchronized String[] getItemNames() {
|
||||
if (allItemNames == null) {
|
||||
// initialize when forming the composite type
|
||||
getGcInfoCompositeType();
|
||||
}
|
||||
return allItemNames;
|
||||
}
|
||||
|
||||
// Retrieve information about extension attributes
|
||||
private native int getNumGcExtAttributes(GarbageCollectorMXBean gc);
|
||||
private native void fillGcAttributeInfo(GarbageCollectorMXBean gc,
|
||||
int numAttributes,
|
||||
String[] attributeNames,
|
||||
char[] types,
|
||||
String[] descriptions);
|
||||
|
||||
/**
|
||||
* Returns the last GcInfo
|
||||
*
|
||||
* @param gc GarbageCollectorMXBean that the gc info is associated with.
|
||||
* @param numExtAtts number of extension attributes
|
||||
* @param extAttValues Values of extension attributes to be filled.
|
||||
* @param before Memory usage before GC to be filled.
|
||||
* @param after Memory usage after GC to be filled.
|
||||
*/
|
||||
private native GcInfo getLastGcInfo0(GarbageCollectorMXBean gc,
|
||||
int numExtAtts,
|
||||
Object[] extAttValues,
|
||||
char[] extAttTypes,
|
||||
MemoryUsage[] before,
|
||||
MemoryUsage[] after);
|
||||
}
|
||||
276
jdkSrc/jdk8/sun/management/GcInfoCompositeData.java
Normal file
276
jdkSrc/jdk8/sun/management/GcInfoCompositeData.java
Normal file
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.io.InvalidObjectException;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.TabularData;
|
||||
import javax.management.openmbean.SimpleType;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import com.sun.management.GcInfo;
|
||||
import com.sun.management.GarbageCollectionNotificationInfo;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* A CompositeData for GcInfo for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class GcInfoCompositeData extends LazyCompositeData {
|
||||
private final GcInfo info;
|
||||
private final GcInfoBuilder builder;
|
||||
private final Object[] gcExtItemValues;
|
||||
|
||||
public GcInfoCompositeData(GcInfo info,
|
||||
GcInfoBuilder builder,
|
||||
Object[] gcExtItemValues) {
|
||||
this.info = info;
|
||||
this.builder = builder;
|
||||
this.gcExtItemValues = gcExtItemValues;
|
||||
}
|
||||
|
||||
public GcInfo getGcInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(final GcInfo info) {
|
||||
final GcInfoBuilder builder = AccessController.doPrivileged (new PrivilegedAction<GcInfoBuilder>() {
|
||||
public GcInfoBuilder run() {
|
||||
try {
|
||||
Class cl = Class.forName("com.sun.management.GcInfo");
|
||||
Field f = cl.getDeclaredField("builder");
|
||||
f.setAccessible(true);
|
||||
return (GcInfoBuilder)f.get(info);
|
||||
} catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
final Object[] extAttr = AccessController.doPrivileged (new PrivilegedAction<Object[]>() {
|
||||
public Object[] run() {
|
||||
try {
|
||||
Class cl = Class.forName("com.sun.management.GcInfo");
|
||||
Field f = cl.getDeclaredField("extAttributes");
|
||||
f.setAccessible(true);
|
||||
return (Object[])f.get(info);
|
||||
} catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
GcInfoCompositeData gcicd =
|
||||
new GcInfoCompositeData(info,builder,extAttr);
|
||||
return gcicd.getCompositeData();
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// baseGcInfoItemNames!
|
||||
final Object[] baseGcInfoItemValues;
|
||||
|
||||
try {
|
||||
baseGcInfoItemValues = new Object[] {
|
||||
new Long(info.getId()),
|
||||
new Long(info.getStartTime()),
|
||||
new Long(info.getEndTime()),
|
||||
new Long(info.getDuration()),
|
||||
memoryUsageMapType.toOpenTypeData(info.getMemoryUsageBeforeGc()),
|
||||
memoryUsageMapType.toOpenTypeData(info.getMemoryUsageAfterGc()),
|
||||
};
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
||||
// Get the item values for the extension attributes
|
||||
final int gcExtItemCount = builder.getGcExtItemCount();
|
||||
if (gcExtItemCount == 0 &&
|
||||
gcExtItemValues != null && gcExtItemValues.length != 0) {
|
||||
throw new AssertionError("Unexpected Gc Extension Item Values");
|
||||
}
|
||||
|
||||
if (gcExtItemCount > 0 && (gcExtItemValues == null ||
|
||||
gcExtItemCount != gcExtItemValues.length)) {
|
||||
throw new AssertionError("Unmatched Gc Extension Item Values");
|
||||
}
|
||||
|
||||
Object[] values = new Object[baseGcInfoItemValues.length +
|
||||
gcExtItemCount];
|
||||
System.arraycopy(baseGcInfoItemValues, 0, values, 0,
|
||||
baseGcInfoItemValues.length);
|
||||
|
||||
if (gcExtItemCount > 0) {
|
||||
System.arraycopy(gcExtItemValues, 0, values,
|
||||
baseGcInfoItemValues.length, gcExtItemCount);
|
||||
}
|
||||
|
||||
try {
|
||||
return new CompositeDataSupport(builder.getGcInfoCompositeType(),
|
||||
builder.getItemNames(),
|
||||
values);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String ID = "id";
|
||||
private static final String START_TIME = "startTime";
|
||||
private static final String END_TIME = "endTime";
|
||||
private static final String DURATION = "duration";
|
||||
private static final String MEMORY_USAGE_BEFORE_GC = "memoryUsageBeforeGc";
|
||||
private static final String MEMORY_USAGE_AFTER_GC = "memoryUsageAfterGc";
|
||||
|
||||
private static final String[] baseGcInfoItemNames = {
|
||||
ID,
|
||||
START_TIME,
|
||||
END_TIME,
|
||||
DURATION,
|
||||
MEMORY_USAGE_BEFORE_GC,
|
||||
MEMORY_USAGE_AFTER_GC,
|
||||
};
|
||||
|
||||
|
||||
private static MappedMXBeanType memoryUsageMapType;
|
||||
static {
|
||||
try {
|
||||
Method m = GcInfo.class.getMethod("getMemoryUsageBeforeGc");
|
||||
memoryUsageMapType =
|
||||
MappedMXBeanType.getMappedType(m.getGenericReturnType());
|
||||
} catch (NoSuchMethodException | OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
static String[] getBaseGcInfoItemNames() {
|
||||
return baseGcInfoItemNames;
|
||||
}
|
||||
|
||||
private static OpenType[] baseGcInfoItemTypes = null;
|
||||
static synchronized OpenType[] getBaseGcInfoItemTypes() {
|
||||
if (baseGcInfoItemTypes == null) {
|
||||
OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType();
|
||||
baseGcInfoItemTypes = new OpenType<?>[] {
|
||||
SimpleType.LONG,
|
||||
SimpleType.LONG,
|
||||
SimpleType.LONG,
|
||||
SimpleType.LONG,
|
||||
|
||||
memoryUsageOpenType,
|
||||
memoryUsageOpenType,
|
||||
};
|
||||
}
|
||||
return baseGcInfoItemTypes;
|
||||
}
|
||||
|
||||
public static long getId(CompositeData cd) {
|
||||
return getLong(cd, ID);
|
||||
}
|
||||
public static long getStartTime(CompositeData cd) {
|
||||
return getLong(cd, START_TIME);
|
||||
}
|
||||
public static long getEndTime(CompositeData cd) {
|
||||
return getLong(cd, END_TIME);
|
||||
}
|
||||
|
||||
public static Map<String, MemoryUsage>
|
||||
getMemoryUsageBeforeGc(CompositeData cd) {
|
||||
try {
|
||||
TabularData td = (TabularData) cd.get(MEMORY_USAGE_BEFORE_GC);
|
||||
return cast(memoryUsageMapType.toJavaTypeData(td));
|
||||
} catch (InvalidObjectException | OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, MemoryUsage> cast(Object x) {
|
||||
return (Map<String, MemoryUsage>) x;
|
||||
}
|
||||
public static Map<String, MemoryUsage>
|
||||
getMemoryUsageAfterGc(CompositeData cd) {
|
||||
try {
|
||||
TabularData td = (TabularData) cd.get(MEMORY_USAGE_AFTER_GC);
|
||||
//return (Map<String,MemoryUsage>)
|
||||
return cast(memoryUsageMapType.toJavaTypeData(td));
|
||||
} catch (InvalidObjectException | OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the input CompositeData has the expected
|
||||
* CompositeType (i.e. contain all attributes with expected
|
||||
* names and types). Otherwise, return false.
|
||||
*/
|
||||
public static void validateCompositeData(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
if (!isTypeMatched(getBaseGcInfoCompositeType(),
|
||||
cd.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for GcInfo");
|
||||
}
|
||||
}
|
||||
|
||||
// This is only used for validation.
|
||||
private static CompositeType baseGcInfoCompositeType = null;
|
||||
static synchronized CompositeType getBaseGcInfoCompositeType() {
|
||||
if (baseGcInfoCompositeType == null) {
|
||||
try {
|
||||
baseGcInfoCompositeType =
|
||||
new CompositeType("sun.management.BaseGcInfoCompositeType",
|
||||
"CompositeType for Base GcInfo",
|
||||
getBaseGcInfoItemNames(),
|
||||
getBaseGcInfoItemNames(),
|
||||
getBaseGcInfoItemTypes());
|
||||
} catch (OpenDataException e) {
|
||||
// shouldn't reach here
|
||||
throw Util.newException(e);
|
||||
}
|
||||
}
|
||||
return baseGcInfoCompositeType;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -5716428894085882742L;
|
||||
}
|
||||
153
jdkSrc/jdk8/sun/management/HotSpotDiagnostic.java
Normal file
153
jdkSrc/jdk8/sun/management/HotSpotDiagnostic.java
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
import com.sun.management.VMOption;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* Implementation of the diagnostic MBean for Hotspot VM.
|
||||
*/
|
||||
public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean {
|
||||
public HotSpotDiagnostic() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpHeap(String outputFile, boolean live) throws IOException {
|
||||
|
||||
String propertyName = "jdk.management.heapdump.allowAnyFileSuffix";
|
||||
PrivilegedAction<Boolean> pa = () -> Boolean.parseBoolean(System.getProperty(propertyName, "false"));
|
||||
boolean allowAnyFileSuffix = AccessController.doPrivileged(pa);
|
||||
if (!allowAnyFileSuffix && !outputFile.endsWith(".hprof")) {
|
||||
throw new IllegalArgumentException("heapdump file must have .hprof extention");
|
||||
}
|
||||
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkWrite(outputFile);
|
||||
Util.checkControlAccess();
|
||||
}
|
||||
|
||||
dumpHeap0(outputFile, live);
|
||||
}
|
||||
|
||||
private native void dumpHeap0(String outputFile, boolean live) throws IOException;
|
||||
|
||||
@Override
|
||||
public List<VMOption> getDiagnosticOptions() {
|
||||
List<Flag> allFlags = Flag.getAllFlags();
|
||||
List<VMOption> result = new ArrayList<>();
|
||||
for (Flag flag : allFlags) {
|
||||
if (flag.isWriteable() && flag.isExternal()) {
|
||||
result.add(flag.getVMOption());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMOption getVMOption(String name) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name cannot be null");
|
||||
}
|
||||
|
||||
Flag f = Flag.getFlag(name);
|
||||
if (f == null) {
|
||||
throw new IllegalArgumentException("VM option \"" +
|
||||
name + "\" does not exist");
|
||||
}
|
||||
return f.getVMOption();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVMOption(String name, String value) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name cannot be null");
|
||||
}
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value cannot be null");
|
||||
}
|
||||
|
||||
Util.checkControlAccess();
|
||||
Flag flag = Flag.getFlag(name);
|
||||
if (flag == null) {
|
||||
throw new IllegalArgumentException("VM option \"" +
|
||||
name + "\" does not exist");
|
||||
}
|
||||
if (!flag.isWriteable()){
|
||||
throw new IllegalArgumentException("VM Option \"" +
|
||||
name + "\" is not writeable");
|
||||
}
|
||||
|
||||
// Check the type of the value
|
||||
Object v = flag.getValue();
|
||||
if (v instanceof Long) {
|
||||
try {
|
||||
long l = Long.parseLong(value);
|
||||
Flag.setLongValue(name, l);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("Invalid value:" +
|
||||
" VM Option \"" + name + "\"" +
|
||||
" expects numeric value", e);
|
||||
}
|
||||
} else if (v instanceof Double) {
|
||||
try {
|
||||
double d = Double.parseDouble(value);
|
||||
Flag.setDoubleValue(name, d);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("Invalid value:" +
|
||||
" VM Option \"" + name + "\"" +
|
||||
" expects numeric value", e);
|
||||
}
|
||||
} else if (v instanceof Boolean) {
|
||||
if (!value.equalsIgnoreCase("true") &&
|
||||
!value.equalsIgnoreCase("false")) {
|
||||
throw new IllegalArgumentException("Invalid value:" +
|
||||
" VM Option \"" + name + "\"" +
|
||||
" expects \"true\" or \"false\".");
|
||||
}
|
||||
Flag.setBooleanValue(name, Boolean.parseBoolean(value));
|
||||
} else if (v instanceof String) {
|
||||
Flag.setStringValue(name, value);
|
||||
} else {
|
||||
throw new IllegalArgumentException("VM Option \"" +
|
||||
name + "\" is of an unsupported type: " +
|
||||
v.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName("com.sun.management:type=HotSpotDiagnostic");
|
||||
}
|
||||
}
|
||||
86
jdkSrc/jdk8/sun/management/HotspotClassLoading.java
Normal file
86
jdkSrc/jdk8/sun/management/HotspotClassLoading.java
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import sun.management.counter.*;
|
||||
|
||||
/**
|
||||
* Implementation class of HotspotClassLoadingMBean interface.
|
||||
*
|
||||
* Internal, uncommitted management interface for Hotspot class loading
|
||||
* system.
|
||||
*/
|
||||
class HotspotClassLoading
|
||||
implements HotspotClassLoadingMBean {
|
||||
|
||||
private VMManagement jvm;
|
||||
|
||||
/**
|
||||
* Constructor of HotspotClassLoading class.
|
||||
*/
|
||||
HotspotClassLoading(VMManagement vm) {
|
||||
jvm = vm;
|
||||
}
|
||||
|
||||
public long getLoadedClassSize() {
|
||||
return jvm.getLoadedClassSize();
|
||||
}
|
||||
|
||||
public long getUnloadedClassSize() {
|
||||
return jvm.getUnloadedClassSize();
|
||||
}
|
||||
|
||||
public long getClassLoadingTime() {
|
||||
return jvm.getClassLoadingTime();
|
||||
}
|
||||
|
||||
public long getMethodDataSize() {
|
||||
return jvm.getMethodDataSize();
|
||||
}
|
||||
|
||||
public long getInitializedClassCount() {
|
||||
return jvm.getInitializedClassCount();
|
||||
}
|
||||
|
||||
public long getClassInitializationTime() {
|
||||
return jvm.getClassInitializationTime();
|
||||
}
|
||||
|
||||
public long getClassVerificationTime() {
|
||||
return jvm.getClassVerificationTime();
|
||||
}
|
||||
|
||||
// Performance counter support
|
||||
private static final String JAVA_CLS = "java.cls.";
|
||||
private static final String COM_SUN_CLS = "com.sun.cls.";
|
||||
private static final String SUN_CLS = "sun.cls.";
|
||||
private static final String CLS_COUNTER_NAME_PATTERN =
|
||||
JAVA_CLS + "|" + COM_SUN_CLS + "|" + SUN_CLS;
|
||||
|
||||
public java.util.List<Counter> getInternalClassLoadingCounters() {
|
||||
return jvm.getInternalCounters(CLS_COUNTER_NAME_PATTERN);
|
||||
}
|
||||
}
|
||||
108
jdkSrc/jdk8/sun/management/HotspotClassLoadingMBean.java
Normal file
108
jdkSrc/jdk8/sun/management/HotspotClassLoadingMBean.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.ClassLoadingMXBean;
|
||||
import sun.management.counter.Counter;
|
||||
|
||||
/**
|
||||
* Hotspot internal management interface for the class loading system.
|
||||
*
|
||||
* This management interface is internal and uncommitted
|
||||
* and subject to change without notice.
|
||||
*/
|
||||
public interface HotspotClassLoadingMBean {
|
||||
/**
|
||||
* Returns the amount of memory in bytes occupied by loaded classes
|
||||
* in the Java virtual machine.
|
||||
*
|
||||
* @return the amount of memory in bytes occupied by loaded classes
|
||||
* in the Java virtual machine.
|
||||
*/
|
||||
public long getLoadedClassSize();
|
||||
|
||||
/**
|
||||
* Returns the number of bytes that the Java virtual machine
|
||||
* collected due to class unloading.
|
||||
*
|
||||
* @return the number of bytes that the VM collected due to
|
||||
* class unloading.
|
||||
*/
|
||||
public long getUnloadedClassSize();
|
||||
|
||||
/**
|
||||
* Returns the accumulated elapsed time spent by class loading
|
||||
* in milliseconds.
|
||||
*
|
||||
* @return the accumulated elapsed time spent by class loading
|
||||
* in milliseconds.
|
||||
*/
|
||||
public long getClassLoadingTime();
|
||||
|
||||
/**
|
||||
* Returns the amount of memory in bytes occupied by the method
|
||||
* data.
|
||||
*
|
||||
* @return the amount of memory in bytes occupied by the method
|
||||
* data.
|
||||
*/
|
||||
public long getMethodDataSize();
|
||||
|
||||
/**
|
||||
* Returns the number of classes for which initializers were run.
|
||||
*
|
||||
* @return the number of classes for which initializers were run.
|
||||
*/
|
||||
public long getInitializedClassCount();
|
||||
|
||||
/**
|
||||
* Returns the accumulated elapsed time spent in class initializers
|
||||
* in milliseconds.
|
||||
*
|
||||
* @return the accumulated elapsed time spent in class initializers
|
||||
* in milliseconds.
|
||||
*/
|
||||
public long getClassInitializationTime();
|
||||
|
||||
/**
|
||||
* Returns the accumulated elapsed time spent in class verifier
|
||||
* in milliseconds.
|
||||
*
|
||||
* @return the accumulated elapsed time spent in class verifier
|
||||
* in milliseconds.
|
||||
*/
|
||||
public long getClassVerificationTime();
|
||||
|
||||
/**
|
||||
* Returns a list of internal counters maintained in the Java
|
||||
* virtual machine for the class loading system.
|
||||
*
|
||||
* @return a list of internal counters maintained in the VM
|
||||
* for the class loading system.
|
||||
*/
|
||||
public java.util.List<Counter> getInternalClassLoadingCounters();
|
||||
|
||||
}
|
||||
234
jdkSrc/jdk8/sun/management/HotspotCompilation.java
Normal file
234
jdkSrc/jdk8/sun/management/HotspotCompilation.java
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.util.regex.*;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import sun.management.counter.*;
|
||||
|
||||
/**
|
||||
* Implementation class of HotspotCompilationMBean interface.
|
||||
*
|
||||
* Internal, uncommitted management interface for Hotspot compilation
|
||||
* system.
|
||||
*
|
||||
*/
|
||||
class HotspotCompilation
|
||||
implements HotspotCompilationMBean {
|
||||
|
||||
private VMManagement jvm;
|
||||
|
||||
/**
|
||||
* Constructor of HotspotRuntime class.
|
||||
*/
|
||||
HotspotCompilation(VMManagement vm) {
|
||||
jvm = vm;
|
||||
initCompilerCounters();
|
||||
}
|
||||
|
||||
// Performance counter support
|
||||
private static final String JAVA_CI = "java.ci.";
|
||||
private static final String COM_SUN_CI = "com.sun.ci.";
|
||||
private static final String SUN_CI = "sun.ci.";
|
||||
private static final String CI_COUNTER_NAME_PATTERN =
|
||||
JAVA_CI + "|" + COM_SUN_CI + "|" + SUN_CI;
|
||||
|
||||
private LongCounter compilerThreads;
|
||||
private LongCounter totalCompiles;
|
||||
private LongCounter totalBailouts;
|
||||
private LongCounter totalInvalidates;
|
||||
private LongCounter nmethodCodeSize;
|
||||
private LongCounter nmethodSize;
|
||||
private StringCounter lastMethod;
|
||||
private LongCounter lastSize;
|
||||
private LongCounter lastType;
|
||||
private StringCounter lastFailedMethod;
|
||||
private LongCounter lastFailedType;
|
||||
private StringCounter lastInvalidatedMethod;
|
||||
private LongCounter lastInvalidatedType;
|
||||
|
||||
private class CompilerThreadInfo {
|
||||
int index;
|
||||
String name;
|
||||
StringCounter method;
|
||||
LongCounter type;
|
||||
LongCounter compiles;
|
||||
LongCounter time;
|
||||
CompilerThreadInfo(String bname, int index) {
|
||||
String basename = bname + "." + index + ".";
|
||||
this.name = bname + "-" + index;
|
||||
this.method = (StringCounter) lookup(basename + "method");
|
||||
this.type = (LongCounter) lookup(basename + "type");
|
||||
this.compiles = (LongCounter) lookup(basename + "compiles");
|
||||
this.time = (LongCounter) lookup(basename + "time");
|
||||
}
|
||||
CompilerThreadInfo(String bname) {
|
||||
String basename = bname + ".";
|
||||
this.name = bname;
|
||||
this.method = (StringCounter) lookup(basename + "method");
|
||||
this.type = (LongCounter) lookup(basename + "type");
|
||||
this.compiles = (LongCounter) lookup(basename + "compiles");
|
||||
this.time = (LongCounter) lookup(basename + "time");
|
||||
}
|
||||
|
||||
CompilerThreadStat getCompilerThreadStat() {
|
||||
MethodInfo minfo = new MethodInfo(method.stringValue(),
|
||||
(int) type.longValue(),
|
||||
-1);
|
||||
return new CompilerThreadStat(name,
|
||||
compiles.longValue(),
|
||||
time.longValue(),
|
||||
minfo);
|
||||
}
|
||||
}
|
||||
private CompilerThreadInfo[] threads;
|
||||
private int numActiveThreads; // number of active compiler threads
|
||||
|
||||
private Map<String, Counter> counters;
|
||||
private Counter lookup(String name) {
|
||||
Counter c = null;
|
||||
|
||||
// Only one counter exists with the specified name in the
|
||||
// current implementation. We first look up in the SUN_CI namespace
|
||||
// since most counters are in SUN_CI namespace.
|
||||
|
||||
if ((c = counters.get(SUN_CI + name)) != null) {
|
||||
return c;
|
||||
}
|
||||
if ((c = counters.get(COM_SUN_CI + name)) != null) {
|
||||
return c;
|
||||
}
|
||||
if ((c = counters.get(JAVA_CI + name)) != null) {
|
||||
return c;
|
||||
}
|
||||
|
||||
// FIXME: should tolerate if counter doesn't exist
|
||||
throw new AssertionError("Counter " + name + " does not exist");
|
||||
}
|
||||
|
||||
private void initCompilerCounters() {
|
||||
// Build a tree map of the current list of performance counters
|
||||
counters = new TreeMap<>();
|
||||
for (Counter c: getInternalCompilerCounters()) {
|
||||
counters.put(c.getName(), c);
|
||||
}
|
||||
|
||||
compilerThreads = (LongCounter) lookup("threads");
|
||||
totalCompiles = (LongCounter) lookup("totalCompiles");
|
||||
totalBailouts = (LongCounter) lookup("totalBailouts");
|
||||
totalInvalidates = (LongCounter) lookup("totalInvalidates");
|
||||
nmethodCodeSize = (LongCounter) lookup("nmethodCodeSize");
|
||||
nmethodSize = (LongCounter) lookup("nmethodSize");
|
||||
lastMethod = (StringCounter) lookup("lastMethod");
|
||||
lastSize = (LongCounter) lookup("lastSize");
|
||||
lastType = (LongCounter) lookup("lastType");
|
||||
lastFailedMethod = (StringCounter) lookup("lastFailedMethod");
|
||||
lastFailedType = (LongCounter) lookup("lastFailedType");
|
||||
lastInvalidatedMethod = (StringCounter) lookup("lastInvalidatedMethod");
|
||||
lastInvalidatedType = (LongCounter) lookup("lastInvalidatedType");
|
||||
|
||||
numActiveThreads = (int) compilerThreads.longValue();
|
||||
|
||||
// Allocate CompilerThreadInfo for compilerThread and adaptorThread
|
||||
threads = new CompilerThreadInfo[numActiveThreads+1];
|
||||
|
||||
// AdaptorThread has index 0
|
||||
if (counters.containsKey(SUN_CI + "adapterThread.compiles")) {
|
||||
threads[0] = new CompilerThreadInfo("adapterThread", 0);
|
||||
numActiveThreads++;
|
||||
} else {
|
||||
threads[0] = null;
|
||||
}
|
||||
|
||||
for (int i = 1; i < threads.length; i++) {
|
||||
threads[i] = new CompilerThreadInfo("compilerThread", i-1);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCompilerThreadCount() {
|
||||
return numActiveThreads;
|
||||
}
|
||||
|
||||
public long getTotalCompileCount() {
|
||||
return totalCompiles.longValue();
|
||||
}
|
||||
|
||||
public long getBailoutCompileCount() {
|
||||
return totalBailouts.longValue();
|
||||
}
|
||||
|
||||
public long getInvalidatedCompileCount() {
|
||||
return totalInvalidates.longValue();
|
||||
}
|
||||
|
||||
public long getCompiledMethodCodeSize() {
|
||||
return nmethodCodeSize.longValue();
|
||||
}
|
||||
|
||||
public long getCompiledMethodSize() {
|
||||
return nmethodSize.longValue();
|
||||
}
|
||||
|
||||
public java.util.List<CompilerThreadStat> getCompilerThreadStats() {
|
||||
List<CompilerThreadStat> list = new ArrayList<>(threads.length);
|
||||
int i = 0;
|
||||
if (threads[0] == null) {
|
||||
// no adaptor thread
|
||||
i = 1;
|
||||
}
|
||||
for (; i < threads.length; i++) {
|
||||
list.add(threads[i].getCompilerThreadStat());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public MethodInfo getLastCompile() {
|
||||
return new MethodInfo(lastMethod.stringValue(),
|
||||
(int) lastType.longValue(),
|
||||
(int) lastSize.longValue());
|
||||
}
|
||||
|
||||
public MethodInfo getFailedCompile() {
|
||||
return new MethodInfo(lastFailedMethod.stringValue(),
|
||||
(int) lastFailedType.longValue(),
|
||||
-1);
|
||||
}
|
||||
|
||||
public MethodInfo getInvalidatedCompile() {
|
||||
return new MethodInfo(lastInvalidatedMethod.stringValue(),
|
||||
(int) lastInvalidatedType.longValue(),
|
||||
-1);
|
||||
}
|
||||
|
||||
public java.util.List<Counter> getInternalCompilerCounters() {
|
||||
return jvm.getInternalCounters(CI_COUNTER_NAME_PATTERN);
|
||||
}
|
||||
}
|
||||
116
jdkSrc/jdk8/sun/management/HotspotCompilationMBean.java
Normal file
116
jdkSrc/jdk8/sun/management/HotspotCompilationMBean.java
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import sun.management.counter.Counter;
|
||||
|
||||
/**
|
||||
* Hotspot internal management interface for the compilation system.
|
||||
*/
|
||||
public interface HotspotCompilationMBean {
|
||||
|
||||
/**
|
||||
* Returns the number of compiler threads.
|
||||
*
|
||||
* @return the number of compiler threads.
|
||||
*/
|
||||
public int getCompilerThreadCount();
|
||||
|
||||
/**
|
||||
* Returns the statistic of all compiler threads.
|
||||
*
|
||||
* @return a list of {@link CompilerThreadStat} object containing
|
||||
* the statistic of a compiler thread.
|
||||
*
|
||||
*/
|
||||
public java.util.List<CompilerThreadStat> getCompilerThreadStats();
|
||||
|
||||
/**
|
||||
* Returns the total number of compiles.
|
||||
*
|
||||
* @return the total number of compiles.
|
||||
*/
|
||||
public long getTotalCompileCount();
|
||||
|
||||
/**
|
||||
* Returns the number of bailout compiles.
|
||||
*
|
||||
* @return the number of bailout compiles.
|
||||
*/
|
||||
public long getBailoutCompileCount();
|
||||
|
||||
/**
|
||||
* Returns the number of invalidated compiles.
|
||||
*
|
||||
* @return the number of invalidated compiles.
|
||||
*/
|
||||
public long getInvalidatedCompileCount();
|
||||
|
||||
/**
|
||||
* Returns the method information of the last compiled method.
|
||||
*
|
||||
* @return a {@link MethodInfo} of the last compiled method.
|
||||
*/
|
||||
public MethodInfo getLastCompile();
|
||||
|
||||
/**
|
||||
* Returns the method information of the last failed compile.
|
||||
*
|
||||
* @return a {@link MethodInfo} of the last failed compile.
|
||||
*/
|
||||
public MethodInfo getFailedCompile();
|
||||
|
||||
/**
|
||||
* Returns the method information of the last invalidated compile.
|
||||
*
|
||||
* @return a {@link MethodInfo} of the last invalidated compile.
|
||||
*/
|
||||
public MethodInfo getInvalidatedCompile();
|
||||
|
||||
/**
|
||||
* Returns the number of bytes for the code of the
|
||||
* compiled methods.
|
||||
*
|
||||
* @return the number of bytes for the code of the compiled methods.
|
||||
*/
|
||||
public long getCompiledMethodCodeSize();
|
||||
|
||||
/**
|
||||
* Returns the number of bytes occupied by the compiled methods.
|
||||
*
|
||||
* @return the number of bytes occupied by the compiled methods.
|
||||
*/
|
||||
public long getCompiledMethodSize();
|
||||
|
||||
/**
|
||||
* Returns a list of internal counters maintained in the Java
|
||||
* virtual machine for the compilation system.
|
||||
*
|
||||
* @return a list of internal counters maintained in the VM
|
||||
* for the compilation system.
|
||||
*/
|
||||
public java.util.List<Counter> getInternalCompilerCounters();
|
||||
}
|
||||
72
jdkSrc/jdk8/sun/management/HotspotInternal.java
Normal file
72
jdkSrc/jdk8/sun/management/HotspotInternal.java
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import javax.management.MBeanRegistration;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* Implementation class of HotspotInternalMBean interface.
|
||||
*
|
||||
* <p> This is designed for internal customer use to create
|
||||
* this MBean dynamically from an agent which will then register
|
||||
* all internal MBeans to the platform MBeanServer.
|
||||
*/
|
||||
public class HotspotInternal
|
||||
implements HotspotInternalMBean, MBeanRegistration {
|
||||
|
||||
private final static String HOTSPOT_INTERNAL_MBEAN_NAME =
|
||||
"sun.management:type=HotspotInternal";
|
||||
private static ObjectName objName = Util.newObjectName(HOTSPOT_INTERNAL_MBEAN_NAME);
|
||||
private MBeanServer server = null;
|
||||
|
||||
/**
|
||||
* Default constructor that registers all hotspot internal MBeans
|
||||
* to the MBeanServer that creates this MBean.
|
||||
*/
|
||||
public HotspotInternal() {
|
||||
}
|
||||
|
||||
public ObjectName preRegister(MBeanServer server,
|
||||
ObjectName name) throws java.lang.Exception {
|
||||
// register all internal MBeans when this MBean is instantiated
|
||||
// and to be registered in a MBeanServer.
|
||||
ManagementFactoryHelper.registerInternalMBeans(server);
|
||||
this.server = server;
|
||||
return objName;
|
||||
}
|
||||
|
||||
public void postRegister(Boolean registrationDone) {};
|
||||
|
||||
public void preDeregister() throws java.lang.Exception {
|
||||
// unregister all internal MBeans when this MBean is unregistered.
|
||||
ManagementFactoryHelper.unregisterInternalMBeans(server);
|
||||
}
|
||||
|
||||
public void postDeregister() {};
|
||||
|
||||
}
|
||||
36
jdkSrc/jdk8/sun/management/HotspotInternalMBean.java
Normal file
36
jdkSrc/jdk8/sun/management/HotspotInternalMBean.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
/**
|
||||
* This management interface does not contain any method.
|
||||
*
|
||||
* <p> This is designed for internal customer use to create
|
||||
* this MBean dynamically from an agent which will then register
|
||||
* all internal MBeans to the platform MBeanServer.
|
||||
*/
|
||||
public interface HotspotInternalMBean {
|
||||
}
|
||||
60
jdkSrc/jdk8/sun/management/HotspotMemory.java
Normal file
60
jdkSrc/jdk8/sun/management/HotspotMemory.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.util.List;
|
||||
import sun.management.counter.*;
|
||||
|
||||
/**
|
||||
* Implementation class of HotspotMemoryMBean interface.
|
||||
*
|
||||
* Internal, uncommitted management interface for Hotspot memory
|
||||
* system.
|
||||
*
|
||||
*/
|
||||
class HotspotMemory
|
||||
implements HotspotMemoryMBean {
|
||||
|
||||
private VMManagement jvm;
|
||||
|
||||
/**
|
||||
* Constructor of HotspotRuntime class.
|
||||
*/
|
||||
HotspotMemory(VMManagement vm) {
|
||||
jvm = vm;
|
||||
}
|
||||
|
||||
// Performance counter support
|
||||
private static final String JAVA_GC = "java.gc.";
|
||||
private static final String COM_SUN_GC = "com.sun.gc.";
|
||||
private static final String SUN_GC = "sun.gc.";
|
||||
private static final String GC_COUNTER_NAME_PATTERN =
|
||||
JAVA_GC + "|" + COM_SUN_GC + "|" + SUN_GC;
|
||||
|
||||
public java.util.List<Counter> getInternalMemoryCounters() {
|
||||
return jvm.getInternalCounters(GC_COUNTER_NAME_PATTERN);
|
||||
}
|
||||
}
|
||||
42
jdkSrc/jdk8/sun/management/HotspotMemoryMBean.java
Normal file
42
jdkSrc/jdk8/sun/management/HotspotMemoryMBean.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import sun.management.counter.Counter;
|
||||
/**
|
||||
* Hotspot internal management interface for the compilation system.
|
||||
*/
|
||||
public interface HotspotMemoryMBean {
|
||||
|
||||
/**
|
||||
* Returns a list of internal counters maintained in the Java
|
||||
* virtual machine for the memory system.
|
||||
*
|
||||
* @return a list of internal counters maintained in the VM
|
||||
* for the memory system.
|
||||
*/
|
||||
public java.util.List<Counter> getInternalMemoryCounters();
|
||||
}
|
||||
77
jdkSrc/jdk8/sun/management/HotspotRuntime.java
Normal file
77
jdkSrc/jdk8/sun/management/HotspotRuntime.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import sun.management.counter.Counter;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation class of HotspotRuntimeMBean interface.
|
||||
*
|
||||
* Internal, uncommitted management interface for Hotspot runtime
|
||||
* system.
|
||||
*/
|
||||
class HotspotRuntime
|
||||
implements HotspotRuntimeMBean {
|
||||
|
||||
private VMManagement jvm;
|
||||
|
||||
/**
|
||||
* Constructor of HotspotRuntime class.
|
||||
*/
|
||||
HotspotRuntime(VMManagement vm) {
|
||||
jvm = vm;
|
||||
}
|
||||
|
||||
public long getSafepointCount() {
|
||||
return jvm.getSafepointCount();
|
||||
}
|
||||
|
||||
public long getTotalSafepointTime() {
|
||||
return jvm.getTotalSafepointTime();
|
||||
}
|
||||
|
||||
public long getSafepointSyncTime() {
|
||||
return jvm.getSafepointSyncTime();
|
||||
}
|
||||
|
||||
// Performance counter support
|
||||
private static final String JAVA_RT = "java.rt.";
|
||||
private static final String COM_SUN_RT = "com.sun.rt.";
|
||||
private static final String SUN_RT = "sun.rt.";
|
||||
private static final String JAVA_PROPERTY = "java.property.";
|
||||
private static final String COM_SUN_PROPERTY = "com.sun.property.";
|
||||
private static final String SUN_PROPERTY = "sun.property.";
|
||||
private static final String RT_COUNTER_NAME_PATTERN =
|
||||
JAVA_RT + "|" + COM_SUN_RT + "|" + SUN_RT + "|" +
|
||||
JAVA_PROPERTY + "|" + COM_SUN_PROPERTY + "|" + SUN_PROPERTY;
|
||||
|
||||
public java.util.List<Counter> getInternalRuntimeCounters() {
|
||||
return jvm.getInternalCounters(RT_COUNTER_NAME_PATTERN);
|
||||
}
|
||||
}
|
||||
71
jdkSrc/jdk8/sun/management/HotspotRuntimeMBean.java
Normal file
71
jdkSrc/jdk8/sun/management/HotspotRuntimeMBean.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import sun.management.counter.Counter;
|
||||
|
||||
/**
|
||||
* Hotspot internal management interface for the runtime system.
|
||||
*
|
||||
* This management interface is internal and uncommitted
|
||||
* and subject to change without notice.
|
||||
*/
|
||||
public interface HotspotRuntimeMBean {
|
||||
|
||||
/**
|
||||
* Returns the number of safepoints taken place since the Java
|
||||
* virtual machine started.
|
||||
*
|
||||
* @return the number of safepoints taken place since the Java
|
||||
* virtual machine started.
|
||||
*/
|
||||
public long getSafepointCount();
|
||||
|
||||
/**
|
||||
* Returns the accumulated time spent at safepoints in milliseconds.
|
||||
* This is the accumulated elapsed time that the application has
|
||||
* been stopped for safepoint operations.
|
||||
*
|
||||
* @return the accumulated time spent at safepoints in milliseconds.
|
||||
*/
|
||||
public long getTotalSafepointTime();
|
||||
|
||||
/**
|
||||
* Returns the accumulated time spent getting to safepoints in milliseconds.
|
||||
*
|
||||
* @return the accumulated time spent getting to safepoints in milliseconds.
|
||||
*/
|
||||
public long getSafepointSyncTime();
|
||||
|
||||
/**
|
||||
* Returns a list of internal counters maintained in the Java
|
||||
* virtual machine for the runtime system.
|
||||
*
|
||||
* @return a <tt>List</tt> of internal counters maintained in the VM
|
||||
* for the runtime system.
|
||||
*/
|
||||
public java.util.List<Counter> getInternalRuntimeCounters();
|
||||
}
|
||||
79
jdkSrc/jdk8/sun/management/HotspotThread.java
Normal file
79
jdkSrc/jdk8/sun/management/HotspotThread.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import sun.management.counter.Counter;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation class of HotspotThreadMBean interface.
|
||||
*
|
||||
* Internal, uncommitted management interface for Hotspot threading
|
||||
* system.
|
||||
*/
|
||||
class HotspotThread
|
||||
implements HotspotThreadMBean {
|
||||
|
||||
private VMManagement jvm;
|
||||
|
||||
/**
|
||||
* Constructor of HotspotThread class.
|
||||
*/
|
||||
HotspotThread(VMManagement vm) {
|
||||
jvm = vm;
|
||||
}
|
||||
|
||||
public native int getInternalThreadCount();
|
||||
|
||||
public Map<String, Long> getInternalThreadCpuTimes() {
|
||||
int count = getInternalThreadCount();
|
||||
if (count == 0) {
|
||||
return java.util.Collections.emptyMap();
|
||||
}
|
||||
String[] names = new String[count];
|
||||
long[] times = new long[count];
|
||||
int numThreads = getInternalThreadTimes0(names, times);
|
||||
Map<String, Long> result = new HashMap<>(numThreads);
|
||||
for (int i = 0; i < numThreads; i++) {
|
||||
result.put(names[i], new Long(times[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public native int getInternalThreadTimes0(String[] names, long[] times);
|
||||
|
||||
// Performance counter support
|
||||
private static final String JAVA_THREADS = "java.threads.";
|
||||
private static final String COM_SUN_THREADS = "com.sun.threads.";
|
||||
private static final String SUN_THREADS = "sun.threads.";
|
||||
private static final String THREADS_COUNTER_NAME_PATTERN =
|
||||
JAVA_THREADS + "|" + COM_SUN_THREADS + "|" + SUN_THREADS;
|
||||
|
||||
public java.util.List<Counter> getInternalThreadingCounters() {
|
||||
return jvm.getInternalCounters(THREADS_COUNTER_NAME_PATTERN);
|
||||
}
|
||||
}
|
||||
66
jdkSrc/jdk8/sun/management/HotspotThreadMBean.java
Normal file
66
jdkSrc/jdk8/sun/management/HotspotThreadMBean.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import sun.management.counter.Counter;
|
||||
|
||||
/**
|
||||
* Hotspot internal management interface for the thread system.
|
||||
*/
|
||||
public interface HotspotThreadMBean {
|
||||
|
||||
/**
|
||||
* Returns the current number of VM internal threads.
|
||||
*
|
||||
* @return the current number of VM internal threads.
|
||||
*/
|
||||
public int getInternalThreadCount();
|
||||
|
||||
/**
|
||||
* Returns a <tt>Map</tt> of the name of all VM internal threads
|
||||
* to the thread CPU time in nanoseconds. The returned value is
|
||||
* of nanoseconds precision but not necessarily nanoseconds accuracy.
|
||||
* <p>
|
||||
*
|
||||
* @return a <tt>Map</tt> object of the name of all VM internal threads
|
||||
* to the thread CPU time in nanoseconds.
|
||||
*
|
||||
* @throws java.lang.UnsupportedOperationException if the Java virtual
|
||||
* machine does not support CPU time measurement.
|
||||
*
|
||||
* @see java.lang.management.ThreadMBean#isThreadCpuTimeSupported
|
||||
*/
|
||||
public java.util.Map<String,Long> getInternalThreadCpuTimes();
|
||||
|
||||
/**
|
||||
* Returns a list of internal counters maintained in the Java
|
||||
* virtual machine for the thread system.
|
||||
*
|
||||
* @return a list of internal counters maintained in the VM
|
||||
* for the thread system.
|
||||
*/
|
||||
public java.util.List<Counter> getInternalThreadingCounters();
|
||||
}
|
||||
231
jdkSrc/jdk8/sun/management/LazyCompositeData.java
Normal file
231
jdkSrc/jdk8/sun/management/LazyCompositeData.java
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import javax.management.openmbean.ArrayType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.TabularType;
|
||||
|
||||
/**
|
||||
* This abstract class provides the implementation of the CompositeData
|
||||
* interface. A CompositeData object will be lazily created only when
|
||||
* the CompositeData interface is used.
|
||||
*
|
||||
* Classes that extends this abstract class will implement the
|
||||
* getCompositeData() method. The object returned by the
|
||||
* getCompositeData() is an instance of CompositeData such that
|
||||
* the instance serializes itself as the type CompositeDataSupport.
|
||||
*/
|
||||
public abstract class LazyCompositeData
|
||||
implements CompositeData, Serializable {
|
||||
|
||||
private CompositeData compositeData;
|
||||
|
||||
// Implementation of the CompositeData interface
|
||||
@Override
|
||||
public boolean containsKey(String key) {
|
||||
return compositeData().containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
return compositeData().containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return compositeData().equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String key) {
|
||||
return compositeData().get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getAll(String[] keys) {
|
||||
return compositeData().getAll(keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeType getCompositeType() {
|
||||
return compositeData().getCompositeType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return compositeData().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
/** FIXME: What should this be?? */
|
||||
return compositeData().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<?> values() {
|
||||
return compositeData().values();
|
||||
}
|
||||
|
||||
/* Lazy creation of a CompositeData object
|
||||
* only when the CompositeData interface is used.
|
||||
*/
|
||||
private synchronized CompositeData compositeData() {
|
||||
if (compositeData != null)
|
||||
return compositeData;
|
||||
compositeData = getCompositeData();
|
||||
return compositeData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Designate to a CompositeData object when writing to an
|
||||
* output stream during serialization so that the receiver
|
||||
* only requires JMX 1.2 classes but not any implementation
|
||||
* specific class.
|
||||
*/
|
||||
protected Object writeReplace() throws java.io.ObjectStreamException {
|
||||
return compositeData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CompositeData representing this object.
|
||||
* The returned CompositeData object must be an instance
|
||||
* of javax.management.openmbean.CompositeDataSupport class
|
||||
* so that no implementation specific class is required
|
||||
* for unmarshalling besides JMX 1.2 classes.
|
||||
*/
|
||||
protected abstract CompositeData getCompositeData();
|
||||
|
||||
// Helper methods
|
||||
static String getString(CompositeData cd, String itemName) {
|
||||
if (cd == null)
|
||||
throw new IllegalArgumentException("Null CompositeData");
|
||||
|
||||
return (String) cd.get(itemName);
|
||||
}
|
||||
|
||||
static boolean getBoolean(CompositeData cd, String itemName) {
|
||||
if (cd == null)
|
||||
throw new IllegalArgumentException("Null CompositeData");
|
||||
|
||||
return ((Boolean) cd.get(itemName));
|
||||
}
|
||||
|
||||
static long getLong(CompositeData cd, String itemName) {
|
||||
if (cd == null)
|
||||
throw new IllegalArgumentException("Null CompositeData");
|
||||
|
||||
return ((Long) cd.get(itemName));
|
||||
}
|
||||
|
||||
static int getInt(CompositeData cd, String itemName) {
|
||||
if (cd == null)
|
||||
throw new IllegalArgumentException("Null CompositeData");
|
||||
|
||||
return ((Integer) cd.get(itemName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two CompositeTypes and returns true if
|
||||
* all items in type1 exist in type2 and their item types
|
||||
* are the same.
|
||||
* @param type1 the base composite type
|
||||
* @param type2 the checked composite type
|
||||
* @return {@code true} if all items in type1 exist in type2 and their item
|
||||
* types are the same.
|
||||
*/
|
||||
protected static boolean isTypeMatched(CompositeType type1, CompositeType type2) {
|
||||
if (type1 == type2) return true;
|
||||
|
||||
// We can't use CompositeType.isValue() since it returns false
|
||||
// if the type name doesn't match.
|
||||
Set<String> allItems = type1.keySet();
|
||||
|
||||
// Check all items in the type1 exist in type2
|
||||
if (!type2.keySet().containsAll(allItems))
|
||||
return false;
|
||||
|
||||
return allItems.stream().allMatch(
|
||||
item -> isTypeMatched(type1.getType(item), type2.getType(item))
|
||||
);
|
||||
}
|
||||
|
||||
protected static boolean isTypeMatched(TabularType type1, TabularType type2) {
|
||||
if (type1 == type2) return true;
|
||||
|
||||
List<String> list1 = type1.getIndexNames();
|
||||
List<String> list2 = type2.getIndexNames();
|
||||
|
||||
// check if the list of index names are the same
|
||||
if (!list1.equals(list2))
|
||||
return false;
|
||||
|
||||
return isTypeMatched(type1.getRowType(), type2.getRowType());
|
||||
}
|
||||
|
||||
protected static boolean isTypeMatched(ArrayType<?> type1, ArrayType<?> type2) {
|
||||
if (type1 == type2) return true;
|
||||
|
||||
int dim1 = type1.getDimension();
|
||||
int dim2 = type2.getDimension();
|
||||
|
||||
// check if the array dimensions are the same
|
||||
if (dim1 != dim2)
|
||||
return false;
|
||||
|
||||
return isTypeMatched(type1.getElementOpenType(), type2.getElementOpenType());
|
||||
}
|
||||
|
||||
private static boolean isTypeMatched(OpenType<?> ot1, OpenType<?> ot2) {
|
||||
if (ot1 instanceof CompositeType) {
|
||||
if (! (ot2 instanceof CompositeType))
|
||||
return false;
|
||||
if (!isTypeMatched((CompositeType) ot1, (CompositeType) ot2))
|
||||
return false;
|
||||
} else if (ot1 instanceof TabularType) {
|
||||
if (! (ot2 instanceof TabularType))
|
||||
return false;
|
||||
if (!isTypeMatched((TabularType) ot1, (TabularType) ot2))
|
||||
return false;
|
||||
} else if (ot1 instanceof ArrayType) {
|
||||
if (! (ot2 instanceof ArrayType))
|
||||
return false;
|
||||
if (!isTypeMatched((ArrayType<?>) ot1, (ArrayType<?>) ot2)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!ot1.equals(ot2)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -2190411934472666714L;
|
||||
}
|
||||
118
jdkSrc/jdk8/sun/management/LockInfoCompositeData.java
Normal file
118
jdkSrc/jdk8/sun/management/LockInfoCompositeData.java
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.LockInfo;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
|
||||
/**
|
||||
* A CompositeData for LockInfo for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class LockInfoCompositeData extends LazyCompositeData {
|
||||
private final LockInfo lock;
|
||||
|
||||
private LockInfoCompositeData(LockInfo li) {
|
||||
this.lock = li;
|
||||
}
|
||||
|
||||
public LockInfo getLockInfo() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(LockInfo li) {
|
||||
if (li == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
LockInfoCompositeData licd = new LockInfoCompositeData(li);
|
||||
return licd.getCompositeData();
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// lockInfoItemNames!
|
||||
final Object[] lockInfoItemValues = {
|
||||
new String(lock.getClassName()),
|
||||
new Integer(lock.getIdentityHashCode()),
|
||||
};
|
||||
|
||||
try {
|
||||
return new CompositeDataSupport(lockInfoCompositeType,
|
||||
lockInfoItemNames,
|
||||
lockInfoItemValues);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw Util.newException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final CompositeType lockInfoCompositeType;
|
||||
static {
|
||||
try {
|
||||
lockInfoCompositeType = (CompositeType)
|
||||
MappedMXBeanType.toOpenType(LockInfo.class);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw Util.newException(e);
|
||||
}
|
||||
}
|
||||
|
||||
static CompositeType getLockInfoCompositeType() {
|
||||
return lockInfoCompositeType;
|
||||
}
|
||||
|
||||
private static final String CLASS_NAME = "className";
|
||||
private static final String IDENTITY_HASH_CODE = "identityHashCode";
|
||||
private static final String[] lockInfoItemNames = {
|
||||
CLASS_NAME,
|
||||
IDENTITY_HASH_CODE,
|
||||
};
|
||||
|
||||
/*
|
||||
* Returns a LockInfo object mapped from the given CompositeData.
|
||||
*/
|
||||
public static LockInfo toLockInfo(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for LockInfo");
|
||||
}
|
||||
|
||||
String className = getString(cd, CLASS_NAME);
|
||||
int identityHashCode = getInt(cd, IDENTITY_HASH_CODE);
|
||||
return new LockInfo(className, identityHashCode);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -6374759159749014052L;
|
||||
}
|
||||
55
jdkSrc/jdk8/sun/management/ManagementFactory.java
Normal file
55
jdkSrc/jdk8/sun/management/ManagementFactory.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.MemoryManagerMXBean;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
|
||||
/**
|
||||
* ManagementFactory class provides the methods that the HotSpot VM
|
||||
* will invoke. So the class and method names cannot be renamed.
|
||||
*/
|
||||
class ManagementFactory {
|
||||
private ManagementFactory() {};
|
||||
|
||||
// Invoked by the VM
|
||||
private static MemoryPoolMXBean createMemoryPool
|
||||
(String name, boolean isHeap, long uThreshold, long gcThreshold) {
|
||||
return new MemoryPoolImpl(name, isHeap, uThreshold, gcThreshold);
|
||||
}
|
||||
|
||||
private static MemoryManagerMXBean createMemoryManager(String name) {
|
||||
return new MemoryManagerImpl(name);
|
||||
}
|
||||
|
||||
private static GarbageCollectorMXBean
|
||||
createGarbageCollector(String name, String type) {
|
||||
|
||||
// ignore type parameter which is for future extension
|
||||
return new GarbageCollectorImpl(name);
|
||||
}
|
||||
}
|
||||
477
jdkSrc/jdk8/sun/management/ManagementFactoryHelper.java
Normal file
477
jdkSrc/jdk8/sun/management/ManagementFactoryHelper.java
Normal file
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.*;
|
||||
|
||||
import javax.management.DynamicMBean;
|
||||
import javax.management.InstanceAlreadyExistsException;
|
||||
import javax.management.InstanceNotFoundException;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanRegistrationException;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.RuntimeOperationsException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
import sun.util.logging.LoggingSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import com.sun.management.DiagnosticCommandMBean;
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
|
||||
import static java.lang.management.ManagementFactory.*;
|
||||
|
||||
/**
|
||||
* ManagementFactoryHelper provides static factory methods to create
|
||||
* instances of the management interface.
|
||||
*/
|
||||
public class ManagementFactoryHelper {
|
||||
private ManagementFactoryHelper() {};
|
||||
|
||||
private static VMManagement jvm;
|
||||
|
||||
private static ClassLoadingImpl classMBean = null;
|
||||
private static MemoryImpl memoryMBean = null;
|
||||
private static ThreadImpl threadMBean = null;
|
||||
private static RuntimeImpl runtimeMBean = null;
|
||||
private static CompilationImpl compileMBean = null;
|
||||
private static OperatingSystemImpl osMBean = null;
|
||||
|
||||
public static synchronized ClassLoadingMXBean getClassLoadingMXBean() {
|
||||
if (classMBean == null) {
|
||||
classMBean = new ClassLoadingImpl(jvm);
|
||||
}
|
||||
return classMBean;
|
||||
}
|
||||
|
||||
public static synchronized MemoryMXBean getMemoryMXBean() {
|
||||
if (memoryMBean == null) {
|
||||
memoryMBean = new MemoryImpl(jvm);
|
||||
}
|
||||
return memoryMBean;
|
||||
}
|
||||
|
||||
public static synchronized ThreadMXBean getThreadMXBean() {
|
||||
if (threadMBean == null) {
|
||||
threadMBean = new ThreadImpl(jvm);
|
||||
}
|
||||
return threadMBean;
|
||||
}
|
||||
|
||||
public static synchronized RuntimeMXBean getRuntimeMXBean() {
|
||||
if (runtimeMBean == null) {
|
||||
runtimeMBean = new RuntimeImpl(jvm);
|
||||
}
|
||||
return runtimeMBean;
|
||||
}
|
||||
|
||||
public static synchronized CompilationMXBean getCompilationMXBean() {
|
||||
if (compileMBean == null && jvm.getCompilerName() != null) {
|
||||
compileMBean = new CompilationImpl(jvm);
|
||||
}
|
||||
return compileMBean;
|
||||
}
|
||||
|
||||
public static synchronized OperatingSystemMXBean getOperatingSystemMXBean() {
|
||||
if (osMBean == null) {
|
||||
osMBean = new OperatingSystemImpl(jvm);
|
||||
}
|
||||
return osMBean;
|
||||
}
|
||||
|
||||
public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
|
||||
MemoryPoolMXBean[] pools = MemoryImpl.getMemoryPools();
|
||||
List<MemoryPoolMXBean> list = new ArrayList<>(pools.length);
|
||||
for (MemoryPoolMXBean p : pools) {
|
||||
list.add(p);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<MemoryManagerMXBean> getMemoryManagerMXBeans() {
|
||||
MemoryManagerMXBean[] mgrs = MemoryImpl.getMemoryManagers();
|
||||
List<MemoryManagerMXBean> result = new ArrayList<>(mgrs.length);
|
||||
for (MemoryManagerMXBean m : mgrs) {
|
||||
result.add(m);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
|
||||
MemoryManagerMXBean[] mgrs = MemoryImpl.getMemoryManagers();
|
||||
List<GarbageCollectorMXBean> result = new ArrayList<>(mgrs.length);
|
||||
for (MemoryManagerMXBean m : mgrs) {
|
||||
if (GarbageCollectorMXBean.class.isInstance(m)) {
|
||||
result.add(GarbageCollectorMXBean.class.cast(m));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static PlatformLoggingMXBean getPlatformLoggingMXBean() {
|
||||
if (LoggingSupport.isAvailable()) {
|
||||
return PlatformLoggingImpl.instance;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The logging MXBean object is an instance of
|
||||
* PlatformLoggingMXBean and java.util.logging.LoggingMXBean
|
||||
* but it can't directly implement two MXBean interfaces
|
||||
* as a compliant MXBean implements exactly one MXBean interface,
|
||||
* or if it implements one interface that is a subinterface of
|
||||
* all the others; otherwise, it is a non-compliant MXBean
|
||||
* and MBeanServer will throw NotCompliantMBeanException.
|
||||
* See the Definition of an MXBean section in javax.management.MXBean spec.
|
||||
*
|
||||
* To create a compliant logging MXBean, define a LoggingMXBean interface
|
||||
* that extend PlatformLoggingMXBean and j.u.l.LoggingMXBean
|
||||
*/
|
||||
public interface LoggingMXBean
|
||||
extends PlatformLoggingMXBean, java.util.logging.LoggingMXBean {
|
||||
}
|
||||
|
||||
static class PlatformLoggingImpl implements LoggingMXBean
|
||||
{
|
||||
final static PlatformLoggingMXBean instance = new PlatformLoggingImpl();
|
||||
final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
|
||||
|
||||
private volatile ObjectName objname; // created lazily
|
||||
@Override
|
||||
public ObjectName getObjectName() {
|
||||
ObjectName result = objname;
|
||||
if (result == null) {
|
||||
synchronized (this) {
|
||||
result = objname;
|
||||
if (result == null) {
|
||||
result = Util.newObjectName(LOGGING_MXBEAN_NAME);
|
||||
objname = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.List<String> getLoggerNames() {
|
||||
return LoggingSupport.getLoggerNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLoggerLevel(String loggerName) {
|
||||
return LoggingSupport.getLoggerLevel(loggerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoggerLevel(String loggerName, String levelName) {
|
||||
LoggingSupport.setLoggerLevel(loggerName, levelName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentLoggerName(String loggerName) {
|
||||
return LoggingSupport.getParentLoggerName(loggerName);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<BufferPoolMXBean> bufferPools = null;
|
||||
public static synchronized List<BufferPoolMXBean> getBufferPoolMXBeans() {
|
||||
if (bufferPools == null) {
|
||||
bufferPools = new ArrayList<>(2);
|
||||
bufferPools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
|
||||
.getDirectBufferPool()));
|
||||
bufferPools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
|
||||
.getMappedBufferPool()));
|
||||
}
|
||||
return bufferPools;
|
||||
}
|
||||
|
||||
private final static String BUFFER_POOL_MXBEAN_NAME = "java.nio:type=BufferPool";
|
||||
|
||||
/**
|
||||
* Creates management interface for the given buffer pool.
|
||||
*/
|
||||
private static BufferPoolMXBean
|
||||
createBufferPoolMXBean(final sun.misc.JavaNioAccess.BufferPool pool)
|
||||
{
|
||||
return new BufferPoolMXBean() {
|
||||
private volatile ObjectName objname; // created lazily
|
||||
@Override
|
||||
public ObjectName getObjectName() {
|
||||
ObjectName result = objname;
|
||||
if (result == null) {
|
||||
synchronized (this) {
|
||||
result = objname;
|
||||
if (result == null) {
|
||||
result = Util.newObjectName(BUFFER_POOL_MXBEAN_NAME +
|
||||
",name=" + pool.getName());
|
||||
objname = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return pool.getName();
|
||||
}
|
||||
@Override
|
||||
public long getCount() {
|
||||
return pool.getCount();
|
||||
}
|
||||
@Override
|
||||
public long getTotalCapacity() {
|
||||
return pool.getTotalCapacity();
|
||||
}
|
||||
@Override
|
||||
public long getMemoryUsed() {
|
||||
return pool.getMemoryUsed();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static HotSpotDiagnostic hsDiagMBean = null;
|
||||
private static HotspotRuntime hsRuntimeMBean = null;
|
||||
private static HotspotClassLoading hsClassMBean = null;
|
||||
private static HotspotThread hsThreadMBean = null;
|
||||
private static HotspotCompilation hsCompileMBean = null;
|
||||
private static HotspotMemory hsMemoryMBean = null;
|
||||
private static DiagnosticCommandImpl hsDiagCommandMBean = null;
|
||||
|
||||
public static synchronized HotSpotDiagnosticMXBean getDiagnosticMXBean() {
|
||||
if (hsDiagMBean == null) {
|
||||
hsDiagMBean = new HotSpotDiagnostic();
|
||||
}
|
||||
return hsDiagMBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is for testing only.
|
||||
*/
|
||||
public static synchronized HotspotRuntimeMBean getHotspotRuntimeMBean() {
|
||||
if (hsRuntimeMBean == null) {
|
||||
hsRuntimeMBean = new HotspotRuntime(jvm);
|
||||
}
|
||||
return hsRuntimeMBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is for testing only.
|
||||
*/
|
||||
public static synchronized HotspotClassLoadingMBean getHotspotClassLoadingMBean() {
|
||||
if (hsClassMBean == null) {
|
||||
hsClassMBean = new HotspotClassLoading(jvm);
|
||||
}
|
||||
return hsClassMBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is for testing only.
|
||||
*/
|
||||
public static synchronized HotspotThreadMBean getHotspotThreadMBean() {
|
||||
if (hsThreadMBean == null) {
|
||||
hsThreadMBean = new HotspotThread(jvm);
|
||||
}
|
||||
return hsThreadMBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is for testing only.
|
||||
*/
|
||||
public static synchronized HotspotMemoryMBean getHotspotMemoryMBean() {
|
||||
if (hsMemoryMBean == null) {
|
||||
hsMemoryMBean = new HotspotMemory(jvm);
|
||||
}
|
||||
return hsMemoryMBean;
|
||||
}
|
||||
|
||||
public static synchronized DiagnosticCommandMBean getDiagnosticCommandMBean() {
|
||||
// Remote Diagnostic Commands may not be supported
|
||||
if (hsDiagCommandMBean == null && jvm.isRemoteDiagnosticCommandsSupported()) {
|
||||
hsDiagCommandMBean = new DiagnosticCommandImpl(jvm);
|
||||
}
|
||||
return hsDiagCommandMBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is for testing only.
|
||||
*/
|
||||
public static synchronized HotspotCompilationMBean getHotspotCompilationMBean() {
|
||||
if (hsCompileMBean == null) {
|
||||
hsCompileMBean = new HotspotCompilation(jvm);
|
||||
}
|
||||
return hsCompileMBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a given MBean if not registered in the MBeanServer;
|
||||
* otherwise, just return.
|
||||
*/
|
||||
private static void addMBean(MBeanServer mbs, Object mbean, String mbeanName) {
|
||||
try {
|
||||
final ObjectName objName = Util.newObjectName(mbeanName);
|
||||
|
||||
// inner class requires these fields to be final
|
||||
final MBeanServer mbs0 = mbs;
|
||||
final Object mbean0 = mbean;
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
|
||||
public Void run() throws MBeanRegistrationException,
|
||||
NotCompliantMBeanException {
|
||||
try {
|
||||
mbs0.registerMBean(mbean0, objName);
|
||||
return null;
|
||||
} catch (InstanceAlreadyExistsException e) {
|
||||
// if an instance with the object name exists in
|
||||
// the MBeanServer ignore the exception
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
throw Util.newException(e.getException());
|
||||
}
|
||||
}
|
||||
|
||||
private final static String HOTSPOT_CLASS_LOADING_MBEAN_NAME =
|
||||
"sun.management:type=HotspotClassLoading";
|
||||
|
||||
private final static String HOTSPOT_COMPILATION_MBEAN_NAME =
|
||||
"sun.management:type=HotspotCompilation";
|
||||
|
||||
private final static String HOTSPOT_MEMORY_MBEAN_NAME =
|
||||
"sun.management:type=HotspotMemory";
|
||||
|
||||
private static final String HOTSPOT_RUNTIME_MBEAN_NAME =
|
||||
"sun.management:type=HotspotRuntime";
|
||||
|
||||
private final static String HOTSPOT_THREAD_MBEAN_NAME =
|
||||
"sun.management:type=HotspotThreading";
|
||||
|
||||
final static String HOTSPOT_DIAGNOSTIC_COMMAND_MBEAN_NAME =
|
||||
"com.sun.management:type=DiagnosticCommand";
|
||||
|
||||
public static HashMap<ObjectName, DynamicMBean> getPlatformDynamicMBeans() {
|
||||
HashMap<ObjectName, DynamicMBean> map = new HashMap<>();
|
||||
DiagnosticCommandMBean diagMBean = getDiagnosticCommandMBean();
|
||||
if (diagMBean != null) {
|
||||
map.put(Util.newObjectName(HOTSPOT_DIAGNOSTIC_COMMAND_MBEAN_NAME), diagMBean);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
static void registerInternalMBeans(MBeanServer mbs) {
|
||||
// register all internal MBeans if not registered
|
||||
// No exception is thrown if a MBean with that object name
|
||||
// already registered
|
||||
addMBean(mbs, getHotspotClassLoadingMBean(),
|
||||
HOTSPOT_CLASS_LOADING_MBEAN_NAME);
|
||||
addMBean(mbs, getHotspotMemoryMBean(),
|
||||
HOTSPOT_MEMORY_MBEAN_NAME);
|
||||
addMBean(mbs, getHotspotRuntimeMBean(),
|
||||
HOTSPOT_RUNTIME_MBEAN_NAME);
|
||||
addMBean(mbs, getHotspotThreadMBean(),
|
||||
HOTSPOT_THREAD_MBEAN_NAME);
|
||||
|
||||
// CompilationMBean may not exist
|
||||
if (getCompilationMXBean() != null) {
|
||||
addMBean(mbs, getHotspotCompilationMBean(),
|
||||
HOTSPOT_COMPILATION_MBEAN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
private static void unregisterMBean(MBeanServer mbs, String mbeanName) {
|
||||
try {
|
||||
final ObjectName objName = Util.newObjectName(mbeanName);
|
||||
|
||||
// inner class requires these fields to be final
|
||||
final MBeanServer mbs0 = mbs;
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
|
||||
public Void run() throws MBeanRegistrationException,
|
||||
RuntimeOperationsException {
|
||||
try {
|
||||
mbs0.unregisterMBean(objName);
|
||||
} catch (InstanceNotFoundException e) {
|
||||
// ignore exception if not found
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
throw Util.newException(e.getException());
|
||||
}
|
||||
}
|
||||
|
||||
static void unregisterInternalMBeans(MBeanServer mbs) {
|
||||
// unregister all internal MBeans
|
||||
unregisterMBean(mbs, HOTSPOT_CLASS_LOADING_MBEAN_NAME);
|
||||
unregisterMBean(mbs, HOTSPOT_MEMORY_MBEAN_NAME);
|
||||
unregisterMBean(mbs, HOTSPOT_RUNTIME_MBEAN_NAME);
|
||||
unregisterMBean(mbs, HOTSPOT_THREAD_MBEAN_NAME);
|
||||
|
||||
// CompilationMBean may not exist
|
||||
if (getCompilationMXBean() != null) {
|
||||
unregisterMBean(mbs, HOTSPOT_COMPILATION_MBEAN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("management");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
jvm = new VMManagementImpl();
|
||||
}
|
||||
|
||||
public static boolean isThreadSuspended(int state) {
|
||||
return ((state & JMM_THREAD_STATE_FLAG_SUSPENDED) != 0);
|
||||
}
|
||||
|
||||
public static boolean isThreadRunningNative(int state) {
|
||||
return ((state & JMM_THREAD_STATE_FLAG_NATIVE) != 0);
|
||||
}
|
||||
|
||||
public static Thread.State toThreadState(int state) {
|
||||
// suspended and native bits may be set in state
|
||||
int threadStatus = state & ~JMM_THREAD_STATE_FLAG_MASK;
|
||||
return sun.misc.VM.toThreadState(threadStatus);
|
||||
}
|
||||
|
||||
// These values are defined in jmm.h
|
||||
private static final int JMM_THREAD_STATE_FLAG_MASK = 0xFFF00000;
|
||||
private static final int JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000;
|
||||
private static final int JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000;
|
||||
|
||||
}
|
||||
860
jdkSrc/jdk8/sun/management/MappedMXBeanType.java
Normal file
860
jdkSrc/jdk8/sun/management/MappedMXBeanType.java
Normal file
@@ -0,0 +1,860 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.lang.management.MemoryNotificationInfo;
|
||||
import java.lang.management.MonitorInfo;
|
||||
import java.lang.management.LockInfo;
|
||||
import java.lang.management.ThreadInfo;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import javax.management.*;
|
||||
import javax.management.openmbean.*;
|
||||
import static javax.management.openmbean.SimpleType.*;
|
||||
import com.sun.management.VMOption;
|
||||
|
||||
/**
|
||||
* A mapped mxbean type maps a Java type to an open type.
|
||||
* Only the following Java types are mappable
|
||||
* (currently required by the platform MXBeans):
|
||||
* 1. Primitive types
|
||||
* 2. Wrapper classes such java.lang.Integer, etc
|
||||
* 3. Classes with only getter methods and with a static "from" method
|
||||
* that takes a CompositeData argument.
|
||||
* 4. E[] where E is a type of 1-4 (can be multi-dimensional array)
|
||||
* 5. List<E> where E is a type of 1-3
|
||||
* 6. Map<K, V> where K and V are a type of 1-4
|
||||
*
|
||||
* OpenDataException will be thrown if a Java type is not supported.
|
||||
*/
|
||||
// Suppress unchecked cast warnings at line 442, 523 and 546
|
||||
// Suppress unchecked calls at line 235, 284, 380 and 430.
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class MappedMXBeanType {
|
||||
private static final WeakHashMap<Type,MappedMXBeanType> convertedTypes =
|
||||
new WeakHashMap<>();
|
||||
|
||||
boolean isBasicType = false;
|
||||
OpenType<?> openType = inProgress;
|
||||
Class<?> mappedTypeClass;
|
||||
|
||||
static synchronized MappedMXBeanType newMappedType(Type javaType)
|
||||
throws OpenDataException {
|
||||
|
||||
MappedMXBeanType mt = null;
|
||||
if (javaType instanceof Class) {
|
||||
final Class<?> c = (Class<?>) javaType;
|
||||
if (c.isEnum()) {
|
||||
mt = new EnumMXBeanType(c);
|
||||
} else if (c.isArray()) {
|
||||
mt = new ArrayMXBeanType(c);
|
||||
} else {
|
||||
mt = new CompositeDataMXBeanType(c);
|
||||
}
|
||||
} else if (javaType instanceof ParameterizedType) {
|
||||
final ParameterizedType pt = (ParameterizedType) javaType;
|
||||
final Type rawType = pt.getRawType();
|
||||
if (rawType instanceof Class) {
|
||||
final Class<?> rc = (Class<?>) rawType;
|
||||
if (rc == List.class) {
|
||||
mt = new ListMXBeanType(pt);
|
||||
} else if (rc == Map.class) {
|
||||
mt = new MapMXBeanType(pt);
|
||||
}
|
||||
}
|
||||
} else if (javaType instanceof GenericArrayType) {
|
||||
final GenericArrayType t = (GenericArrayType) javaType;
|
||||
mt = new GenericArrayMXBeanType(t);
|
||||
}
|
||||
// No open type mapped for the javaType
|
||||
if (mt == null) {
|
||||
throw new OpenDataException(javaType +
|
||||
" is not a supported MXBean type.");
|
||||
}
|
||||
convertedTypes.put(javaType, mt);
|
||||
return mt;
|
||||
}
|
||||
|
||||
// basic types do not require data mapping
|
||||
static synchronized MappedMXBeanType newBasicType(Class<?> c, OpenType<?> ot)
|
||||
throws OpenDataException {
|
||||
MappedMXBeanType mt = new BasicMXBeanType(c, ot);
|
||||
convertedTypes.put(c, mt);
|
||||
return mt;
|
||||
}
|
||||
|
||||
static synchronized MappedMXBeanType getMappedType(Type t)
|
||||
throws OpenDataException {
|
||||
MappedMXBeanType mt = convertedTypes.get(t);
|
||||
if (mt == null) {
|
||||
mt = newMappedType(t);
|
||||
}
|
||||
|
||||
if (mt.getOpenType() instanceof InProgress) {
|
||||
throw new OpenDataException("Recursive data structure");
|
||||
}
|
||||
return mt;
|
||||
}
|
||||
|
||||
// Convert a class to an OpenType
|
||||
public static synchronized OpenType<?> toOpenType(Type t)
|
||||
throws OpenDataException {
|
||||
MappedMXBeanType mt = getMappedType(t);
|
||||
return mt.getOpenType();
|
||||
}
|
||||
|
||||
public static Object toJavaTypeData(Object openData, Type t)
|
||||
throws OpenDataException, InvalidObjectException {
|
||||
if (openData == null) {
|
||||
return null;
|
||||
}
|
||||
MappedMXBeanType mt = getMappedType(t);
|
||||
return mt.toJavaTypeData(openData);
|
||||
}
|
||||
|
||||
public static Object toOpenTypeData(Object data, Type t)
|
||||
throws OpenDataException {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
MappedMXBeanType mt = getMappedType(t);
|
||||
return mt.toOpenTypeData(data);
|
||||
}
|
||||
|
||||
// Return the mapped open type
|
||||
OpenType<?> getOpenType() {
|
||||
return openType;
|
||||
}
|
||||
|
||||
boolean isBasicType() {
|
||||
return isBasicType;
|
||||
}
|
||||
|
||||
// Return the type name of the mapped open type
|
||||
// For primitive types, the type name is the same as the javaType
|
||||
// but the mapped open type is the wrapper class
|
||||
String getTypeName() {
|
||||
return getMappedTypeClass().getName();
|
||||
}
|
||||
|
||||
// Return the mapped open type
|
||||
Class<?> getMappedTypeClass() {
|
||||
return mappedTypeClass;
|
||||
}
|
||||
|
||||
abstract Type getJavaType();
|
||||
|
||||
// return name of the class or the generic type
|
||||
abstract String getName();
|
||||
|
||||
abstract Object toOpenTypeData(Object javaTypeData)
|
||||
throws OpenDataException;
|
||||
|
||||
abstract Object toJavaTypeData(Object openTypeData)
|
||||
throws OpenDataException, InvalidObjectException;
|
||||
|
||||
// Basic Types - Classes that do not require data conversion
|
||||
// including primitive types and all SimpleType
|
||||
//
|
||||
// Mapped open type: SimpleType for corresponding basic type
|
||||
//
|
||||
// Data Mapping:
|
||||
// T <-> T (no conversion)
|
||||
//
|
||||
static class BasicMXBeanType extends MappedMXBeanType {
|
||||
final Class<?> basicType;
|
||||
BasicMXBeanType(Class<?> c, OpenType<?> openType) {
|
||||
this.basicType = c;
|
||||
this.openType = openType;
|
||||
this.mappedTypeClass = c;
|
||||
this.isBasicType = true;
|
||||
}
|
||||
|
||||
Type getJavaType() {
|
||||
return basicType;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return basicType.getName();
|
||||
}
|
||||
|
||||
Object toOpenTypeData(Object data) throws OpenDataException {
|
||||
return data;
|
||||
}
|
||||
|
||||
Object toJavaTypeData(Object data)
|
||||
throws OpenDataException, InvalidObjectException {
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Enum subclasses
|
||||
// Mapped open type - String
|
||||
//
|
||||
// Data Mapping:
|
||||
// Enum <-> enum's name
|
||||
//
|
||||
static class EnumMXBeanType extends MappedMXBeanType {
|
||||
final Class enumClass;
|
||||
EnumMXBeanType(Class<?> c) {
|
||||
this.enumClass = c;
|
||||
this.openType = STRING;
|
||||
this.mappedTypeClass = String.class;
|
||||
}
|
||||
|
||||
Type getJavaType() {
|
||||
return enumClass;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return enumClass.getName();
|
||||
}
|
||||
|
||||
Object toOpenTypeData(Object data) throws OpenDataException {
|
||||
return ((Enum) data).name();
|
||||
}
|
||||
|
||||
Object toJavaTypeData(Object data)
|
||||
throws OpenDataException, InvalidObjectException {
|
||||
|
||||
try {
|
||||
return Enum.valueOf(enumClass, (String) data);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// missing enum constants
|
||||
final InvalidObjectException ioe =
|
||||
new InvalidObjectException("Enum constant named " +
|
||||
(String) data + " is missing");
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Array E[]
|
||||
// Mapped open type - Array with element of OpenType for E
|
||||
//
|
||||
// Data Mapping:
|
||||
// E[] <-> openTypeData(E)[]
|
||||
//
|
||||
static class ArrayMXBeanType extends MappedMXBeanType {
|
||||
final Class<?> arrayClass;
|
||||
protected MappedMXBeanType componentType;
|
||||
protected MappedMXBeanType baseElementType;
|
||||
|
||||
ArrayMXBeanType(Class<?> c) throws OpenDataException {
|
||||
this.arrayClass = c;
|
||||
this.componentType = getMappedType(c.getComponentType());
|
||||
|
||||
StringBuilder className = new StringBuilder();
|
||||
Class<?> et = c;
|
||||
int dim;
|
||||
for (dim = 0; et.isArray(); dim++) {
|
||||
className.append('[');
|
||||
et = et.getComponentType();
|
||||
}
|
||||
baseElementType = getMappedType(et);
|
||||
if (et.isPrimitive()) {
|
||||
className = new StringBuilder(c.getName());
|
||||
} else {
|
||||
className.append("L" + baseElementType.getTypeName() + ";");
|
||||
}
|
||||
try {
|
||||
mappedTypeClass = Class.forName(className.toString());
|
||||
} catch (ClassNotFoundException e) {
|
||||
final OpenDataException ode =
|
||||
new OpenDataException("Cannot obtain array class");
|
||||
ode.initCause(e);
|
||||
throw ode;
|
||||
}
|
||||
|
||||
openType = new ArrayType<>(dim, baseElementType.getOpenType());
|
||||
}
|
||||
|
||||
protected ArrayMXBeanType() {
|
||||
arrayClass = null;
|
||||
};
|
||||
|
||||
Type getJavaType() {
|
||||
return arrayClass;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return arrayClass.getName();
|
||||
}
|
||||
|
||||
Object toOpenTypeData(Object data) throws OpenDataException {
|
||||
// If the base element type is a basic type
|
||||
// return the data as no conversion is needed.
|
||||
// Primitive types are not converted to wrappers.
|
||||
if (baseElementType.isBasicType()) {
|
||||
return data;
|
||||
}
|
||||
|
||||
final Object[] array = (Object[]) data;
|
||||
final Object[] openArray = (Object[])
|
||||
Array.newInstance(componentType.getMappedTypeClass(),
|
||||
array.length);
|
||||
int i = 0;
|
||||
for (Object o : array) {
|
||||
if (o == null) {
|
||||
openArray[i] = null;
|
||||
} else {
|
||||
openArray[i] = componentType.toOpenTypeData(o);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return openArray;
|
||||
}
|
||||
|
||||
|
||||
Object toJavaTypeData(Object data)
|
||||
throws OpenDataException, InvalidObjectException {
|
||||
|
||||
// If the base element type is a basic type
|
||||
// return the data as no conversion is needed.
|
||||
if (baseElementType.isBasicType()) {
|
||||
return data;
|
||||
}
|
||||
|
||||
final Object[] openArray = (Object[]) data;
|
||||
final Object[] array = (Object[])
|
||||
Array.newInstance((Class) componentType.getJavaType(),
|
||||
openArray.length);
|
||||
int i = 0;
|
||||
for (Object o : openArray) {
|
||||
if (o == null) {
|
||||
array[i] = null;
|
||||
} else {
|
||||
array[i] = componentType.toJavaTypeData(o);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class GenericArrayMXBeanType extends ArrayMXBeanType {
|
||||
final GenericArrayType gtype;
|
||||
GenericArrayMXBeanType(GenericArrayType gat) throws OpenDataException {
|
||||
this.gtype = gat;
|
||||
this.componentType = getMappedType(gat.getGenericComponentType());
|
||||
|
||||
StringBuilder className = new StringBuilder();
|
||||
Type elementType = gat;
|
||||
int dim;
|
||||
for (dim = 0; elementType instanceof GenericArrayType; dim++) {
|
||||
className.append('[');
|
||||
GenericArrayType et = (GenericArrayType) elementType;
|
||||
elementType = et.getGenericComponentType();
|
||||
}
|
||||
baseElementType = getMappedType(elementType);
|
||||
if (elementType instanceof Class && ((Class) elementType).isPrimitive()) {
|
||||
className = new StringBuilder(gat.toString());
|
||||
} else {
|
||||
className.append("L" + baseElementType.getTypeName() + ";");
|
||||
}
|
||||
try {
|
||||
mappedTypeClass = Class.forName(className.toString());
|
||||
} catch (ClassNotFoundException e) {
|
||||
final OpenDataException ode =
|
||||
new OpenDataException("Cannot obtain array class");
|
||||
ode.initCause(e);
|
||||
throw ode;
|
||||
}
|
||||
|
||||
openType = new ArrayType<>(dim, baseElementType.getOpenType());
|
||||
}
|
||||
|
||||
Type getJavaType() {
|
||||
return gtype;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return gtype.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// List<E>
|
||||
// Mapped open type - Array with element of OpenType for E
|
||||
//
|
||||
// Data Mapping:
|
||||
// List<E> <-> openTypeData(E)[]
|
||||
//
|
||||
static class ListMXBeanType extends MappedMXBeanType {
|
||||
final ParameterizedType javaType;
|
||||
final MappedMXBeanType paramType;
|
||||
final String typeName;
|
||||
|
||||
ListMXBeanType(ParameterizedType pt) throws OpenDataException {
|
||||
this.javaType = pt;
|
||||
|
||||
final Type[] argTypes = pt.getActualTypeArguments();
|
||||
assert(argTypes.length == 1);
|
||||
|
||||
if (!(argTypes[0] instanceof Class)) {
|
||||
throw new OpenDataException("Element Type for " + pt +
|
||||
" not supported");
|
||||
}
|
||||
final Class<?> et = (Class<?>) argTypes[0];
|
||||
if (et.isArray()) {
|
||||
throw new OpenDataException("Element Type for " + pt +
|
||||
" not supported");
|
||||
}
|
||||
paramType = getMappedType(et);
|
||||
typeName = "List<" + paramType.getName() + ">";
|
||||
|
||||
try {
|
||||
mappedTypeClass = Class.forName(
|
||||
"[L" + paramType.getTypeName() + ";");
|
||||
} catch (ClassNotFoundException e) {
|
||||
final OpenDataException ode =
|
||||
new OpenDataException("Array class not found");
|
||||
ode.initCause(e);
|
||||
throw ode;
|
||||
}
|
||||
openType = new ArrayType<>(1, paramType.getOpenType());
|
||||
}
|
||||
|
||||
Type getJavaType() {
|
||||
return javaType;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
Object toOpenTypeData(Object data) throws OpenDataException {
|
||||
final List<Object> list = (List<Object>) data;
|
||||
|
||||
final Object[] openArray = (Object[])
|
||||
Array.newInstance(paramType.getMappedTypeClass(),
|
||||
list.size());
|
||||
int i = 0;
|
||||
for (Object o : list) {
|
||||
openArray[i++] = paramType.toOpenTypeData(o);
|
||||
}
|
||||
return openArray;
|
||||
}
|
||||
|
||||
Object toJavaTypeData(Object data)
|
||||
throws OpenDataException, InvalidObjectException {
|
||||
|
||||
final Object[] openArray = (Object[]) data;
|
||||
List<Object> result = new ArrayList<>(openArray.length);
|
||||
for (Object o : openArray) {
|
||||
result.add(paramType.toJavaTypeData(o));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String KEY = "key";
|
||||
private static final String VALUE = "value";
|
||||
private static final String[] mapIndexNames = {KEY};
|
||||
private static final String[] mapItemNames = {KEY, VALUE};
|
||||
|
||||
// Map<K,V>
|
||||
// Mapped open type - TabularType with row type:
|
||||
// CompositeType:
|
||||
// "key" of openDataType(K)
|
||||
// "value" of openDataType(V)
|
||||
// "key" is the index name
|
||||
//
|
||||
// Data Mapping:
|
||||
// Map<K,V> <-> TabularData
|
||||
//
|
||||
static class MapMXBeanType extends MappedMXBeanType {
|
||||
final ParameterizedType javaType;
|
||||
final MappedMXBeanType keyType;
|
||||
final MappedMXBeanType valueType;
|
||||
final String typeName;
|
||||
|
||||
MapMXBeanType(ParameterizedType pt) throws OpenDataException {
|
||||
this.javaType = pt;
|
||||
|
||||
final Type[] argTypes = pt.getActualTypeArguments();
|
||||
assert(argTypes.length == 2);
|
||||
this.keyType = getMappedType(argTypes[0]);
|
||||
this.valueType = getMappedType(argTypes[1]);
|
||||
|
||||
|
||||
// FIXME: generate typeName for generic
|
||||
typeName = "Map<" + keyType.getName() + "," +
|
||||
valueType.getName() + ">";
|
||||
final OpenType<?>[] mapItemTypes = new OpenType<?>[] {
|
||||
keyType.getOpenType(),
|
||||
valueType.getOpenType(),
|
||||
};
|
||||
final CompositeType rowType =
|
||||
new CompositeType(typeName,
|
||||
typeName,
|
||||
mapItemNames,
|
||||
mapItemNames,
|
||||
mapItemTypes);
|
||||
|
||||
openType = new TabularType(typeName, typeName, rowType, mapIndexNames);
|
||||
mappedTypeClass = javax.management.openmbean.TabularData.class;
|
||||
}
|
||||
|
||||
Type getJavaType() {
|
||||
return javaType;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
Object toOpenTypeData(Object data) throws OpenDataException {
|
||||
final Map<Object,Object> map = (Map<Object,Object>) data;
|
||||
final TabularType tabularType = (TabularType) openType;
|
||||
final TabularData table = new TabularDataSupport(tabularType);
|
||||
final CompositeType rowType = tabularType.getRowType();
|
||||
|
||||
for (Map.Entry<Object, Object> entry : map.entrySet()) {
|
||||
final Object key = keyType.toOpenTypeData(entry.getKey());
|
||||
final Object value = valueType.toOpenTypeData(entry.getValue());
|
||||
final CompositeData row =
|
||||
new CompositeDataSupport(rowType,
|
||||
mapItemNames,
|
||||
new Object[] {key, value});
|
||||
table.put(row);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
Object toJavaTypeData(Object data)
|
||||
throws OpenDataException, InvalidObjectException {
|
||||
|
||||
final TabularData td = (TabularData) data;
|
||||
|
||||
Map<Object, Object> result = new HashMap<>();
|
||||
for (CompositeData row : (Collection<CompositeData>) td.values()) {
|
||||
Object key = keyType.toJavaTypeData(row.get(KEY));
|
||||
Object value = valueType.toJavaTypeData(row.get(VALUE));
|
||||
result.put(key, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Class<?> COMPOSITE_DATA_CLASS =
|
||||
javax.management.openmbean.CompositeData.class;
|
||||
|
||||
// Classes that have a static from method
|
||||
// Mapped open type - CompositeData
|
||||
//
|
||||
// Data Mapping:
|
||||
// Classes <-> CompositeData
|
||||
//
|
||||
// The name and type of items for a class are identified from
|
||||
// the getter methods. For example, a class defines a method:
|
||||
//
|
||||
// public FooType getFoo();
|
||||
//
|
||||
// The composite data view for this class will contain one
|
||||
// item entry for a "foo" attribute and the item type is
|
||||
// one of the open types defined in the OpenType class that
|
||||
// can be determined in the following manner:
|
||||
// o If FooType is a primitive type, the item type a wrapper
|
||||
// class for the corresponding primitive type (such as
|
||||
// Integer, Long, Boolean, etc).
|
||||
// o If FooType is of type CompositeData or TabularData,
|
||||
// the item type is FooType.
|
||||
// o If FooType is an Enum, the item type is a String and
|
||||
// the value is the name of the enum constant.
|
||||
// o If FooType is a class or an interface other than the above,
|
||||
// the item type is CompositeData. The same convention
|
||||
// can be recursively applied to the FooType class when
|
||||
// constructing the composite data for the "foo" attribute.
|
||||
// o If FooType is an array, the item type is an array and
|
||||
// its element type is determined as described above.
|
||||
//
|
||||
static class CompositeDataMXBeanType extends MappedMXBeanType {
|
||||
final Class<?> javaClass;
|
||||
final boolean isCompositeData;
|
||||
Method fromMethod = null;
|
||||
|
||||
CompositeDataMXBeanType(Class<?> c) throws OpenDataException {
|
||||
this.javaClass = c;
|
||||
this.mappedTypeClass = COMPOSITE_DATA_CLASS;
|
||||
|
||||
// check if a static from method exists
|
||||
try {
|
||||
fromMethod = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
|
||||
public Method run() throws NoSuchMethodException {
|
||||
return javaClass.getMethod("from", COMPOSITE_DATA_CLASS);
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
// ignore NoSuchMethodException since we allow classes
|
||||
// that has no from method to be embeded in another class.
|
||||
}
|
||||
|
||||
if (COMPOSITE_DATA_CLASS.isAssignableFrom(c)) {
|
||||
// c implements CompositeData - set openType to null
|
||||
// defer generating the CompositeType
|
||||
// until the object is constructed
|
||||
this.isCompositeData = true;
|
||||
this.openType = null;
|
||||
} else {
|
||||
this.isCompositeData = false;
|
||||
|
||||
// Make a CompositeData containing all the getters
|
||||
final Method[] methods =
|
||||
AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
|
||||
public Method[] run() {
|
||||
return javaClass.getMethods();
|
||||
}
|
||||
});
|
||||
final List<String> names = new ArrayList<>();
|
||||
final List<OpenType<?>> types = new ArrayList<>();
|
||||
|
||||
/* Select public methods that look like "T getX()" or "boolean
|
||||
isX()", where T is not void and X is not the empty
|
||||
string. Exclude "Class getClass()" inherited from Object. */
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
final Method method = methods[i];
|
||||
final String name = method.getName();
|
||||
final Type type = method.getGenericReturnType();
|
||||
final String rest;
|
||||
if (name.startsWith("get")) {
|
||||
rest = name.substring(3);
|
||||
} else if (name.startsWith("is") &&
|
||||
type instanceof Class &&
|
||||
((Class) type) == boolean.class) {
|
||||
rest = name.substring(2);
|
||||
} else {
|
||||
// ignore non-getter methods
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rest.equals("") ||
|
||||
method.getParameterTypes().length > 0 ||
|
||||
type == void.class ||
|
||||
rest.equals("Class")) {
|
||||
|
||||
// ignore non-getter methods
|
||||
continue;
|
||||
}
|
||||
names.add(decapitalize(rest));
|
||||
types.add(toOpenType(type));
|
||||
}
|
||||
|
||||
final String[] nameArray = names.toArray(new String[0]);
|
||||
openType = new CompositeType(c.getName(),
|
||||
c.getName(),
|
||||
nameArray, // field names
|
||||
nameArray, // field descriptions
|
||||
types.toArray(new OpenType<?>[0]));
|
||||
}
|
||||
}
|
||||
|
||||
Type getJavaType() {
|
||||
return javaClass;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return javaClass.getName();
|
||||
}
|
||||
|
||||
Object toOpenTypeData(Object data) throws OpenDataException {
|
||||
if (data instanceof MemoryUsage) {
|
||||
return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
|
||||
}
|
||||
|
||||
if (data instanceof ThreadInfo) {
|
||||
return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
|
||||
}
|
||||
|
||||
if (data instanceof LockInfo) {
|
||||
if (data instanceof java.lang.management.MonitorInfo) {
|
||||
return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
|
||||
}
|
||||
return LockInfoCompositeData.toCompositeData((LockInfo) data);
|
||||
}
|
||||
|
||||
if (data instanceof MemoryNotificationInfo) {
|
||||
return MemoryNotifInfoCompositeData.
|
||||
toCompositeData((MemoryNotificationInfo) data);
|
||||
}
|
||||
|
||||
if (data instanceof VMOption) {
|
||||
return VMOptionCompositeData.toCompositeData((VMOption) data);
|
||||
}
|
||||
|
||||
if (isCompositeData) {
|
||||
// Classes that implement CompositeData
|
||||
//
|
||||
// construct a new CompositeDataSupport object
|
||||
// so that no other classes are sent over the wire
|
||||
CompositeData cd = (CompositeData) data;
|
||||
CompositeType ct = cd.getCompositeType();
|
||||
String[] itemNames = ct.keySet().toArray(new String[0]);
|
||||
Object[] itemValues = cd.getAll(itemNames);
|
||||
return new CompositeDataSupport(ct, itemNames, itemValues);
|
||||
}
|
||||
|
||||
throw new OpenDataException(javaClass.getName() +
|
||||
" is not supported for platform MXBeans");
|
||||
}
|
||||
|
||||
Object toJavaTypeData(Object data)
|
||||
throws OpenDataException, InvalidObjectException {
|
||||
|
||||
if (fromMethod == null) {
|
||||
throw new AssertionError("Does not support data conversion");
|
||||
}
|
||||
|
||||
try {
|
||||
return fromMethod.invoke(null, data);
|
||||
} catch (IllegalAccessException e) {
|
||||
// should never reach here
|
||||
throw new AssertionError(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
final OpenDataException ode =
|
||||
new OpenDataException("Failed to invoke " +
|
||||
fromMethod.getName() + " to convert CompositeData " +
|
||||
" to " + javaClass.getName());
|
||||
ode.initCause(e);
|
||||
throw ode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class InProgress extends OpenType {
|
||||
private static final String description =
|
||||
"Marker to detect recursive type use -- internal use only!";
|
||||
|
||||
InProgress() throws OpenDataException {
|
||||
super("java.lang.String", "java.lang.String", description);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isValue(Object o) {
|
||||
return false;
|
||||
}
|
||||
private static final long serialVersionUID = -3413063475064374490L;
|
||||
}
|
||||
private static final OpenType<?> inProgress;
|
||||
static {
|
||||
OpenType<?> t;
|
||||
try {
|
||||
t = new InProgress();
|
||||
} catch (OpenDataException e) {
|
||||
// Should not reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
inProgress = t;
|
||||
}
|
||||
|
||||
private static final OpenType[] simpleTypes = {
|
||||
BIGDECIMAL, BIGINTEGER, BOOLEAN, BYTE, CHARACTER, DATE,
|
||||
DOUBLE, FLOAT, INTEGER, LONG, OBJECTNAME, SHORT, STRING,
|
||||
VOID,
|
||||
};
|
||||
static {
|
||||
try {
|
||||
for (int i = 0; i < simpleTypes.length; i++) {
|
||||
final OpenType<?> t = simpleTypes[i];
|
||||
Class<?> c;
|
||||
try {
|
||||
c = Class.forName(t.getClassName(), false,
|
||||
MappedMXBeanType.class.getClassLoader());
|
||||
MappedMXBeanType.newBasicType(c, t);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// the classes that these predefined types declare
|
||||
// must exist!
|
||||
throw new AssertionError(e);
|
||||
} catch (OpenDataException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
||||
if (c.getName().startsWith("java.lang.")) {
|
||||
try {
|
||||
final Field typeField = c.getField("TYPE");
|
||||
final Class<?> primitiveType = (Class<?>) typeField.get(null);
|
||||
MappedMXBeanType.newBasicType(primitiveType, t);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// OK: must not be a primitive wrapper
|
||||
} catch (IllegalAccessException e) {
|
||||
// Should not reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (OpenDataException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to take a string and convert it to normal Java variable
|
||||
* name capitalization. This normally means converting the first
|
||||
* character from upper case to lower case, but in the (unusual) special
|
||||
* case when there is more than one character and both the first and
|
||||
* second characters are upper case, we leave it alone.
|
||||
* <p>
|
||||
* Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays
|
||||
* as "URL".
|
||||
*
|
||||
* @param name The string to be decapitalized.
|
||||
* @return The decapitalized version of the string.
|
||||
*/
|
||||
private static String decapitalize(String name) {
|
||||
if (name == null || name.length() == 0) {
|
||||
return name;
|
||||
}
|
||||
if (name.length() > 1 && Character.isUpperCase(name.charAt(1)) &&
|
||||
Character.isUpperCase(name.charAt(0))){
|
||||
return name;
|
||||
}
|
||||
char chars[] = name.toCharArray();
|
||||
chars[0] = Character.toLowerCase(chars[0]);
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
}
|
||||
168
jdkSrc/jdk8/sun/management/MemoryImpl.java
Normal file
168
jdkSrc/jdk8/sun/management/MemoryImpl.java
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.lang.management.MemoryNotificationInfo;
|
||||
import java.lang.management.MemoryManagerMXBean;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.MBeanNotificationInfo;
|
||||
import javax.management.Notification;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
|
||||
/**
|
||||
* Implementation class for the memory subsystem.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getMemoryMXBean() returns an instance
|
||||
* of this class.
|
||||
*/
|
||||
class MemoryImpl extends NotificationEmitterSupport
|
||||
implements MemoryMXBean {
|
||||
|
||||
private final VMManagement jvm;
|
||||
|
||||
private static MemoryPoolMXBean[] pools = null;
|
||||
private static MemoryManagerMXBean[] mgrs = null;
|
||||
|
||||
/**
|
||||
* Constructor of MemoryImpl class
|
||||
*/
|
||||
MemoryImpl(VMManagement vm) {
|
||||
this.jvm = vm;
|
||||
}
|
||||
|
||||
public int getObjectPendingFinalizationCount() {
|
||||
return sun.misc.VM.getFinalRefCount();
|
||||
}
|
||||
|
||||
public void gc() {
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
|
||||
// Need to make a VM call to get coherent value
|
||||
public MemoryUsage getHeapMemoryUsage() {
|
||||
return getMemoryUsage0(true);
|
||||
}
|
||||
|
||||
public MemoryUsage getNonHeapMemoryUsage() {
|
||||
return getMemoryUsage0(false);
|
||||
}
|
||||
|
||||
public boolean isVerbose() {
|
||||
return jvm.getVerboseGC();
|
||||
}
|
||||
|
||||
public void setVerbose(boolean value) {
|
||||
Util.checkControlAccess();
|
||||
|
||||
setVerboseGC(value);
|
||||
}
|
||||
|
||||
// The current Hotspot implementation does not support
|
||||
// dynamically add or remove memory pools & managers.
|
||||
static synchronized MemoryPoolMXBean[] getMemoryPools() {
|
||||
if (pools == null) {
|
||||
pools = getMemoryPools0();
|
||||
}
|
||||
return pools;
|
||||
}
|
||||
static synchronized MemoryManagerMXBean[] getMemoryManagers() {
|
||||
if (mgrs == null) {
|
||||
mgrs = getMemoryManagers0();
|
||||
}
|
||||
return mgrs;
|
||||
}
|
||||
private static native MemoryPoolMXBean[] getMemoryPools0();
|
||||
private static native MemoryManagerMXBean[] getMemoryManagers0();
|
||||
private native MemoryUsage getMemoryUsage0(boolean heap);
|
||||
private native void setVerboseGC(boolean value);
|
||||
|
||||
private final static String notifName =
|
||||
"javax.management.Notification";
|
||||
private final static String[] notifTypes = {
|
||||
MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED,
|
||||
MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED
|
||||
};
|
||||
private final static String[] notifMsgs = {
|
||||
"Memory usage exceeds usage threshold",
|
||||
"Memory usage exceeds collection usage threshold"
|
||||
};
|
||||
|
||||
public MBeanNotificationInfo[] getNotificationInfo() {
|
||||
return new MBeanNotificationInfo[] {
|
||||
new MBeanNotificationInfo(notifTypes, notifName, "Memory Notification")
|
||||
};
|
||||
}
|
||||
|
||||
private static String getNotifMsg(String notifType) {
|
||||
for (int i = 0; i < notifTypes.length; i++) {
|
||||
if (notifType == notifTypes[i]) {
|
||||
return notifMsgs[i];
|
||||
}
|
||||
}
|
||||
return "Unknown message";
|
||||
}
|
||||
|
||||
private static long seqNumber = 0;
|
||||
private static long getNextSeqNumber() {
|
||||
return ++seqNumber;
|
||||
}
|
||||
|
||||
static void createNotification(String notifType,
|
||||
String poolName,
|
||||
MemoryUsage usage,
|
||||
long count) {
|
||||
MemoryImpl mbean = (MemoryImpl) ManagementFactory.getMemoryMXBean();
|
||||
if (!mbean.hasListeners()) {
|
||||
// if no listener is registered.
|
||||
return;
|
||||
}
|
||||
long timestamp = System.currentTimeMillis();
|
||||
String msg = getNotifMsg(notifType);
|
||||
Notification notif = new Notification(notifType,
|
||||
mbean.getObjectName(),
|
||||
getNextSeqNumber(),
|
||||
timestamp,
|
||||
msg);
|
||||
MemoryNotificationInfo info =
|
||||
new MemoryNotificationInfo(poolName,
|
||||
usage,
|
||||
count);
|
||||
CompositeData cd =
|
||||
MemoryNotifInfoCompositeData.toCompositeData(info);
|
||||
notif.setUserData(cd);
|
||||
mbean.sendNotification(notif);
|
||||
}
|
||||
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
95
jdkSrc/jdk8/sun/management/MemoryManagerImpl.java
Normal file
95
jdkSrc/jdk8/sun/management/MemoryManagerImpl.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryManagerMXBean;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
|
||||
import javax.management.MBeanNotificationInfo;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* Implementation class for a memory manager.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getMemoryManagerMXBeans() returns a list
|
||||
* of instances of this class.
|
||||
*/
|
||||
class MemoryManagerImpl extends NotificationEmitterSupport
|
||||
implements MemoryManagerMXBean {
|
||||
|
||||
private final String name;
|
||||
private final boolean isValid;
|
||||
private MemoryPoolMXBean[] pools;
|
||||
|
||||
MemoryManagerImpl(String name) {
|
||||
this.name = name;
|
||||
this.isValid = true;
|
||||
this.pools = null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public String[] getMemoryPoolNames() {
|
||||
MemoryPoolMXBean[] ps = getMemoryPools();
|
||||
|
||||
String[] names = new String[ps.length];
|
||||
for (int i = 0; i < ps.length; i++) {
|
||||
names[i] = ps[i].getName();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
synchronized MemoryPoolMXBean[] getMemoryPools() {
|
||||
if (pools == null) {
|
||||
pools = getMemoryPools0();
|
||||
}
|
||||
return pools;
|
||||
}
|
||||
private native MemoryPoolMXBean[] getMemoryPools0();
|
||||
|
||||
private MBeanNotificationInfo[] notifInfo = null;
|
||||
public MBeanNotificationInfo[] getNotificationInfo() {
|
||||
synchronized (this) {
|
||||
if(notifInfo == null) {
|
||||
notifInfo = new MBeanNotificationInfo[0];
|
||||
}
|
||||
}
|
||||
return notifInfo;
|
||||
}
|
||||
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE, getName());
|
||||
}
|
||||
|
||||
}
|
||||
131
jdkSrc/jdk8/sun/management/MemoryNotifInfoCompositeData.java
Normal file
131
jdkSrc/jdk8/sun/management/MemoryNotifInfoCompositeData.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.MemoryNotificationInfo;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
|
||||
/**
|
||||
* A CompositeData for MemoryNotificationInfo for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class MemoryNotifInfoCompositeData extends LazyCompositeData {
|
||||
private final MemoryNotificationInfo memoryNotifInfo;
|
||||
|
||||
private MemoryNotifInfoCompositeData(MemoryNotificationInfo info) {
|
||||
this.memoryNotifInfo = info;
|
||||
}
|
||||
|
||||
public MemoryNotificationInfo getMemoryNotifInfo() {
|
||||
return memoryNotifInfo;
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(MemoryNotificationInfo info) {
|
||||
MemoryNotifInfoCompositeData mnicd =
|
||||
new MemoryNotifInfoCompositeData(info);
|
||||
return mnicd.getCompositeData();
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// memoryNotifInfoItemNames!
|
||||
final Object[] memoryNotifInfoItemValues = {
|
||||
memoryNotifInfo.getPoolName(),
|
||||
MemoryUsageCompositeData.toCompositeData(memoryNotifInfo.getUsage()),
|
||||
new Long(memoryNotifInfo.getCount()),
|
||||
};
|
||||
|
||||
try {
|
||||
return new CompositeDataSupport(memoryNotifInfoCompositeType,
|
||||
memoryNotifInfoItemNames,
|
||||
memoryNotifInfoItemValues);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final CompositeType memoryNotifInfoCompositeType;
|
||||
static {
|
||||
try {
|
||||
memoryNotifInfoCompositeType = (CompositeType)
|
||||
MappedMXBeanType.toOpenType(MemoryNotificationInfo.class);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String POOL_NAME = "poolName";
|
||||
private static final String USAGE = "usage";
|
||||
private static final String COUNT = "count";
|
||||
private static final String[] memoryNotifInfoItemNames = {
|
||||
POOL_NAME,
|
||||
USAGE,
|
||||
COUNT,
|
||||
};
|
||||
|
||||
|
||||
public static String getPoolName(CompositeData cd) {
|
||||
String poolname = getString(cd, POOL_NAME);
|
||||
if (poolname == null) {
|
||||
throw new IllegalArgumentException("Invalid composite data: " +
|
||||
"Attribute " + POOL_NAME + " has null value");
|
||||
}
|
||||
return poolname;
|
||||
}
|
||||
|
||||
public static MemoryUsage getUsage(CompositeData cd) {
|
||||
CompositeData usageData = (CompositeData) cd.get(USAGE);
|
||||
return MemoryUsage.from(usageData);
|
||||
}
|
||||
|
||||
public static long getCount(CompositeData cd) {
|
||||
return getLong(cd, COUNT);
|
||||
}
|
||||
|
||||
/** Validate if the input CompositeData has the expected
|
||||
* CompositeType (i.e. contain all attributes with expected
|
||||
* names and types).
|
||||
*/
|
||||
public static void validateCompositeData(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
if (!isTypeMatched(memoryNotifInfoCompositeType, cd.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for MemoryNotificationInfo");
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -1805123446483771291L;
|
||||
}
|
||||
345
jdkSrc/jdk8/sun/management/MemoryPoolImpl.java
Normal file
345
jdkSrc/jdk8/sun/management/MemoryPoolImpl.java
Normal file
@@ -0,0 +1,345 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.lang.management.MemoryType;
|
||||
import java.lang.management.MemoryManagerMXBean;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import static java.lang.management.MemoryNotificationInfo.*;
|
||||
|
||||
/**
|
||||
* Implementation class for a memory pool.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getMemoryPoolMXBeans() returns a list of
|
||||
* instances of this class.
|
||||
*/
|
||||
class MemoryPoolImpl implements MemoryPoolMXBean {
|
||||
|
||||
private final String name;
|
||||
private final boolean isHeap;
|
||||
private final boolean isValid;
|
||||
private final boolean collectionThresholdSupported;
|
||||
private final boolean usageThresholdSupported;
|
||||
|
||||
private MemoryManagerMXBean[] managers;
|
||||
|
||||
private long usageThreshold;
|
||||
private long collectionThreshold;
|
||||
|
||||
private boolean usageSensorRegistered;
|
||||
private boolean gcSensorRegistered;
|
||||
private Sensor usageSensor;
|
||||
private Sensor gcSensor;
|
||||
|
||||
MemoryPoolImpl(String name, boolean isHeap, long usageThreshold,
|
||||
long gcThreshold) {
|
||||
this.name = name;
|
||||
this.isHeap = isHeap;
|
||||
this.isValid = true;
|
||||
this.managers = null;
|
||||
this.usageThreshold = usageThreshold;
|
||||
this.collectionThreshold = gcThreshold;
|
||||
this.usageThresholdSupported = (usageThreshold >= 0);
|
||||
this.collectionThresholdSupported = (gcThreshold >= 0);
|
||||
this.usageSensor = new PoolSensor(this, name + " usage sensor");
|
||||
this.gcSensor = new CollectionSensor(this, name + " collection sensor");
|
||||
this.usageSensorRegistered = false;
|
||||
this.gcSensorRegistered = false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public MemoryType getType() {
|
||||
if (isHeap) {
|
||||
return MemoryType.HEAP;
|
||||
} else {
|
||||
return MemoryType.NON_HEAP;
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryUsage getUsage() {
|
||||
return getUsage0();
|
||||
}
|
||||
|
||||
public synchronized MemoryUsage getPeakUsage() {
|
||||
// synchronized since resetPeakUsage may be resetting the peak usage
|
||||
return getPeakUsage0();
|
||||
}
|
||||
|
||||
public synchronized long getUsageThreshold() {
|
||||
if (!isUsageThresholdSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Usage threshold is not supported");
|
||||
}
|
||||
return usageThreshold;
|
||||
}
|
||||
|
||||
public void setUsageThreshold(long newThreshold) {
|
||||
if (!isUsageThresholdSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Usage threshold is not supported");
|
||||
}
|
||||
|
||||
Util.checkControlAccess();
|
||||
|
||||
MemoryUsage usage = getUsage0();
|
||||
if (newThreshold < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid threshold: " + newThreshold);
|
||||
}
|
||||
|
||||
if (usage.getMax() != -1 && newThreshold > usage.getMax()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid threshold: " + newThreshold +
|
||||
" must be <= maxSize." +
|
||||
" Committed = " + usage.getCommitted() +
|
||||
" Max = " + usage.getMax());
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (!usageSensorRegistered) {
|
||||
// pass the sensor to VM to begin monitoring
|
||||
usageSensorRegistered = true;
|
||||
setPoolUsageSensor(usageSensor);
|
||||
}
|
||||
setUsageThreshold0(usageThreshold, newThreshold);
|
||||
this.usageThreshold = newThreshold;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized MemoryManagerMXBean[] getMemoryManagers() {
|
||||
if (managers == null) {
|
||||
managers = getMemoryManagers0();
|
||||
}
|
||||
return managers;
|
||||
}
|
||||
|
||||
public String[] getMemoryManagerNames() {
|
||||
MemoryManagerMXBean[] mgrs = getMemoryManagers();
|
||||
|
||||
String[] names = new String[mgrs.length];
|
||||
for (int i = 0; i < mgrs.length; i++) {
|
||||
names[i] = mgrs[i].getName();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public void resetPeakUsage() {
|
||||
Util.checkControlAccess();
|
||||
|
||||
synchronized (this) {
|
||||
// synchronized since getPeakUsage may be called concurrently
|
||||
resetPeakUsage0();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUsageThresholdExceeded() {
|
||||
if (!isUsageThresholdSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Usage threshold is not supported");
|
||||
}
|
||||
|
||||
// return false if usage threshold crossing checking is disabled
|
||||
if (usageThreshold == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MemoryUsage u = getUsage0();
|
||||
return (u.getUsed() >= usageThreshold ||
|
||||
usageSensor.isOn());
|
||||
}
|
||||
|
||||
public long getUsageThresholdCount() {
|
||||
if (!isUsageThresholdSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Usage threshold is not supported");
|
||||
}
|
||||
|
||||
return usageSensor.getCount();
|
||||
}
|
||||
|
||||
public boolean isUsageThresholdSupported() {
|
||||
return usageThresholdSupported;
|
||||
}
|
||||
|
||||
public synchronized long getCollectionUsageThreshold() {
|
||||
if (!isCollectionUsageThresholdSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"CollectionUsage threshold is not supported");
|
||||
}
|
||||
|
||||
return collectionThreshold;
|
||||
}
|
||||
|
||||
public void setCollectionUsageThreshold(long newThreshold) {
|
||||
if (!isCollectionUsageThresholdSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"CollectionUsage threshold is not supported");
|
||||
}
|
||||
|
||||
Util.checkControlAccess();
|
||||
|
||||
MemoryUsage usage = getUsage0();
|
||||
if (newThreshold < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid threshold: " + newThreshold);
|
||||
}
|
||||
|
||||
if (usage.getMax() != -1 && newThreshold > usage.getMax()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid threshold: " + newThreshold +
|
||||
" > max (" + usage.getMax() + ").");
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (!gcSensorRegistered) {
|
||||
// pass the sensor to VM to begin monitoring
|
||||
gcSensorRegistered = true;
|
||||
setPoolCollectionSensor(gcSensor);
|
||||
}
|
||||
setCollectionThreshold0(collectionThreshold, newThreshold);
|
||||
this.collectionThreshold = newThreshold;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCollectionUsageThresholdExceeded() {
|
||||
if (!isCollectionUsageThresholdSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"CollectionUsage threshold is not supported");
|
||||
}
|
||||
|
||||
// return false if usage threshold crossing checking is disabled
|
||||
if (collectionThreshold == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MemoryUsage u = getCollectionUsage0();
|
||||
return (gcSensor.isOn() ||
|
||||
(u != null && u.getUsed() >= collectionThreshold));
|
||||
}
|
||||
|
||||
public long getCollectionUsageThresholdCount() {
|
||||
if (!isCollectionUsageThresholdSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"CollectionUsage threshold is not supported");
|
||||
}
|
||||
|
||||
return gcSensor.getCount();
|
||||
}
|
||||
|
||||
public MemoryUsage getCollectionUsage() {
|
||||
return getCollectionUsage0();
|
||||
}
|
||||
|
||||
public boolean isCollectionUsageThresholdSupported() {
|
||||
return collectionThresholdSupported;
|
||||
}
|
||||
|
||||
// Native VM support
|
||||
private native MemoryUsage getUsage0();
|
||||
private native MemoryUsage getPeakUsage0();
|
||||
private native MemoryUsage getCollectionUsage0();
|
||||
private native void setUsageThreshold0(long current, long newThreshold);
|
||||
private native void setCollectionThreshold0(long current, long newThreshold);
|
||||
private native void resetPeakUsage0();
|
||||
private native MemoryManagerMXBean[] getMemoryManagers0();
|
||||
private native void setPoolUsageSensor(Sensor s);
|
||||
private native void setPoolCollectionSensor(Sensor s);
|
||||
|
||||
// package private
|
||||
|
||||
/**
|
||||
* PoolSensor will be triggered by the VM when the memory
|
||||
* usage of a memory pool is crossing the usage threshold.
|
||||
* The VM will not trigger this sensor in subsequent crossing
|
||||
* unless the memory usage has returned below the threshold.
|
||||
*/
|
||||
class PoolSensor extends Sensor {
|
||||
MemoryPoolImpl pool;
|
||||
|
||||
PoolSensor(MemoryPoolImpl pool, String name) {
|
||||
super(name);
|
||||
this.pool = pool;
|
||||
}
|
||||
void triggerAction(MemoryUsage usage) {
|
||||
// create and send notification
|
||||
MemoryImpl.createNotification(MEMORY_THRESHOLD_EXCEEDED,
|
||||
pool.getName(),
|
||||
usage,
|
||||
getCount());
|
||||
}
|
||||
void triggerAction() {
|
||||
// do nothing
|
||||
}
|
||||
void clearAction() {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CollectionSensor will be triggered and cleared by the VM
|
||||
* when the memory usage of a memory pool after GC is crossing
|
||||
* the collection threshold.
|
||||
* The VM will trigger this sensor in subsequent crossing
|
||||
* regardless if the memory usage has changed siince the previous GC.
|
||||
*/
|
||||
class CollectionSensor extends Sensor {
|
||||
MemoryPoolImpl pool;
|
||||
CollectionSensor(MemoryPoolImpl pool, String name) {
|
||||
super(name);
|
||||
this.pool = pool;
|
||||
}
|
||||
void triggerAction(MemoryUsage usage) {
|
||||
MemoryImpl.createNotification(MEMORY_COLLECTION_THRESHOLD_EXCEEDED,
|
||||
pool.getName(),
|
||||
usage,
|
||||
gcSensor.getCount());
|
||||
}
|
||||
void triggerAction() {
|
||||
// do nothing
|
||||
}
|
||||
void clearAction() {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE, getName());
|
||||
}
|
||||
|
||||
}
|
||||
131
jdkSrc/jdk8/sun/management/MemoryUsageCompositeData.java
Normal file
131
jdkSrc/jdk8/sun/management/MemoryUsageCompositeData.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.MemoryUsage;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
|
||||
/**
|
||||
* A CompositeData for MemoryUsage for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class MemoryUsageCompositeData extends LazyCompositeData {
|
||||
private final MemoryUsage usage;
|
||||
|
||||
private MemoryUsageCompositeData(MemoryUsage u) {
|
||||
this.usage = u;
|
||||
}
|
||||
|
||||
public MemoryUsage getMemoryUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(MemoryUsage u) {
|
||||
MemoryUsageCompositeData mucd = new MemoryUsageCompositeData(u);
|
||||
return mucd.getCompositeData();
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// memoryUsageItemNames!
|
||||
final Object[] memoryUsageItemValues = {
|
||||
new Long(usage.getInit()),
|
||||
new Long(usage.getUsed()),
|
||||
new Long(usage.getCommitted()),
|
||||
new Long(usage.getMax()),
|
||||
};
|
||||
|
||||
try {
|
||||
return new CompositeDataSupport(memoryUsageCompositeType,
|
||||
memoryUsageItemNames,
|
||||
memoryUsageItemValues);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final CompositeType memoryUsageCompositeType;
|
||||
static {
|
||||
try {
|
||||
memoryUsageCompositeType = (CompositeType)
|
||||
MappedMXBeanType.toOpenType(MemoryUsage.class);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
static CompositeType getMemoryUsageCompositeType() {
|
||||
return memoryUsageCompositeType;
|
||||
}
|
||||
|
||||
private static final String INIT = "init";
|
||||
private static final String USED = "used";
|
||||
private static final String COMMITTED = "committed";
|
||||
private static final String MAX = "max";
|
||||
|
||||
private static final String[] memoryUsageItemNames = {
|
||||
INIT,
|
||||
USED,
|
||||
COMMITTED,
|
||||
MAX,
|
||||
};
|
||||
|
||||
public static long getInit(CompositeData cd) {
|
||||
return getLong(cd, INIT);
|
||||
}
|
||||
public static long getUsed(CompositeData cd) {
|
||||
return getLong(cd, USED);
|
||||
}
|
||||
public static long getCommitted(CompositeData cd) {
|
||||
return getLong(cd, COMMITTED);
|
||||
}
|
||||
public static long getMax(CompositeData cd) {
|
||||
return getLong(cd, MAX);
|
||||
}
|
||||
|
||||
/** Validate if the input CompositeData has the expected
|
||||
* CompositeType (i.e. contain all attributes with expected
|
||||
* names and types).
|
||||
*/
|
||||
public static void validateCompositeData(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
if (!isTypeMatched(memoryUsageCompositeType, cd.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for MemoryUsage");
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -8504291541083874143L;
|
||||
}
|
||||
79
jdkSrc/jdk8/sun/management/MethodInfo.java
Normal file
79
jdkSrc/jdk8/sun/management/MethodInfo.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import sun.management.counter.*;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MethodInfo implements java.io.Serializable {
|
||||
private String name;
|
||||
private long type;
|
||||
private int compileSize;
|
||||
|
||||
MethodInfo(String name, long type, int compileSize) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.compileSize = compileSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the compiled method.
|
||||
*
|
||||
* @return the name of the compiled method.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the compiled method such as normal-compile,
|
||||
* osr-compile, and native-compile.
|
||||
*
|
||||
* @return the type of the compiled method.
|
||||
*/
|
||||
public long getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of bytes occupied by this compiled method.
|
||||
* This method returns -1 if not available.
|
||||
*
|
||||
* @return the number of bytes occupied by this compiled method.
|
||||
*/
|
||||
public int getCompileSize() {
|
||||
return compileSize;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getName() + " type = " + getType() +
|
||||
" compileSize = " + getCompileSize();
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 6992337162326171013L;
|
||||
|
||||
}
|
||||
148
jdkSrc/jdk8/sun/management/MonitorInfoCompositeData.java
Normal file
148
jdkSrc/jdk8/sun/management/MonitorInfoCompositeData.java
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.MonitorInfo;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A CompositeData for MonitorInfo for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class MonitorInfoCompositeData extends LazyCompositeData {
|
||||
private final MonitorInfo lock;
|
||||
|
||||
private MonitorInfoCompositeData(MonitorInfo mi) {
|
||||
this.lock = mi;
|
||||
}
|
||||
|
||||
public MonitorInfo getMonitorInfo() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(MonitorInfo mi) {
|
||||
MonitorInfoCompositeData micd = new MonitorInfoCompositeData(mi);
|
||||
return micd.getCompositeData();
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// monitorInfoItemNames!
|
||||
|
||||
int len = monitorInfoItemNames.length;
|
||||
Object[] values = new Object[len];
|
||||
CompositeData li = LockInfoCompositeData.toCompositeData(lock);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
String item = monitorInfoItemNames[i];
|
||||
if (item.equals(LOCKED_STACK_FRAME)) {
|
||||
StackTraceElement ste = lock.getLockedStackFrame();
|
||||
values[i] = (ste != null ? StackTraceElementCompositeData.
|
||||
toCompositeData(ste)
|
||||
: null);
|
||||
} else if (item.equals(LOCKED_STACK_DEPTH)) {
|
||||
values[i] = new Integer(lock.getLockedStackDepth());
|
||||
} else {
|
||||
values[i] = li.get(item);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return new CompositeDataSupport(monitorInfoCompositeType,
|
||||
monitorInfoItemNames,
|
||||
values);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final CompositeType monitorInfoCompositeType;
|
||||
private static final String[] monitorInfoItemNames;
|
||||
static {
|
||||
try {
|
||||
monitorInfoCompositeType = (CompositeType)
|
||||
MappedMXBeanType.toOpenType(MonitorInfo.class);
|
||||
Set<String> s = monitorInfoCompositeType.keySet();
|
||||
monitorInfoItemNames = s.toArray(new String[0]);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
static CompositeType getMonitorInfoCompositeType() {
|
||||
return monitorInfoCompositeType;
|
||||
}
|
||||
|
||||
private static final String CLASS_NAME = "className";
|
||||
private static final String IDENTITY_HASH_CODE = "identityHashCode";
|
||||
private static final String LOCKED_STACK_FRAME = "lockedStackFrame";
|
||||
private static final String LOCKED_STACK_DEPTH = "lockedStackDepth";
|
||||
|
||||
public static String getClassName(CompositeData cd) {
|
||||
return getString(cd, CLASS_NAME);
|
||||
}
|
||||
|
||||
public static int getIdentityHashCode(CompositeData cd) {
|
||||
return getInt(cd, IDENTITY_HASH_CODE);
|
||||
}
|
||||
|
||||
public static StackTraceElement getLockedStackFrame(CompositeData cd) {
|
||||
CompositeData ste = (CompositeData) cd.get(LOCKED_STACK_FRAME);
|
||||
if (ste != null) {
|
||||
return StackTraceElementCompositeData.from(ste);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getLockedStackDepth(CompositeData cd) {
|
||||
return getInt(cd, LOCKED_STACK_DEPTH);
|
||||
}
|
||||
|
||||
/** Validate if the input CompositeData has the expected
|
||||
* CompositeType (i.e. contain all attributes with expected
|
||||
* names and types).
|
||||
*/
|
||||
public static void validateCompositeData(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
if (!isTypeMatched(monitorInfoCompositeType, cd.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for MonitorInfo");
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -5825215591822908529L;
|
||||
}
|
||||
198
jdkSrc/jdk8/sun/management/NotificationEmitterSupport.java
Normal file
198
jdkSrc/jdk8/sun/management/NotificationEmitterSupport.java
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import javax.management.ListenerNotFoundException;
|
||||
import javax.management.MBeanNotificationInfo;
|
||||
import javax.management.Notification;
|
||||
import javax.management.NotificationEmitter;
|
||||
import javax.management.NotificationFilter;
|
||||
import javax.management.NotificationListener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Abstract helper class for notification emitter support.
|
||||
*/
|
||||
abstract class NotificationEmitterSupport implements NotificationEmitter {
|
||||
|
||||
protected NotificationEmitterSupport() {
|
||||
}
|
||||
|
||||
private Object listenerLock = new Object();
|
||||
|
||||
// Implementation of NotificationEmitter interface
|
||||
// Cloned from JMX NotificationBroadcasterSupport class.
|
||||
public void addNotificationListener(NotificationListener listener,
|
||||
NotificationFilter filter,
|
||||
Object handback) {
|
||||
|
||||
if (listener == null) {
|
||||
throw new IllegalArgumentException ("Listener can't be null") ;
|
||||
}
|
||||
|
||||
/* Adding a new listener takes O(n) time where n is the number
|
||||
of existing listeners. If you have a very large number of
|
||||
listeners performance could degrade. That's a fairly
|
||||
surprising configuration, and it is hard to avoid this
|
||||
behaviour while still retaining the property that the
|
||||
listenerList is not synchronized while notifications are
|
||||
being sent through it. If this becomes a problem, a
|
||||
possible solution would be a multiple-readers single-writer
|
||||
setup, so any number of sendNotification() calls could run
|
||||
concurrently but they would exclude an
|
||||
add/removeNotificationListener. A simpler but less
|
||||
efficient solution would be to clone the listener list
|
||||
every time a notification is sent. */
|
||||
synchronized (listenerLock) {
|
||||
List<ListenerInfo> newList = new ArrayList<>(listenerList.size() + 1);
|
||||
newList.addAll(listenerList);
|
||||
newList.add(new ListenerInfo(listener, filter, handback));
|
||||
listenerList = newList;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeNotificationListener(NotificationListener listener)
|
||||
throws ListenerNotFoundException {
|
||||
|
||||
synchronized (listenerLock) {
|
||||
List<ListenerInfo> newList = new ArrayList<>(listenerList);
|
||||
/* We scan the list of listeners in reverse order because
|
||||
in forward order we would have to repeat the loop with
|
||||
the same index after a remove. */
|
||||
for (int i=newList.size()-1; i>=0; i--) {
|
||||
ListenerInfo li = newList.get(i);
|
||||
|
||||
if (li.listener == listener)
|
||||
newList.remove(i);
|
||||
}
|
||||
if (newList.size() == listenerList.size())
|
||||
throw new ListenerNotFoundException("Listener not registered");
|
||||
listenerList = newList;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeNotificationListener(NotificationListener listener,
|
||||
NotificationFilter filter,
|
||||
Object handback)
|
||||
throws ListenerNotFoundException {
|
||||
|
||||
boolean found = false;
|
||||
|
||||
synchronized (listenerLock) {
|
||||
List<ListenerInfo> newList = new ArrayList<>(listenerList);
|
||||
final int size = newList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
ListenerInfo li = newList.get(i);
|
||||
|
||||
if (li.listener == listener) {
|
||||
found = true;
|
||||
if (li.filter == filter
|
||||
&& li.handback == handback) {
|
||||
newList.remove(i);
|
||||
listenerList = newList;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
/* We found this listener, but not with the given filter
|
||||
* and handback. A more informative exception message may
|
||||
* make debugging easier. */
|
||||
throw new ListenerNotFoundException("Listener not registered " +
|
||||
"with this filter and " +
|
||||
"handback");
|
||||
} else {
|
||||
throw new ListenerNotFoundException("Listener not registered");
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotification(Notification notification) {
|
||||
|
||||
if (notification == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ListenerInfo> currentList;
|
||||
synchronized (listenerLock) {
|
||||
currentList = listenerList;
|
||||
}
|
||||
|
||||
final int size = currentList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
ListenerInfo li = currentList.get(i);
|
||||
|
||||
if (li.filter == null
|
||||
|| li.filter.isNotificationEnabled(notification)) {
|
||||
try {
|
||||
li.listener.handleNotification(notification, li.handback);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new AssertionError("Error in invoking listener");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasListeners() {
|
||||
synchronized (listenerLock) {
|
||||
return !listenerList.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
private class ListenerInfo {
|
||||
public NotificationListener listener;
|
||||
NotificationFilter filter;
|
||||
Object handback;
|
||||
|
||||
public ListenerInfo(NotificationListener listener,
|
||||
NotificationFilter filter,
|
||||
Object handback) {
|
||||
this.listener = listener;
|
||||
this.filter = filter;
|
||||
this.handback = handback;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Current list of listeners, a List of ListenerInfo. The object
|
||||
* referenced by this field is never modified. Instead, the field
|
||||
* is set to a new object when a listener is added or removed,
|
||||
* within a synchronized(this). In this way, there is no need to
|
||||
* synchronize when traversing the list to send a notification to
|
||||
* the listeners in it. That avoids potential deadlocks if the
|
||||
* listeners end up depending on other threads that are themselves
|
||||
* accessing this NotificationBroadcasterSupport.
|
||||
*/
|
||||
private List<ListenerInfo> listenerList = Collections.emptyList();
|
||||
|
||||
abstract public MBeanNotificationInfo[] getNotificationInfo();
|
||||
}
|
||||
97
jdkSrc/jdk8/sun/management/OperatingSystemImpl.java
Normal file
97
jdkSrc/jdk8/sun/management/OperatingSystemImpl.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
|
||||
/**
|
||||
* Implementation class for the operating system.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getOperatingSystemMXBean() returns an instance
|
||||
* of this class.
|
||||
*/
|
||||
class OperatingSystemImpl extends BaseOperatingSystemImpl
|
||||
implements OperatingSystemMXBean {
|
||||
|
||||
// psapiLock is a lock to make sure only one thread loading
|
||||
// PSAPI DLL.
|
||||
private static Object psapiLock = new Object();
|
||||
|
||||
OperatingSystemImpl(VMManagement vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
public long getCommittedVirtualMemorySize() {
|
||||
synchronized (psapiLock) {
|
||||
return getCommittedVirtualMemorySize0();
|
||||
}
|
||||
}
|
||||
|
||||
public long getTotalSwapSpaceSize() {
|
||||
return getTotalSwapSpaceSize0();
|
||||
}
|
||||
|
||||
public long getFreeSwapSpaceSize() {
|
||||
return getFreeSwapSpaceSize0();
|
||||
}
|
||||
|
||||
public long getProcessCpuTime() {
|
||||
return getProcessCpuTime0();
|
||||
}
|
||||
|
||||
public long getFreePhysicalMemorySize() {
|
||||
return getFreePhysicalMemorySize0();
|
||||
}
|
||||
|
||||
public long getTotalPhysicalMemorySize() {
|
||||
return getTotalPhysicalMemorySize0();
|
||||
}
|
||||
|
||||
public double getSystemCpuLoad() {
|
||||
return getSystemCpuLoad0();
|
||||
}
|
||||
|
||||
public double getProcessCpuLoad() {
|
||||
return getProcessCpuLoad0();
|
||||
}
|
||||
|
||||
/* native methods */
|
||||
private native long getCommittedVirtualMemorySize0();
|
||||
private native long getFreePhysicalMemorySize0();
|
||||
private native long getFreeSwapSpaceSize0();
|
||||
private native double getProcessCpuLoad0();
|
||||
private native long getProcessCpuTime0();
|
||||
private native double getSystemCpuLoad0();
|
||||
private native long getTotalPhysicalMemorySize0();
|
||||
private native long getTotalSwapSpaceSize0();
|
||||
|
||||
static {
|
||||
initialize0();
|
||||
}
|
||||
|
||||
private static native void initialize0();
|
||||
}
|
||||
144
jdkSrc/jdk8/sun/management/RuntimeImpl.java
Normal file
144
jdkSrc/jdk8/sun/management/RuntimeImpl.java
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Properties;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* Implementation class for the runtime subsystem.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getRuntimeMXBean() returns an instance
|
||||
* of this class.
|
||||
*/
|
||||
class RuntimeImpl implements RuntimeMXBean {
|
||||
|
||||
private final VMManagement jvm;
|
||||
private final long vmStartupTime;
|
||||
|
||||
/**
|
||||
* Constructor of RuntimeImpl class.
|
||||
*/
|
||||
RuntimeImpl(VMManagement vm) {
|
||||
this.jvm = vm;
|
||||
this.vmStartupTime = jvm.getStartupTime();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return jvm.getVmId();
|
||||
}
|
||||
|
||||
public String getManagementSpecVersion() {
|
||||
return jvm.getManagementVersion();
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return jvm.getVmName();
|
||||
}
|
||||
|
||||
public String getVmVendor() {
|
||||
return jvm.getVmVendor();
|
||||
}
|
||||
|
||||
public String getVmVersion() {
|
||||
return jvm.getVmVersion();
|
||||
}
|
||||
|
||||
public String getSpecName() {
|
||||
return jvm.getVmSpecName();
|
||||
}
|
||||
|
||||
public String getSpecVendor() {
|
||||
return jvm.getVmSpecVendor();
|
||||
}
|
||||
|
||||
public String getSpecVersion() {
|
||||
return jvm.getVmSpecVersion();
|
||||
}
|
||||
|
||||
public String getClassPath() {
|
||||
return jvm.getClassPath();
|
||||
}
|
||||
|
||||
public String getLibraryPath() {
|
||||
return jvm.getLibraryPath();
|
||||
}
|
||||
|
||||
public String getBootClassPath() {
|
||||
if (!isBootClassPathSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Boot class path mechanism is not supported");
|
||||
}
|
||||
Util.checkMonitorAccess();
|
||||
return jvm.getBootClassPath();
|
||||
}
|
||||
|
||||
public List<String> getInputArguments() {
|
||||
Util.checkMonitorAccess();
|
||||
return jvm.getVmArguments();
|
||||
}
|
||||
|
||||
public long getUptime() {
|
||||
return jvm.getUptime();
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return vmStartupTime;
|
||||
}
|
||||
|
||||
public boolean isBootClassPathSupported() {
|
||||
return jvm.isBootClassPathSupported();
|
||||
}
|
||||
|
||||
public Map<String,String> getSystemProperties() {
|
||||
Properties sysProps = System.getProperties();
|
||||
Map<String,String> map = new HashMap<>();
|
||||
|
||||
// Properties.entrySet() does not include the entries in
|
||||
// the default properties. So use Properties.stringPropertyNames()
|
||||
// to get the list of property keys including the default ones.
|
||||
Set<String> keys = sysProps.stringPropertyNames();
|
||||
for (String k : keys) {
|
||||
String value = sysProps.getProperty(k);
|
||||
map.put(k, value);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
172
jdkSrc/jdk8/sun/management/Sensor.java
Normal file
172
jdkSrc/jdk8/sun/management/Sensor.java
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* An abstract sensor.
|
||||
*
|
||||
* <p>
|
||||
* A <tt>AbstractSensor</tt> object consists of two attributes:
|
||||
* <ul>
|
||||
* <li><tt>on</tt> is a boolean flag indicating if a sensor is
|
||||
* triggered. This flag will be set or cleared by the
|
||||
* component that owns the sensor.</li>
|
||||
* <li><tt>count</tt> is the total number of times that a sensor
|
||||
* has been triggered.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Mandy Chung
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public abstract class Sensor {
|
||||
private Object lock;
|
||||
private String name;
|
||||
private long count;
|
||||
private boolean on;
|
||||
|
||||
/**
|
||||
* Constructs a <tt>Sensor</tt> object.
|
||||
*
|
||||
* @param name The name of this sensor.
|
||||
*/
|
||||
public Sensor(String name) {
|
||||
this.name = name;
|
||||
this.count = 0;
|
||||
this.on = false;
|
||||
this.lock = new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this sensor.
|
||||
*
|
||||
* @return the name of this sensor.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of times that this sensor has been triggered.
|
||||
*
|
||||
* @return the total number of times that this sensor has been triggered.
|
||||
*/
|
||||
public long getCount() {
|
||||
synchronized (lock) {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if this sensor is currently on.
|
||||
*
|
||||
* @return <tt>true</tt> if the sensor is currently on;
|
||||
* <tt>false</tt> otherwise.
|
||||
*
|
||||
*/
|
||||
public boolean isOn() {
|
||||
synchronized (lock) {
|
||||
return on;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers this sensor. This method first sets this sensor on
|
||||
* and increments its sensor count.
|
||||
*/
|
||||
public void trigger() {
|
||||
synchronized (lock) {
|
||||
on = true;
|
||||
count++;
|
||||
}
|
||||
triggerAction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers this sensor. This method sets this sensor on
|
||||
* and increments the count with the input <tt>increment</tt>.
|
||||
*/
|
||||
public void trigger(int increment) {
|
||||
synchronized (lock) {
|
||||
on = true;
|
||||
count += increment;
|
||||
// Do something here...
|
||||
}
|
||||
triggerAction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers this sensor piggybacking a memory usage object.
|
||||
* This method sets this sensor on
|
||||
* and increments the count with the input <tt>increment</tt>.
|
||||
*/
|
||||
public void trigger(int increment, MemoryUsage usage) {
|
||||
synchronized (lock) {
|
||||
on = true;
|
||||
count += increment;
|
||||
// Do something here...
|
||||
}
|
||||
triggerAction(usage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears this sensor.
|
||||
*/
|
||||
public void clear() {
|
||||
synchronized (lock) {
|
||||
on = false;
|
||||
}
|
||||
clearAction();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears this sensor
|
||||
* and increments the count with the input <tt>increment</tt>.
|
||||
*/
|
||||
public void clear(int increment) {
|
||||
synchronized (lock) {
|
||||
on = false;
|
||||
count += increment;
|
||||
}
|
||||
clearAction();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Sensor - " + getName() +
|
||||
(isOn() ? " on " : " off ") +
|
||||
" count = " + getCount();
|
||||
}
|
||||
|
||||
abstract void triggerAction();
|
||||
abstract void triggerAction(MemoryUsage u);
|
||||
abstract void clearAction();
|
||||
}
|
||||
125
jdkSrc/jdk8/sun/management/StackTraceElementCompositeData.java
Normal file
125
jdkSrc/jdk8/sun/management/StackTraceElementCompositeData.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
|
||||
/**
|
||||
* A CompositeData for StackTraceElement for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class StackTraceElementCompositeData extends LazyCompositeData {
|
||||
private final StackTraceElement ste;
|
||||
|
||||
private StackTraceElementCompositeData(StackTraceElement ste) {
|
||||
this.ste = ste;
|
||||
}
|
||||
|
||||
public StackTraceElement getStackTraceElement() {
|
||||
return ste;
|
||||
}
|
||||
|
||||
public static StackTraceElement from(CompositeData cd) {
|
||||
validateCompositeData(cd);
|
||||
|
||||
return new StackTraceElement(getString(cd, CLASS_NAME),
|
||||
getString(cd, METHOD_NAME),
|
||||
getString(cd, FILE_NAME),
|
||||
getInt(cd, LINE_NUMBER));
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(StackTraceElement ste) {
|
||||
StackTraceElementCompositeData cd = new StackTraceElementCompositeData(ste);
|
||||
return cd.getCompositeData();
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// stackTraceElementItemNames!
|
||||
final Object[] stackTraceElementItemValues = {
|
||||
ste.getClassName(),
|
||||
ste.getMethodName(),
|
||||
ste.getFileName(),
|
||||
new Integer(ste.getLineNumber()),
|
||||
new Boolean(ste.isNativeMethod()),
|
||||
};
|
||||
try {
|
||||
return new CompositeDataSupport(stackTraceElementCompositeType,
|
||||
stackTraceElementItemNames,
|
||||
stackTraceElementItemValues);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final CompositeType stackTraceElementCompositeType;
|
||||
static {
|
||||
try {
|
||||
stackTraceElementCompositeType = (CompositeType)
|
||||
MappedMXBeanType.toOpenType(StackTraceElement.class);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
// Attribute names
|
||||
private static final String CLASS_NAME = "className";
|
||||
private static final String METHOD_NAME = "methodName";
|
||||
private static final String FILE_NAME = "fileName";
|
||||
private static final String LINE_NUMBER = "lineNumber";
|
||||
private static final String NATIVE_METHOD = "nativeMethod";
|
||||
|
||||
private static final String[] stackTraceElementItemNames = {
|
||||
CLASS_NAME,
|
||||
METHOD_NAME,
|
||||
FILE_NAME,
|
||||
LINE_NUMBER,
|
||||
NATIVE_METHOD,
|
||||
};
|
||||
|
||||
/** Validate if the input CompositeData has the expected
|
||||
* CompositeType (i.e. contain all attributes with expected
|
||||
* names and types).
|
||||
*/
|
||||
public static void validateCompositeData(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
if (!isTypeMatched(stackTraceElementCompositeType, cd.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for StackTraceElement");
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -2704607706598396827L;
|
||||
}
|
||||
536
jdkSrc/jdk8/sun/management/ThreadImpl.java
Normal file
536
jdkSrc/jdk8/sun/management/ThreadImpl.java
Normal file
@@ -0,0 +1,536 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
import java.lang.management.ThreadInfo;
|
||||
|
||||
import javax.management.ObjectName;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Implementation class for the thread subsystem.
|
||||
* Standard and committed hotspot-specific metrics if any.
|
||||
*
|
||||
* ManagementFactory.getThreadMXBean() returns an instance
|
||||
* of this class.
|
||||
*/
|
||||
class ThreadImpl implements com.sun.management.ThreadMXBean {
|
||||
|
||||
private final VMManagement jvm;
|
||||
|
||||
// default for thread contention monitoring is disabled.
|
||||
private boolean contentionMonitoringEnabled = false;
|
||||
private boolean cpuTimeEnabled;
|
||||
private boolean allocatedMemoryEnabled;
|
||||
|
||||
/**
|
||||
* Constructor of ThreadImpl class.
|
||||
*/
|
||||
ThreadImpl(VMManagement vm) {
|
||||
this.jvm = vm;
|
||||
this.cpuTimeEnabled = jvm.isThreadCpuTimeEnabled();
|
||||
this.allocatedMemoryEnabled = jvm.isThreadAllocatedMemoryEnabled();
|
||||
}
|
||||
|
||||
public int getThreadCount() {
|
||||
return jvm.getLiveThreadCount();
|
||||
}
|
||||
|
||||
public int getPeakThreadCount() {
|
||||
return jvm.getPeakThreadCount();
|
||||
}
|
||||
|
||||
public long getTotalStartedThreadCount() {
|
||||
return jvm.getTotalThreadCount();
|
||||
}
|
||||
|
||||
public int getDaemonThreadCount() {
|
||||
return jvm.getDaemonThreadCount();
|
||||
}
|
||||
|
||||
public boolean isThreadContentionMonitoringSupported() {
|
||||
return jvm.isThreadContentionMonitoringSupported();
|
||||
}
|
||||
|
||||
public synchronized boolean isThreadContentionMonitoringEnabled() {
|
||||
if (!isThreadContentionMonitoringSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Thread contention monitoring is not supported.");
|
||||
}
|
||||
return contentionMonitoringEnabled;
|
||||
}
|
||||
|
||||
public boolean isThreadCpuTimeSupported() {
|
||||
return jvm.isOtherThreadCpuTimeSupported();
|
||||
}
|
||||
|
||||
public boolean isCurrentThreadCpuTimeSupported() {
|
||||
return jvm.isCurrentThreadCpuTimeSupported();
|
||||
}
|
||||
|
||||
public boolean isThreadAllocatedMemorySupported() {
|
||||
return jvm.isThreadAllocatedMemorySupported();
|
||||
}
|
||||
|
||||
public boolean isThreadCpuTimeEnabled() {
|
||||
if (!isThreadCpuTimeSupported() &&
|
||||
!isCurrentThreadCpuTimeSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Thread CPU time measurement is not supported");
|
||||
}
|
||||
return cpuTimeEnabled;
|
||||
}
|
||||
|
||||
private void ensureThreadAllocatedMemorySupported() {
|
||||
if (!isThreadAllocatedMemorySupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Thread allocated memory measurement is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isThreadAllocatedMemoryEnabled() {
|
||||
ensureThreadAllocatedMemorySupported();
|
||||
return allocatedMemoryEnabled;
|
||||
}
|
||||
|
||||
public long[] getAllThreadIds() {
|
||||
Util.checkMonitorAccess();
|
||||
|
||||
Thread[] threads = getThreads();
|
||||
int length = threads.length;
|
||||
long[] ids = new long[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
Thread t = threads[i];
|
||||
ids[i] = t.getId();
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public ThreadInfo getThreadInfo(long id) {
|
||||
long[] ids = new long[1];
|
||||
ids[0] = id;
|
||||
final ThreadInfo[] infos = getThreadInfo(ids, 0);
|
||||
return infos[0];
|
||||
}
|
||||
|
||||
public ThreadInfo getThreadInfo(long id, int maxDepth) {
|
||||
long[] ids = new long[1];
|
||||
ids[0] = id;
|
||||
final ThreadInfo[] infos = getThreadInfo(ids, maxDepth);
|
||||
return infos[0];
|
||||
}
|
||||
|
||||
public ThreadInfo[] getThreadInfo(long[] ids) {
|
||||
return getThreadInfo(ids, 0);
|
||||
}
|
||||
|
||||
private void verifyThreadId(long id) {
|
||||
if (id <= 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid thread ID parameter: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyThreadIds(long[] ids) {
|
||||
Objects.requireNonNull(ids);
|
||||
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
verifyThreadId(ids[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) {
|
||||
verifyThreadIds(ids);
|
||||
|
||||
if (maxDepth < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid maxDepth parameter: " + maxDepth);
|
||||
}
|
||||
|
||||
// ids has been verified to be non-null
|
||||
// an empty array of ids should return an empty array of ThreadInfos
|
||||
if (ids.length == 0) return new ThreadInfo[0];
|
||||
|
||||
Util.checkMonitorAccess();
|
||||
|
||||
ThreadInfo[] infos = new ThreadInfo[ids.length]; // nulls
|
||||
if (maxDepth == Integer.MAX_VALUE) {
|
||||
getThreadInfo1(ids, -1, infos);
|
||||
} else {
|
||||
getThreadInfo1(ids, maxDepth, infos);
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
public void setThreadContentionMonitoringEnabled(boolean enable) {
|
||||
if (!isThreadContentionMonitoringSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Thread contention monitoring is not supported");
|
||||
}
|
||||
|
||||
Util.checkControlAccess();
|
||||
|
||||
synchronized (this) {
|
||||
if (contentionMonitoringEnabled != enable) {
|
||||
if (enable) {
|
||||
// if reeabled, reset contention time statistics
|
||||
// for all threads
|
||||
resetContentionTimes0(0);
|
||||
}
|
||||
|
||||
// update the VM of the state change
|
||||
setThreadContentionMonitoringEnabled0(enable);
|
||||
|
||||
contentionMonitoringEnabled = enable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean verifyCurrentThreadCpuTime() {
|
||||
// check if Thread CPU time measurement is supported.
|
||||
if (!isCurrentThreadCpuTimeSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Current thread CPU time measurement is not supported.");
|
||||
}
|
||||
return isThreadCpuTimeEnabled();
|
||||
}
|
||||
|
||||
public long getCurrentThreadCpuTime() {
|
||||
if (verifyCurrentThreadCpuTime()) {
|
||||
return getThreadTotalCpuTime0(0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public long getThreadCpuTime(long id) {
|
||||
long[] ids = new long[1];
|
||||
ids[0] = id;
|
||||
final long[] times = getThreadCpuTime(ids);
|
||||
return times[0];
|
||||
}
|
||||
|
||||
private boolean verifyThreadCpuTime(long[] ids) {
|
||||
verifyThreadIds(ids);
|
||||
|
||||
// check if Thread CPU time measurement is supported.
|
||||
if (!isThreadCpuTimeSupported() &&
|
||||
!isCurrentThreadCpuTimeSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Thread CPU time measurement is not supported.");
|
||||
}
|
||||
|
||||
if (!isThreadCpuTimeSupported()) {
|
||||
// support current thread only
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
if (ids[i] != Thread.currentThread().getId()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Thread CPU time measurement is only supported" +
|
||||
" for the current thread.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isThreadCpuTimeEnabled();
|
||||
}
|
||||
|
||||
public long[] getThreadCpuTime(long[] ids) {
|
||||
boolean verified = verifyThreadCpuTime(ids);
|
||||
|
||||
int length = ids.length;
|
||||
long[] times = new long[length];
|
||||
java.util.Arrays.fill(times, -1);
|
||||
|
||||
if (verified) {
|
||||
if (length == 1) {
|
||||
long id = ids[0];
|
||||
if (id == Thread.currentThread().getId()) {
|
||||
id = 0;
|
||||
}
|
||||
times[0] = getThreadTotalCpuTime0(id);
|
||||
} else {
|
||||
getThreadTotalCpuTime1(ids, times);
|
||||
}
|
||||
}
|
||||
return times;
|
||||
}
|
||||
|
||||
public long getCurrentThreadUserTime() {
|
||||
if (verifyCurrentThreadCpuTime()) {
|
||||
return getThreadUserCpuTime0(0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public long getThreadUserTime(long id) {
|
||||
long[] ids = new long[1];
|
||||
ids[0] = id;
|
||||
final long[] times = getThreadUserTime(ids);
|
||||
return times[0];
|
||||
}
|
||||
|
||||
public long[] getThreadUserTime(long[] ids) {
|
||||
boolean verified = verifyThreadCpuTime(ids);
|
||||
|
||||
int length = ids.length;
|
||||
long[] times = new long[length];
|
||||
java.util.Arrays.fill(times, -1);
|
||||
|
||||
if (verified) {
|
||||
if (length == 1) {
|
||||
long id = ids[0];
|
||||
if (id == Thread.currentThread().getId()) {
|
||||
id = 0;
|
||||
}
|
||||
times[0] = getThreadUserCpuTime0(id);
|
||||
} else {
|
||||
getThreadUserCpuTime1(ids, times);
|
||||
}
|
||||
}
|
||||
return times;
|
||||
}
|
||||
|
||||
public void setThreadCpuTimeEnabled(boolean enable) {
|
||||
if (!isThreadCpuTimeSupported() &&
|
||||
!isCurrentThreadCpuTimeSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Thread CPU time measurement is not supported");
|
||||
}
|
||||
|
||||
Util.checkControlAccess();
|
||||
synchronized (this) {
|
||||
if (cpuTimeEnabled != enable) {
|
||||
// notify VM of the state change
|
||||
setThreadCpuTimeEnabled0(enable);
|
||||
cpuTimeEnabled = enable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long getTotalThreadAllocatedBytes() {
|
||||
if (isThreadAllocatedMemoryEnabled()) {
|
||||
return getTotalThreadAllocatedMemory();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public long getCurrentThreadAllocatedBytes() {
|
||||
if (isThreadAllocatedMemoryEnabled()) {
|
||||
return getThreadAllocatedMemory0(0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean verifyThreadAllocatedMemory(long id) {
|
||||
verifyThreadId(id);
|
||||
return isThreadAllocatedMemoryEnabled();
|
||||
}
|
||||
|
||||
public long getThreadAllocatedBytes(long id) {
|
||||
boolean verified = verifyThreadAllocatedMemory(id);
|
||||
|
||||
if (verified) {
|
||||
return getThreadAllocatedMemory0(
|
||||
Thread.currentThread().getId() == id ? 0 : id);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean verifyThreadAllocatedMemory(long[] ids) {
|
||||
verifyThreadIds(ids);
|
||||
return isThreadAllocatedMemoryEnabled();
|
||||
}
|
||||
|
||||
public long[] getThreadAllocatedBytes(long[] ids) {
|
||||
Objects.requireNonNull(ids);
|
||||
|
||||
if (ids.length == 1) {
|
||||
long size = getThreadAllocatedBytes(ids[0]);
|
||||
return new long[] { size };
|
||||
}
|
||||
|
||||
boolean verified = verifyThreadAllocatedMemory(ids);
|
||||
|
||||
long[] sizes = new long[ids.length];
|
||||
java.util.Arrays.fill(sizes, -1);
|
||||
|
||||
if (verified) {
|
||||
getThreadAllocatedMemory1(ids, sizes);
|
||||
}
|
||||
return sizes;
|
||||
}
|
||||
|
||||
public void setThreadAllocatedMemoryEnabled(boolean enable) {
|
||||
ensureThreadAllocatedMemorySupported();
|
||||
|
||||
Util.checkControlAccess();
|
||||
synchronized (this) {
|
||||
if (allocatedMemoryEnabled != enable) {
|
||||
// notify VM of the state change
|
||||
setThreadAllocatedMemoryEnabled0(enable);
|
||||
allocatedMemoryEnabled = enable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long[] findMonitorDeadlockedThreads() {
|
||||
Util.checkMonitorAccess();
|
||||
|
||||
Thread[] threads = findMonitorDeadlockedThreads0();
|
||||
if (threads == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
long[] ids = new long[threads.length];
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
Thread t = threads[i];
|
||||
ids[i] = t.getId();
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public long[] findDeadlockedThreads() {
|
||||
if (!isSynchronizerUsageSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Monitoring of Synchronizer Usage is not supported.");
|
||||
}
|
||||
|
||||
Util.checkMonitorAccess();
|
||||
|
||||
Thread[] threads = findDeadlockedThreads0();
|
||||
if (threads == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
long[] ids = new long[threads.length];
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
Thread t = threads[i];
|
||||
ids[i] = t.getId();
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void resetPeakThreadCount() {
|
||||
Util.checkControlAccess();
|
||||
resetPeakThreadCount0();
|
||||
}
|
||||
|
||||
public boolean isObjectMonitorUsageSupported() {
|
||||
return jvm.isObjectMonitorUsageSupported();
|
||||
}
|
||||
|
||||
public boolean isSynchronizerUsageSupported() {
|
||||
return jvm.isSynchronizerUsageSupported();
|
||||
}
|
||||
|
||||
private void verifyDumpThreads(boolean lockedMonitors,
|
||||
boolean lockedSynchronizers) {
|
||||
if (lockedMonitors && !isObjectMonitorUsageSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Monitoring of Object Monitor Usage is not supported.");
|
||||
}
|
||||
|
||||
if (lockedSynchronizers && !isSynchronizerUsageSupported()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Monitoring of Synchronizer Usage is not supported.");
|
||||
}
|
||||
|
||||
Util.checkMonitorAccess();
|
||||
}
|
||||
|
||||
public ThreadInfo[] getThreadInfo(long[] ids,
|
||||
boolean lockedMonitors,
|
||||
boolean lockedSynchronizers) {
|
||||
return dumpThreads0(ids, lockedMonitors, lockedSynchronizers,
|
||||
Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public ThreadInfo[] getThreadInfo(long[] ids,
|
||||
boolean lockedMonitors,
|
||||
boolean lockedSynchronizers,
|
||||
int maxDepth) {
|
||||
if (maxDepth < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid maxDepth parameter: " + maxDepth);
|
||||
}
|
||||
verifyThreadIds(ids);
|
||||
// ids has been verified to be non-null
|
||||
// an empty array of ids should return an empty array of ThreadInfos
|
||||
if (ids.length == 0) return new ThreadInfo[0];
|
||||
|
||||
verifyDumpThreads(lockedMonitors, lockedSynchronizers);
|
||||
return dumpThreads0(ids, lockedMonitors, lockedSynchronizers, maxDepth);
|
||||
}
|
||||
|
||||
public ThreadInfo[] dumpAllThreads(boolean lockedMonitors,
|
||||
boolean lockedSynchronizers) {
|
||||
return dumpAllThreads(lockedMonitors, lockedSynchronizers,
|
||||
Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public ThreadInfo[] dumpAllThreads(boolean lockedMonitors,
|
||||
boolean lockedSynchronizers,
|
||||
int maxDepth) {
|
||||
if (maxDepth < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid maxDepth parameter: " + maxDepth);
|
||||
}
|
||||
verifyDumpThreads(lockedMonitors, lockedSynchronizers);
|
||||
return dumpThreads0(null, lockedMonitors, lockedSynchronizers, maxDepth);
|
||||
}
|
||||
|
||||
// VM support where maxDepth == -1 to request entire stack dump
|
||||
private static native Thread[] getThreads();
|
||||
private static native void getThreadInfo1(long[] ids,
|
||||
int maxDepth,
|
||||
ThreadInfo[] result);
|
||||
private static native long getThreadTotalCpuTime0(long id);
|
||||
private static native void getThreadTotalCpuTime1(long[] ids, long[] result);
|
||||
private static native long getThreadUserCpuTime0(long id);
|
||||
private static native void getThreadUserCpuTime1(long[] ids, long[] result);
|
||||
private static native long getThreadAllocatedMemory0(long id);
|
||||
private static native void getThreadAllocatedMemory1(long[] ids, long[] result);
|
||||
private static native long getTotalThreadAllocatedMemory();
|
||||
private static native void setThreadCpuTimeEnabled0(boolean enable);
|
||||
private static native void setThreadAllocatedMemoryEnabled0(boolean enable);
|
||||
private static native void setThreadContentionMonitoringEnabled0(boolean enable);
|
||||
private static native Thread[] findMonitorDeadlockedThreads0();
|
||||
private static native Thread[] findDeadlockedThreads0();
|
||||
private static native void resetPeakThreadCount0();
|
||||
private static native ThreadInfo[] dumpThreads0(long[] ids,
|
||||
boolean lockedMonitors,
|
||||
boolean lockedSynchronizers,
|
||||
int maxDepth);
|
||||
|
||||
// tid == 0 to reset contention times for all threads
|
||||
private static native void resetContentionTimes0(long tid);
|
||||
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
424
jdkSrc/jdk8/sun/management/ThreadInfoCompositeData.java
Normal file
424
jdkSrc/jdk8/sun/management/ThreadInfoCompositeData.java
Normal file
@@ -0,0 +1,424 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.ThreadInfo;
|
||||
import java.lang.management.MonitorInfo;
|
||||
import java.lang.management.LockInfo;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.OpenType;
|
||||
|
||||
/**
|
||||
* A CompositeData for ThreadInfo for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
private final ThreadInfo threadInfo;
|
||||
private final CompositeData cdata;
|
||||
private final boolean currentVersion;
|
||||
|
||||
private ThreadInfoCompositeData(ThreadInfo ti) {
|
||||
this.threadInfo = ti;
|
||||
this.currentVersion = true;
|
||||
this.cdata = null;
|
||||
}
|
||||
|
||||
private ThreadInfoCompositeData(CompositeData cd) {
|
||||
this.threadInfo = null;
|
||||
this.currentVersion = ThreadInfoCompositeData.isCurrentVersion(cd);
|
||||
this.cdata = cd;
|
||||
}
|
||||
|
||||
public ThreadInfo getThreadInfo() {
|
||||
return threadInfo;
|
||||
}
|
||||
|
||||
public boolean isCurrentVersion() {
|
||||
return currentVersion;
|
||||
}
|
||||
|
||||
public static ThreadInfoCompositeData getInstance(CompositeData cd) {
|
||||
validateCompositeData(cd);
|
||||
return new ThreadInfoCompositeData(cd);
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(ThreadInfo ti) {
|
||||
ThreadInfoCompositeData ticd = new ThreadInfoCompositeData(ti);
|
||||
return ticd.getCompositeData();
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// Convert StackTraceElement[] to CompositeData[]
|
||||
StackTraceElement[] stackTrace = threadInfo.getStackTrace();
|
||||
CompositeData[] stackTraceData =
|
||||
new CompositeData[stackTrace.length];
|
||||
for (int i = 0; i < stackTrace.length; i++) {
|
||||
StackTraceElement ste = stackTrace[i];
|
||||
stackTraceData[i] = StackTraceElementCompositeData.toCompositeData(ste);
|
||||
}
|
||||
|
||||
// Convert MonitorInfo[] and LockInfo[] to CompositeData[]
|
||||
CompositeData lockInfoData =
|
||||
LockInfoCompositeData.toCompositeData(threadInfo.getLockInfo());
|
||||
|
||||
// Convert LockInfo[] and MonitorInfo[] to CompositeData[]
|
||||
LockInfo[] lockedSyncs = threadInfo.getLockedSynchronizers();
|
||||
CompositeData[] lockedSyncsData =
|
||||
new CompositeData[lockedSyncs.length];
|
||||
for (int i = 0; i < lockedSyncs.length; i++) {
|
||||
LockInfo li = lockedSyncs[i];
|
||||
lockedSyncsData[i] = LockInfoCompositeData.toCompositeData(li);
|
||||
}
|
||||
|
||||
MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors();
|
||||
CompositeData[] lockedMonitorsData =
|
||||
new CompositeData[lockedMonitors.length];
|
||||
for (int i = 0; i < lockedMonitors.length; i++) {
|
||||
MonitorInfo mi = lockedMonitors[i];
|
||||
lockedMonitorsData[i] = MonitorInfoCompositeData.toCompositeData(mi);
|
||||
}
|
||||
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// threadInfoItemNames!
|
||||
final Object[] threadInfoItemValues = {
|
||||
new Long(threadInfo.getThreadId()),
|
||||
threadInfo.getThreadName(),
|
||||
threadInfo.getThreadState().name(),
|
||||
new Long(threadInfo.getBlockedTime()),
|
||||
new Long(threadInfo.getBlockedCount()),
|
||||
new Long(threadInfo.getWaitedTime()),
|
||||
new Long(threadInfo.getWaitedCount()),
|
||||
lockInfoData,
|
||||
threadInfo.getLockName(),
|
||||
new Long(threadInfo.getLockOwnerId()),
|
||||
threadInfo.getLockOwnerName(),
|
||||
stackTraceData,
|
||||
new Boolean(threadInfo.isSuspended()),
|
||||
new Boolean(threadInfo.isInNative()),
|
||||
lockedMonitorsData,
|
||||
lockedSyncsData,
|
||||
};
|
||||
|
||||
try {
|
||||
return new CompositeDataSupport(threadInfoCompositeType,
|
||||
threadInfoItemNames,
|
||||
threadInfoItemValues);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
// Attribute names
|
||||
private static final String THREAD_ID = "threadId";
|
||||
private static final String THREAD_NAME = "threadName";
|
||||
private static final String THREAD_STATE = "threadState";
|
||||
private static final String BLOCKED_TIME = "blockedTime";
|
||||
private static final String BLOCKED_COUNT = "blockedCount";
|
||||
private static final String WAITED_TIME = "waitedTime";
|
||||
private static final String WAITED_COUNT = "waitedCount";
|
||||
private static final String LOCK_INFO = "lockInfo";
|
||||
private static final String LOCK_NAME = "lockName";
|
||||
private static final String LOCK_OWNER_ID = "lockOwnerId";
|
||||
private static final String LOCK_OWNER_NAME = "lockOwnerName";
|
||||
private static final String STACK_TRACE = "stackTrace";
|
||||
private static final String SUSPENDED = "suspended";
|
||||
private static final String IN_NATIVE = "inNative";
|
||||
private static final String LOCKED_MONITORS = "lockedMonitors";
|
||||
private static final String LOCKED_SYNCS = "lockedSynchronizers";
|
||||
|
||||
private static final String[] threadInfoItemNames = {
|
||||
THREAD_ID,
|
||||
THREAD_NAME,
|
||||
THREAD_STATE,
|
||||
BLOCKED_TIME,
|
||||
BLOCKED_COUNT,
|
||||
WAITED_TIME,
|
||||
WAITED_COUNT,
|
||||
LOCK_INFO,
|
||||
LOCK_NAME,
|
||||
LOCK_OWNER_ID,
|
||||
LOCK_OWNER_NAME,
|
||||
STACK_TRACE,
|
||||
SUSPENDED,
|
||||
IN_NATIVE,
|
||||
LOCKED_MONITORS,
|
||||
LOCKED_SYNCS,
|
||||
};
|
||||
|
||||
// New attributes added in 6.0 ThreadInfo
|
||||
private static final String[] threadInfoV6Attributes = {
|
||||
LOCK_INFO,
|
||||
LOCKED_MONITORS,
|
||||
LOCKED_SYNCS,
|
||||
};
|
||||
|
||||
// Current version of ThreadInfo
|
||||
private static final CompositeType threadInfoCompositeType;
|
||||
// Previous version of ThreadInfo
|
||||
private static final CompositeType threadInfoV5CompositeType;
|
||||
private static final CompositeType lockInfoCompositeType;
|
||||
static {
|
||||
try {
|
||||
threadInfoCompositeType = (CompositeType)
|
||||
MappedMXBeanType.toOpenType(ThreadInfo.class);
|
||||
// Form a CompositeType for JDK 5.0 ThreadInfo version
|
||||
String[] itemNames =
|
||||
threadInfoCompositeType.keySet().toArray(new String[0]);
|
||||
int numV5Attributes = threadInfoItemNames.length -
|
||||
threadInfoV6Attributes.length;
|
||||
String[] v5ItemNames = new String[numV5Attributes];
|
||||
String[] v5ItemDescs = new String[numV5Attributes];
|
||||
OpenType<?>[] v5ItemTypes = new OpenType<?>[numV5Attributes];
|
||||
int i = 0;
|
||||
for (String n : itemNames) {
|
||||
if (isV5Attribute(n)) {
|
||||
v5ItemNames[i] = n;
|
||||
v5ItemDescs[i] = threadInfoCompositeType.getDescription(n);
|
||||
v5ItemTypes[i] = threadInfoCompositeType.getType(n);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
threadInfoV5CompositeType =
|
||||
new CompositeType("java.lang.management.ThreadInfo",
|
||||
"J2SE 5.0 java.lang.management.ThreadInfo",
|
||||
v5ItemNames,
|
||||
v5ItemDescs,
|
||||
v5ItemTypes);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
||||
// Each CompositeData object has its CompositeType associated
|
||||
// with it. So we can get the CompositeType representing LockInfo
|
||||
// from a mapped CompositeData for any LockInfo object.
|
||||
// Thus we construct a random LockInfo object and pass it
|
||||
// to LockInfoCompositeData to do the conversion.
|
||||
Object o = new Object();
|
||||
LockInfo li = new LockInfo(o.getClass().getName(),
|
||||
System.identityHashCode(o));
|
||||
CompositeData cd = LockInfoCompositeData.toCompositeData(li);
|
||||
lockInfoCompositeType = cd.getCompositeType();
|
||||
}
|
||||
|
||||
private static boolean isV5Attribute(String itemName) {
|
||||
for (String n : threadInfoV6Attributes) {
|
||||
if (itemName.equals(n)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isCurrentVersion(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
return isTypeMatched(threadInfoCompositeType, cd.getCompositeType());
|
||||
}
|
||||
|
||||
public long threadId() {
|
||||
return getLong(cdata, THREAD_ID);
|
||||
}
|
||||
|
||||
public String threadName() {
|
||||
// The ThreadName item cannot be null so we check that
|
||||
// it is present with a non-null value.
|
||||
String name = getString(cdata, THREAD_NAME);
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Invalid composite data: " +
|
||||
"Attribute " + THREAD_NAME + " has null value");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public Thread.State threadState() {
|
||||
return Thread.State.valueOf(getString(cdata, THREAD_STATE));
|
||||
}
|
||||
|
||||
public long blockedTime() {
|
||||
return getLong(cdata, BLOCKED_TIME);
|
||||
}
|
||||
|
||||
public long blockedCount() {
|
||||
return getLong(cdata, BLOCKED_COUNT);
|
||||
}
|
||||
|
||||
public long waitedTime() {
|
||||
return getLong(cdata, WAITED_TIME);
|
||||
}
|
||||
|
||||
public long waitedCount() {
|
||||
return getLong(cdata, WAITED_COUNT);
|
||||
}
|
||||
|
||||
public String lockName() {
|
||||
// The LockName and LockOwnerName can legitimately be null,
|
||||
// we don't bother to check the value
|
||||
return getString(cdata, LOCK_NAME);
|
||||
}
|
||||
|
||||
public long lockOwnerId() {
|
||||
return getLong(cdata, LOCK_OWNER_ID);
|
||||
}
|
||||
|
||||
public String lockOwnerName() {
|
||||
return getString(cdata, LOCK_OWNER_NAME);
|
||||
}
|
||||
|
||||
public boolean suspended() {
|
||||
return getBoolean(cdata, SUSPENDED);
|
||||
}
|
||||
|
||||
public boolean inNative() {
|
||||
return getBoolean(cdata, IN_NATIVE);
|
||||
}
|
||||
|
||||
public StackTraceElement[] stackTrace() {
|
||||
CompositeData[] stackTraceData =
|
||||
(CompositeData[]) cdata.get(STACK_TRACE);
|
||||
|
||||
// The StackTrace item cannot be null, but if it is we will get
|
||||
// a NullPointerException when we ask for its length.
|
||||
StackTraceElement[] stackTrace =
|
||||
new StackTraceElement[stackTraceData.length];
|
||||
for (int i = 0; i < stackTraceData.length; i++) {
|
||||
CompositeData cdi = stackTraceData[i];
|
||||
stackTrace[i] = StackTraceElementCompositeData.from(cdi);
|
||||
}
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
// 6.0 new attributes
|
||||
public LockInfo lockInfo() {
|
||||
CompositeData lockInfoData = (CompositeData) cdata.get(LOCK_INFO);
|
||||
return LockInfo.from(lockInfoData);
|
||||
}
|
||||
|
||||
public MonitorInfo[] lockedMonitors() {
|
||||
CompositeData[] lockedMonitorsData =
|
||||
(CompositeData[]) cdata.get(LOCKED_MONITORS);
|
||||
|
||||
// The LockedMonitors item cannot be null, but if it is we will get
|
||||
// a NullPointerException when we ask for its length.
|
||||
MonitorInfo[] monitors =
|
||||
new MonitorInfo[lockedMonitorsData.length];
|
||||
for (int i = 0; i < lockedMonitorsData.length; i++) {
|
||||
CompositeData cdi = lockedMonitorsData[i];
|
||||
monitors[i] = MonitorInfo.from(cdi);
|
||||
}
|
||||
return monitors;
|
||||
}
|
||||
|
||||
public LockInfo[] lockedSynchronizers() {
|
||||
CompositeData[] lockedSyncsData =
|
||||
(CompositeData[]) cdata.get(LOCKED_SYNCS);
|
||||
|
||||
// The LockedSynchronizers item cannot be null, but if it is we will
|
||||
// get a NullPointerException when we ask for its length.
|
||||
LockInfo[] locks = new LockInfo[lockedSyncsData.length];
|
||||
for (int i = 0; i < lockedSyncsData.length; i++) {
|
||||
CompositeData cdi = lockedSyncsData[i];
|
||||
locks[i] = LockInfo.from(cdi);
|
||||
}
|
||||
return locks;
|
||||
}
|
||||
|
||||
/** Validate if the input CompositeData has the expected
|
||||
* CompositeType (i.e. contain all attributes with expected
|
||||
* names and types).
|
||||
*/
|
||||
public static void validateCompositeData(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
CompositeType type = cd.getCompositeType();
|
||||
boolean currentVersion = true;
|
||||
if (!isTypeMatched(threadInfoCompositeType, type)) {
|
||||
currentVersion = false;
|
||||
// check if cd is an older version
|
||||
if (!isTypeMatched(threadInfoV5CompositeType, type)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for ThreadInfo");
|
||||
}
|
||||
}
|
||||
|
||||
CompositeData[] stackTraceData =
|
||||
(CompositeData[]) cd.get(STACK_TRACE);
|
||||
if (stackTraceData == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"StackTraceElement[] is missing");
|
||||
}
|
||||
if (stackTraceData.length > 0) {
|
||||
StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
|
||||
}
|
||||
|
||||
// validate v6 attributes
|
||||
if (currentVersion) {
|
||||
CompositeData li = (CompositeData) cd.get(LOCK_INFO);
|
||||
if (li != null) {
|
||||
if (!isTypeMatched(lockInfoCompositeType,
|
||||
li.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for \"" +
|
||||
LOCK_INFO + "\" attribute.");
|
||||
}
|
||||
}
|
||||
|
||||
CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
|
||||
if (lms == null) {
|
||||
throw new IllegalArgumentException("MonitorInfo[] is null");
|
||||
}
|
||||
if (lms.length > 0) {
|
||||
MonitorInfoCompositeData.validateCompositeData(lms[0]);
|
||||
}
|
||||
|
||||
CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
|
||||
if (lsyncs == null) {
|
||||
throw new IllegalArgumentException("LockInfo[] is null");
|
||||
}
|
||||
if (lsyncs.length > 0) {
|
||||
if (!isTypeMatched(lockInfoCompositeType,
|
||||
lsyncs[0].getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for \"" +
|
||||
LOCKED_SYNCS + "\" attribute.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 2464378539119753175L;
|
||||
}
|
||||
87
jdkSrc/jdk8/sun/management/Util.java
Normal file
87
jdkSrc/jdk8/sun/management/Util.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.ManagementPermission;
|
||||
import java.util.List;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
|
||||
|
||||
public class Util {
|
||||
private Util() {} // there are no instances of this class
|
||||
|
||||
static RuntimeException newException(Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
static String[] toStringArray(List<String> list) {
|
||||
return list.toArray(EMPTY_STRING_ARRAY);
|
||||
}
|
||||
|
||||
public static ObjectName newObjectName(String domainAndType, String name) {
|
||||
return newObjectName(domainAndType + ",name=" + name);
|
||||
}
|
||||
|
||||
public static ObjectName newObjectName(String name) {
|
||||
try {
|
||||
return ObjectName.getInstance(name);
|
||||
} catch (MalformedObjectNameException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static ManagementPermission monitorPermission =
|
||||
new ManagementPermission("monitor");
|
||||
private static ManagementPermission controlPermission =
|
||||
new ManagementPermission("control");
|
||||
|
||||
/**
|
||||
* Check that the current context is trusted to perform monitoring
|
||||
* or management.
|
||||
* <p>
|
||||
* If the check fails we throw a SecurityException, otherwise
|
||||
* we return normally.
|
||||
*
|
||||
* @exception SecurityException if a security manager exists and if
|
||||
* the caller does not have ManagementPermission("control").
|
||||
*/
|
||||
static void checkAccess(ManagementPermission p)
|
||||
throws SecurityException {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(p);
|
||||
}
|
||||
}
|
||||
|
||||
static void checkMonitorAccess() throws SecurityException {
|
||||
checkAccess(monitorPermission);
|
||||
}
|
||||
static void checkControlAccess() throws SecurityException {
|
||||
checkAccess(controlPermission);
|
||||
}
|
||||
}
|
||||
108
jdkSrc/jdk8/sun/management/VMManagement.java
Normal file
108
jdkSrc/jdk8/sun/management/VMManagement.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import java.util.List;
|
||||
import sun.management.counter.Counter;
|
||||
/**
|
||||
* An interface for the monitoring and management of the
|
||||
* Java virtual machine.
|
||||
*/
|
||||
public interface VMManagement {
|
||||
|
||||
// Optional supports
|
||||
public boolean isCompilationTimeMonitoringSupported();
|
||||
public boolean isThreadContentionMonitoringSupported();
|
||||
public boolean isThreadContentionMonitoringEnabled();
|
||||
public boolean isCurrentThreadCpuTimeSupported();
|
||||
public boolean isOtherThreadCpuTimeSupported();
|
||||
public boolean isThreadCpuTimeEnabled();
|
||||
public boolean isBootClassPathSupported();
|
||||
public boolean isObjectMonitorUsageSupported();
|
||||
public boolean isSynchronizerUsageSupported();
|
||||
public boolean isThreadAllocatedMemorySupported();
|
||||
public boolean isThreadAllocatedMemoryEnabled();
|
||||
public boolean isGcNotificationSupported();
|
||||
public boolean isRemoteDiagnosticCommandsSupported();
|
||||
|
||||
// Class Loading Subsystem
|
||||
public long getTotalClassCount();
|
||||
public int getLoadedClassCount();
|
||||
public long getUnloadedClassCount();
|
||||
public boolean getVerboseClass();
|
||||
|
||||
// Memory Subsystem
|
||||
public boolean getVerboseGC();
|
||||
|
||||
// Runtime Subsystem
|
||||
public String getManagementVersion();
|
||||
public String getVmId();
|
||||
public String getVmName();
|
||||
public String getVmVendor();
|
||||
public String getVmVersion();
|
||||
public String getVmSpecName();
|
||||
public String getVmSpecVendor();
|
||||
public String getVmSpecVersion();
|
||||
public String getClassPath();
|
||||
public String getLibraryPath();
|
||||
public String getBootClassPath();
|
||||
public List<String> getVmArguments();
|
||||
public long getStartupTime();
|
||||
public long getUptime();
|
||||
public int getAvailableProcessors();
|
||||
|
||||
// Compilation Subsystem
|
||||
public String getCompilerName();
|
||||
public long getTotalCompileTime();
|
||||
|
||||
// Thread Subsystem
|
||||
public long getTotalThreadCount();
|
||||
public int getLiveThreadCount();
|
||||
public int getPeakThreadCount();
|
||||
public int getDaemonThreadCount();
|
||||
|
||||
// Operating System
|
||||
public String getOsName();
|
||||
public String getOsArch();
|
||||
public String getOsVersion();
|
||||
|
||||
// Hotspot-specific Runtime support
|
||||
public long getSafepointCount();
|
||||
public long getTotalSafepointTime();
|
||||
public long getSafepointSyncTime();
|
||||
public long getTotalApplicationNonStoppedTime();
|
||||
|
||||
public long getLoadedClassSize();
|
||||
public long getUnloadedClassSize();
|
||||
public long getClassLoadingTime();
|
||||
public long getMethodDataSize();
|
||||
public long getInitializedClassCount();
|
||||
public long getClassInitializationTime();
|
||||
public long getClassVerificationTime();
|
||||
|
||||
// Performance counter support
|
||||
public List<Counter> getInternalCounters(String pattern);
|
||||
}
|
||||
281
jdkSrc/jdk8/sun/management/VMManagementImpl.java
Normal file
281
jdkSrc/jdk8/sun/management/VMManagementImpl.java
Normal file
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import sun.misc.Perf;
|
||||
import sun.management.counter.*;
|
||||
import sun.management.counter.perf.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
/**
|
||||
* Implementation of VMManagement interface that accesses the management
|
||||
* attributes and operations locally within the same Java virtual
|
||||
* machine.
|
||||
*/
|
||||
class VMManagementImpl implements VMManagement {
|
||||
|
||||
private static String version;
|
||||
|
||||
private static boolean compTimeMonitoringSupport;
|
||||
private static boolean threadContentionMonitoringSupport;
|
||||
private static boolean currentThreadCpuTimeSupport;
|
||||
private static boolean otherThreadCpuTimeSupport;
|
||||
private static boolean bootClassPathSupport;
|
||||
private static boolean objectMonitorUsageSupport;
|
||||
private static boolean synchronizerUsageSupport;
|
||||
private static boolean threadAllocatedMemorySupport;
|
||||
private static boolean gcNotificationSupport;
|
||||
private static boolean remoteDiagnosticCommandsSupport;
|
||||
|
||||
|
||||
static {
|
||||
version = getVersion0();
|
||||
if (version == null) {
|
||||
throw new AssertionError("Invalid Management Version");
|
||||
}
|
||||
initOptionalSupportFields();
|
||||
}
|
||||
private native static String getVersion0();
|
||||
private native static void initOptionalSupportFields();
|
||||
|
||||
// Optional supports
|
||||
public boolean isCompilationTimeMonitoringSupported() {
|
||||
return compTimeMonitoringSupport;
|
||||
}
|
||||
|
||||
public boolean isThreadContentionMonitoringSupported() {
|
||||
return threadContentionMonitoringSupport;
|
||||
}
|
||||
|
||||
public boolean isCurrentThreadCpuTimeSupported() {
|
||||
return currentThreadCpuTimeSupport;
|
||||
}
|
||||
|
||||
public boolean isOtherThreadCpuTimeSupported() {
|
||||
return otherThreadCpuTimeSupport;
|
||||
}
|
||||
|
||||
public boolean isBootClassPathSupported() {
|
||||
return bootClassPathSupport;
|
||||
}
|
||||
|
||||
public boolean isObjectMonitorUsageSupported() {
|
||||
return objectMonitorUsageSupport;
|
||||
}
|
||||
|
||||
public boolean isSynchronizerUsageSupported() {
|
||||
return synchronizerUsageSupport;
|
||||
}
|
||||
|
||||
public boolean isThreadAllocatedMemorySupported() {
|
||||
return threadAllocatedMemorySupport;
|
||||
}
|
||||
|
||||
public boolean isGcNotificationSupported() {
|
||||
return gcNotificationSupport;
|
||||
}
|
||||
|
||||
public boolean isRemoteDiagnosticCommandsSupported() {
|
||||
return remoteDiagnosticCommandsSupport;
|
||||
}
|
||||
|
||||
public native boolean isThreadContentionMonitoringEnabled();
|
||||
public native boolean isThreadCpuTimeEnabled();
|
||||
public native boolean isThreadAllocatedMemoryEnabled();
|
||||
|
||||
// Class Loading Subsystem
|
||||
public int getLoadedClassCount() {
|
||||
long count = getTotalClassCount() - getUnloadedClassCount();
|
||||
return (int) count;
|
||||
}
|
||||
public native long getTotalClassCount();
|
||||
public native long getUnloadedClassCount();
|
||||
|
||||
public native boolean getVerboseClass();
|
||||
|
||||
// Memory Subsystem
|
||||
public native boolean getVerboseGC();
|
||||
|
||||
// Runtime Subsystem
|
||||
public String getManagementVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getVmId() {
|
||||
int pid = getProcessId();
|
||||
String hostname = "localhost";
|
||||
try {
|
||||
hostname = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
return pid + "@" + hostname;
|
||||
}
|
||||
private native int getProcessId();
|
||||
|
||||
public String getVmName() {
|
||||
return System.getProperty("java.vm.name");
|
||||
}
|
||||
|
||||
public String getVmVendor() {
|
||||
return System.getProperty("java.vm.vendor");
|
||||
}
|
||||
public String getVmVersion() {
|
||||
return System.getProperty("java.vm.version");
|
||||
}
|
||||
public String getVmSpecName() {
|
||||
return System.getProperty("java.vm.specification.name");
|
||||
}
|
||||
public String getVmSpecVendor() {
|
||||
return System.getProperty("java.vm.specification.vendor");
|
||||
}
|
||||
public String getVmSpecVersion() {
|
||||
return System.getProperty("java.vm.specification.version");
|
||||
}
|
||||
public String getClassPath() {
|
||||
return System.getProperty("java.class.path");
|
||||
}
|
||||
public String getLibraryPath() {
|
||||
return System.getProperty("java.library.path");
|
||||
}
|
||||
|
||||
public String getBootClassPath( ) {
|
||||
PrivilegedAction<String> pa
|
||||
= new GetPropertyAction("sun.boot.class.path");
|
||||
String result = AccessController.doPrivileged(pa);
|
||||
return result;
|
||||
}
|
||||
|
||||
public long getUptime() {
|
||||
return getUptime0();
|
||||
}
|
||||
|
||||
private List<String> vmArgs = null;
|
||||
public synchronized List<String> getVmArguments() {
|
||||
if (vmArgs == null) {
|
||||
String[] args = getVmArguments0();
|
||||
List<String> l = ((args != null && args.length != 0) ? Arrays.asList(args) :
|
||||
Collections.<String>emptyList());
|
||||
vmArgs = Collections.unmodifiableList(l);
|
||||
}
|
||||
return vmArgs;
|
||||
}
|
||||
public native String[] getVmArguments0();
|
||||
|
||||
public native long getStartupTime();
|
||||
private native long getUptime0();
|
||||
public native int getAvailableProcessors();
|
||||
|
||||
// Compilation Subsystem
|
||||
public String getCompilerName() {
|
||||
String name = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
return System.getProperty("sun.management.compiler");
|
||||
}
|
||||
});
|
||||
return name;
|
||||
}
|
||||
public native long getTotalCompileTime();
|
||||
|
||||
// Thread Subsystem
|
||||
public native long getTotalThreadCount();
|
||||
public native int getLiveThreadCount();
|
||||
public native int getPeakThreadCount();
|
||||
public native int getDaemonThreadCount();
|
||||
|
||||
// Operating System
|
||||
public String getOsName() {
|
||||
return System.getProperty("os.name");
|
||||
}
|
||||
public String getOsArch() {
|
||||
return System.getProperty("os.arch");
|
||||
}
|
||||
public String getOsVersion() {
|
||||
return System.getProperty("os.version");
|
||||
}
|
||||
|
||||
// Hotspot-specific runtime support
|
||||
public native long getSafepointCount();
|
||||
public native long getTotalSafepointTime();
|
||||
public native long getSafepointSyncTime();
|
||||
public native long getTotalApplicationNonStoppedTime();
|
||||
|
||||
public native long getLoadedClassSize();
|
||||
public native long getUnloadedClassSize();
|
||||
public native long getClassLoadingTime();
|
||||
public native long getMethodDataSize();
|
||||
public native long getInitializedClassCount();
|
||||
public native long getClassInitializationTime();
|
||||
public native long getClassVerificationTime();
|
||||
|
||||
// Performance Counter Support
|
||||
private PerfInstrumentation perfInstr = null;
|
||||
private boolean noPerfData = false;
|
||||
|
||||
private synchronized PerfInstrumentation getPerfInstrumentation() {
|
||||
if (noPerfData || perfInstr != null) {
|
||||
return perfInstr;
|
||||
}
|
||||
|
||||
// construct PerfInstrumentation object
|
||||
Perf perf = AccessController.doPrivileged(new Perf.GetPerfAction());
|
||||
try {
|
||||
ByteBuffer bb = perf.attach(0, "r");
|
||||
if (bb.capacity() == 0) {
|
||||
noPerfData = true;
|
||||
return null;
|
||||
}
|
||||
perfInstr = new PerfInstrumentation(bb);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// If the shared memory doesn't exist e.g. if -XX:-UsePerfData
|
||||
// was set
|
||||
noPerfData = true;
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
return perfInstr;
|
||||
}
|
||||
|
||||
public List<Counter> getInternalCounters(String pattern) {
|
||||
PerfInstrumentation perf = getPerfInstrumentation();
|
||||
if (perf != null) {
|
||||
return perf.findByPattern(pattern);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
133
jdkSrc/jdk8/sun/management/VMOptionCompositeData.java
Normal file
133
jdkSrc/jdk8/sun/management/VMOptionCompositeData.java
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management;
|
||||
|
||||
import com.sun.management.VMOption;
|
||||
import com.sun.management.VMOption.Origin;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
|
||||
/**
|
||||
* A CompositeData for VMOption for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class VMOptionCompositeData extends LazyCompositeData {
|
||||
private final VMOption option;
|
||||
|
||||
private VMOptionCompositeData(VMOption option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
public VMOption getVMOption() {
|
||||
return option;
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(VMOption option) {
|
||||
VMOptionCompositeData vcd = new VMOptionCompositeData(option);
|
||||
return vcd.getCompositeData();
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// vmOptionItemNames!
|
||||
final Object[] vmOptionItemValues = {
|
||||
option.getName(),
|
||||
option.getValue(),
|
||||
new Boolean(option.isWriteable()),
|
||||
option.getOrigin().toString(),
|
||||
};
|
||||
|
||||
try {
|
||||
return new CompositeDataSupport(vmOptionCompositeType,
|
||||
vmOptionItemNames,
|
||||
vmOptionItemValues);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final CompositeType vmOptionCompositeType;
|
||||
static {
|
||||
try {
|
||||
vmOptionCompositeType = (CompositeType)
|
||||
MappedMXBeanType.toOpenType(VMOption.class);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
static CompositeType getVMOptionCompositeType() {
|
||||
return vmOptionCompositeType;
|
||||
}
|
||||
|
||||
private static final String NAME = "name";
|
||||
private static final String VALUE = "value";
|
||||
private static final String WRITEABLE = "writeable";
|
||||
private static final String ORIGIN = "origin";
|
||||
|
||||
private static final String[] vmOptionItemNames = {
|
||||
NAME,
|
||||
VALUE,
|
||||
WRITEABLE,
|
||||
ORIGIN,
|
||||
};
|
||||
|
||||
public static String getName(CompositeData cd) {
|
||||
return getString(cd, NAME);
|
||||
}
|
||||
public static String getValue(CompositeData cd) {
|
||||
return getString(cd, VALUE);
|
||||
}
|
||||
public static Origin getOrigin(CompositeData cd) {
|
||||
String o = getString(cd, ORIGIN);
|
||||
return Enum.valueOf(Origin.class, o);
|
||||
}
|
||||
public static boolean isWriteable(CompositeData cd) {
|
||||
return getBoolean(cd, WRITEABLE);
|
||||
}
|
||||
|
||||
/** Validate if the input CompositeData has the expected
|
||||
* CompositeType (i.e. contain all attributes with expected
|
||||
* names and types).
|
||||
*/
|
||||
public static void validateCompositeData(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
if (!isTypeMatched(vmOptionCompositeType, cd.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for VMOption");
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -2395573975093578470L;
|
||||
}
|
||||
121
jdkSrc/jdk8/sun/management/counter/AbstractCounter.java
Normal file
121
jdkSrc/jdk8/sun/management/counter/AbstractCounter.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class AbstractCounter implements Counter {
|
||||
|
||||
String name;
|
||||
Units units;
|
||||
Variability variability;
|
||||
int flags;
|
||||
int vectorLength;
|
||||
|
||||
// Flags defined in hotspot implementation
|
||||
class Flags {
|
||||
static final int SUPPORTED = 0x1;
|
||||
}
|
||||
|
||||
protected AbstractCounter(String name, Units units,
|
||||
Variability variability, int flags,
|
||||
int vectorLength) {
|
||||
this.name = name;
|
||||
this.units = units;
|
||||
this.variability = variability;
|
||||
this.flags = flags;
|
||||
this.vectorLength = vectorLength;
|
||||
}
|
||||
|
||||
protected AbstractCounter(String name, Units units,
|
||||
Variability variability, int flags) {
|
||||
this(name, units, variability, flags, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the Performance Counter
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Units for this Performance Counter
|
||||
*/
|
||||
public Units getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Variability for this performance Object
|
||||
*/
|
||||
public Variability getVariability() {
|
||||
return variability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this performance counter is a vector
|
||||
*/
|
||||
public boolean isVector() {
|
||||
return vectorLength > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the length of the vector
|
||||
*/
|
||||
public int getVectorLength() {
|
||||
return vectorLength;
|
||||
}
|
||||
|
||||
public boolean isInternal() {
|
||||
return (flags & Flags.SUPPORTED) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the flags associated with the counter.
|
||||
*/
|
||||
public int getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
public abstract Object getValue();
|
||||
|
||||
public String toString() {
|
||||
String result = getName() + ": " + getValue() + " " + getUnits();
|
||||
if (isInternal()) {
|
||||
return result + " [INTERNAL]";
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 6992337162326171013L;
|
||||
|
||||
}
|
||||
44
jdkSrc/jdk8/sun/management/counter/ByteArrayCounter.java
Normal file
44
jdkSrc/jdk8/sun/management/counter/ByteArrayCounter.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter;
|
||||
|
||||
/**
|
||||
* Interface for performance counter wrapping <code>byte[]</code> objects.
|
||||
*
|
||||
* @author Brian Doherty
|
||||
*/
|
||||
public interface ByteArrayCounter extends Counter {
|
||||
|
||||
/**
|
||||
* Get a copy of the elements of the ByteArrayCounter.
|
||||
*/
|
||||
public byte[] byteArrayValue();
|
||||
|
||||
/**
|
||||
* Get the value of an element of the ByteArrayCounter object.
|
||||
*/
|
||||
public byte byteAt(int index);
|
||||
}
|
||||
74
jdkSrc/jdk8/sun/management/counter/Counter.java
Normal file
74
jdkSrc/jdk8/sun/management/counter/Counter.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter;
|
||||
|
||||
/**
|
||||
* The base class for a performance counter.
|
||||
*
|
||||
* @author Brian Doherty
|
||||
*/
|
||||
public interface Counter extends java.io.Serializable {
|
||||
|
||||
/**
|
||||
* Returns the name of this performance counter
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns the Units for this performance counter
|
||||
*/
|
||||
public Units getUnits();
|
||||
|
||||
/**
|
||||
* Returns the Variability for this performance counter
|
||||
*/
|
||||
public Variability getVariability();
|
||||
|
||||
/**
|
||||
* Returns true if this performance counter is a vector
|
||||
*/
|
||||
public boolean isVector();
|
||||
|
||||
/**
|
||||
* Returns the length of the vector
|
||||
*/
|
||||
public int getVectorLength();
|
||||
|
||||
/**
|
||||
* Returns an Object that encapsulates the data value of this counter
|
||||
*/
|
||||
public Object getValue();
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this counter is an internal counter.
|
||||
*/
|
||||
public boolean isInternal();
|
||||
|
||||
/**
|
||||
* Return the flags associated with the counter.
|
||||
*/
|
||||
public int getFlags();
|
||||
}
|
||||
43
jdkSrc/jdk8/sun/management/counter/LongArrayCounter.java
Normal file
43
jdkSrc/jdk8/sun/management/counter/LongArrayCounter.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter;
|
||||
|
||||
/**
|
||||
* Interface for performance counter wrapping <code>long[]</code> objects.
|
||||
*
|
||||
*/
|
||||
public interface LongArrayCounter extends Counter {
|
||||
|
||||
/**
|
||||
* Get a copy of the elements of the LongArrayCounter.
|
||||
*/
|
||||
public long[] longArrayValue();
|
||||
|
||||
/**
|
||||
* Get the value of an element of the LongArrayCounter object.
|
||||
*/
|
||||
public long longAt(int index);
|
||||
}
|
||||
40
jdkSrc/jdk8/sun/management/counter/LongCounter.java
Normal file
40
jdkSrc/jdk8/sun/management/counter/LongCounter.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter;
|
||||
|
||||
/**
|
||||
* Interface for a performance counter wrapping a
|
||||
* <code>long</code> basic type.
|
||||
*
|
||||
* @author Brian Doherty
|
||||
*/
|
||||
public interface LongCounter extends Counter {
|
||||
|
||||
/**
|
||||
* Get the value of this Long performance counter
|
||||
*/
|
||||
public long longValue();
|
||||
}
|
||||
39
jdkSrc/jdk8/sun/management/counter/StringCounter.java
Normal file
39
jdkSrc/jdk8/sun/management/counter/StringCounter.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter;
|
||||
|
||||
/**
|
||||
* Interface for a performance counter wrapping a <code>String</code> object.
|
||||
*
|
||||
* @author Brian Doherty
|
||||
*/
|
||||
public interface StringCounter extends Counter {
|
||||
|
||||
/**
|
||||
* Get a copy of the value of the StringCounter.
|
||||
*/
|
||||
public String stringValue();
|
||||
}
|
||||
128
jdkSrc/jdk8/sun/management/counter/Units.java
Normal file
128
jdkSrc/jdk8/sun/management/counter/Units.java
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter;
|
||||
|
||||
/**
|
||||
* Provides a typesafe enumeration for describing units of measurement
|
||||
* attribute for instrumentation objects.
|
||||
*
|
||||
* @author Brian Doherty
|
||||
*/
|
||||
public class Units implements java.io.Serializable {
|
||||
|
||||
/* The enumeration values for this typesafe enumeration must be
|
||||
* kept in synchronization with the Units enum in the perfData.hpp file
|
||||
* in the HotSpot source base.
|
||||
*/
|
||||
|
||||
private static final int NUNITS=8;
|
||||
|
||||
private static Units[] map = new Units[NUNITS];
|
||||
|
||||
private final String name;
|
||||
private final int value;
|
||||
|
||||
/**
|
||||
* An Invalid Units value.
|
||||
*/
|
||||
public static final Units INVALID = new Units("Invalid", 0);
|
||||
|
||||
/**
|
||||
* Units attribute representing unit-less quantities.
|
||||
*/
|
||||
public static final Units NONE = new Units("None", 1);
|
||||
|
||||
/**
|
||||
* Units attribute representing Bytes.
|
||||
*/
|
||||
public static final Units BYTES = new Units("Bytes", 2);
|
||||
|
||||
/**
|
||||
* Units attribute representing Ticks.
|
||||
*/
|
||||
public static final Units TICKS = new Units("Ticks", 3);
|
||||
|
||||
/**
|
||||
* Units attribute representing a count of events.
|
||||
*/
|
||||
public static final Units EVENTS = new Units("Events", 4);
|
||||
|
||||
/**
|
||||
* Units attribute representing String data. Although not really
|
||||
* a unit of measure, this Units value serves to distinguish String
|
||||
* instrumentation objects from instrumentation objects of other types.
|
||||
*/
|
||||
public static final Units STRING = new Units("String", 5);
|
||||
|
||||
/**
|
||||
* Units attribute representing Hertz (frequency).
|
||||
*/
|
||||
public static final Units HERTZ = new Units("Hertz", 6);
|
||||
|
||||
/**
|
||||
* Returns a string describing this Unit of measurement attribute
|
||||
*
|
||||
* @return String - a descriptive string for this enum.
|
||||
*/
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer representation of this Units attribute
|
||||
*
|
||||
* @return int - an integer representation of this Units attribute.
|
||||
*/
|
||||
public int intValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an integer value to its corresponding Units attribute.
|
||||
* If the integer value does not have a corresponding Units enum
|
||||
* value, then {@link Units#INVALID} is returned.
|
||||
*
|
||||
* @param value an integer representation of counter Units
|
||||
* @return Units - the Units object for the given <code>value</code>
|
||||
* or {@link Units#INVALID} if out of range.
|
||||
*/
|
||||
public static Units toUnits(int value) {
|
||||
|
||||
if (value < 0 || value >= map.length || map[value] == null) {
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
return map[value];
|
||||
}
|
||||
|
||||
private Units(String name, int value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
map[value] = this;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 6992337162326171013L;
|
||||
}
|
||||
111
jdkSrc/jdk8/sun/management/counter/Variability.java
Normal file
111
jdkSrc/jdk8/sun/management/counter/Variability.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter;
|
||||
|
||||
/**
|
||||
* Provides a typesafe enumeration for the Variability attribute for
|
||||
* instrumentation objects.
|
||||
*
|
||||
* @author Brian Doherty
|
||||
*/
|
||||
public class Variability implements java.io.Serializable {
|
||||
|
||||
/* The enumeration values for this typesafe enumeration must be
|
||||
* kept in synchronization with the Variability enum in the perfData.hpp file
|
||||
* in the HotSpot source base.
|
||||
*/
|
||||
|
||||
private static final int NATTRIBUTES = 4;
|
||||
private static Variability[] map = new Variability[NATTRIBUTES];
|
||||
|
||||
private String name;
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* An invalid Variablity value.
|
||||
*/
|
||||
public static final Variability INVALID = new Variability("Invalid",0);
|
||||
|
||||
/**
|
||||
* Variability attribute representing Constant counters.
|
||||
*/
|
||||
public static final Variability CONSTANT = new Variability("Constant",1);
|
||||
|
||||
/**
|
||||
* Variability attribute representing a Monotonically changing counters.
|
||||
*/
|
||||
public static final Variability MONOTONIC = new Variability("Monotonic",2);
|
||||
|
||||
/**
|
||||
* Variability attribute representing Variable counters.
|
||||
*/
|
||||
public static final Variability VARIABLE = new Variability("Variable",3);
|
||||
|
||||
/**
|
||||
* Returns a string describing this Variability attribute.
|
||||
*
|
||||
* @return String - a descriptive string for this enum.
|
||||
*/
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer representation of this Variability attribute.
|
||||
*
|
||||
* @return int - an integer representation of this Variability attribute.
|
||||
*/
|
||||
public int intValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an integer value its corresponding Variability attribute.
|
||||
* If the integer value does not have a corresponding Variability enum
|
||||
* value, the {@link Variability#INVALID} is returned
|
||||
*
|
||||
* @param value an integer representation of a Variability attribute
|
||||
* @return Variability - The Variability object for the given
|
||||
* <code>value</code> or {@link Variability#INVALID}
|
||||
* if out of range.
|
||||
*/
|
||||
public static Variability toVariability(int value) {
|
||||
|
||||
if (value < 0 || value >= map.length || map[value] == null) {
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
return map[value];
|
||||
}
|
||||
|
||||
private Variability(String name, int value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
map[value]=this;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 6992337162326171013L;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
|
||||
/**
|
||||
* A snapshot of the perf counter for serialization.
|
||||
*/
|
||||
class ByteArrayCounterSnapshot extends AbstractCounter
|
||||
implements ByteArrayCounter {
|
||||
|
||||
byte[] value;
|
||||
|
||||
// package private
|
||||
ByteArrayCounterSnapshot(String name, Units u, Variability v, int flags,
|
||||
int vectorLength, byte[] value) {
|
||||
super(name, u, v, flags, vectorLength);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public byte[] byteArrayValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public byte byteAt(int index) {
|
||||
return value[index];
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1444793459838438979L;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
public class InstrumentationException extends RuntimeException {
|
||||
/**
|
||||
* Constructs a <tt>InstrumentationException</tt> with no
|
||||
* detail message.
|
||||
*/
|
||||
public InstrumentationException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <tt>InstrumentationException</tt> with a specified
|
||||
* detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public InstrumentationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 8060117844393922797L;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
|
||||
/**
|
||||
* A snapshot of the perf counter for serialization.
|
||||
*/
|
||||
class LongArrayCounterSnapshot extends AbstractCounter
|
||||
implements LongArrayCounter {
|
||||
|
||||
long[] value;
|
||||
|
||||
// package private
|
||||
LongArrayCounterSnapshot(String name, Units u, Variability v, int flags,
|
||||
int vectorLength, long[] value) {
|
||||
super(name, u, v, flags, vectorLength);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public long[] longArrayValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public long longAt(int index) {
|
||||
return value[index];
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 3585870271405924292L;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
|
||||
/**
|
||||
* A snapshot of the perf counter for serialization.
|
||||
*/
|
||||
class LongCounterSnapshot extends AbstractCounter
|
||||
implements LongCounter {
|
||||
|
||||
long value;
|
||||
|
||||
// package private
|
||||
LongCounterSnapshot(String name, Units u, Variability v, int flags,
|
||||
long value) {
|
||||
super(name, u, v, flags);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return new Long(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of this Long performance counter
|
||||
*/
|
||||
public long longValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 2054263861474565758L;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class PerfByteArrayCounter extends AbstractCounter
|
||||
implements ByteArrayCounter {
|
||||
|
||||
ByteBuffer bb;
|
||||
|
||||
PerfByteArrayCounter(String name, Units u, Variability v,
|
||||
int flags, int vectorLength,
|
||||
ByteBuffer bb) {
|
||||
|
||||
super(name, u, v, flags, vectorLength);
|
||||
this.bb = bb;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return byteArrayValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the elements of the ByteArrayCounter.
|
||||
*/
|
||||
public byte[] byteArrayValue() {
|
||||
|
||||
bb.position(0);
|
||||
byte[] b = new byte[bb.limit()];
|
||||
|
||||
// copy the bytes
|
||||
bb.get(b);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of an element of the ByteArrayCounter object.
|
||||
*/
|
||||
public byte byteAt(int index) {
|
||||
bb.position(index);
|
||||
return bb.get();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String result = getName() + ": " + new String(byteArrayValue()) +
|
||||
" " + getUnits();
|
||||
if (isInternal()) {
|
||||
return result + " [INTERNAL]";
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize as a snapshot object.
|
||||
*/
|
||||
protected Object writeReplace() throws java.io.ObjectStreamException {
|
||||
return new ByteArrayCounterSnapshot(getName(),
|
||||
getUnits(),
|
||||
getVariability(),
|
||||
getFlags(),
|
||||
getVectorLength(),
|
||||
byteArrayValue());
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 2545474036937279921L;
|
||||
}
|
||||
211
jdkSrc/jdk8/sun/management/counter/perf/PerfDataEntry.java
Normal file
211
jdkSrc/jdk8/sun/management/counter/perf/PerfDataEntry.java
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
import java.nio.*;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
class PerfDataEntry {
|
||||
private class EntryFieldOffset {
|
||||
private final static int SIZEOF_BYTE = 1;
|
||||
private final static int SIZEOF_INT = 4;
|
||||
private final static int SIZEOF_LONG = 8;
|
||||
|
||||
private final static int ENTRY_LENGTH_SIZE = SIZEOF_INT;
|
||||
private final static int NAME_OFFSET_SIZE = SIZEOF_INT;
|
||||
private final static int VECTOR_LENGTH_SIZE = SIZEOF_INT;
|
||||
private final static int DATA_TYPE_SIZE = SIZEOF_BYTE;
|
||||
private final static int FLAGS_SIZE = SIZEOF_BYTE;
|
||||
private final static int DATA_UNIT_SIZE = SIZEOF_BYTE;
|
||||
private final static int DATA_VAR_SIZE = SIZEOF_BYTE;
|
||||
private final static int DATA_OFFSET_SIZE = SIZEOF_INT;
|
||||
|
||||
final static int ENTRY_LENGTH = 0;
|
||||
final static int NAME_OFFSET = ENTRY_LENGTH + ENTRY_LENGTH_SIZE;
|
||||
final static int VECTOR_LENGTH = NAME_OFFSET + NAME_OFFSET_SIZE;;
|
||||
final static int DATA_TYPE = VECTOR_LENGTH + VECTOR_LENGTH_SIZE;
|
||||
final static int FLAGS = DATA_TYPE + DATA_TYPE_SIZE;
|
||||
final static int DATA_UNIT = FLAGS + FLAGS_SIZE;
|
||||
final static int DATA_VAR = DATA_UNIT + DATA_UNIT_SIZE;
|
||||
final static int DATA_OFFSET = DATA_VAR + DATA_VAR_SIZE;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private int entryStart;
|
||||
private int entryLength;
|
||||
private int vectorLength;
|
||||
private PerfDataType dataType;
|
||||
private int flags;
|
||||
private Units unit;
|
||||
private Variability variability;
|
||||
private int dataOffset;
|
||||
private int dataSize;
|
||||
private ByteBuffer data;
|
||||
|
||||
PerfDataEntry(ByteBuffer b) {
|
||||
entryStart = b.position();
|
||||
entryLength = b.getInt();
|
||||
|
||||
// check for valid entry length
|
||||
if (entryLength <= 0 || entryLength > b.limit()) {
|
||||
throw new InstrumentationException("Invalid entry length: " +
|
||||
" entryLength = " + entryLength);
|
||||
}
|
||||
// check if last entry occurs before the eof.
|
||||
if ((entryStart + entryLength) > b.limit()) {
|
||||
throw new InstrumentationException("Entry extends beyond end of buffer: " +
|
||||
" entryStart = " + entryStart +
|
||||
" entryLength = " + entryLength +
|
||||
" buffer limit = " + b.limit());
|
||||
}
|
||||
|
||||
b.position(entryStart + EntryFieldOffset.NAME_OFFSET);
|
||||
int nameOffset = b.getInt();
|
||||
|
||||
if ((entryStart + nameOffset) > b.limit()) {
|
||||
throw new InstrumentationException("Invalid name offset: " +
|
||||
" entryStart = " + entryStart +
|
||||
" nameOffset = " + nameOffset +
|
||||
" buffer limit = " + b.limit());
|
||||
}
|
||||
|
||||
|
||||
b.position(entryStart + EntryFieldOffset.VECTOR_LENGTH);
|
||||
vectorLength = b.getInt();
|
||||
|
||||
b.position(entryStart + EntryFieldOffset.DATA_TYPE);
|
||||
dataType = PerfDataType.toPerfDataType(b.get());
|
||||
|
||||
b.position(entryStart + EntryFieldOffset.FLAGS);
|
||||
flags = b.get();
|
||||
|
||||
b.position(entryStart + EntryFieldOffset.DATA_UNIT);
|
||||
unit = Units.toUnits(b.get());
|
||||
|
||||
b.position(entryStart + EntryFieldOffset.DATA_VAR);
|
||||
variability = Variability.toVariability(b.get());
|
||||
|
||||
b.position(entryStart + EntryFieldOffset.DATA_OFFSET);
|
||||
dataOffset = b.getInt();
|
||||
|
||||
// read in the perfData item name, casting bytes to chars. skip the
|
||||
// null terminator
|
||||
b.position(entryStart + nameOffset);
|
||||
// calculate the length of the name
|
||||
int nameLength = 0;
|
||||
byte c;
|
||||
for (; (c = b.get()) != (byte)0; nameLength++);
|
||||
|
||||
byte[] symbolBytes = new byte[nameLength];
|
||||
b.position(entryStart + nameOffset);
|
||||
for (int i = 0; i < nameLength; i++) {
|
||||
symbolBytes[i] = b.get();
|
||||
}
|
||||
|
||||
// convert name into a String
|
||||
try {
|
||||
name = new String(symbolBytes, "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
// should not reach here
|
||||
// "UTF-8" is always a known encoding
|
||||
throw new InternalError(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (variability == Variability.INVALID) {
|
||||
throw new InstrumentationException("Invalid variability attribute:" +
|
||||
" name = " + name);
|
||||
}
|
||||
if (unit == Units.INVALID) {
|
||||
throw new InstrumentationException("Invalid units attribute: " +
|
||||
" name = " + name);
|
||||
}
|
||||
|
||||
if (vectorLength > 0) {
|
||||
dataSize = vectorLength * dataType.size();
|
||||
} else {
|
||||
dataSize = dataType.size();
|
||||
}
|
||||
|
||||
// check if data beyond the eof.
|
||||
if ((entryStart + dataOffset + dataSize) > b.limit()) {
|
||||
throw new InstrumentationException("Data extends beyond end of buffer: " +
|
||||
" entryStart = " + entryStart +
|
||||
" dataOffset = " + dataOffset+
|
||||
" dataSize = " + dataSize +
|
||||
" buffer limit = " + b.limit());
|
||||
}
|
||||
// Construct a ByteBuffer for the data
|
||||
b.position(entryStart + dataOffset);
|
||||
data = b.slice();
|
||||
data.order(b.order());
|
||||
data.limit(dataSize);
|
||||
}
|
||||
|
||||
|
||||
public int size() {
|
||||
return entryLength;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public PerfDataType type() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public Units units() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public int flags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements in the data.
|
||||
*/
|
||||
public int vectorLength() {
|
||||
return vectorLength;
|
||||
}
|
||||
|
||||
public Variability variability() {
|
||||
return variability;
|
||||
}
|
||||
|
||||
public ByteBuffer byteData() {
|
||||
data.position(0);
|
||||
assert data.remaining() == vectorLength();
|
||||
return data.duplicate();
|
||||
}
|
||||
|
||||
public LongBuffer longData() {
|
||||
LongBuffer lb = data.asLongBuffer();
|
||||
return lb;
|
||||
}
|
||||
}
|
||||
99
jdkSrc/jdk8/sun/management/counter/perf/PerfDataType.java
Normal file
99
jdkSrc/jdk8/sun/management/counter/perf/PerfDataType.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* A typesafe enumeration for the data types supported for
|
||||
* performance data.
|
||||
*
|
||||
* <p> The enumeration values for this typesafe enumeration must be
|
||||
* kept in synchronization with the PerfDataType enum in the
|
||||
* globalsDefinitions.hpp file in the HotSpot source base.</p>
|
||||
*
|
||||
* @author Brian Doherty
|
||||
*/
|
||||
class PerfDataType {
|
||||
|
||||
private final String name;
|
||||
private final byte value;
|
||||
private final int size;
|
||||
|
||||
public static final PerfDataType BOOLEAN = new PerfDataType("boolean", "Z", 1);
|
||||
public static final PerfDataType CHAR = new PerfDataType("char", "C", 1);
|
||||
public static final PerfDataType FLOAT = new PerfDataType("float", "F", 8);
|
||||
public static final PerfDataType DOUBLE = new PerfDataType("double", "D", 8);
|
||||
public static final PerfDataType BYTE = new PerfDataType("byte", "B", 1);
|
||||
public static final PerfDataType SHORT = new PerfDataType("short", "S", 2);
|
||||
public static final PerfDataType INT = new PerfDataType("int", "I", 4);
|
||||
public static final PerfDataType LONG = new PerfDataType("long", "J", 8);
|
||||
public static final PerfDataType ILLEGAL = new PerfDataType("illegal", "X", 0);
|
||||
|
||||
private static PerfDataType basicTypes[] = {
|
||||
LONG, BYTE, BOOLEAN, CHAR, FLOAT, DOUBLE, SHORT, INT
|
||||
};
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an integer PerfDataType value to its corresponding PerfDataType
|
||||
* object.
|
||||
*
|
||||
* @param i an integer representation of a PerfDataType
|
||||
* @return The PerfDataType object for <code>i</code>
|
||||
*/
|
||||
public static PerfDataType toPerfDataType(byte type) {
|
||||
for (int j = 0; j < basicTypes.length; j++) {
|
||||
if (basicTypes[j].byteValue() == type) {
|
||||
return (basicTypes[j]);
|
||||
}
|
||||
}
|
||||
return ILLEGAL;
|
||||
}
|
||||
|
||||
private PerfDataType(String name, String c, int size) {
|
||||
this.name = name;
|
||||
this.size = size;
|
||||
try {
|
||||
byte[] b = c.getBytes("UTF-8");
|
||||
this.value = b[0];
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// ignore, "UTF-8" is always a known encoding
|
||||
throw new InternalError("Unknown encoding", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
186
jdkSrc/jdk8/sun/management/counter/perf/PerfInstrumentation.java
Normal file
186
jdkSrc/jdk8/sun/management/counter/perf/PerfInstrumentation.java
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
import java.nio.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class PerfInstrumentation {
|
||||
private ByteBuffer buffer;
|
||||
private Prologue prologue;
|
||||
private long lastModificationTime;
|
||||
private long lastUsed;
|
||||
private int nextEntry;
|
||||
private SortedMap<String, Counter> map;
|
||||
|
||||
public PerfInstrumentation(ByteBuffer b) {
|
||||
prologue = new Prologue(b);
|
||||
buffer = b;
|
||||
buffer.order(prologue.getByteOrder());
|
||||
|
||||
// Check recognized versions
|
||||
int major = getMajorVersion();
|
||||
int minor = getMinorVersion();
|
||||
|
||||
// Support only 2.0 version
|
||||
if (major < 2) {
|
||||
throw new InstrumentationException("Unsupported version: " +
|
||||
major + "." + minor);
|
||||
}
|
||||
rewind();
|
||||
}
|
||||
|
||||
public int getMajorVersion() {
|
||||
return prologue.getMajorVersion();
|
||||
}
|
||||
|
||||
public int getMinorVersion() {
|
||||
return prologue.getMinorVersion();
|
||||
}
|
||||
|
||||
public long getModificationTimeStamp() {
|
||||
return prologue.getModificationTimeStamp();
|
||||
}
|
||||
|
||||
void rewind() {
|
||||
// rewind to the first entry
|
||||
buffer.rewind();
|
||||
buffer.position(prologue.getEntryOffset());
|
||||
nextEntry = buffer.position();
|
||||
// rebuild all the counters
|
||||
map = new TreeMap<>();
|
||||
}
|
||||
|
||||
boolean hasNext() {
|
||||
return (nextEntry < prologue.getUsed());
|
||||
}
|
||||
|
||||
Counter getNextCounter() {
|
||||
if (! hasNext()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ((nextEntry % 4) != 0) {
|
||||
// entries are always 4 byte aligned.
|
||||
throw new InstrumentationException(
|
||||
"Entry index not properly aligned: " + nextEntry);
|
||||
}
|
||||
|
||||
if (nextEntry < 0 || nextEntry > buffer.limit()) {
|
||||
// defensive check to protect against a corrupted shared memory region.
|
||||
throw new InstrumentationException(
|
||||
"Entry index out of bounds: nextEntry = " + nextEntry +
|
||||
", limit = " + buffer.limit());
|
||||
}
|
||||
|
||||
buffer.position(nextEntry);
|
||||
PerfDataEntry entry = new PerfDataEntry(buffer);
|
||||
nextEntry = nextEntry + entry.size();
|
||||
|
||||
Counter counter = null;
|
||||
PerfDataType type = entry.type();
|
||||
if (type == PerfDataType.BYTE) {
|
||||
if (entry.units() == Units.STRING && entry.vectorLength() > 0) {
|
||||
counter = new PerfStringCounter(entry.name(),
|
||||
entry.variability(),
|
||||
entry.flags(),
|
||||
entry.vectorLength(),
|
||||
entry.byteData());
|
||||
} else if (entry.vectorLength() > 0) {
|
||||
counter = new PerfByteArrayCounter(entry.name(),
|
||||
entry.units(),
|
||||
entry.variability(),
|
||||
entry.flags(),
|
||||
entry.vectorLength(),
|
||||
entry.byteData());
|
||||
} else {
|
||||
// ByteArrayCounter must have vectorLength > 0
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
else if (type == PerfDataType.LONG) {
|
||||
if (entry.vectorLength() == 0) {
|
||||
counter = new PerfLongCounter(entry.name(),
|
||||
entry.units(),
|
||||
entry.variability(),
|
||||
entry.flags(),
|
||||
entry.longData());
|
||||
} else {
|
||||
counter = new PerfLongArrayCounter(entry.name(),
|
||||
entry.units(),
|
||||
entry.variability(),
|
||||
entry.flags(),
|
||||
entry.vectorLength(),
|
||||
entry.longData());
|
||||
}
|
||||
}
|
||||
else {
|
||||
// FIXME: Should we throw an exception for unsupported type?
|
||||
// Currently skip such entry
|
||||
assert false;
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
public synchronized List<Counter> getAllCounters() {
|
||||
while (hasNext()) {
|
||||
Counter c = getNextCounter();
|
||||
if (c != null) {
|
||||
map.put(c.getName(), c);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(map.values());
|
||||
}
|
||||
|
||||
public synchronized List<Counter> findByPattern(String patternString) {
|
||||
while (hasNext()) {
|
||||
Counter c = getNextCounter();
|
||||
if (c != null) {
|
||||
map.put(c.getName(), c);
|
||||
}
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile(patternString);
|
||||
Matcher matcher = pattern.matcher("");
|
||||
List<Counter> matches = new ArrayList<>();
|
||||
|
||||
|
||||
for (Map.Entry<String,Counter> me: map.entrySet()) {
|
||||
String name = me.getKey();
|
||||
|
||||
// apply pattern to counter name
|
||||
matcher.reset(name);
|
||||
|
||||
// if the pattern matches, then add Counter to list
|
||||
if (matcher.lookingAt()) {
|
||||
matches.add(me.getValue());
|
||||
}
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
|
||||
public class PerfLongArrayCounter extends AbstractCounter
|
||||
implements LongArrayCounter {
|
||||
|
||||
LongBuffer lb;
|
||||
|
||||
PerfLongArrayCounter(String name, Units u, Variability v,
|
||||
int flags, int vectorLength,
|
||||
LongBuffer lb) {
|
||||
|
||||
super(name, u, v, flags, vectorLength);
|
||||
this.lb = lb;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return longArrayValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the elements of the LongArrayCounter.
|
||||
*/
|
||||
public long[] longArrayValue() {
|
||||
|
||||
lb.position(0);
|
||||
long[] l = new long[lb.limit()];
|
||||
|
||||
// copy the bytes
|
||||
lb.get(l);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of an element of the LongArrayCounter object.
|
||||
*/
|
||||
public long longAt(int index) {
|
||||
lb.position(index);
|
||||
return lb.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize as a snapshot object.
|
||||
*/
|
||||
protected Object writeReplace() throws java.io.ObjectStreamException {
|
||||
return new LongArrayCounterSnapshot(getName(),
|
||||
getUnits(),
|
||||
getVariability(),
|
||||
getFlags(),
|
||||
getVectorLength(),
|
||||
longArrayValue());
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -2733617913045487126L;
|
||||
}
|
||||
67
jdkSrc/jdk8/sun/management/counter/perf/PerfLongCounter.java
Normal file
67
jdkSrc/jdk8/sun/management/counter/perf/PerfLongCounter.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
|
||||
public class PerfLongCounter extends AbstractCounter
|
||||
implements LongCounter {
|
||||
|
||||
LongBuffer lb;
|
||||
|
||||
// package private
|
||||
PerfLongCounter(String name, Units u, Variability v, int flags,
|
||||
LongBuffer lb) {
|
||||
super(name, u, v, flags);
|
||||
this.lb = lb;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return new Long(lb.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of this Long performance counter
|
||||
*/
|
||||
public long longValue() {
|
||||
return lb.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize as a snapshot object.
|
||||
*/
|
||||
protected Object writeReplace() throws java.io.ObjectStreamException {
|
||||
return new LongCounterSnapshot(getName(),
|
||||
getUnits(),
|
||||
getVariability(),
|
||||
getFlags(),
|
||||
longValue());
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 857711729279242948L;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class PerfStringCounter extends PerfByteArrayCounter
|
||||
implements StringCounter {
|
||||
|
||||
private static Charset defaultCharset = Charset.defaultCharset();
|
||||
PerfStringCounter(String name, Variability v,
|
||||
int flags, ByteBuffer bb) {
|
||||
this(name, v, flags, bb.limit(), bb);
|
||||
}
|
||||
|
||||
PerfStringCounter(String name, Variability v, int flags,
|
||||
int maxLength, ByteBuffer bb) {
|
||||
|
||||
super(name, Units.STRING, v, flags, maxLength, bb);
|
||||
}
|
||||
|
||||
// override isVector and getVectorLength in ByteArrayCounter
|
||||
public boolean isVector() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getVectorLength() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return stringValue();
|
||||
}
|
||||
|
||||
public String stringValue() {
|
||||
|
||||
String str = "";
|
||||
byte[] b = byteArrayValue();
|
||||
|
||||
if (b == null || b.length <= 1) {
|
||||
return str;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < b.length && b[i] != (byte)0; i++);
|
||||
|
||||
// convert byte array to string, using all bytes up to, but
|
||||
// not including the first null byte.
|
||||
return new String(b , 0, i, defaultCharset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize as a snapshot object.
|
||||
*/
|
||||
protected Object writeReplace() throws java.io.ObjectStreamException {
|
||||
return new StringCounterSnapshot(getName(),
|
||||
getUnits(),
|
||||
getVariability(),
|
||||
getFlags(),
|
||||
stringValue());
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 6802913433363692452L;
|
||||
}
|
||||
164
jdkSrc/jdk8/sun/management/counter/perf/Prologue.java
Normal file
164
jdkSrc/jdk8/sun/management/counter/perf/Prologue.java
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
import java.nio.*;
|
||||
|
||||
class Prologue {
|
||||
// these constants should match their #define counterparts in vmdata.hpp
|
||||
private final static byte PERFDATA_BIG_ENDIAN = 0;
|
||||
private final static byte PERFDATA_LITTLE_ENDIAN = 1;
|
||||
private final static int PERFDATA_MAGIC = 0xcafec0c0;
|
||||
|
||||
private class PrologueFieldOffset {
|
||||
private final static int SIZEOF_BYTE = 1;
|
||||
private final static int SIZEOF_INT = 4;
|
||||
private final static int SIZEOF_LONG = 8;
|
||||
|
||||
private final static int MAGIC_SIZE = SIZEOF_INT;
|
||||
private final static int BYTE_ORDER_SIZE = SIZEOF_BYTE;
|
||||
private final static int MAJOR_SIZE = SIZEOF_BYTE;
|
||||
private final static int MINOR_SIZE = SIZEOF_BYTE;
|
||||
private final static int ACCESSIBLE_SIZE = SIZEOF_BYTE;
|
||||
private final static int USED_SIZE = SIZEOF_INT;
|
||||
private final static int OVERFLOW_SIZE = SIZEOF_INT;
|
||||
private final static int MOD_TIMESTAMP_SIZE = SIZEOF_LONG;
|
||||
private final static int ENTRY_OFFSET_SIZE = SIZEOF_INT;
|
||||
private final static int NUM_ENTRIES_SIZE = SIZEOF_INT;
|
||||
|
||||
// these constants must match the field offsets and sizes
|
||||
// in the PerfDataPrologue structure in perfMemory.hpp
|
||||
final static int MAGIC = 0;
|
||||
final static int BYTE_ORDER = MAGIC + MAGIC_SIZE;
|
||||
final static int MAJOR_VERSION = BYTE_ORDER + BYTE_ORDER_SIZE;
|
||||
final static int MINOR_VERSION = MAJOR_VERSION + MAJOR_SIZE;
|
||||
final static int ACCESSIBLE = MINOR_VERSION + MINOR_SIZE;
|
||||
final static int USED = ACCESSIBLE + ACCESSIBLE_SIZE;
|
||||
final static int OVERFLOW = USED + USED_SIZE;
|
||||
final static int MOD_TIMESTAMP = OVERFLOW + OVERFLOW_SIZE;
|
||||
final static int ENTRY_OFFSET = MOD_TIMESTAMP + MOD_TIMESTAMP_SIZE;
|
||||
final static int NUM_ENTRIES = ENTRY_OFFSET + ENTRY_OFFSET_SIZE;
|
||||
final static int PROLOGUE_2_0_SIZE = NUM_ENTRIES + NUM_ENTRIES_SIZE;
|
||||
}
|
||||
|
||||
|
||||
private ByteBuffer header;
|
||||
private int magic;
|
||||
|
||||
Prologue(ByteBuffer b) {
|
||||
this.header = b.duplicate();
|
||||
|
||||
// the magic number is always stored in big-endian format
|
||||
// save and restore the buffer's initial byte order around
|
||||
// the fetch of the data.
|
||||
header.order(ByteOrder.BIG_ENDIAN);
|
||||
header.position(PrologueFieldOffset.MAGIC);
|
||||
magic = header.getInt();
|
||||
|
||||
// the magic number is always stored in big-endian format
|
||||
if (magic != PERFDATA_MAGIC) {
|
||||
throw new InstrumentationException("Bad Magic: " +
|
||||
Integer.toHexString(getMagic()));
|
||||
}
|
||||
|
||||
|
||||
// set the buffer's byte order according to the value of its
|
||||
// byte order field.
|
||||
header.order(getByteOrder());
|
||||
|
||||
// Check version
|
||||
int major = getMajorVersion();
|
||||
int minor = getMinorVersion();
|
||||
|
||||
if (major < 2) {
|
||||
throw new InstrumentationException("Unsupported version: " +
|
||||
major + "." + minor);
|
||||
}
|
||||
|
||||
// Currently, only support 2.0 version.
|
||||
header.limit(PrologueFieldOffset.PROLOGUE_2_0_SIZE);
|
||||
}
|
||||
|
||||
public int getMagic() {
|
||||
return magic;
|
||||
}
|
||||
|
||||
public int getMajorVersion() {
|
||||
header.position(PrologueFieldOffset.MAJOR_VERSION);
|
||||
return (int)header.get();
|
||||
}
|
||||
|
||||
public int getMinorVersion() {
|
||||
header.position(PrologueFieldOffset.MINOR_VERSION);
|
||||
return (int)header.get();
|
||||
}
|
||||
|
||||
public ByteOrder getByteOrder() {
|
||||
header.position(PrologueFieldOffset.BYTE_ORDER);
|
||||
|
||||
byte byte_order = header.get();
|
||||
if (byte_order == PERFDATA_BIG_ENDIAN) {
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
}
|
||||
else {
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
}
|
||||
}
|
||||
|
||||
public int getEntryOffset() {
|
||||
header.position(PrologueFieldOffset.ENTRY_OFFSET);
|
||||
return header.getInt();
|
||||
}
|
||||
|
||||
// The following fields are updated asynchronously
|
||||
// while they are accessed by these methods.
|
||||
public int getUsed() {
|
||||
header.position(PrologueFieldOffset.USED);
|
||||
return header.getInt();
|
||||
}
|
||||
|
||||
public int getOverflow() {
|
||||
header.position(PrologueFieldOffset.OVERFLOW);
|
||||
return header.getInt();
|
||||
}
|
||||
|
||||
public long getModificationTimeStamp() {
|
||||
header.position(PrologueFieldOffset.MOD_TIMESTAMP);
|
||||
return header.getLong();
|
||||
}
|
||||
|
||||
public int getNumEntries() {
|
||||
header.position(PrologueFieldOffset.NUM_ENTRIES);
|
||||
return header.getInt();
|
||||
}
|
||||
|
||||
public boolean isAccessible() {
|
||||
header.position(PrologueFieldOffset.ACCESSIBLE);
|
||||
byte b = header.get();
|
||||
return (b == 0 ? false : true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.counter.perf;
|
||||
|
||||
import sun.management.counter.*;
|
||||
|
||||
/**
|
||||
* A snapshot of the perf counter for serialization.
|
||||
*/
|
||||
class StringCounterSnapshot extends AbstractCounter
|
||||
implements StringCounter {
|
||||
|
||||
String value;
|
||||
|
||||
// package private
|
||||
StringCounterSnapshot(String name, Units u, Variability v, int flags,
|
||||
String value) {
|
||||
super(name, u, v, flags);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String stringValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1132921539085572034L;
|
||||
}
|
||||
126
jdkSrc/jdk8/sun/management/jdp/JdpBroadcaster.java
Normal file
126
jdkSrc/jdk8/sun/management/jdp/JdpBroadcaster.java
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management.jdp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.ProtocolFamily;
|
||||
import java.net.StandardProtocolFamily;
|
||||
import java.net.StandardSocketOptions;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.DatagramChannel;
|
||||
import java.nio.channels.UnsupportedAddressTypeException;
|
||||
|
||||
/**
|
||||
* JdpBroadcaster is responsible for sending pre-built JDP packet across a Net
|
||||
*
|
||||
* <p> Multicast group address, port number and ttl have to be chosen on upper
|
||||
* level and passed to broadcaster constructor. Also it's possible to specify
|
||||
* source address to broadcast from. </p>
|
||||
*
|
||||
* <p>JdpBradcaster doesn't perform any validation on a supplied {@code port} and {@code ttl} because
|
||||
* the allowed values depend on an operating system setup</p>
|
||||
*
|
||||
*/
|
||||
public final class JdpBroadcaster {
|
||||
|
||||
private final InetAddress addr;
|
||||
private final int port;
|
||||
private final DatagramChannel channel;
|
||||
|
||||
/**
|
||||
* Create a new broadcaster
|
||||
*
|
||||
* @param address - multicast group address
|
||||
* @param srcAddress - address of interface we should use to broadcast.
|
||||
* @param port - udp port to use
|
||||
* @param ttl - packet ttl
|
||||
* @throws IOException
|
||||
*/
|
||||
public JdpBroadcaster(InetAddress address, InetAddress srcAddress, int port, int ttl)
|
||||
throws IOException, JdpException {
|
||||
this.addr = address;
|
||||
this.port = port;
|
||||
|
||||
ProtocolFamily family = (address instanceof Inet6Address)
|
||||
? StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
|
||||
|
||||
channel = DatagramChannel.open(family);
|
||||
channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
|
||||
channel.setOption(StandardSocketOptions.IP_MULTICAST_TTL, ttl);
|
||||
|
||||
// with srcAddress equal to null, this constructor do exactly the same as
|
||||
// if srcAddress is not passed
|
||||
if (srcAddress != null) {
|
||||
// User requests particular interface to bind to
|
||||
NetworkInterface interf = NetworkInterface.getByInetAddress(srcAddress);
|
||||
try {
|
||||
channel.bind(new InetSocketAddress(srcAddress, 0));
|
||||
} catch (UnsupportedAddressTypeException ex) {
|
||||
throw new JdpException("Unable to bind to source address");
|
||||
}
|
||||
channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new broadcaster
|
||||
*
|
||||
* @param address - multicast group address
|
||||
* @param port - udp port to use
|
||||
* @param ttl - packet ttl
|
||||
* @throws IOException
|
||||
*/
|
||||
public JdpBroadcaster(InetAddress address, int port, int ttl)
|
||||
throws IOException, JdpException {
|
||||
this(address, null, port, ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast pre-built packet
|
||||
*
|
||||
* @param packet - instance of JdpPacket
|
||||
* @throws IOException
|
||||
*/
|
||||
public void sendPacket(JdpPacket packet)
|
||||
throws IOException {
|
||||
byte[] data = packet.getPacketData();
|
||||
// Unlike allocate/put wrap don't need a flip afterward
|
||||
ByteBuffer b = ByteBuffer.wrap(data);
|
||||
channel.send(b, new InetSocketAddress(addr, port));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown broadcaster and close underlying socket channel
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void shutdown() throws IOException {
|
||||
channel.close();
|
||||
}
|
||||
}
|
||||
237
jdkSrc/jdk8/sun/management/jdp/JdpController.java
Normal file
237
jdkSrc/jdk8/sun/management/jdp/JdpController.java
Normal file
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management.jdp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.UUID;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import sun.management.VMManagement;
|
||||
|
||||
/**
|
||||
* JdpController is responsible to create and manage a broadcast loop
|
||||
*
|
||||
* <p> Other part of code has no access to broadcast loop and have to use
|
||||
* provided static methods
|
||||
* {@link #startDiscoveryService(InetAddress,int,String,String) startDiscoveryService}
|
||||
* and {@link #stopDiscoveryService() stopDiscoveryService}</p>
|
||||
* <p>{@link #startDiscoveryService(InetAddress,int,String,String) startDiscoveryService} could be called multiple
|
||||
* times as it stops the running service if it is necessary. Call to {@link #stopDiscoveryService() stopDiscoveryService}
|
||||
* ignored if service isn't run</p>
|
||||
*
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* <p> System properties below could be used to control broadcast loop behavior.
|
||||
* Property below have to be set explicitly in command line. It's not possible to
|
||||
* set it in management.config file. Careless changes of these properties could
|
||||
* lead to security or network issues.
|
||||
* <ul>
|
||||
* <li>com.sun.management.jdp.ttl - set ttl for broadcast packet</li>
|
||||
* <li>com.sun.management.jdp.pause - set broadcast interval in seconds</li>
|
||||
* <li>com.sun.management.jdp.source_addr - an address of interface to use for broadcast</li>
|
||||
* </ul>
|
||||
</p>
|
||||
* <p>null parameters values are filtered out on {@link JdpPacketWriter} level and
|
||||
* corresponding keys are not placed to packet.</p>
|
||||
*/
|
||||
public final class JdpController {
|
||||
|
||||
private static class JDPControllerRunner implements Runnable {
|
||||
|
||||
private final JdpJmxPacket packet;
|
||||
private final JdpBroadcaster bcast;
|
||||
private final int pause;
|
||||
private volatile boolean shutdown = false;
|
||||
|
||||
private JDPControllerRunner(JdpBroadcaster bcast, JdpJmxPacket packet, int pause) {
|
||||
this.bcast = bcast;
|
||||
this.packet = packet;
|
||||
this.pause = pause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while (!shutdown) {
|
||||
bcast.sendPacket(packet);
|
||||
try {
|
||||
Thread.sleep(this.pause);
|
||||
} catch (InterruptedException e) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
// pass;
|
||||
}
|
||||
|
||||
// It's not possible to re-use controller,
|
||||
// nevertheless reset shutdown variable
|
||||
try {
|
||||
stop();
|
||||
bcast.shutdown();
|
||||
} catch (IOException ex) {
|
||||
// pass - ignore IOException during shutdown
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
shutdown = true;
|
||||
}
|
||||
}
|
||||
private static JDPControllerRunner controller = null;
|
||||
|
||||
private JdpController(){
|
||||
// Don't allow to instantiate this class.
|
||||
}
|
||||
|
||||
// Utility to handle optional system properties
|
||||
// Parse an integer from string or return default if provided string is null
|
||||
private static int getInteger(String val, int dflt, String msg) throws JdpException {
|
||||
try {
|
||||
return (val == null) ? dflt : Integer.parseInt(val);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new JdpException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse an inet address from string or return default if provided string is null
|
||||
private static InetAddress getInetAddress(String val, InetAddress dflt, String msg) throws JdpException {
|
||||
try {
|
||||
return (val == null) ? dflt : InetAddress.getByName(val);
|
||||
} catch (UnknownHostException ex) {
|
||||
throw new JdpException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the process id of the current running Java process
|
||||
private static Integer getProcessId() {
|
||||
try {
|
||||
// Get the current process id using a reflection hack
|
||||
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
|
||||
Field jvm = runtime.getClass().getDeclaredField("jvm");
|
||||
jvm.setAccessible(true);
|
||||
|
||||
VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
|
||||
Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
|
||||
pid_method.setAccessible(true);
|
||||
Integer pid = (Integer) pid_method.invoke(mgmt);
|
||||
return pid;
|
||||
} catch(Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Starts discovery service
|
||||
*
|
||||
* @param address - multicast group address
|
||||
* @param port - udp port to use
|
||||
* @param instanceName - name of running JVM instance
|
||||
* @param url - JMX service url
|
||||
* @throws IOException
|
||||
*/
|
||||
public static synchronized void startDiscoveryService(InetAddress address, int port, String instanceName, String url)
|
||||
throws IOException, JdpException {
|
||||
|
||||
// Limit packet to local subnet by default
|
||||
int ttl = getInteger(
|
||||
System.getProperty("com.sun.management.jdp.ttl"), 1,
|
||||
"Invalid jdp packet ttl");
|
||||
|
||||
// Broadcast once a 5 seconds by default
|
||||
int pause = getInteger(
|
||||
System.getProperty("com.sun.management.jdp.pause"), 5,
|
||||
"Invalid jdp pause");
|
||||
|
||||
// Converting seconds to milliseconds
|
||||
pause = pause * 1000;
|
||||
|
||||
// Allow OS to choose broadcast source
|
||||
InetAddress sourceAddress = getInetAddress(
|
||||
System.getProperty("com.sun.management.jdp.source_addr"), null,
|
||||
"Invalid source address provided");
|
||||
|
||||
// Generate session id
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
JdpJmxPacket packet = new JdpJmxPacket(id, url);
|
||||
|
||||
// Don't broadcast whole command line for security reason.
|
||||
// Strip everything after first space
|
||||
String javaCommand = System.getProperty("sun.java.command");
|
||||
if (javaCommand != null) {
|
||||
String[] arr = javaCommand.split(" ", 2);
|
||||
packet.setMainClass(arr[0]);
|
||||
}
|
||||
|
||||
// Put optional explicit java instance name to packet, if user doesn't specify
|
||||
// it the key is skipped. PacketWriter is responsible to skip keys having null value.
|
||||
packet.setInstanceName(instanceName);
|
||||
|
||||
// Set rmi server hostname if it explicitly specified by user with
|
||||
// java.rmi.server.hostname
|
||||
String rmiHostname = System.getProperty("java.rmi.server.hostname");
|
||||
packet.setRmiHostname(rmiHostname);
|
||||
|
||||
// Set broadcast interval
|
||||
packet.setBroadcastInterval(new Integer(pause).toString());
|
||||
|
||||
// Set process id
|
||||
Integer pid = getProcessId();
|
||||
if (pid != null) {
|
||||
packet.setProcessId(pid.toString());
|
||||
}
|
||||
|
||||
JdpBroadcaster bcast = new JdpBroadcaster(address, sourceAddress, port, ttl);
|
||||
|
||||
// Stop discovery service if it's already running
|
||||
stopDiscoveryService();
|
||||
|
||||
controller = new JDPControllerRunner(bcast, packet, pause);
|
||||
|
||||
Thread t = new Thread(controller, "JDP broadcaster");
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop running discovery service,
|
||||
* it's safe to attempt to stop not started service
|
||||
*/
|
||||
public static synchronized void stopDiscoveryService() {
|
||||
if ( controller != null ){
|
||||
controller.stop();
|
||||
controller = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
jdkSrc/jdk8/sun/management/jdp/JdpException.java
Normal file
42
jdkSrc/jdk8/sun/management/jdp/JdpException.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management.jdp;
|
||||
|
||||
/**
|
||||
* An Exception thrown if a JDP implementation encounters a problem.
|
||||
*/
|
||||
public final class JdpException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Construct a new JDP exception with a meaningful message
|
||||
*
|
||||
* @param msg - message
|
||||
*/
|
||||
public JdpException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
97
jdkSrc/jdk8/sun/management/jdp/JdpGenericPacket.java
Normal file
97
jdkSrc/jdk8/sun/management/jdp/JdpGenericPacket.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management.jdp;
|
||||
|
||||
/**
|
||||
* JdpGenericPacket responsible to provide fields
|
||||
* common for all Jdp packets
|
||||
*/
|
||||
public abstract class JdpGenericPacket implements JdpPacket {
|
||||
|
||||
/**
|
||||
* JDP protocol magic. Magic allows a reader to quickly select
|
||||
* JDP packets from a bunch of broadcast packets addressed to the same port
|
||||
* and broadcast group. Any packet intended to be parsed by JDP client
|
||||
* has to start from this magic.
|
||||
*/
|
||||
private static final int MAGIC = 0xC0FFEE42;
|
||||
|
||||
/**
|
||||
* Current version of protocol. Any implementation of this protocol has to
|
||||
* conform with the packet structure and the flow described in JEP-168
|
||||
*/
|
||||
private static final short PROTOCOL_VERSION = 1;
|
||||
|
||||
/**
|
||||
* Default do-nothing constructor
|
||||
*/
|
||||
protected JdpGenericPacket(){
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate protocol header magic field
|
||||
*
|
||||
* @param magic - value to validate
|
||||
* @throws JdpException
|
||||
*/
|
||||
public static void checkMagic(int magic)
|
||||
throws JdpException {
|
||||
if (magic != MAGIC) {
|
||||
throw new JdpException("Invalid JDP magic header: " + magic);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate protocol header version field
|
||||
*
|
||||
* @param version - value to validate
|
||||
* @throws JdpException
|
||||
*/
|
||||
public static void checkVersion(short version)
|
||||
throws JdpException {
|
||||
|
||||
if (version > PROTOCOL_VERSION) {
|
||||
throw new JdpException("Unsupported protocol version: " + version);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return protocol magic
|
||||
*/
|
||||
public static int getMagic() {
|
||||
return MAGIC;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return current protocol version
|
||||
*/
|
||||
public static short getVersion() {
|
||||
return PROTOCOL_VERSION;
|
||||
}
|
||||
}
|
||||
245
jdkSrc/jdk8/sun/management/jdp/JdpJmxPacket.java
Normal file
245
jdkSrc/jdk8/sun/management/jdp/JdpJmxPacket.java
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management.jdp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A packet to broadcasts JMX URL
|
||||
*
|
||||
* Fields:
|
||||
*
|
||||
* <ul>
|
||||
* <li>UUID - broadcast session ID, changed every time when we start/stop
|
||||
* discovery service</li>
|
||||
* <li>JMX_URL - URL to connect to JMX service</li>
|
||||
* <li>MAIN_CLASS - optional name of main class, filled from sun.java.command stripped for
|
||||
* security reason to first space</li>
|
||||
* <li>INSTANCE_NAME - optional custom name of particular instance as provided by customer</li>
|
||||
* </ul>
|
||||
*/
|
||||
public final class JdpJmxPacket
|
||||
extends JdpGenericPacket
|
||||
implements JdpPacket {
|
||||
|
||||
/**
|
||||
* Session ID
|
||||
*/
|
||||
public final static String UUID_KEY = "DISCOVERABLE_SESSION_UUID";
|
||||
/**
|
||||
* Name of main class
|
||||
*/
|
||||
public final static String MAIN_CLASS_KEY = "MAIN_CLASS";
|
||||
/**
|
||||
* JMX service URL
|
||||
*/
|
||||
public final static String JMX_SERVICE_URL_KEY = "JMX_SERVICE_URL";
|
||||
/**
|
||||
* Name of Java instance
|
||||
*/
|
||||
public final static String INSTANCE_NAME_KEY = "INSTANCE_NAME";
|
||||
/**
|
||||
* PID of java process, optional presented if it could be obtained
|
||||
*/
|
||||
public final static String PROCESS_ID_KEY = "PROCESS_ID";
|
||||
/**
|
||||
* Hostname of rmi server, optional presented if user overrides rmi server
|
||||
* hostname by java.rmi.server.hostname property
|
||||
*/
|
||||
public final static String RMI_HOSTNAME_KEY = "RMI_HOSTNAME";
|
||||
/**
|
||||
* Configured broadcast interval, optional
|
||||
*/
|
||||
public final static String BROADCAST_INTERVAL_KEY = "BROADCAST_INTERVAL";
|
||||
|
||||
private UUID id;
|
||||
private String mainClass;
|
||||
private String jmxServiceUrl;
|
||||
private String instanceName;
|
||||
private String processId;
|
||||
private String rmiHostname;
|
||||
private String broadcastInterval;
|
||||
|
||||
/**
|
||||
* Create new instance from user provided data. Set mandatory fields
|
||||
*
|
||||
* @param id - java instance id
|
||||
* @param jmxServiceUrl - JMX service url
|
||||
*/
|
||||
public JdpJmxPacket(UUID id, String jmxServiceUrl) {
|
||||
this.id = id;
|
||||
this.jmxServiceUrl = jmxServiceUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new instance from network data Parse packet and set fields.
|
||||
*
|
||||
* @param data - raw packet data as it came from a Net
|
||||
* @throws JdpException
|
||||
*/
|
||||
public JdpJmxPacket(byte[] data)
|
||||
throws JdpException {
|
||||
JdpPacketReader reader;
|
||||
|
||||
reader = new JdpPacketReader(data);
|
||||
Map<String, String> p = reader.getDiscoveryDataAsMap();
|
||||
|
||||
String sId = p.get(UUID_KEY);
|
||||
this.id = (sId == null) ? null : UUID.fromString(sId);
|
||||
this.jmxServiceUrl = p.get(JMX_SERVICE_URL_KEY);
|
||||
this.mainClass = p.get(MAIN_CLASS_KEY);
|
||||
this.instanceName = p.get(INSTANCE_NAME_KEY);
|
||||
this.processId = p.get(PROCESS_ID_KEY);
|
||||
this.rmiHostname = p.get(RMI_HOSTNAME_KEY);
|
||||
this.broadcastInterval = p.get(BROADCAST_INTERVAL_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set main class field
|
||||
*
|
||||
* @param mainClass - main class of running app
|
||||
*/
|
||||
public void setMainClass(String mainClass) {
|
||||
this.mainClass = mainClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set instance name field
|
||||
*
|
||||
* @param instanceName - name of instance as provided by customer
|
||||
*/
|
||||
public void setInstanceName(String instanceName) {
|
||||
this.instanceName = instanceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return id of discovery session
|
||||
*/
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return main class field
|
||||
*/
|
||||
public String getMainClass() {
|
||||
return mainClass;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return JMX service URL
|
||||
*/
|
||||
public String getJmxServiceUrl() {
|
||||
return jmxServiceUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return instance name
|
||||
*/
|
||||
public String getInstanceName() {
|
||||
return instanceName;
|
||||
}
|
||||
|
||||
public String getProcessId() {
|
||||
return processId;
|
||||
}
|
||||
|
||||
public void setProcessId(String processId) {
|
||||
this.processId = processId;
|
||||
}
|
||||
|
||||
public String getRmiHostname() {
|
||||
return rmiHostname;
|
||||
}
|
||||
|
||||
public void setRmiHostname(String rmiHostname) {
|
||||
this.rmiHostname = rmiHostname;
|
||||
}
|
||||
|
||||
public String getBroadcastInterval() {
|
||||
return broadcastInterval;
|
||||
}
|
||||
|
||||
public void setBroadcastInterval(String broadcastInterval) {
|
||||
this.broadcastInterval = broadcastInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return assembled packet ready to be sent across a Net
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public byte[] getPacketData() throws IOException {
|
||||
// Assemble packet from fields to byte array
|
||||
JdpPacketWriter writer;
|
||||
writer = new JdpPacketWriter();
|
||||
writer.addEntry(UUID_KEY, (id == null) ? null : id.toString());
|
||||
writer.addEntry(MAIN_CLASS_KEY, mainClass);
|
||||
writer.addEntry(JMX_SERVICE_URL_KEY, jmxServiceUrl);
|
||||
writer.addEntry(INSTANCE_NAME_KEY, instanceName);
|
||||
writer.addEntry(PROCESS_ID_KEY, processId);
|
||||
writer.addEntry(RMI_HOSTNAME_KEY, rmiHostname);
|
||||
writer.addEntry(BROADCAST_INTERVAL_KEY, broadcastInterval);
|
||||
|
||||
return writer.getPacketBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return packet hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1;
|
||||
hash = hash * 31 + id.hashCode();
|
||||
hash = hash * 31 + jmxServiceUrl.hashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two packets
|
||||
*
|
||||
* @param o - packet to compare
|
||||
* @return either packet equals or not
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o == null || ! (o instanceof JdpJmxPacket) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
JdpJmxPacket p = (JdpJmxPacket) o;
|
||||
return Objects.equals(id, p.getId()) && Objects.equals(jmxServiceUrl, p.getJmxServiceUrl());
|
||||
}
|
||||
}
|
||||
64
jdkSrc/jdk8/sun/management/jdp/JdpPacket.java
Normal file
64
jdkSrc/jdk8/sun/management/jdp/JdpPacket.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management.jdp;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Packet to broadcast
|
||||
*
|
||||
* <p>Each packet have to contain MAGIC and PROTOCOL_VERSION in order to be
|
||||
* recognized as a valid JDP packet.</p>
|
||||
*
|
||||
* <p>Default implementation build packet as a set of UTF-8 encoded Key/Value pairs
|
||||
* are stored as an ordered list of values, and are sent to the server
|
||||
* in that order.</p>
|
||||
*
|
||||
* <p>
|
||||
* Packet structure:
|
||||
*
|
||||
* 4 bytes JDP magic (0xC0FFE42)
|
||||
* 2 bytes JDP protocol version (01)
|
||||
*
|
||||
* 2 bytes size of key
|
||||
* x bytes key (UTF-8 encoded)
|
||||
* 2 bytes size of value
|
||||
* x bytes value (UTF-8 encoded)
|
||||
*
|
||||
* repeat as many times as necessary ...
|
||||
* </p>
|
||||
*/
|
||||
public interface JdpPacket {
|
||||
|
||||
/**
|
||||
* This method responsible to assemble packet and return a byte array
|
||||
* ready to be sent across a Net.
|
||||
*
|
||||
* @return assembled packet as an array of bytes
|
||||
* @throws IOException
|
||||
*/
|
||||
public byte[] getPacketData() throws IOException;
|
||||
|
||||
}
|
||||
141
jdkSrc/jdk8/sun/management/jdp/JdpPacketReader.java
Normal file
141
jdkSrc/jdk8/sun/management/jdp/JdpPacketReader.java
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management.jdp;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* JdpPacketReader responsible for reading a packet <p>This class gets a byte
|
||||
* array as it came from a Net, validates it and breaks a part </p>
|
||||
*/
|
||||
public final class JdpPacketReader {
|
||||
|
||||
private final DataInputStream pkt;
|
||||
private Map<String, String> pmap = null;
|
||||
|
||||
/**
|
||||
* Create packet reader, extract and check magic and version
|
||||
*
|
||||
* @param packet - packet received from a Net
|
||||
* @throws JdpException
|
||||
*/
|
||||
public JdpPacketReader(byte[] packet)
|
||||
throws JdpException {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(packet);
|
||||
pkt = new DataInputStream(bais);
|
||||
|
||||
try {
|
||||
int magic = pkt.readInt();
|
||||
JdpGenericPacket.checkMagic(magic);
|
||||
} catch (IOException e) {
|
||||
throw new JdpException("Invalid JDP packet received, bad magic");
|
||||
}
|
||||
|
||||
try {
|
||||
short version = pkt.readShort();
|
||||
JdpGenericPacket.checkVersion(version);
|
||||
} catch (IOException e) {
|
||||
throw new JdpException("Invalid JDP packet received, bad protocol version");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next entry from packet
|
||||
*
|
||||
* @return the entry
|
||||
* @throws EOFException
|
||||
* @throws JdpException
|
||||
*/
|
||||
public String getEntry()
|
||||
throws EOFException, JdpException {
|
||||
|
||||
try {
|
||||
short len = pkt.readShort();
|
||||
// Artificial setting the "len" field to Short.MAX_VALUE may cause a reader to allocate
|
||||
// to much memory. Prevent this possible DOS attack.
|
||||
if (len < 1 && len > pkt.available()) {
|
||||
throw new JdpException("Broken JDP packet. Invalid entry length field.");
|
||||
}
|
||||
|
||||
byte[] b = new byte[len];
|
||||
if (pkt.read(b) != len) {
|
||||
throw new JdpException("Broken JDP packet. Unable to read entry.");
|
||||
}
|
||||
return new String(b, "UTF-8");
|
||||
|
||||
} catch (EOFException e) {
|
||||
throw e;
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new JdpException("Broken JDP packet. Unable to decode entry.");
|
||||
} catch (IOException e) {
|
||||
throw new JdpException("Broken JDP packet. Unable to read entry.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* return packet content as a key/value map
|
||||
*
|
||||
* @return map containing packet entries pair of entries treated as
|
||||
* key,value
|
||||
* @throws IOException
|
||||
* @throws JdpException
|
||||
*/
|
||||
public Map<String, String> getDiscoveryDataAsMap()
|
||||
throws JdpException {
|
||||
// return cached map if possible
|
||||
if (pmap != null) {
|
||||
return pmap;
|
||||
}
|
||||
|
||||
String key = null, value = null;
|
||||
|
||||
final Map<String, String> tmpMap = new HashMap<>();
|
||||
try {
|
||||
while (true) {
|
||||
key = getEntry();
|
||||
value = getEntry();
|
||||
tmpMap.put(key, value);
|
||||
}
|
||||
} catch (EOFException e) {
|
||||
// EOF reached on reading value, report broken packet
|
||||
// otherwise ignore it.
|
||||
if (value == null) {
|
||||
throw new JdpException("Broken JDP packet. Key without value." + key);
|
||||
}
|
||||
}
|
||||
|
||||
pmap = Collections.unmodifiableMap(tmpMap);
|
||||
return pmap;
|
||||
}
|
||||
}
|
||||
98
jdkSrc/jdk8/sun/management/jdp/JdpPacketWriter.java
Normal file
98
jdkSrc/jdk8/sun/management/jdp/JdpPacketWriter.java
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
package sun.management.jdp;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* JdpPacketWriter responsible for writing a packet
|
||||
* <p>This class assembles a set of key/value pairs to valid JDP packet,
|
||||
* ready to be sent across a Net</p>
|
||||
*/
|
||||
public final class JdpPacketWriter {
|
||||
|
||||
private final ByteArrayOutputStream baos;
|
||||
private final DataOutputStream pkt;
|
||||
|
||||
/**
|
||||
* Create a JDP packet, add mandatory magic and version headers
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public JdpPacketWriter()
|
||||
throws IOException {
|
||||
baos = new ByteArrayOutputStream();
|
||||
pkt = new DataOutputStream(baos);
|
||||
|
||||
pkt.writeInt(JdpGenericPacket.getMagic());
|
||||
pkt.writeShort(JdpGenericPacket.getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Put string entry to packet
|
||||
*
|
||||
* @param entry - string to put (utf-8 encoded)
|
||||
* @throws IOException
|
||||
*/
|
||||
public void addEntry(String entry)
|
||||
throws IOException {
|
||||
/* DataOutputStream.writeUTF() do essentially
|
||||
* the same as:
|
||||
* pkt.writeShort(entry.getBytes("UTF-8").length);
|
||||
* pkt.write(entry.getBytes("UTF-8"));
|
||||
*/
|
||||
pkt.writeUTF(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put key/value pair to packet
|
||||
*
|
||||
* @param key - key to put (utf-8 encoded)
|
||||
* @param val - value to put (utf-8 encoded)
|
||||
* @throws IOException
|
||||
*/
|
||||
public void addEntry(String key, String val)
|
||||
throws IOException {
|
||||
/* Silently skip key if value is null.
|
||||
* We don't need to distinguish between key missing
|
||||
* and key has no value cases
|
||||
*/
|
||||
if (val != null) {
|
||||
addEntry(key);
|
||||
addEntry(val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return assembled packet as a byte array
|
||||
*
|
||||
* @return packet bytes
|
||||
*/
|
||||
public byte[] getPacketBytes() {
|
||||
return baos.toByteArray();
|
||||
}
|
||||
}
|
||||
79
jdkSrc/jdk8/sun/management/jdp/package-info.java
Normal file
79
jdkSrc/jdk8/sun/management/jdp/package-info.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* Summary
|
||||
* -------
|
||||
*
|
||||
* Define a lightweight network protocol for discovering running and
|
||||
* manageable Java processes within a network subnet.
|
||||
*
|
||||
*
|
||||
* Description
|
||||
* -----------
|
||||
*
|
||||
* The protocol is lightweight multicast based, and works like a beacon,
|
||||
* broadcasting the JMXService URL needed to connect to the external JMX
|
||||
* agent if an application is started with appropriate parameters.
|
||||
*
|
||||
* The payload is structured like this:
|
||||
*
|
||||
* 4 bytes JDP magic (0xC0FFEE42)
|
||||
* 2 bytes JDP protocol version (1)
|
||||
* 2 bytes size of the next entry
|
||||
* x bytes next entry (UTF-8 encoded)
|
||||
* 2 bytes size of next entry
|
||||
* ... Rinse and repeat...
|
||||
*
|
||||
* The payload will be parsed as even entries being keys, odd entries being
|
||||
* values.
|
||||
*
|
||||
* The standard JDP packet contains four entries:
|
||||
*
|
||||
* - `DISCOVERABLE_SESSION_UUID` -- Unique id of the instance; this id changes every time
|
||||
* the discovery protocol starts and stops
|
||||
*
|
||||
* - `MAIN_CLASS` -- The value of the `sun.java.command` property
|
||||
*
|
||||
* - `JMX_SERVICE_URL` -- The URL to connect to the JMX agent
|
||||
*
|
||||
* - `INSTANCE_NAME` -- The user-provided name of the running instance
|
||||
*
|
||||
* The protocol sends packets to 224.0.23.178:7095 by default.
|
||||
*
|
||||
* The protocol uses system properties to control it's behaviour:
|
||||
* - `com.sun.management.jdp.port` -- override default port
|
||||
*
|
||||
* - `com.sun.management.jdp.address` -- override default address
|
||||
*
|
||||
* - `com.sun.management.jmxremote.autodiscovery` -- whether we should start autodiscovery or
|
||||
* not. Autodiscovery starts if and only if following conditions are met: (autodiscovery is
|
||||
* true OR (autodiscovery is not set AND jdp.port is set))
|
||||
*
|
||||
* - `com.sun.management.jdp.ttl` -- set ttl for broadcast packet, default is 1
|
||||
* - `com.sun.management.jdp.pause` -- set broadcast interval in seconds default is 5
|
||||
* - `com.sun.management.jdp.source_addr` -- an address of interface to use for broadcast
|
||||
*/
|
||||
|
||||
package sun.management.jdp;
|
||||
1040
jdkSrc/jdk8/sun/management/jmxremote/ConnectorBootstrap.java
Normal file
1040
jdkSrc/jdk8/sun/management/jmxremote/ConnectorBootstrap.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.jmxremote;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.rmi.server.RMIServerSocketFactory;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* This RMI server socket factory creates server sockets that
|
||||
* will only accept connection requests from clients running
|
||||
* on the host where the RMI remote objects have been exported.
|
||||
*/
|
||||
public final class LocalRMIServerSocketFactory implements RMIServerSocketFactory {
|
||||
/**
|
||||
* Creates a server socket that only accepts connection requests from
|
||||
* clients running on the host where the RMI remote objects have been
|
||||
* exported.
|
||||
*/
|
||||
public ServerSocket createServerSocket(int port) throws IOException {
|
||||
return new ServerSocket(port) {
|
||||
@Override
|
||||
public Socket accept() throws IOException {
|
||||
final Socket socket = super.accept();
|
||||
final InetAddress remoteAddr = socket.getInetAddress();
|
||||
final String msg = "The server sockets created using the " +
|
||||
"LocalRMIServerSocketFactory only accept connections " +
|
||||
"from clients running on the host where the RMI " +
|
||||
"remote objects have been exported.";
|
||||
|
||||
if (remoteAddr == null) {
|
||||
// Though unlikeky, the socket could be already
|
||||
// closed... Send a more detailed message in
|
||||
// this case. Also avoid throwing NullPointerExceptiion
|
||||
//
|
||||
String details = "";
|
||||
if (socket.isClosed()) {
|
||||
details = " Socket is closed.";
|
||||
} else if (!socket.isConnected()) {
|
||||
details = " Socket is not connected";
|
||||
}
|
||||
try {
|
||||
socket.close();
|
||||
} catch (Exception ok) {
|
||||
// ok - this is just cleanup before throwing detailed
|
||||
// exception.
|
||||
}
|
||||
throw new IOException(msg +
|
||||
" Couldn't determine client address." +
|
||||
details);
|
||||
} else if (remoteAddr.isLoopbackAddress()) {
|
||||
// local address: accept the connection.
|
||||
return socket;
|
||||
}
|
||||
// Retrieve all the network interfaces on this host.
|
||||
Enumeration<NetworkInterface> nis;
|
||||
try {
|
||||
nis = NetworkInterface.getNetworkInterfaces();
|
||||
} catch (SocketException e) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException ioe) {
|
||||
// Ignore...
|
||||
}
|
||||
throw new IOException(msg, e);
|
||||
}
|
||||
// Walk through the network interfaces to see
|
||||
// if any of them matches the client's address.
|
||||
// If true, then the client's address is local.
|
||||
while (nis.hasMoreElements()) {
|
||||
NetworkInterface ni = nis.nextElement();
|
||||
Enumeration<InetAddress> addrs = ni.getInetAddresses();
|
||||
while (addrs.hasMoreElements()) {
|
||||
InetAddress localAddr = addrs.nextElement();
|
||||
if (localAddr.equals(remoteAddr)) {
|
||||
return socket;
|
||||
}
|
||||
}
|
||||
}
|
||||
// The client's address is remote so refuse the connection.
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException ioe) {
|
||||
// Ignore...
|
||||
}
|
||||
throw new IOException(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Two LocalRMIServerSocketFactory objects
|
||||
* are equal if they are of the same type.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof LocalRMIServerSocketFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this LocalRMIServerSocketFactory.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
}
|
||||
109
jdkSrc/jdk8/sun/management/jmxremote/SingleEntryRegistry.java
Normal file
109
jdkSrc/jdk8/sun/management/jmxremote/SingleEntryRegistry.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author Sun Microsystems, Inc.
|
||||
* @build @BUILD_TAG_PLACEHOLDER@
|
||||
*
|
||||
* @COPYRIGHT_MINI_LEGAL_NOTICE_PLACEHOLDER@
|
||||
*/
|
||||
|
||||
package sun.management.jmxremote;
|
||||
|
||||
import sun.misc.ObjectInputFilter;
|
||||
import java.rmi.AccessException;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.RMIClientSocketFactory;
|
||||
import java.rmi.server.RMIServerSocketFactory;
|
||||
|
||||
import sun.rmi.registry.RegistryImpl;
|
||||
|
||||
/** A Registry that consists of a single entry that never changes. */
|
||||
public class SingleEntryRegistry extends RegistryImpl {
|
||||
SingleEntryRegistry(int port, String name, Remote object)
|
||||
throws RemoteException {
|
||||
super(port, null, null, SingleEntryRegistry::singleRegistryFilter);
|
||||
this.name = name;
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
SingleEntryRegistry(int port,
|
||||
RMIClientSocketFactory csf,
|
||||
RMIServerSocketFactory ssf,
|
||||
String name,
|
||||
Remote object)
|
||||
throws RemoteException {
|
||||
super(port, csf, ssf, SingleEntryRegistry::singleRegistryFilter);
|
||||
this.name = name;
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public String[] list() {
|
||||
return new String[] {name};
|
||||
}
|
||||
|
||||
public Remote lookup(String name) throws NotBoundException {
|
||||
if (name.equals(this.name))
|
||||
return object;
|
||||
throw new NotBoundException("Not bound: \"" + name + "\" (only " +
|
||||
"bound name is \"" + this.name + "\")");
|
||||
}
|
||||
|
||||
public void bind(String name, Remote obj) throws AccessException {
|
||||
throw new AccessException("Cannot modify this registry");
|
||||
}
|
||||
|
||||
public void rebind(String name, Remote obj) throws AccessException {
|
||||
throw new AccessException("Cannot modify this registry");
|
||||
}
|
||||
|
||||
public void unbind(String name) throws AccessException {
|
||||
throw new AccessException("Cannot modify this registry");
|
||||
}
|
||||
|
||||
/**
|
||||
* ObjectInputFilter to check parameters to SingleEntryRegistry.
|
||||
* Since it is a read-only Registry, no classes are accepted.
|
||||
* String arguments are accepted without passing them to the serialFilter.
|
||||
*
|
||||
* @param info a reference to the serialization filter information
|
||||
* @return Status.REJECTED if parameters are out of range
|
||||
*/
|
||||
private static ObjectInputFilter.Status singleRegistryFilter(ObjectInputFilter.FilterInfo info) {
|
||||
return (info.serialClass() != null ||
|
||||
info.depth() > 2 ||
|
||||
info.references() > 4 ||
|
||||
info.arrayLength() >= 0)
|
||||
? ObjectInputFilter.Status.REJECTED
|
||||
: ObjectInputFilter.Status.ALLOWED;
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final Remote object;
|
||||
|
||||
private static final long serialVersionUID = -4897238949499730950L;
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "Access file not readable" },
|
||||
{ "agent.err.access.file.notfound", "Access file not found" },
|
||||
{ "agent.err.access.file.notset", "Access file is not specified but com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.access.file.read.failed", "Failed in reading the access file" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "Password file read access must be restricted" },
|
||||
{ "agent.err.acl.file.not.readable", "SNMP ACL file not readable" },
|
||||
{ "agent.err.acl.file.notfound", "SNMP ACL file not found" },
|
||||
{ "agent.err.acl.file.notset", "No SNMP ACL file is specified but com.sun.management.snmp.acl=true" },
|
||||
{ "agent.err.acl.file.read.failed", "Failed in reading SNMP ACL file" },
|
||||
{ "agent.err.agentclass.access.denied", "Access to premain(String) is denied" },
|
||||
{ "agent.err.agentclass.failed", "Management agent class failed " },
|
||||
{ "agent.err.agentclass.notfound", "Management agent class not found" },
|
||||
{ "agent.err.configfile.access.denied", "Access to the config file is denied" },
|
||||
{ "agent.err.configfile.closed.failed", "Failed in closing the config file" },
|
||||
{ "agent.err.configfile.failed", "Failed in reading the config file" },
|
||||
{ "agent.err.configfile.notfound", "Config file not found" },
|
||||
{ "agent.err.connector.server.io.error", "JMX connector server communication error" },
|
||||
{ "agent.err.error", "Error" },
|
||||
{ "agent.err.exception", "Exception thrown by the agent " },
|
||||
{ "agent.err.exportaddress.failed", "Export of JMX connector address to instrumentation buffer failed" },
|
||||
{ "agent.err.file.access.not.restricted", "File read access must be restricted" },
|
||||
{ "agent.err.file.not.found", "File not found" },
|
||||
{ "agent.err.file.not.readable", "File not readable" },
|
||||
{ "agent.err.file.not.set", "File not specified" },
|
||||
{ "agent.err.file.read.failed", "Failed in reading the file" },
|
||||
{ "agent.err.invalid.agentclass", "Invalid com.sun.management.agent.class property value" },
|
||||
{ "agent.err.invalid.jmxremote.port", "Invalid com.sun.management.jmxremote.port number" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "Invalid com.sun.management.jmxremote.rmi.port number" },
|
||||
{ "agent.err.invalid.option", "Invalid option specified" },
|
||||
{ "agent.err.invalid.snmp.port", "Invalid com.sun.management.snmp.port number" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "Invalid com.sun.management.snmp.trap number" },
|
||||
{ "agent.err.invalid.state", "Invalid agent state: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "Password file read access must be restricted" },
|
||||
{ "agent.err.password.file.not.readable", "Password file not readable" },
|
||||
{ "agent.err.password.file.notfound", "Password file not found" },
|
||||
{ "agent.err.password.file.notset", "Password file is not specified but com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.password.file.read.failed", "Failed in reading the password file" },
|
||||
{ "agent.err.premain.notfound", "premain(String) does not exist in agent class" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "Failed to start SNMP adaptor with address" },
|
||||
{ "agent.err.snmp.mib.init.failed", "Failed to initialize SNMP MIB with error" },
|
||||
{ "agent.err.unknown.snmp.interface", "Unknown SNMP interface" },
|
||||
{ "agent.err.warning", "Warning" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "Adding target: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "Adaptor ready." },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "SNMP Adaptor ready on: {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "Processing ACL" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "Starting Adaptor Server:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "terminate {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "File read access must be restricted: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "No Authentication" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "Password file read access must be restricted: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "JMX Connector ready at: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "Starting JMX Connector Server:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_de.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_de.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_de extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "Zugriffsdatei kann nicht gelesen werden" },
|
||||
{ "agent.err.access.file.notfound", "Zugriffsdatei nicht gefunden" },
|
||||
{ "agent.err.access.file.notset", "Es wurde keine Zugriffsdatei angegeben, obwohl com.sun.management.jmxremote.authenticate auf \"true\" gesetzt ist" },
|
||||
{ "agent.err.access.file.read.failed", "Zugriffsdatei konnte nicht gelesen werden" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "Lesezugriff auf Kennwortdatei muss eingeschr\u00E4nkt werden" },
|
||||
{ "agent.err.acl.file.not.readable", "SNMP-ACL-Datei kann nicht gelesen werden" },
|
||||
{ "agent.err.acl.file.notfound", "SNMP-ACL-Datei konnte nicht gefunden werden" },
|
||||
{ "agent.err.acl.file.notset", "Es wurde keine SNMP-ACL-Datei angegeben, obwohl com.sun.management.snmp.acl auf \"true\" gesetzt ist" },
|
||||
{ "agent.err.acl.file.read.failed", "SNMP-ACL-Datei konnte nicht gelesen werden" },
|
||||
{ "agent.err.agentclass.access.denied", "Zugriff auf premain(String) wurde abgelehnt" },
|
||||
{ "agent.err.agentclass.failed", "Management Agent-Klasse nicht erfolgreich" },
|
||||
{ "agent.err.agentclass.notfound", "Management Agent-Klasse nicht gefunden" },
|
||||
{ "agent.err.configfile.access.denied", "Zugriff auf Konfigurationsdatei wurde abgelehnt" },
|
||||
{ "agent.err.configfile.closed.failed", "Konfigurationsdatei konnte nicht geschlossen werden" },
|
||||
{ "agent.err.configfile.failed", "Konfigurationsdatei konnte nicht gelesen werden" },
|
||||
{ "agent.err.configfile.notfound", "Konfigurationsdatei wurde nicht gefunden" },
|
||||
{ "agent.err.connector.server.io.error", "Fehler bei JMX-Connector-Serverkommunikation" },
|
||||
{ "agent.err.error", "Fehler" },
|
||||
{ "agent.err.exception", "Ausnahme von Agent ausgel\u00F6st " },
|
||||
{ "agent.err.exportaddress.failed", "Export der JMX-Connector-Adresse in Instrumentierungspuffer nicht erfolgreich" },
|
||||
{ "agent.err.file.access.not.restricted", "Lesezugriff auf Datei muss eingeschr\u00E4nkt werden" },
|
||||
{ "agent.err.file.not.found", "Datei wurde nicht gefunden" },
|
||||
{ "agent.err.file.not.readable", "Datei nicht lesbar" },
|
||||
{ "agent.err.file.not.set", "Datei nicht angegeben" },
|
||||
{ "agent.err.file.read.failed", "Datei konnte nicht gelesen werden" },
|
||||
{ "agent.err.invalid.agentclass", "Ung\u00FCltiger Eigenschaftswert f\u00FCr com.sun.management.agent.class" },
|
||||
{ "agent.err.invalid.jmxremote.port", "Ung\u00FCltige Nummer f\u00FCr com.sun.management.jmxremote.port" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "Ung\u00FCltige Nummer f\u00FCr com.sun.management.jmxremote.rmi.port" },
|
||||
{ "agent.err.invalid.option", "Ung\u00FCltige Option angegeben" },
|
||||
{ "agent.err.invalid.snmp.port", "Ung\u00FCltige Nummer f\u00FCr com.sun.management.snmp.port" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "Ung\u00FCltige Nummer f\u00FCr com.sun.management.snmp.trap" },
|
||||
{ "agent.err.invalid.state", "Ung\u00FCltiger Agent-Zustand: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "Lesezugriff auf Kennwortdatei muss eingeschr\u00E4nkt werden" },
|
||||
{ "agent.err.password.file.not.readable", "Kennwortdatei nicht lesbar" },
|
||||
{ "agent.err.password.file.notfound", "Kennwortdatei nicht gefunden" },
|
||||
{ "agent.err.password.file.notset", "Es wurde keine Kennwortdatei angegeben, obwohl com.sun.management.jmxremote.authenticate auf \"true\" gesetzt ist" },
|
||||
{ "agent.err.password.file.read.failed", "Kennwortdatei konnte nicht gelesen werden" },
|
||||
{ "agent.err.premain.notfound", "premain(String) ist in Agent-Klasse nicht vorhanden" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "Fehler beim Starten des SNMP-Adaptors mit Adresse" },
|
||||
{ "agent.err.snmp.mib.init.failed", "Initialisierung von SNMP-MIB nicht erfolgreich mit Fehler" },
|
||||
{ "agent.err.unknown.snmp.interface", "Unbekannte SNMP-Schnittstelle" },
|
||||
{ "agent.err.warning", "Warnung" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "Ziel hinzuf\u00FCgen: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "Adaptor bereit." },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "SNMP-Adaptor bereit unter: {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "ACL wird verarbeitet" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "Adaptor-Server starten:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "{0} beenden" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "Lesezugriff auf Datei muss eingeschr\u00E4nkt werden: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "Keine Authentifizierung" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "Lesezugriff auf Kennwortdatei muss eingeschr\u00E4nkt werden: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "JMX-Connector bereit unter: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "JMX-Connector-Server starten:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_es.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_es.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_es extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "No se puede leer el archivo de acceso" },
|
||||
{ "agent.err.access.file.notfound", "Archivo de acceso no encontrado" },
|
||||
{ "agent.err.access.file.notset", "El archivo de acceso no se ha especificado, pero com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.access.file.read.failed", "Fallo al leer el archivo de acceso" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "Se debe restringir el acceso de lectura al archivo de contrase\u00F1as" },
|
||||
{ "agent.err.acl.file.not.readable", "No se puede leer el archivo ACL de SNMP" },
|
||||
{ "agent.err.acl.file.notfound", "Archivo ACL de SNMP no encontrado" },
|
||||
{ "agent.err.acl.file.notset", "No se ha especificado ning\u00FAn archivo ACL de SNMP, pero com.sun.management.snmp.acl=true" },
|
||||
{ "agent.err.acl.file.read.failed", "Fallo al leer el archivo ACL de SNMP" },
|
||||
{ "agent.err.agentclass.access.denied", "Acceso denegado a premain(String)" },
|
||||
{ "agent.err.agentclass.failed", "Fallo de clase de agente de gesti\u00F3n " },
|
||||
{ "agent.err.agentclass.notfound", "Clase de agente de gesti\u00F3n no encontrada" },
|
||||
{ "agent.err.configfile.access.denied", "Acceso denegado al archivo de configuraci\u00F3n" },
|
||||
{ "agent.err.configfile.closed.failed", "Fallo al cerrar el archivo de configuraci\u00F3n" },
|
||||
{ "agent.err.configfile.failed", "Fallo al leer el archivo de configuraci\u00F3n" },
|
||||
{ "agent.err.configfile.notfound", "No se ha encontrado el archivo de configuraci\u00F3n" },
|
||||
{ "agent.err.connector.server.io.error", "Error de comunicaci\u00F3n con el servidor de conector JMX" },
|
||||
{ "agent.err.error", "Error" },
|
||||
{ "agent.err.exception", "Excepci\u00F3n devuelta por el agente " },
|
||||
{ "agent.err.exportaddress.failed", "Fallo al exportar la direcci\u00F3n del conector JMX al buffer de instrumentaci\u00F3n" },
|
||||
{ "agent.err.file.access.not.restricted", "El acceso de lectura al archivo debe ser restringido" },
|
||||
{ "agent.err.file.not.found", "Archivo no encontrado" },
|
||||
{ "agent.err.file.not.readable", "Archivo ilegible" },
|
||||
{ "agent.err.file.not.set", "Archivo no especificado" },
|
||||
{ "agent.err.file.read.failed", "Fallo al leer el archivo" },
|
||||
{ "agent.err.invalid.agentclass", "Valor de propiedad com.sun.management.agent.class no v\u00E1lido" },
|
||||
{ "agent.err.invalid.jmxremote.port", "N\u00FAmero com.sun.management.jmxremote.port no v\u00E1lido" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "N\u00FAmero com.sun.management.jmxremote.rmi.port no v\u00E1lido" },
|
||||
{ "agent.err.invalid.option", "Opci\u00F3n especificada no v\u00E1lida" },
|
||||
{ "agent.err.invalid.snmp.port", "N\u00FAmero de com.sun.management.snmp.port no v\u00E1lido" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "N\u00FAmero de com.sun.management.snmp.trap no v\u00E1lido" },
|
||||
{ "agent.err.invalid.state", "Estado de agente no v\u00E1lido: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "Se debe restringir el acceso de lectura al archivo de contrase\u00F1as" },
|
||||
{ "agent.err.password.file.not.readable", "No se puede leer el archivo de contrase\u00F1as" },
|
||||
{ "agent.err.password.file.notfound", "Archivo de contrase\u00F1as no encontrado" },
|
||||
{ "agent.err.password.file.notset", "El archivo de contrase\u00F1as no se ha especificado, pero com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.password.file.read.failed", "Fallo al leer el archivo de contrase\u00F1as" },
|
||||
{ "agent.err.premain.notfound", "premain(String) no existe en la clase del agente" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "Fallo al iniciar el adaptador de SNMP con la direcci\u00F3n" },
|
||||
{ "agent.err.snmp.mib.init.failed", "Fallo al inicializar el MIB de SNMP con error" },
|
||||
{ "agent.err.unknown.snmp.interface", "Interfaz SNMP desconocida" },
|
||||
{ "agent.err.warning", "Advertencia" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "Agregando destino: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "Adaptador listo." },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "Adaptador SNMP listo en: {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "Procesando ACL" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "Iniciando servidor de adaptador:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "terminar {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "El acceso de lectura al archivo debe ser restringido: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "Sin autenticaci\u00F3n" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "Se debe restringir el acceso de lectura al archivo de contrase\u00F1as: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "Conector JMX listo en: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "Iniciando servidor de conector JMX:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_fr.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_fr.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_fr extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "Fichier d'acc\u00E8s illisible" },
|
||||
{ "agent.err.access.file.notfound", "Fichier d'acc\u00E8s introuvable" },
|
||||
{ "agent.err.access.file.notset", "Le fichier d'acc\u00E8s n'est pas sp\u00E9cifi\u00E9 mais com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.access.file.read.failed", "Impossible de lire le fichier d'acc\u00E8s" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "L'acc\u00E8s en lecture au fichier de mots de passe doit \u00EAtre limit\u00E9" },
|
||||
{ "agent.err.acl.file.not.readable", "Fichier de liste de contr\u00F4le d'acc\u00E8s (ACL) SNMP illisible" },
|
||||
{ "agent.err.acl.file.notfound", "Fichier de liste de contr\u00F4le d'acc\u00E8s (ACL) SNMP introuvable" },
|
||||
{ "agent.err.acl.file.notset", "Aucun fichier de liste de contr\u00F4le d'acc\u00E8s (ACL) SNMP n'est sp\u00E9cifi\u00E9 mais com.sun.management.snmp.acl=true" },
|
||||
{ "agent.err.acl.file.read.failed", "Impossible de lire le fichier de liste de contr\u00F4le d'acc\u00E8s (ACL) SNMP" },
|
||||
{ "agent.err.agentclass.access.denied", "Acc\u00E8s \u00E0 premain(String) refus\u00E9" },
|
||||
{ "agent.err.agentclass.failed", "Echec de la classe d'agents de gestion " },
|
||||
{ "agent.err.agentclass.notfound", "Classe d'agents de gestion introuvable" },
|
||||
{ "agent.err.configfile.access.denied", "Acc\u00E8s refus\u00E9 au fichier de configuration" },
|
||||
{ "agent.err.configfile.closed.failed", "Impossible de fermer le fichier de configuration" },
|
||||
{ "agent.err.configfile.failed", "Impossible de lire le fichier de configuration" },
|
||||
{ "agent.err.configfile.notfound", "Fichier de configuration introuvable" },
|
||||
{ "agent.err.connector.server.io.error", "Erreur de communication avec le serveur du connecteur JMX" },
|
||||
{ "agent.err.error", "Erreur" },
|
||||
{ "agent.err.exception", "Exception envoy\u00E9e par l'agent " },
|
||||
{ "agent.err.exportaddress.failed", "Impossible d'exporter l'adresse du connecteur JMX dans le tampon d'instrumentation" },
|
||||
{ "agent.err.file.access.not.restricted", "L'acc\u00E8s en lecture au fichier doit \u00EAtre limit\u00E9" },
|
||||
{ "agent.err.file.not.found", "Fichier introuvable" },
|
||||
{ "agent.err.file.not.readable", "Fichier illisible" },
|
||||
{ "agent.err.file.not.set", "Fichier non sp\u00E9cifi\u00E9" },
|
||||
{ "agent.err.file.read.failed", "Impossible de lire le fichier" },
|
||||
{ "agent.err.invalid.agentclass", "Valeur de propri\u00E9t\u00E9 com.sun.management.agent.class incorrecte" },
|
||||
{ "agent.err.invalid.jmxremote.port", "Num\u00E9ro com.sun.management.jmxremote.port incorrect" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "Num\u00E9ro com.sun.management.jmxremote.rmi.port non valide" },
|
||||
{ "agent.err.invalid.option", "Option sp\u00E9cifi\u00E9e non valide" },
|
||||
{ "agent.err.invalid.snmp.port", "Num\u00E9ro com.sun.management.snmp.port incorrect" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "Num\u00E9ro com.sun.management.snmp.trap incorrect" },
|
||||
{ "agent.err.invalid.state", "Etat de l''agent non valide : {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "L'acc\u00E8s en lecture au fichier de mots de passe doit \u00EAtre limit\u00E9" },
|
||||
{ "agent.err.password.file.not.readable", "Fichier de mots de passe illisible" },
|
||||
{ "agent.err.password.file.notfound", "Fichier de mots de passe introuvable" },
|
||||
{ "agent.err.password.file.notset", "Le fichier de mots de passe n'est pas sp\u00E9cifi\u00E9 mais com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.password.file.read.failed", "Impossible de lire le fichier de mots de passe" },
|
||||
{ "agent.err.premain.notfound", "premain(String) n'existe pas dans la classe d'agents" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "Impossible de d\u00E9marrer l'adaptateur SNMP avec l'adresse" },
|
||||
{ "agent.err.snmp.mib.init.failed", "Impossible d'initialiser SNMP MIB avec l'erreur" },
|
||||
{ "agent.err.unknown.snmp.interface", "Interface SNMP inconnue" },
|
||||
{ "agent.err.warning", "Avertissement" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "Ajout de la cible : {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "Adaptateur pr\u00EAt." },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "Adaptateur SNMP pr\u00EAt sur : {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "Traitement de la liste de contr\u00F4le d'acc\u00E8s (ACL)" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "D\u00E9marrage du serveur de l'adaptateur :" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "terminer {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "L''acc\u00E8s en lecture au fichier doit \u00EAtre limit\u00E9 : {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "Pas d'authentification" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "L''acc\u00E8s en lecture au fichier de mots de passe doit \u00EAtre limit\u00E9 : {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "Connecteur JMX pr\u00EAt \u00E0 : {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "D\u00E9marrage du serveur du connecteur JMX :" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_it.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_it.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_it extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "File di accesso non leggibile" },
|
||||
{ "agent.err.access.file.notfound", "File di accesso non trovato" },
|
||||
{ "agent.err.access.file.notset", "Il file di accesso non \u00E8 specificato ma com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.access.file.read.failed", "Errore di lettura file di accesso" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "Limitare l'accesso in lettura al password file" },
|
||||
{ "agent.err.acl.file.not.readable", "File SNMP ACL non leggibile" },
|
||||
{ "agent.err.acl.file.notfound", "File SNMP ACL non trovato" },
|
||||
{ "agent.err.acl.file.notset", "Nessun file SNMP ACL specificato ma com.sun.management.snmp.acl=true" },
|
||||
{ "agent.err.acl.file.read.failed", "Errore di lettura file SNMP ACL" },
|
||||
{ "agent.err.agentclass.access.denied", "Accesso negato a premain(String)" },
|
||||
{ "agent.err.agentclass.failed", "Errore classe agente gestione " },
|
||||
{ "agent.err.agentclass.notfound", "Classe agente gestione non trovata" },
|
||||
{ "agent.err.configfile.access.denied", "Accesso negato al file di configurazione" },
|
||||
{ "agent.err.configfile.closed.failed", "Errore di chiusura file di configurazione" },
|
||||
{ "agent.err.configfile.failed", "Errore di lettura file di configurazione" },
|
||||
{ "agent.err.configfile.notfound", "File di configurazione non trovato" },
|
||||
{ "agent.err.connector.server.io.error", "Errore di comunicazione server del connettore JMX" },
|
||||
{ "agent.err.error", "Errore" },
|
||||
{ "agent.err.exception", "Eccezione dell'agente " },
|
||||
{ "agent.err.exportaddress.failed", "Errore di esportazione dell'indirizzo connettore JMX nel buffer strumenti" },
|
||||
{ "agent.err.file.access.not.restricted", "Limitare l'accesso in lettura al file" },
|
||||
{ "agent.err.file.not.found", "File non trovato" },
|
||||
{ "agent.err.file.not.readable", "File non leggibile" },
|
||||
{ "agent.err.file.not.set", "File non specificato" },
|
||||
{ "agent.err.file.read.failed", "Errore di lettura file" },
|
||||
{ "agent.err.invalid.agentclass", "Valore propriet\u00E0 com.sun.management.agent.class non valido" },
|
||||
{ "agent.err.invalid.jmxremote.port", "Numero com.sun.management.jmxremote.port non valido" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "Numero com.sun.management.jmxremote.rmi.port non valido" },
|
||||
{ "agent.err.invalid.option", "Specificata opzione non valida" },
|
||||
{ "agent.err.invalid.snmp.port", "Numero com.sun.management.snmp.port non valido" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "Numero com.sun.management.snmp.trap non valido" },
|
||||
{ "agent.err.invalid.state", "Stato agente non valido: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "Limitare l'accesso in lettura al password file" },
|
||||
{ "agent.err.password.file.not.readable", "Password file non leggibile" },
|
||||
{ "agent.err.password.file.notfound", "Password file non trovato" },
|
||||
{ "agent.err.password.file.notset", "Il password file non \u00E8 specificato ma com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.password.file.read.failed", "Errore di lettura password file" },
|
||||
{ "agent.err.premain.notfound", "premain(String) non esiste nella classe agente" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "Impossibile avviare l'adattatore SNMP con indirizzo" },
|
||||
{ "agent.err.snmp.mib.init.failed", "Impossibile inizializzare MIB SNMP con errore" },
|
||||
{ "agent.err.unknown.snmp.interface", "Interfaccia SNMP sconosciuta" },
|
||||
{ "agent.err.warning", "Avvertenza" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "Aggiunta destinazione: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "Adattatore pronto." },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "Adattatore SNMP pronto in: {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "Elaborazione ACL" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "Avvio del server adattatore:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "interrompere {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "Limitare l''accesso in lettura al file: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "Nessuna autenticazione" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "Limitare l''accesso in lettura al password file: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "Connettore JMX pronto in: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "Avvio del server connettore JMX:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_ja.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_ja.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_ja extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "\u30A2\u30AF\u30BB\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u307F\u53D6\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093" },
|
||||
{ "agent.err.access.file.notfound", "\u30A2\u30AF\u30BB\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093" },
|
||||
{ "agent.err.access.file.notset", "\u30A2\u30AF\u30BB\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u304C\u3001com.sun.management.jmxremote.authenticate=true\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059" },
|
||||
{ "agent.err.access.file.read.failed", "\u30A2\u30AF\u30BB\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u306B\u5931\u6557\u3057\u307E\u3057\u305F" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "\u30D1\u30B9\u30EF\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u30A2\u30AF\u30BB\u30B9\u306F\u5236\u9650\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059" },
|
||||
{ "agent.err.acl.file.not.readable", "SNMP ACL\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u307F\u53D6\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093" },
|
||||
{ "agent.err.acl.file.notfound", "SNMP ACL\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093" },
|
||||
{ "agent.err.acl.file.notset", "SNMP ACL\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u304C\u3001com.sun.management.snmp.acl=true\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059" },
|
||||
{ "agent.err.acl.file.read.failed", "SNMP ACL\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u306B\u5931\u6557\u3057\u307E\u3057\u305F" },
|
||||
{ "agent.err.agentclass.access.denied", "premain(String)\u3078\u306E\u30A2\u30AF\u30BB\u30B9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F" },
|
||||
{ "agent.err.agentclass.failed", "\u7BA1\u7406\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30FB\u30AF\u30E9\u30B9\u304C\u5931\u6557\u3057\u307E\u3057\u305F " },
|
||||
{ "agent.err.agentclass.notfound", "\u7BA1\u7406\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30FB\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093" },
|
||||
{ "agent.err.configfile.access.denied", "\u69CB\u6210\u30D5\u30A1\u30A4\u30EB\u3078\u306E\u30A2\u30AF\u30BB\u30B9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F" },
|
||||
{ "agent.err.configfile.closed.failed", "\u69CB\u6210\u30D5\u30A1\u30A4\u30EB\u3092\u9589\u3058\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F" },
|
||||
{ "agent.err.configfile.failed", "\u69CB\u6210\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u306B\u5931\u6557\u3057\u307E\u3057\u305F" },
|
||||
{ "agent.err.configfile.notfound", "\u69CB\u6210\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093" },
|
||||
{ "agent.err.connector.server.io.error", "JMX\u30B3\u30CD\u30AF\u30BF\u30FB\u30B5\u30FC\u30D0\u30FC\u306E\u901A\u4FE1\u30A8\u30E9\u30FC" },
|
||||
{ "agent.err.error", "\u30A8\u30E9\u30FC" },
|
||||
{ "agent.err.exception", "\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u304C\u4F8B\u5916\u3092\u30B9\u30ED\u30FC\u3057\u307E\u3057\u305F " },
|
||||
{ "agent.err.exportaddress.failed", "JMX\u30B3\u30CD\u30AF\u30BF\u30FB\u30A2\u30C9\u30EC\u30B9\u306E\u8A08\u6E2C\u30D0\u30C3\u30D5\u30A1\u3078\u306E\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u304C\u5931\u6557\u3057\u307E\u3057\u305F" },
|
||||
{ "agent.err.file.access.not.restricted", "\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u30A2\u30AF\u30BB\u30B9\u306F\u5236\u9650\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059" },
|
||||
{ "agent.err.file.not.found", "\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F" },
|
||||
{ "agent.err.file.not.readable", "\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u307F\u53D6\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093" },
|
||||
{ "agent.err.file.not.set", "\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093" },
|
||||
{ "agent.err.file.read.failed", "\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u306B\u5931\u6557\u3057\u307E\u3057\u305F" },
|
||||
{ "agent.err.invalid.agentclass", "com.sun.management.agent.class\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u5024\u304C\u7121\u52B9\u3067\u3059" },
|
||||
{ "agent.err.invalid.jmxremote.port", "com.sun.management.jmxremote.port\u306E\u756A\u53F7\u304C\u7121\u52B9\u3067\u3059" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "com.sun.management.jmxremote.rmi.port\u306E\u756A\u53F7\u304C\u7121\u52B9\u3067\u3059" },
|
||||
{ "agent.err.invalid.option", "\u7121\u52B9\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u6307\u5B9A\u3055\u308C\u307E\u3057\u305F" },
|
||||
{ "agent.err.invalid.snmp.port", "com.sun.management.snmp.port\u306E\u756A\u53F7\u304C\u7121\u52B9\u3067\u3059" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "com.sun.management.snmp.trap\u306E\u756A\u53F7\u304C\u7121\u52B9\u3067\u3059" },
|
||||
{ "agent.err.invalid.state", "\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u306E\u72B6\u614B\u304C\u7121\u52B9\u3067\u3059: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "\u30D1\u30B9\u30EF\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u30A2\u30AF\u30BB\u30B9\u306F\u5236\u9650\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059" },
|
||||
{ "agent.err.password.file.not.readable", "\u30D1\u30B9\u30EF\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u307F\u53D6\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093" },
|
||||
{ "agent.err.password.file.notfound", "\u30D1\u30B9\u30EF\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093" },
|
||||
{ "agent.err.password.file.notset", "\u30D1\u30B9\u30EF\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u304C\u3001com.sun.management.jmxremote.authenticate=true\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059" },
|
||||
{ "agent.err.password.file.read.failed", "\u30D1\u30B9\u30EF\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u306B\u5931\u6557\u3057\u307E\u3057\u305F" },
|
||||
{ "agent.err.premain.notfound", "premain(String)\u304C\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30FB\u30AF\u30E9\u30B9\u306B\u5B58\u5728\u3057\u307E\u305B\u3093" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "\u3053\u306E\u30A2\u30C9\u30EC\u30B9\u3067SNMP\u30A2\u30C0\u30D7\u30BF\u3092\u958B\u59CB\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F" },
|
||||
{ "agent.err.snmp.mib.init.failed", "\u30A8\u30E9\u30FC\u3067SNMP MIB\u3092\u521D\u671F\u5316\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F" },
|
||||
{ "agent.err.unknown.snmp.interface", "\u4E0D\u660E\u306ASNMP\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u3059" },
|
||||
{ "agent.err.warning", "\u8B66\u544A" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "\u30BF\u30FC\u30B2\u30C3\u30C8\u3092\u8FFD\u52A0\u3057\u3066\u3044\u307E\u3059: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "\u30A2\u30C0\u30D7\u30BF\u306E\u6E96\u5099\u304C\u3067\u304D\u307E\u3057\u305F\u3002" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "SNMP\u30A2\u30C0\u30D7\u30BF\u306E\u6E96\u5099\u304C\u3067\u304D\u307E\u3057\u305F: {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "ACL\u3092\u51E6\u7406\u3057\u3066\u3044\u307E\u3059" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "\u30A2\u30C0\u30D7\u30BF\u30FB\u30B5\u30FC\u30D0\u30FC\u3092\u8D77\u52D5\u3057\u3066\u3044\u307E\u3059:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "{0}\u3092\u7D42\u4E86\u3057\u307E\u3059" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u30A2\u30AF\u30BB\u30B9\u306F\u5236\u9650\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "\u8A8D\u8A3C\u306A\u3057" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "\u30D1\u30B9\u30EF\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u30A2\u30AF\u30BB\u30B9\u306F\u5236\u9650\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "JMX\u30B3\u30CD\u30AF\u30BF\u306E\u6E96\u5099\u304C\u3067\u304D\u307E\u3057\u305F: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "JMX\u30B3\u30CD\u30AF\u30BF\u30FB\u30B5\u30FC\u30D0\u30FC\u3092\u8D77\u52D5\u3057\u3066\u3044\u307E\u3059:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_ko.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_ko.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_ko extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "\uC561\uC138\uC2A4 \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.access.file.notfound", "\uC561\uC138\uC2A4 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.access.file.notset", "\uC561\uC138\uC2A4 \uD30C\uC77C\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC9C0\uB9CC com.sun.management.jmxremote.authenticate=true\uC785\uB2C8\uB2E4." },
|
||||
{ "agent.err.access.file.read.failed", "\uC561\uC138\uC2A4 \uD30C\uC77C \uC77D\uAE30\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.acl.file.access.notrestricted", "\uBE44\uBC00\uBC88\uD638 \uD30C\uC77C \uC77D\uAE30 \uC561\uC138\uC2A4\uB294 \uC81C\uD55C\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4." },
|
||||
{ "agent.err.acl.file.not.readable", "SNMP ACL \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.acl.file.notfound", "SNMP ACL \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.acl.file.notset", "SNMP ACL \uD30C\uC77C\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC9C0\uB9CC com.sun.management.snmp.acl=true\uC785\uB2C8\uB2E4." },
|
||||
{ "agent.err.acl.file.read.failed", "SNMP ACL \uD30C\uC77C \uC77D\uAE30\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.agentclass.access.denied", "premain(\uBB38\uC790\uC5F4)\uC5D0 \uB300\uD55C \uC561\uC138\uC2A4\uAC00 \uAC70\uBD80\uB418\uC5C8\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.agentclass.failed", "\uAD00\uB9AC \uC5D0\uC774\uC804\uD2B8 \uD074\uB798\uC2A4\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4. " },
|
||||
{ "agent.err.agentclass.notfound", "\uAD00\uB9AC \uC5D0\uC774\uC804\uD2B8 \uD074\uB798\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.configfile.access.denied", "\uAD6C\uC131 \uD30C\uC77C\uC5D0 \uB300\uD55C \uC561\uC138\uC2A4\uAC00 \uAC70\uBD80\uB418\uC5C8\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.configfile.closed.failed", "\uAD6C\uC131 \uD30C\uC77C \uB2EB\uAE30\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.configfile.failed", "\uAD6C\uC131 \uD30C\uC77C \uC77D\uAE30\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.configfile.notfound", "\uAD6C\uC131 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.connector.server.io.error", "JMX \uCEE4\uB125\uD130 \uC11C\uBC84 \uD1B5\uC2E0 \uC624\uB958" },
|
||||
{ "agent.err.error", "\uC624\uB958" },
|
||||
{ "agent.err.exception", "\uC5D0\uC774\uC804\uD2B8\uC5D0 \uC608\uC678\uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4. " },
|
||||
{ "agent.err.exportaddress.failed", "\uAE30\uAE30 \uBC84\uD37C\uB85C JMX \uCEE4\uB125\uD130 \uC8FC\uC18C \uC775\uC2A4\uD3EC\uD2B8\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.file.access.not.restricted", "\uD30C\uC77C \uC77D\uAE30 \uC561\uC138\uC2A4\uB294 \uC81C\uD55C\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4." },
|
||||
{ "agent.err.file.not.found", "\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.file.not.readable", "\uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.file.not.set", "\uD30C\uC77C\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.file.read.failed", "\uD30C\uC77C \uC77D\uAE30\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.invalid.agentclass", "com.sun.management.agent.class \uC18D\uC131 \uAC12\uC774 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4." },
|
||||
{ "agent.err.invalid.jmxremote.port", "com.sun.management.jmxremote.port \uBC88\uD638\uAC00 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4." },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "\uBD80\uC801\uD569\uD55C com.sun.management.jmxremote.rmi.port \uBC88\uD638" },
|
||||
{ "agent.err.invalid.option", "\uBD80\uC801\uD569\uD55C \uC635\uC158\uC774 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.invalid.snmp.port", "com.sun.management.snmp.port \uBC88\uD638\uAC00 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4." },
|
||||
{ "agent.err.invalid.snmp.trap.port", "com.sun.management.snmp.trap \uBC88\uD638\uAC00 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4." },
|
||||
{ "agent.err.invalid.state", "\uBD80\uC801\uD569\uD55C \uC5D0\uC774\uC804\uD2B8 \uC0C1\uD0DC: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "\uBE44\uBC00\uBC88\uD638 \uD30C\uC77C \uC77D\uAE30 \uC561\uC138\uC2A4\uB294 \uC81C\uD55C\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4." },
|
||||
{ "agent.err.password.file.not.readable", "\uBE44\uBC00\uBC88\uD638 \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.password.file.notfound", "\uBE44\uBC00\uBC88\uD638 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.password.file.notset", "\uBE44\uBC00\uBC88\uD638 \uD30C\uC77C\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC9C0\uB9CC com.sun.management.jmxremote.authenticate=true\uC785\uB2C8\uB2E4." },
|
||||
{ "agent.err.password.file.read.failed", "\uBE44\uBC00\uBC88\uD638 \uD30C\uC77C \uC77D\uAE30\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.premain.notfound", "\uC5D0\uC774\uC804\uD2B8 \uD074\uB798\uC2A4\uC5D0 premain(\uBB38\uC790\uC5F4)\uC774 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "\uC8FC\uC18C\uAC00 \uC788\uB294 SNMP \uC5B4\uB311\uD130 \uC2DC\uC791\uC744 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.snmp.mib.init.failed", "\uC624\uB958\uB85C \uC778\uD574 SNMP MIB \uCD08\uAE30\uD654\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4." },
|
||||
{ "agent.err.unknown.snmp.interface", "\uC54C \uC218 \uC5C6\uB294 SNMP \uC778\uD130\uD398\uC774\uC2A4" },
|
||||
{ "agent.err.warning", "\uACBD\uACE0" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "\uB300\uC0C1\uC744 \uCD94\uAC00\uD558\uB294 \uC911: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "\uC5B4\uB311\uD130\uAC00 \uC900\uBE44\uB418\uC5C8\uC2B5\uB2C8\uB2E4." },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "{0}:{1}\uC5D0\uC11C SNMP \uC5B4\uB311\uD130\uAC00 \uC900\uBE44\uB418\uC5C8\uC2B5\uB2C8\uB2E4." },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "ACL\uC744 \uCC98\uB9AC\uD558\uB294 \uC911" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "\uC5B4\uB311\uD130 \uC11C\uBC84\uB97C \uC2DC\uC791\uD558\uB294 \uC911:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "{0} \uC885\uB8CC" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "\uD30C\uC77C \uC77D\uAE30 \uC561\uC138\uC2A4\uB294 \uC81C\uD55C\uB418\uC5B4\uC57C \uD568: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "\uC778\uC99D \uC5C6\uC74C" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "\uBE44\uBC00\uBC88\uD638 \uD30C\uC77C \uC77D\uAE30 \uC561\uC138\uC2A4\uB294 \uC81C\uD55C\uB418\uC5B4\uC57C \uD568: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "{0}\uC5D0\uC11C JMX \uCEE4\uB125\uD130\uAC00 \uC900\uBE44\uB418\uC5C8\uC2B5\uB2C8\uB2E4." },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "JMX \uCEE4\uB125\uD130 \uC11C\uBC84\uB97C \uC2DC\uC791\uD558\uB294 \uC911:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_pt_BR.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_pt_BR.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_pt_BR extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "Arquivo de acesso ileg\u00EDvel" },
|
||||
{ "agent.err.access.file.notfound", "Arquivo de acesso n\u00E3o encontrado" },
|
||||
{ "agent.err.access.file.notset", "O arquivo de acesso n\u00E3o est\u00E1 especificado, mas com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.access.file.read.failed", "Falha ao ler o arquivo de acesso" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "O acesso de leitura do arquivo de senha deve ser limitado" },
|
||||
{ "agent.err.acl.file.not.readable", "Arquivo ACL SNMP ileg\u00EDvel" },
|
||||
{ "agent.err.acl.file.notfound", "Arquivo ACL SNMP n\u00E3o encontrado" },
|
||||
{ "agent.err.acl.file.notset", "N\u00E3o h\u00E1 um arquivo ACL SNMP especificado, mas com.sun.management.snmp.acl=true" },
|
||||
{ "agent.err.acl.file.read.failed", "Falha ao ler o arquivo ACL SNMP" },
|
||||
{ "agent.err.agentclass.access.denied", "Acesso negado a premain(String)" },
|
||||
{ "agent.err.agentclass.failed", "Falha na classe do agente de gerenciamento " },
|
||||
{ "agent.err.agentclass.notfound", "Classe do agente de gerenciamento n\u00E3o encontrada" },
|
||||
{ "agent.err.configfile.access.denied", "Acesso negado ao arquivo de configura\u00E7\u00E3o" },
|
||||
{ "agent.err.configfile.closed.failed", "Falha ao fechar o arquivo de configura\u00E7\u00E3o" },
|
||||
{ "agent.err.configfile.failed", "Falha ao ler o arquivo de configura\u00E7\u00E3o" },
|
||||
{ "agent.err.configfile.notfound", "Arquivo de configura\u00E7\u00E3o n\u00E3o encontrado" },
|
||||
{ "agent.err.connector.server.io.error", "Erro de comunica\u00E7\u00E3o do servidor do conector JMX" },
|
||||
{ "agent.err.error", "Erro" },
|
||||
{ "agent.err.exception", "Exce\u00E7\u00E3o gerada pelo agente " },
|
||||
{ "agent.err.exportaddress.failed", "Falha na exporta\u00E7\u00E3o do endere\u00E7o do conector JMX para o buffer de instrumenta\u00E7\u00E3o" },
|
||||
{ "agent.err.file.access.not.restricted", "O acesso de leitura do arquivo deve ser limitado" },
|
||||
{ "agent.err.file.not.found", "Arquivo n\u00E3o encontrado" },
|
||||
{ "agent.err.file.not.readable", "Arquivo ileg\u00EDvel" },
|
||||
{ "agent.err.file.not.set", "Arquivo n\u00E3o especificado" },
|
||||
{ "agent.err.file.read.failed", "Falha ao ler o arquivo" },
|
||||
{ "agent.err.invalid.agentclass", "Valor inv\u00E1lido da propriedade com.sun.management.agent.class" },
|
||||
{ "agent.err.invalid.jmxremote.port", "N\u00FAmero inv\u00E1lido de com.sun.management.jmxremote.port" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "N\u00FAmero inv\u00E1lido do com.sun.management.jmxremote.rmi.port" },
|
||||
{ "agent.err.invalid.option", "Op\u00E7\u00E3o especificada inv\u00E1lida" },
|
||||
{ "agent.err.invalid.snmp.port", "N\u00FAmero inv\u00E1lido de com.sun.management.snmp.port" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "N\u00FAmero inv\u00E1lido de com.sun.management.snmp.trap" },
|
||||
{ "agent.err.invalid.state", "Estado inv\u00E1lido do agente: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "O acesso de leitura do arquivo de senha deve ser limitado" },
|
||||
{ "agent.err.password.file.not.readable", "Arquivo de senha ileg\u00EDvel" },
|
||||
{ "agent.err.password.file.notfound", "Arquivo de senha n\u00E3o encontrado" },
|
||||
{ "agent.err.password.file.notset", "O arquivo de senha n\u00E3o est\u00E1 especificado, mas com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.password.file.read.failed", "Falha ao ler o arquivo de senha" },
|
||||
{ "agent.err.premain.notfound", "premain(String) n\u00E3o existe na classe do agente" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "Falha ao iniciar o adaptador SNMP com endere\u00E7o" },
|
||||
{ "agent.err.snmp.mib.init.failed", "Falha ao inicializar o MIB SNMP com erro" },
|
||||
{ "agent.err.unknown.snmp.interface", "Interface SNMP desconhecida" },
|
||||
{ "agent.err.warning", "Advert\u00EAncia" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "Adicionando destino: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "Adaptador pronto." },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "Adaptador SNMP pronto em: {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "Processando ACL" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "Iniciando o Servidor do Adaptador:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "encerrar {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "O acesso de leitura do arquivo deve ser limitado: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "Sem autentica\u00E7\u00E3o" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "O acesso de leitura do arquivo de senha deve ser limitado: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "Conector JMX pronto em: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "Iniciando o Servidor do Conector JMX:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_sv.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_sv.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_sv extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "Access-filen \u00E4r inte l\u00E4sbar" },
|
||||
{ "agent.err.access.file.notfound", "Access-filen hittades inte" },
|
||||
{ "agent.err.access.file.notset", "\u00C5tkomstfilen har inte angetts men com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.access.file.read.failed", "Kunde inte l\u00E4sa \u00E5tkomstfilen" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "L\u00E4sbeh\u00F6righeten f\u00F6r filen m\u00E5ste begr\u00E4nsas" },
|
||||
{ "agent.err.acl.file.not.readable", "SNMP \u00E5tkomstkontrollista-filen \u00E4r inte l\u00E4sbar" },
|
||||
{ "agent.err.acl.file.notfound", "SNMP \u00E5tkomstkontrollista-filen hittades inte" },
|
||||
{ "agent.err.acl.file.notset", "Ingen SNMP \u00E5tkomstkontrollista-fil har angetts, men com.sun.management.snmp.acl=true" },
|
||||
{ "agent.err.acl.file.read.failed", "Kunde inte l\u00E4sa filen SNMP \u00E5tkomstkontrollista" },
|
||||
{ "agent.err.agentclass.access.denied", "\u00C5tkomst till premain(String) nekad" },
|
||||
{ "agent.err.agentclass.failed", "Administrationsagentklassen utf\u00F6rdes inte " },
|
||||
{ "agent.err.agentclass.notfound", "Administrationsagentklassen hittades inte" },
|
||||
{ "agent.err.configfile.access.denied", "\u00C5tkomst till konfigurationsfilen nekad" },
|
||||
{ "agent.err.configfile.closed.failed", "Kunde inte st\u00E4nga konfigurationsfilen" },
|
||||
{ "agent.err.configfile.failed", "Kunde inte l\u00E4sa konfigurationsfilen" },
|
||||
{ "agent.err.configfile.notfound", "Konfigurationsfilen hittades inte" },
|
||||
{ "agent.err.connector.server.io.error", "Serverkommunikationsfel f\u00F6r JMX-anslutning" },
|
||||
{ "agent.err.error", "Fel" },
|
||||
{ "agent.err.exception", "Agenten orsakade ett undantag " },
|
||||
{ "agent.err.exportaddress.failed", "Kunde inte exportera JMX-anslutningsadressen till instrumentbufferten" },
|
||||
{ "agent.err.file.access.not.restricted", "Fill\u00E4snings\u00E5tkomst m\u00E5ste begr\u00E4nsas" },
|
||||
{ "agent.err.file.not.found", "Filen hittades inte" },
|
||||
{ "agent.err.file.not.readable", "Filen \u00E4r inte l\u00E4sbar" },
|
||||
{ "agent.err.file.not.set", "Filen \u00E4r inte angiven" },
|
||||
{ "agent.err.file.read.failed", "Kunde inte l\u00E4sa filen" },
|
||||
{ "agent.err.invalid.agentclass", "Ogiltigt egenskapsv\u00E4rde f\u00F6r com.sun.management.agent.class" },
|
||||
{ "agent.err.invalid.jmxremote.port", "Ogiltigt com.sun.management.jmxremote.port-nummer" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "Ogiltigt com.sun.management.jmxremote.rmi.port-nummer" },
|
||||
{ "agent.err.invalid.option", "Det angivna alternativet \u00E4r ogiltigt" },
|
||||
{ "agent.err.invalid.snmp.port", "Ogiltigt com.sun.management.snmp.port-nummer" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "Ogiltigt com.sun.management.snmp.trap-nummer" },
|
||||
{ "agent.err.invalid.state", "Ogiltig agentstatus: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "L\u00E4sbeh\u00F6righeten f\u00F6r filen m\u00E5ste begr\u00E4nsas" },
|
||||
{ "agent.err.password.file.not.readable", "L\u00F6senordsfilen \u00E4r inte l\u00E4sbar" },
|
||||
{ "agent.err.password.file.notfound", "Hittar inte l\u00F6senordsfilen" },
|
||||
{ "agent.err.password.file.notset", "L\u00F6senordsfilen har inte angetts men com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.password.file.read.failed", "Kunde inte l\u00E4sa l\u00F6senordsfilen" },
|
||||
{ "agent.err.premain.notfound", "premain(String) finns inte i agentklassen" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "Kunde inte starta SNMP-adaptern med adressen" },
|
||||
{ "agent.err.snmp.mib.init.failed", "Kunde inte initiera SNMP MIB. Returnerade felet" },
|
||||
{ "agent.err.unknown.snmp.interface", "Ok\u00E4nt SNMP-gr\u00E4nssnitt" },
|
||||
{ "agent.err.warning", "Varning" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "M\u00E5l l\u00E4ggs till: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "Adaptern redo." },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "SNMP-adaptern redo p\u00E5: {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "\u00E5tkomstkontrollista bearbetas" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "Adapterservern startas:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "avsluta {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "Fill\u00E4snings\u00E5tkomst m\u00E5ste begr\u00E4nsas {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "Ingen autentisering" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "L\u00E4sbeh\u00F6righeten f\u00F6r l\u00F6senordsfilen m\u00E5ste begr\u00E4nsas: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "JMX-anslutning redo p\u00E5: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "Startar server f\u00F6r JMX-anslutning:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_zh_CN.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_zh_CN.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_zh_CN extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "\u8BBF\u95EE\u6587\u4EF6\u4E0D\u53EF\u8BFB\u53D6" },
|
||||
{ "agent.err.access.file.notfound", "\u627E\u4E0D\u5230\u8BBF\u95EE\u6587\u4EF6" },
|
||||
{ "agent.err.access.file.notset", "\u672A\u6307\u5B9A\u8BBF\u95EE\u6587\u4EF6, \u4F46 com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.access.file.read.failed", "\u8BFB\u53D6\u8BBF\u95EE\u6587\u4EF6\u5931\u8D25" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "\u5FC5\u987B\u9650\u5236\u53E3\u4EE4\u6587\u4EF6\u8BFB\u53D6\u8BBF\u95EE\u6743\u9650" },
|
||||
{ "agent.err.acl.file.not.readable", "SNMP ACL \u6587\u4EF6\u4E0D\u53EF\u8BFB\u53D6" },
|
||||
{ "agent.err.acl.file.notfound", "\u627E\u4E0D\u5230 SNMP ACL \u6587\u4EF6" },
|
||||
{ "agent.err.acl.file.notset", "\u672A\u6307\u5B9A SNMP ACL \u6587\u4EF6, \u4F46 com.sun.management.snmp.acl=true" },
|
||||
{ "agent.err.acl.file.read.failed", "\u672A\u80FD\u8BFB\u53D6 SNMP ACL \u6587\u4EF6" },
|
||||
{ "agent.err.agentclass.access.denied", "\u62D2\u7EDD\u8BBF\u95EE premain(String)" },
|
||||
{ "agent.err.agentclass.failed", "\u7BA1\u7406\u4EE3\u7406\u7C7B\u5931\u8D25 " },
|
||||
{ "agent.err.agentclass.notfound", "\u627E\u4E0D\u5230\u7BA1\u7406\u4EE3\u7406\u7C7B" },
|
||||
{ "agent.err.configfile.access.denied", "\u62D2\u7EDD\u8BBF\u95EE\u914D\u7F6E\u6587\u4EF6" },
|
||||
{ "agent.err.configfile.closed.failed", "\u672A\u80FD\u5173\u95ED\u914D\u7F6E\u6587\u4EF6" },
|
||||
{ "agent.err.configfile.failed", "\u672A\u80FD\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6" },
|
||||
{ "agent.err.configfile.notfound", "\u627E\u4E0D\u5230\u914D\u7F6E\u6587\u4EF6" },
|
||||
{ "agent.err.connector.server.io.error", "JMX \u8FDE\u63A5\u5668\u670D\u52A1\u5668\u901A\u4FE1\u9519\u8BEF" },
|
||||
{ "agent.err.error", "\u9519\u8BEF" },
|
||||
{ "agent.err.exception", "\u4EE3\u7406\u629B\u51FA\u5F02\u5E38\u9519\u8BEF" },
|
||||
{ "agent.err.exportaddress.failed", "\u672A\u80FD\u5C06 JMX \u8FDE\u63A5\u5668\u5730\u5740\u5BFC\u51FA\u5230\u68C0\u6D4B\u7F13\u51B2\u533A" },
|
||||
{ "agent.err.file.access.not.restricted", "\u5FC5\u987B\u9650\u5236\u6587\u4EF6\u8BFB\u53D6\u8BBF\u95EE\u6743\u9650" },
|
||||
{ "agent.err.file.not.found", "\u627E\u4E0D\u5230\u6587\u4EF6" },
|
||||
{ "agent.err.file.not.readable", "\u6587\u4EF6\u4E0D\u53EF\u8BFB\u53D6" },
|
||||
{ "agent.err.file.not.set", "\u672A\u6307\u5B9A\u6587\u4EF6" },
|
||||
{ "agent.err.file.read.failed", "\u672A\u80FD\u8BFB\u53D6\u6587\u4EF6" },
|
||||
{ "agent.err.invalid.agentclass", "com.sun.management.agent.class \u5C5E\u6027\u503C\u65E0\u6548" },
|
||||
{ "agent.err.invalid.jmxremote.port", "com.sun.management.jmxremote.port \u7F16\u53F7\u65E0\u6548" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "com.sun.management.jmxremote.rmi.port \u7F16\u53F7\u65E0\u6548" },
|
||||
{ "agent.err.invalid.option", "\u6307\u5B9A\u7684\u9009\u9879\u65E0\u6548" },
|
||||
{ "agent.err.invalid.snmp.port", "com.sun.management.snmp.port number \u65E0\u6548" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "com.sun.management.snmp.trap number \u65E0\u6548" },
|
||||
{ "agent.err.invalid.state", "\u65E0\u6548\u7684\u4EE3\u7406\u72B6\u6001: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "\u5FC5\u987B\u9650\u5236\u53E3\u4EE4\u6587\u4EF6\u8BFB\u53D6\u8BBF\u95EE\u6743\u9650" },
|
||||
{ "agent.err.password.file.not.readable", "\u53E3\u4EE4\u6587\u4EF6\u4E0D\u53EF\u8BFB\u53D6" },
|
||||
{ "agent.err.password.file.notfound", "\u627E\u4E0D\u5230\u53E3\u4EE4\u6587\u4EF6" },
|
||||
{ "agent.err.password.file.notset", "\u672A\u6307\u5B9A\u53E3\u4EE4\u6587\u4EF6, \u4F46 com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.password.file.read.failed", "\u8BFB\u53D6\u53E3\u4EE4\u6587\u4EF6\u5931\u8D25" },
|
||||
{ "agent.err.premain.notfound", "\u4EE3\u7406\u7C7B\u4E2D\u4E0D\u5B58\u5728 premain(String)" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "\u65E0\u6CD5\u542F\u52A8\u5E26\u6709\u5730\u5740\u7684 SNMP \u9002\u914D\u5668" },
|
||||
{ "agent.err.snmp.mib.init.failed", "\u65E0\u6CD5\u521D\u59CB\u5316\u5E26\u6709\u9519\u8BEF\u7684 SNMP MIB" },
|
||||
{ "agent.err.unknown.snmp.interface", "\u672A\u77E5 SNMP \u63A5\u53E3" },
|
||||
{ "agent.err.warning", "\u8B66\u544A" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "\u6B63\u5728\u6DFB\u52A0\u76EE\u6807: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "\u9002\u914D\u5668\u5C31\u7EEA\u3002" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "\u4F4D\u4E8E {0}:{1} \u7684 SNMP \u9002\u914D\u5668\u5C31\u7EEA" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "\u6B63\u5728\u5904\u7406 ACL" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "\u6B63\u5728\u542F\u52A8\u9002\u914D\u5668\u670D\u52A1\u5668: " },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "\u7EC8\u6B62{0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "\u5FC5\u987B\u9650\u5236\u6587\u4EF6\u8BFB\u53D6\u8BBF\u95EE\u6743\u9650: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "\u65E0\u9A8C\u8BC1" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "\u5FC5\u987B\u9650\u5236\u53E3\u4EE4\u6587\u4EF6\u8BFB\u53D6\u8BBF\u95EE\u6743\u9650: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "\u4F4D\u4E8E{0}\u7684 JMX \u8FDE\u63A5\u5668\u5DF2\u5C31\u7EEA" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "\u6B63\u5728\u542F\u52A8 JMX \u8FDE\u63A5\u5668\u670D\u52A1\u5668: " },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_zh_HK.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_zh_HK.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_zh_HK extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "\u5B58\u53D6\u6A94\u6848\u7121\u6CD5\u8B80\u53D6" },
|
||||
{ "agent.err.access.file.notfound", "\u627E\u4E0D\u5230\u5B58\u53D6\u6A94\u6848" },
|
||||
{ "agent.err.access.file.notset", "\u672A\u6307\u5B9A\u5B58\u53D6\u6A94\u6848\uFF0C\u4F46 com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.access.file.read.failed", "\u7121\u6CD5\u8B80\u53D6\u5B58\u53D6\u6A94\u6848" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "\u5FC5\u9808\u9650\u5236\u5BC6\u78BC\u6A94\u6848\u8B80\u53D6\u5B58\u53D6" },
|
||||
{ "agent.err.acl.file.not.readable", "SNMP ACL \u6A94\u6848\u7121\u6CD5\u8B80\u53D6" },
|
||||
{ "agent.err.acl.file.notfound", "\u627E\u4E0D\u5230 SNMP ACL \u6A94\u6848" },
|
||||
{ "agent.err.acl.file.notset", "\u672A\u6307\u5B9A SNMP ACL \u6A94\u6848\uFF0C\u4F46 com.sun.management.snmp.acl=true" },
|
||||
{ "agent.err.acl.file.read.failed", "\u7121\u6CD5\u8B80\u53D6 SNMP ACL \u6A94\u6848" },
|
||||
{ "agent.err.agentclass.access.denied", "\u5B58\u53D6 premain(String) \u906D\u5230\u62D2\u7D55" },
|
||||
{ "agent.err.agentclass.failed", "\u7BA1\u7406\u4EE3\u7406\u7A0B\u5F0F\u985E\u5225\u5931\u6557 " },
|
||||
{ "agent.err.agentclass.notfound", "\u627E\u4E0D\u5230\u7BA1\u7406\u4EE3\u7406\u7A0B\u5F0F\u985E\u5225" },
|
||||
{ "agent.err.configfile.access.denied", "\u5B58\u53D6\u7D44\u614B\u6A94\u6848\u906D\u5230\u62D2\u7D55" },
|
||||
{ "agent.err.configfile.closed.failed", "\u7121\u6CD5\u95DC\u9589\u7D44\u614B\u6A94\u6848" },
|
||||
{ "agent.err.configfile.failed", "\u7121\u6CD5\u8B80\u53D6\u7D44\u614B\u6A94\u6848" },
|
||||
{ "agent.err.configfile.notfound", "\u627E\u4E0D\u5230\u7D44\u614B\u6A94\u6848" },
|
||||
{ "agent.err.connector.server.io.error", "JMX \u9023\u63A5\u5668\u4F3A\u670D\u5668\u901A\u8A0A\u932F\u8AA4" },
|
||||
{ "agent.err.error", "\u932F\u8AA4" },
|
||||
{ "agent.err.exception", "\u4EE3\u7406\u7A0B\u5F0F\u767C\u751F\u7570\u5E38 " },
|
||||
{ "agent.err.exportaddress.failed", "\u5C07 JMX \u9023\u63A5\u5668\u4F4D\u5740\u532F\u51FA\u81F3\u8A2D\u5099\u7DE9\u885D\u5340\u5931\u6557" },
|
||||
{ "agent.err.file.access.not.restricted", "\u5FC5\u9808\u9650\u5236\u6A94\u6848\u8B80\u53D6\u5B58\u53D6\u6B0A" },
|
||||
{ "agent.err.file.not.found", "\u627E\u4E0D\u5230\u6A94\u6848" },
|
||||
{ "agent.err.file.not.readable", "\u6A94\u6848\u7121\u6CD5\u8B80\u53D6" },
|
||||
{ "agent.err.file.not.set", "\u672A\u6307\u5B9A\u6A94\u6848" },
|
||||
{ "agent.err.file.read.failed", "\u7121\u6CD5\u8B80\u53D6\u6A94\u6848" },
|
||||
{ "agent.err.invalid.agentclass", "com.sun.management.agent.class \u5C6C\u6027\u503C\u7121\u6548" },
|
||||
{ "agent.err.invalid.jmxremote.port", "com.sun.management.jmxremote.port \u865F\u78BC\u7121\u6548" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "com.sun.management.jmxremote.rmi.port \u865F\u78BC\u7121\u6548" },
|
||||
{ "agent.err.invalid.option", "\u6307\u5B9A\u7684\u9078\u9805\u7121\u6548" },
|
||||
{ "agent.err.invalid.snmp.port", "com.sun.management.snmp.port \u865F\u78BC\u7121\u6548" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "com.sun.management.snmp.trap \u7DE8\u865F\u7121\u6548" },
|
||||
{ "agent.err.invalid.state", "\u7121\u6548\u7684\u4EE3\u7406\u7A0B\u5F0F\u72C0\u614B: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "\u5FC5\u9808\u9650\u5236\u5BC6\u78BC\u6A94\u6848\u8B80\u53D6\u5B58\u53D6" },
|
||||
{ "agent.err.password.file.not.readable", "\u5BC6\u78BC\u6A94\u6848\u7121\u6CD5\u8B80\u53D6" },
|
||||
{ "agent.err.password.file.notfound", "\u627E\u4E0D\u5230\u5BC6\u78BC\u6A94\u6848" },
|
||||
{ "agent.err.password.file.notset", "\u672A\u6307\u5B9A\u5BC6\u78BC\u6A94\u6848\uFF0C\u4F46 com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.password.file.read.failed", "\u7121\u6CD5\u8B80\u53D6\u5BC6\u78BC\u6A94\u6848" },
|
||||
{ "agent.err.premain.notfound", "\u4EE3\u7406\u7A0B\u5F0F\u985E\u5225\u4E2D\u4E0D\u5B58\u5728 premain(String)" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "\u7121\u6CD5\u4F7F\u7528\u4F4D\u5740\u555F\u52D5 SNMP \u914D\u63A5\u5361" },
|
||||
{ "agent.err.snmp.mib.init.failed", "\u7121\u6CD5\u521D\u59CB\u5316 SNMP MIB\uFF0C\u51FA\u73FE\u932F\u8AA4" },
|
||||
{ "agent.err.unknown.snmp.interface", "\u4E0D\u660E\u7684 SNMP \u4ECB\u9762" },
|
||||
{ "agent.err.warning", "\u8B66\u544A" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "\u6B63\u5728\u65B0\u589E\u76EE\u6A19: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "\u914D\u63A5\u5361\u5C31\u7DD2\u3002" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "SNMP \u914D\u63A5\u5361\u5C31\u7DD2\uFF0C\u4F4D\u65BC: {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "\u6B63\u5728\u8655\u7406 ACL" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "\u6B63\u5728\u555F\u52D5\u914D\u63A5\u5361\u4F3A\u670D\u5668:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "\u7D42\u6B62 {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "\u5FC5\u9808\u9650\u5236\u6A94\u6848\u8B80\u53D6\u5B58\u53D6\u6B0A: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "\u7121\u8A8D\u8B49" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "\u5FC5\u9808\u9650\u5236\u5BC6\u78BC\u6A94\u6848\u8B80\u53D6\u5B58\u53D6: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "JMX \u9023\u63A5\u5668\u5C31\u7DD2\uFF0C\u4F4D\u65BC: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "\u6B63\u5728\u555F\u52D5 JMX \u9023\u63A5\u5668\u4F3A\u670D\u5668:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/management/resources/agent_zh_TW.java
Normal file
63
jdkSrc/jdk8/sun/management/resources/agent_zh_TW.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package sun.management.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class agent_zh_TW extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "agent.err.access.file.not.readable", "\u5B58\u53D6\u6A94\u6848\u7121\u6CD5\u8B80\u53D6" },
|
||||
{ "agent.err.access.file.notfound", "\u627E\u4E0D\u5230\u5B58\u53D6\u6A94\u6848" },
|
||||
{ "agent.err.access.file.notset", "\u672A\u6307\u5B9A\u5B58\u53D6\u6A94\u6848\uFF0C\u4F46 com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.access.file.read.failed", "\u7121\u6CD5\u8B80\u53D6\u5B58\u53D6\u6A94\u6848" },
|
||||
{ "agent.err.acl.file.access.notrestricted", "\u5FC5\u9808\u9650\u5236\u5BC6\u78BC\u6A94\u6848\u8B80\u53D6\u5B58\u53D6" },
|
||||
{ "agent.err.acl.file.not.readable", "SNMP ACL \u6A94\u6848\u7121\u6CD5\u8B80\u53D6" },
|
||||
{ "agent.err.acl.file.notfound", "\u627E\u4E0D\u5230 SNMP ACL \u6A94\u6848" },
|
||||
{ "agent.err.acl.file.notset", "\u672A\u6307\u5B9A SNMP ACL \u6A94\u6848\uFF0C\u4F46 com.sun.management.snmp.acl=true" },
|
||||
{ "agent.err.acl.file.read.failed", "\u7121\u6CD5\u8B80\u53D6 SNMP ACL \u6A94\u6848" },
|
||||
{ "agent.err.agentclass.access.denied", "\u5B58\u53D6 premain(String) \u906D\u5230\u62D2\u7D55" },
|
||||
{ "agent.err.agentclass.failed", "\u7BA1\u7406\u4EE3\u7406\u7A0B\u5F0F\u985E\u5225\u5931\u6557 " },
|
||||
{ "agent.err.agentclass.notfound", "\u627E\u4E0D\u5230\u7BA1\u7406\u4EE3\u7406\u7A0B\u5F0F\u985E\u5225" },
|
||||
{ "agent.err.configfile.access.denied", "\u5B58\u53D6\u7D44\u614B\u6A94\u6848\u906D\u5230\u62D2\u7D55" },
|
||||
{ "agent.err.configfile.closed.failed", "\u7121\u6CD5\u95DC\u9589\u7D44\u614B\u6A94\u6848" },
|
||||
{ "agent.err.configfile.failed", "\u7121\u6CD5\u8B80\u53D6\u7D44\u614B\u6A94\u6848" },
|
||||
{ "agent.err.configfile.notfound", "\u627E\u4E0D\u5230\u7D44\u614B\u6A94\u6848" },
|
||||
{ "agent.err.connector.server.io.error", "JMX \u9023\u63A5\u5668\u4F3A\u670D\u5668\u901A\u8A0A\u932F\u8AA4" },
|
||||
{ "agent.err.error", "\u932F\u8AA4" },
|
||||
{ "agent.err.exception", "\u4EE3\u7406\u7A0B\u5F0F\u767C\u751F\u7570\u5E38 " },
|
||||
{ "agent.err.exportaddress.failed", "\u5C07 JMX \u9023\u63A5\u5668\u4F4D\u5740\u532F\u51FA\u81F3\u8A2D\u5099\u7DE9\u885D\u5340\u5931\u6557" },
|
||||
{ "agent.err.file.access.not.restricted", "\u5FC5\u9808\u9650\u5236\u6A94\u6848\u8B80\u53D6\u5B58\u53D6\u6B0A" },
|
||||
{ "agent.err.file.not.found", "\u627E\u4E0D\u5230\u6A94\u6848" },
|
||||
{ "agent.err.file.not.readable", "\u6A94\u6848\u7121\u6CD5\u8B80\u53D6" },
|
||||
{ "agent.err.file.not.set", "\u672A\u6307\u5B9A\u6A94\u6848" },
|
||||
{ "agent.err.file.read.failed", "\u7121\u6CD5\u8B80\u53D6\u6A94\u6848" },
|
||||
{ "agent.err.invalid.agentclass", "com.sun.management.agent.class \u5C6C\u6027\u503C\u7121\u6548" },
|
||||
{ "agent.err.invalid.jmxremote.port", "com.sun.management.jmxremote.port \u865F\u78BC\u7121\u6548" },
|
||||
{ "agent.err.invalid.jmxremote.rmi.port", "com.sun.management.jmxremote.rmi.port \u865F\u78BC\u7121\u6548" },
|
||||
{ "agent.err.invalid.option", "\u6307\u5B9A\u7684\u9078\u9805\u7121\u6548" },
|
||||
{ "agent.err.invalid.snmp.port", "com.sun.management.snmp.port \u865F\u78BC\u7121\u6548" },
|
||||
{ "agent.err.invalid.snmp.trap.port", "com.sun.management.snmp.trap \u7DE8\u865F\u7121\u6548" },
|
||||
{ "agent.err.invalid.state", "\u7121\u6548\u7684\u4EE3\u7406\u7A0B\u5F0F\u72C0\u614B: {0}" },
|
||||
{ "agent.err.password.file.access.notrestricted", "\u5FC5\u9808\u9650\u5236\u5BC6\u78BC\u6A94\u6848\u8B80\u53D6\u5B58\u53D6" },
|
||||
{ "agent.err.password.file.not.readable", "\u5BC6\u78BC\u6A94\u6848\u7121\u6CD5\u8B80\u53D6" },
|
||||
{ "agent.err.password.file.notfound", "\u627E\u4E0D\u5230\u5BC6\u78BC\u6A94\u6848" },
|
||||
{ "agent.err.password.file.notset", "\u672A\u6307\u5B9A\u5BC6\u78BC\u6A94\u6848\uFF0C\u4F46 com.sun.management.jmxremote.authenticate=true" },
|
||||
{ "agent.err.password.file.read.failed", "\u7121\u6CD5\u8B80\u53D6\u5BC6\u78BC\u6A94\u6848" },
|
||||
{ "agent.err.premain.notfound", "\u4EE3\u7406\u7A0B\u5F0F\u985E\u5225\u4E2D\u4E0D\u5B58\u5728 premain(String)" },
|
||||
{ "agent.err.snmp.adaptor.start.failed", "\u7121\u6CD5\u4F7F\u7528\u4F4D\u5740\u555F\u52D5 SNMP \u914D\u63A5\u5361" },
|
||||
{ "agent.err.snmp.mib.init.failed", "\u7121\u6CD5\u521D\u59CB\u5316 SNMP MIB\uFF0C\u51FA\u73FE\u932F\u8AA4" },
|
||||
{ "agent.err.unknown.snmp.interface", "\u4E0D\u660E\u7684 SNMP \u4ECB\u9762" },
|
||||
{ "agent.err.warning", "\u8B66\u544A" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.adding", "\u6B63\u5728\u65B0\u589E\u76EE\u6A19: {0}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize1", "\u914D\u63A5\u5361\u5C31\u7DD2\u3002" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.initialize2", "SNMP \u914D\u63A5\u5361\u5C31\u7DD2\uFF0C\u4F4D\u65BC: {0}:{1}" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.processing", "\u6B63\u5728\u8655\u7406 ACL" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.starting", "\u6B63\u5728\u555F\u52D5\u914D\u63A5\u5361\u4F3A\u670D\u5668:" },
|
||||
{ "jmxremote.AdaptorBootstrap.getTargetList.terminate", "\u7D42\u6B62 {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.file.readonly", "\u5FC5\u9808\u9650\u5236\u6A94\u6848\u8B80\u53D6\u5B58\u53D6\u6B0A: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.noAuthentication", "\u7121\u8A8D\u8B49" },
|
||||
{ "jmxremote.ConnectorBootstrap.password.readonly", "\u5FC5\u9808\u9650\u5236\u5BC6\u78BC\u6A94\u6848\u8B80\u53D6\u5B58\u53D6: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.ready", "JMX \u9023\u63A5\u5668\u5C31\u7DD2\uFF0C\u4F4D\u65BC: {0}" },
|
||||
{ "jmxremote.ConnectorBootstrap.starting", "\u6B63\u5728\u555F\u52D5 JMX \u9023\u63A5\u5668\u4F3A\u670D\u5668:" },
|
||||
};
|
||||
}
|
||||
}
|
||||
396
jdkSrc/jdk8/sun/management/snmp/AdaptorBootstrap.java
Normal file
396
jdkSrc/jdk8/sun/management/snmp/AdaptorBootstrap.java
Normal file
@@ -0,0 +1,396 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.management.snmp;
|
||||
|
||||
import com.sun.jmx.snmp.daemon.SnmpAdaptorServer;
|
||||
import com.sun.jmx.snmp.InetAddressAcl;
|
||||
import com.sun.jmx.snmp.IPAcl.SnmpAcl;
|
||||
import sun.management.snmp.jvmmib.JVM_MANAGEMENT_MIB;
|
||||
import sun.management.snmp.jvminstr.JVM_MANAGEMENT_MIB_IMPL;
|
||||
import sun.management.snmp.jvminstr.NotificationTarget;
|
||||
import sun.management.snmp.jvminstr.NotificationTargetImpl;
|
||||
import sun.management.snmp.util.MibLogger;
|
||||
import sun.management.snmp.util.JvmContextFactory;
|
||||
|
||||
import sun.management.Agent;
|
||||
import sun.management.AgentConfigurationError;
|
||||
import static sun.management.AgentConfigurationError.*;
|
||||
import sun.management.FileSystem;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* This class initializes and starts the SNMP Adaptor for JSR 163 SNMP
|
||||
* Monitoring.
|
||||
**/
|
||||
public final class AdaptorBootstrap {
|
||||
|
||||
private static final MibLogger log = new MibLogger(AdaptorBootstrap.class);
|
||||
|
||||
/**
|
||||
* Default values for SNMP configuration properties.
|
||||
**/
|
||||
public static interface DefaultValues {
|
||||
public static final String PORT="161";
|
||||
public static final String CONFIG_FILE_NAME="management.properties";
|
||||
public static final String TRAP_PORT="162";
|
||||
public static final String USE_ACL="true";
|
||||
public static final String ACL_FILE_NAME="snmp.acl";
|
||||
public static final String BIND_ADDRESS="localhost";
|
||||
}
|
||||
|
||||
/**
|
||||
* Names of SNMP configuration properties.
|
||||
**/
|
||||
public static interface PropertyNames {
|
||||
public static final String PORT="com.sun.management.snmp.port";
|
||||
public static final String CONFIG_FILE_NAME=
|
||||
"com.sun.management.config.file";
|
||||
public static final String TRAP_PORT=
|
||||
"com.sun.management.snmp.trap";
|
||||
public static final String USE_ACL=
|
||||
"com.sun.management.snmp.acl";
|
||||
public static final String ACL_FILE_NAME=
|
||||
"com.sun.management.snmp.acl.file";
|
||||
public static final String BIND_ADDRESS=
|
||||
"com.sun.management.snmp.interface";
|
||||
}
|
||||
|
||||
/**
|
||||
* We keep a reference - so that we can possibly call
|
||||
* terminate(). As of now, terminate() is only called by unit tests
|
||||
* (makes it possible to run several testcases sequentially in the
|
||||
* same JVM).
|
||||
**/
|
||||
private SnmpAdaptorServer adaptor;
|
||||
private JVM_MANAGEMENT_MIB_IMPL jvmmib;
|
||||
|
||||
private AdaptorBootstrap(SnmpAdaptorServer snmpas,
|
||||
JVM_MANAGEMENT_MIB_IMPL mib) {
|
||||
jvmmib = mib;
|
||||
adaptor = snmpas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the full path name for a default file.
|
||||
* @param basename basename (with extension) of the default file.
|
||||
* @return ${JRE}/lib/management/${basename}
|
||||
**/
|
||||
private static String getDefaultFileName(String basename) {
|
||||
final String fileSeparator = File.separator;
|
||||
return System.getProperty("java.home") + fileSeparator + "lib" +
|
||||
fileSeparator + "management" + fileSeparator + basename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Trap Target List from the ACL file.
|
||||
**/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<NotificationTarget> getTargetList(InetAddressAcl acl,
|
||||
int defaultTrapPort) {
|
||||
final ArrayList<NotificationTarget> result =
|
||||
new ArrayList<>();
|
||||
if (acl != null) {
|
||||
if (log.isDebugOn())
|
||||
log.debug("getTargetList",Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.processing"));
|
||||
|
||||
final Enumeration<InetAddress> td = acl.getTrapDestinations();
|
||||
for (; td.hasMoreElements() ;) {
|
||||
final InetAddress targetAddr = td.nextElement();
|
||||
final Enumeration<String> tc =
|
||||
acl.getTrapCommunities(targetAddr);
|
||||
for (;tc.hasMoreElements() ;) {
|
||||
final String community = tc.nextElement();
|
||||
final NotificationTarget target =
|
||||
new NotificationTargetImpl(targetAddr,
|
||||
defaultTrapPort,
|
||||
community);
|
||||
if (log.isDebugOn())
|
||||
log.debug("getTargetList",
|
||||
Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.adding",
|
||||
target.toString()));
|
||||
result.add(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes and starts the SNMP Adaptor Server.
|
||||
* If the com.sun.management.snmp.port property is not defined,
|
||||
* simply return. Otherwise, attempts to load the config file, and
|
||||
* then calls {@link #initialize(java.lang.String, java.util.Properties)}.
|
||||
*
|
||||
**/
|
||||
public static synchronized AdaptorBootstrap initialize() {
|
||||
|
||||
// Load a new properties
|
||||
final Properties props = Agent.loadManagementProperties();
|
||||
if (props == null) return null;
|
||||
|
||||
final String portStr = props.getProperty(PropertyNames.PORT);
|
||||
|
||||
return initialize(portStr,props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes and starts the SNMP Adaptor Server.
|
||||
**/
|
||||
public static synchronized
|
||||
AdaptorBootstrap initialize(String portStr, Properties props) {
|
||||
|
||||
// Get port number
|
||||
if (portStr.length()==0) portStr=DefaultValues.PORT;
|
||||
final int port;
|
||||
try {
|
||||
port = Integer.parseInt(portStr);
|
||||
} catch (NumberFormatException x) {
|
||||
throw new AgentConfigurationError(INVALID_SNMP_PORT, x, portStr);
|
||||
}
|
||||
|
||||
if (port < 0) {
|
||||
throw new AgentConfigurationError(INVALID_SNMP_PORT, portStr);
|
||||
}
|
||||
|
||||
// Get trap port number
|
||||
final String trapPortStr =
|
||||
props.getProperty(PropertyNames.TRAP_PORT,
|
||||
DefaultValues.TRAP_PORT);
|
||||
|
||||
final int trapPort;
|
||||
try {
|
||||
trapPort = Integer.parseInt(trapPortStr);
|
||||
} catch (NumberFormatException x) {
|
||||
throw new AgentConfigurationError(INVALID_SNMP_TRAP_PORT, x, trapPortStr);
|
||||
}
|
||||
|
||||
if (trapPort < 0) {
|
||||
throw new AgentConfigurationError(INVALID_SNMP_TRAP_PORT, trapPortStr);
|
||||
}
|
||||
|
||||
// Get bind address
|
||||
final String addrStr =
|
||||
props.getProperty(PropertyNames.BIND_ADDRESS,
|
||||
DefaultValues.BIND_ADDRESS);
|
||||
|
||||
// Get ACL File
|
||||
final String defaultAclFileName =
|
||||
getDefaultFileName(DefaultValues.ACL_FILE_NAME);
|
||||
final String aclFileName =
|
||||
props.getProperty(PropertyNames.ACL_FILE_NAME,
|
||||
defaultAclFileName);
|
||||
final String useAclStr =
|
||||
props.getProperty(PropertyNames.USE_ACL,DefaultValues.USE_ACL);
|
||||
final boolean useAcl =
|
||||
Boolean.valueOf(useAclStr).booleanValue();
|
||||
|
||||
if (useAcl) checkAclFile(aclFileName);
|
||||
|
||||
AdaptorBootstrap adaptor = null;
|
||||
try {
|
||||
adaptor = getAdaptorBootstrap(port, trapPort, addrStr,
|
||||
useAcl, aclFileName);
|
||||
} catch (Exception e) {
|
||||
throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.getMessage());
|
||||
}
|
||||
return adaptor;
|
||||
}
|
||||
|
||||
private static AdaptorBootstrap getAdaptorBootstrap
|
||||
(int port, int trapPort, String bindAddress, boolean useAcl,
|
||||
String aclFileName) {
|
||||
|
||||
final InetAddress address;
|
||||
try {
|
||||
address = InetAddress.getByName(bindAddress);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new AgentConfigurationError(UNKNOWN_SNMP_INTERFACE, e, bindAddress);
|
||||
}
|
||||
if (log.isDebugOn()) {
|
||||
log.debug("initialize",
|
||||
Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.starting" +
|
||||
"\n\t" + PropertyNames.PORT + "=" + port +
|
||||
"\n\t" + PropertyNames.TRAP_PORT + "=" + trapPort +
|
||||
"\n\t" + PropertyNames.BIND_ADDRESS + "=" + address +
|
||||
(useAcl?("\n\t" + PropertyNames.ACL_FILE_NAME + "="
|
||||
+ aclFileName):"\n\tNo ACL")+
|
||||
""));
|
||||
}
|
||||
|
||||
final InetAddressAcl acl;
|
||||
try {
|
||||
acl = useAcl ? new SnmpAcl(System.getProperty("user.name"),aclFileName)
|
||||
: null;
|
||||
} catch (UnknownHostException e) {
|
||||
throw new AgentConfigurationError(UNKNOWN_SNMP_INTERFACE, e, e.getMessage());
|
||||
}
|
||||
|
||||
// Create adaptor
|
||||
final SnmpAdaptorServer adaptor =
|
||||
new SnmpAdaptorServer(acl, port, address);
|
||||
adaptor.setUserDataFactory(new JvmContextFactory());
|
||||
adaptor.setTrapPort(trapPort);
|
||||
|
||||
// Create MIB
|
||||
//
|
||||
final JVM_MANAGEMENT_MIB_IMPL mib = new JVM_MANAGEMENT_MIB_IMPL();
|
||||
try {
|
||||
mib.init();
|
||||
} catch (IllegalAccessException x) {
|
||||
throw new AgentConfigurationError(SNMP_MIB_INIT_FAILED, x, x.getMessage());
|
||||
}
|
||||
|
||||
// Configure the trap destinations.
|
||||
//
|
||||
mib.addTargets(getTargetList(acl,trapPort));
|
||||
|
||||
|
||||
// Start Adaptor
|
||||
//
|
||||
try {
|
||||
// Will wait until the adaptor starts or fails to start.
|
||||
// If the adaptor fails to start, a CommunicationException or
|
||||
// an InterruptedException is thrown.
|
||||
//
|
||||
adaptor.start(Long.MAX_VALUE);
|
||||
} catch (Exception x) {
|
||||
Throwable t=x;
|
||||
if (x instanceof com.sun.jmx.snmp.daemon.CommunicationException) {
|
||||
final Throwable next = t.getCause();
|
||||
if (next != null) t = next;
|
||||
}
|
||||
throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED, t,
|
||||
address + ":" + port,
|
||||
"(" + t.getMessage() + ")");
|
||||
}
|
||||
|
||||
// double check that adaptor is actually started (should always
|
||||
// be active, so that exception should never be thrown from here)
|
||||
//
|
||||
if (!adaptor.isActive()) {
|
||||
throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED,
|
||||
address + ":" + port);
|
||||
}
|
||||
|
||||
try {
|
||||
// Add MIB to adaptor
|
||||
//
|
||||
adaptor.addMib(mib);
|
||||
|
||||
// Add Adaptor to the MIB
|
||||
//
|
||||
mib.setSnmpAdaptor(adaptor);
|
||||
} catch (RuntimeException x) {
|
||||
new AdaptorBootstrap(adaptor,mib).terminate();
|
||||
throw x;
|
||||
}
|
||||
|
||||
log.debug("initialize",
|
||||
Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.initialize1"));
|
||||
log.config("initialize",
|
||||
Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.initialize2",
|
||||
address.toString(), java.lang.Integer.toString(adaptor.getPort())));
|
||||
return new AdaptorBootstrap(adaptor,mib);
|
||||
}
|
||||
|
||||
private static void checkAclFile(String aclFileName) {
|
||||
if (aclFileName == null || aclFileName.length()==0) {
|
||||
throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_SET);
|
||||
}
|
||||
final File file = new File(aclFileName);
|
||||
if (!file.exists()) {
|
||||
throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_FOUND, aclFileName);
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_READABLE, aclFileName);
|
||||
}
|
||||
|
||||
FileSystem fs = FileSystem.open();
|
||||
try {
|
||||
if (fs.supportsFileSecurity(file)) {
|
||||
if (!fs.isAccessUserOnly(file)) {
|
||||
throw new AgentConfigurationError(SNMP_ACL_FILE_ACCESS_NOT_RESTRICTED,
|
||||
aclFileName);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new AgentConfigurationError(SNMP_ACL_FILE_READ_FAILED, aclFileName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the port on which the adaptor is bound.
|
||||
* Returns 0 if the adaptor is already terminated.
|
||||
*
|
||||
**/
|
||||
public synchronized int getPort() {
|
||||
if (adaptor != null) return adaptor.getPort();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the adaptor server.
|
||||
**/
|
||||
public synchronized void terminate() {
|
||||
if (adaptor == null) return;
|
||||
|
||||
// Terminate the MIB (deregister NotificationListener from
|
||||
// MemoryMBean)
|
||||
//
|
||||
try {
|
||||
jvmmib.terminate();
|
||||
} catch (Exception x) {
|
||||
// Must not prevent to stop...
|
||||
//
|
||||
log.debug("jmxremote.AdaptorBootstrap.getTargetList.terminate",
|
||||
x.toString());
|
||||
} finally {
|
||||
jvmmib=null;
|
||||
}
|
||||
|
||||
// Stop the adaptor
|
||||
//
|
||||
try {
|
||||
adaptor.stop();
|
||||
} finally {
|
||||
adaptor = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user