Merge

Wed, 22 Feb 2012 10:32:29 -0800

author
dsamersoff
date
Wed, 22 Feb 2012 10:32:29 -0800
changeset 3599
b5ab7482dbf9
parent 3589
1a4e5feb63c4
parent 3598
645162d94294
child 3600
7292cff45988

Merge

     1.1 --- a/src/share/vm/classfile/vmSymbols.hpp	Wed Feb 22 08:19:27 2012 -0800
     1.2 +++ b/src/share/vm/classfile/vmSymbols.hpp	Wed Feb 22 10:32:29 2012 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -509,6 +509,9 @@
    1.11    template(clear_name,                                 "clear")                                                   \
    1.12    template(trigger_method_signature,                   "(ILjava/lang/management/MemoryUsage;)V")                                                 \
    1.13    template(startAgent_name,                            "startAgent")                                              \
    1.14 +  template(startRemoteAgent_name,                      "startRemoteManagementAgent")                              \
    1.15 +  template(startLocalAgent_name,                       "startLocalManagementAgent")                               \
    1.16 +  template(stopRemoteAgent_name,                       "stopRemoteManagementAgent")                               \
    1.17    template(java_lang_management_ThreadInfo_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;)V") \
    1.18    template(java_lang_management_ThreadInfo_with_locks_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;[Ljava/lang/Object;[I[Ljava/lang/Object;)V") \
    1.19    template(long_long_long_long_void_signature,         "(JJJJ)V")                                                 \
     2.1 --- a/src/share/vm/services/diagnosticCommand.cpp	Wed Feb 22 08:19:27 2012 -0800
     2.2 +++ b/src/share/vm/services/diagnosticCommand.cpp	Wed Feb 22 10:32:29 2012 -0800
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -49,6 +49,11 @@
    2.11    DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(true, false));
    2.12    DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(true, false));
    2.13  
    2.14 +  //Enhanced JMX Agent Support
    2.15 +  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(true,false));
    2.16 +  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(true,false));
    2.17 +  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(true,false));
    2.18 +
    2.19  }
    2.20  
    2.21  #ifndef HAVE_EXTRA_DCMD
    2.22 @@ -344,3 +349,185 @@
    2.23      return 0;
    2.24    }
    2.25  }
    2.26 +
    2.27 +// Enhanced JMX Agent support
    2.28 +
    2.29 +JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) :
    2.30 +
    2.31 +  DCmdWithParser(output, heap_allocated),
    2.32 +
    2.33 +  _config_file
    2.34 +  ("config.file",
    2.35 +   "set com.sun.management.config.file", "STRING", false),
    2.36 +
    2.37 +  _jmxremote_port
    2.38 +  ("jmxremote.port",
    2.39 +   "set com.sun.management.jmxremote.port", "STRING", false),
    2.40 +
    2.41 +  _jmxremote_rmi_port
    2.42 +  ("jmxremote.rmi.port",
    2.43 +   "set com.sun.management.jmxremote.rmi.port", "STRING", false),
    2.44 +
    2.45 +  _jmxremote_ssl
    2.46 +  ("jmxremote.ssl",
    2.47 +   "set com.sun.management.jmxremote.ssl", "STRING", false),
    2.48 +
    2.49 +  _jmxremote_registry_ssl
    2.50 +  ("jmxremote.registry.ssl",
    2.51 +   "set com.sun.management.jmxremote.registry.ssl", "STRING", false),
    2.52 +
    2.53 +  _jmxremote_authenticate
    2.54 +  ("jmxremote.authenticate",
    2.55 +   "set com.sun.management.jmxremote.authenticate", "STRING", false),
    2.56 +
    2.57 +  _jmxremote_password_file
    2.58 +  ("jmxremote.password.file",
    2.59 +   "set com.sun.management.jmxremote.password.file", "STRING", false),
    2.60 +
    2.61 +  _jmxremote_access_file
    2.62 +  ("jmxremote.access.file",
    2.63 +   "set com.sun.management.jmxremote.access.file", "STRING", false),
    2.64 +
    2.65 +  _jmxremote_login_config
    2.66 +  ("jmxremote.login.config",
    2.67 +   "set com.sun.management.jmxremote.login.config", "STRING", false),
    2.68 +
    2.69 +  _jmxremote_ssl_enabled_cipher_suites
    2.70 +  ("jmxremote.ssl.enabled.cipher.suites",
    2.71 +   "set com.sun.management.jmxremote.ssl.enabled.cipher.suite", "STRING", false),
    2.72 +
    2.73 +  _jmxremote_ssl_enabled_protocols
    2.74 +  ("jmxremote.ssl.enabled.protocols",
    2.75 +   "set com.sun.management.jmxremote.ssl.enabled.protocols", "STRING", false),
    2.76 +
    2.77 +  _jmxremote_ssl_need_client_auth
    2.78 +  ("jmxremote.ssl.need.client.auth",
    2.79 +   "set com.sun.management.jmxremote.need.client.auth", "STRING", false),
    2.80 +
    2.81 +  _jmxremote_ssl_config_file
    2.82 +  ("jmxremote.ssl.config.file",
    2.83 +   "set com.sun.management.jmxremote.ssl_config_file", "STRING", false)
    2.84 +
    2.85 +  {
    2.86 +    _dcmdparser.add_dcmd_option(&_config_file);
    2.87 +    _dcmdparser.add_dcmd_option(&_jmxremote_port);
    2.88 +    _dcmdparser.add_dcmd_option(&_jmxremote_rmi_port);
    2.89 +    _dcmdparser.add_dcmd_option(&_jmxremote_ssl);
    2.90 +    _dcmdparser.add_dcmd_option(&_jmxremote_registry_ssl);
    2.91 +    _dcmdparser.add_dcmd_option(&_jmxremote_authenticate);
    2.92 +    _dcmdparser.add_dcmd_option(&_jmxremote_password_file);
    2.93 +    _dcmdparser.add_dcmd_option(&_jmxremote_access_file);
    2.94 +    _dcmdparser.add_dcmd_option(&_jmxremote_login_config);
    2.95 +    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_cipher_suites);
    2.96 +    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_protocols);
    2.97 +    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_need_client_auth);
    2.98 +    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file);
    2.99 +}
   2.100 +
   2.101 +
   2.102 +int JMXStartRemoteDCmd::num_arguments() {
   2.103 +  ResourceMark rm;
   2.104 +  JMXStartRemoteDCmd* dcmd = new JMXStartRemoteDCmd(NULL, false);
   2.105 +  if (dcmd != NULL) {
   2.106 +    DCmdMark mark(dcmd);
   2.107 +    return dcmd->_dcmdparser.num_arguments();
   2.108 +  } else {
   2.109 +    return 0;
   2.110 +  }
   2.111 +}
   2.112 +
   2.113 +
   2.114 +void JMXStartRemoteDCmd::execute(TRAPS) {
   2.115 +    ResourceMark rm(THREAD);
   2.116 +    HandleMark hm(THREAD);
   2.117 +
   2.118 +    // Load and initialize the sun.management.Agent class
   2.119 +    // invoke startRemoteManagementAgent(string) method to start
   2.120 +    // the remote management server.
   2.121 +    // throw java.lang.NoSuchMethodError if the method doesn't exist
   2.122 +
   2.123 +    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
   2.124 +    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
   2.125 +    instanceKlassHandle ik (THREAD, k);
   2.126 +
   2.127 +    JavaValue result(T_VOID);
   2.128 +
   2.129 +    // Pass all command line arguments to java as key=value,...
   2.130 +    // All checks are done on java side
   2.131 +
   2.132 +    int len = 0;
   2.133 +    stringStream options;
   2.134 +    char comma[2] = {0,0};
   2.135 +
   2.136 +    // Leave default values on Agent.class side and pass only
   2.137 +    // agruments explicitly set by user. All arguments passed
   2.138 +    // to jcmd override properties with the same name set by
   2.139 +    // command line with -D or by managmenent.properties
   2.140 +    // file.
   2.141 +#define PUT_OPTION(a) \
   2.142 +    if ( (a).is_set() ){ \
   2.143 +        options.print("%scom.sun.management.%s=%s", comma, (a).name(), (a).value()); \
   2.144 +        comma[0] = ','; \
   2.145 +    }
   2.146 +
   2.147 +    PUT_OPTION(_config_file);
   2.148 +    PUT_OPTION(_jmxremote_port);
   2.149 +    PUT_OPTION(_jmxremote_rmi_port);
   2.150 +    PUT_OPTION(_jmxremote_ssl);
   2.151 +    PUT_OPTION(_jmxremote_registry_ssl);
   2.152 +    PUT_OPTION(_jmxremote_authenticate);
   2.153 +    PUT_OPTION(_jmxremote_password_file);
   2.154 +    PUT_OPTION(_jmxremote_access_file);
   2.155 +    PUT_OPTION(_jmxremote_login_config);
   2.156 +    PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);
   2.157 +    PUT_OPTION(_jmxremote_ssl_enabled_protocols);
   2.158 +    PUT_OPTION(_jmxremote_ssl_need_client_auth);
   2.159 +    PUT_OPTION(_jmxremote_ssl_config_file);
   2.160 +
   2.161 +#undef PUT_OPTION
   2.162 +
   2.163 +    Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
   2.164 +    JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
   2.165 +}
   2.166 +
   2.167 +JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
   2.168 +  DCmd(output, heap_allocated)
   2.169 +{
   2.170 +  // do nothing
   2.171 +}
   2.172 +
   2.173 +void JMXStartLocalDCmd::execute(TRAPS) {
   2.174 +    ResourceMark rm(THREAD);
   2.175 +    HandleMark hm(THREAD);
   2.176 +
   2.177 +    // Load and initialize the sun.management.Agent class
   2.178 +    // invoke startLocalManagementAgent(void) method to start
   2.179 +    // the local management server
   2.180 +    // throw java.lang.NoSuchMethodError if method doesn't exist
   2.181 +
   2.182 +    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
   2.183 +    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
   2.184 +    instanceKlassHandle ik (THREAD, k);
   2.185 +
   2.186 +    JavaValue result(T_VOID);
   2.187 +    JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
   2.188 +}
   2.189 +
   2.190 +
   2.191 +void JMXStopRemoteDCmd::execute(TRAPS) {
   2.192 +    ResourceMark rm(THREAD);
   2.193 +    HandleMark hm(THREAD);
   2.194 +
   2.195 +    // Load and initialize the sun.management.Agent class
   2.196 +    // invoke stopRemoteManagementAgent method to stop the
   2.197 +    // management server
   2.198 +    // throw java.lang.NoSuchMethodError if method doesn't exist
   2.199 +
   2.200 +    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
   2.201 +    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
   2.202 +    instanceKlassHandle ik (THREAD, k);
   2.203 +
   2.204 +    JavaValue result(T_VOID);
   2.205 +    JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
   2.206 +}
   2.207 +
     3.1 --- a/src/share/vm/services/diagnosticCommand.hpp	Wed Feb 22 08:19:27 2012 -0800
     3.2 +++ b/src/share/vm/services/diagnosticCommand.hpp	Wed Feb 22 10:32:29 2012 -0800
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -214,4 +214,82 @@
    3.11    virtual void execute(TRAPS);
    3.12  };
    3.13  
    3.14 +// Enhanced JMX Agent support
    3.15 +
    3.16 +class JMXStartRemoteDCmd : public DCmdWithParser {
    3.17 +
    3.18 +  // Explicitly list all properties that could be
    3.19 +  // passed to Agent.startRemoteManagementAgent()
    3.20 +  // com.sun.management is omitted
    3.21 +
    3.22 +  DCmdArgument<char *> _config_file;
    3.23 +  DCmdArgument<char *> _jmxremote_port;
    3.24 +  DCmdArgument<char *> _jmxremote_rmi_port;
    3.25 +  DCmdArgument<char *> _jmxremote_ssl;
    3.26 +  DCmdArgument<char *> _jmxremote_registry_ssl;
    3.27 +  DCmdArgument<char *> _jmxremote_authenticate;
    3.28 +  DCmdArgument<char *> _jmxremote_password_file;
    3.29 +  DCmdArgument<char *> _jmxremote_access_file;
    3.30 +  DCmdArgument<char *> _jmxremote_login_config;
    3.31 +  DCmdArgument<char *> _jmxremote_ssl_enabled_cipher_suites;
    3.32 +  DCmdArgument<char *> _jmxremote_ssl_enabled_protocols;
    3.33 +  DCmdArgument<char *> _jmxremote_ssl_need_client_auth;
    3.34 +  DCmdArgument<char *> _jmxremote_ssl_config_file;
    3.35 +
    3.36 +public:
    3.37 +  JMXStartRemoteDCmd(outputStream *output, bool heap_allocated);
    3.38 +
    3.39 +  static const char *name() {
    3.40 +    return "ManagementAgent.start";
    3.41 +  }
    3.42 +
    3.43 +  static const char *description() {
    3.44 +    return "Start remote management agent.";
    3.45 +  }
    3.46 +
    3.47 +  static int num_arguments();
    3.48 +
    3.49 +  virtual void execute(TRAPS);
    3.50 +
    3.51 +};
    3.52 +
    3.53 +class JMXStartLocalDCmd : public DCmd {
    3.54 +
    3.55 +  // Explicitly request start of local agent,
    3.56 +  // it will not be started by start dcmd
    3.57 +
    3.58 +
    3.59 +public:
    3.60 +  JMXStartLocalDCmd(outputStream *output, bool heap_allocated);
    3.61 +
    3.62 +  static const char *name() {
    3.63 +    return "ManagementAgent.start_local";
    3.64 +  }
    3.65 +
    3.66 +  static const char *description() {
    3.67 +    return "Start local management agent.";
    3.68 +  }
    3.69 +
    3.70 +  virtual void execute(TRAPS);
    3.71 +
    3.72 +};
    3.73 +
    3.74 +class JMXStopRemoteDCmd : public DCmd {
    3.75 +public:
    3.76 +  JMXStopRemoteDCmd(outputStream *output, bool heap_allocated) :
    3.77 +  DCmd(output, heap_allocated) {
    3.78 +    // Do Nothing
    3.79 +  }
    3.80 +
    3.81 +  static const char *name() {
    3.82 +    return "ManagementAgent.stop";
    3.83 +  }
    3.84 +
    3.85 +  static const char *description() {
    3.86 +    return "Stop remote management agent.";
    3.87 +  }
    3.88 +
    3.89 +  virtual void execute(TRAPS);
    3.90 +};
    3.91 +
    3.92  #endif // SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP

mercurial