src/share/vm/services/diagnosticCommand.cpp

Fri, 25 Jan 2013 10:04:08 -0500

author
zgu
date
Fri, 25 Jan 2013 10:04:08 -0500
changeset 4492
8b46b0196eb0
parent 4167
9855b7e559ae
child 4497
16fb9f942703
child 4542
db9981fd3124
permissions
-rw-r--r--

8000692: Remove old KERNEL code
Summary: Removed depreciated kernel VM source code from hotspot VM
Reviewed-by: dholmes, acorn

fparain@3329 1 /*
dsamersoff@3598 2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
fparain@3329 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fparain@3329 4 *
fparain@3329 5 * This code is free software; you can redistribute it and/or modify it
fparain@3329 6 * under the terms of the GNU General Public License version 2 only, as
fparain@3329 7 * published by the Free Software Foundation.
fparain@3329 8 *
fparain@3329 9 * This code is distributed in the hope that it will be useful, but WITHOUT
fparain@3329 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fparain@3329 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fparain@3329 12 * version 2 for more details (a copy is included in the LICENSE file that
fparain@3329 13 * accompanied this code).
fparain@3329 14 *
fparain@3329 15 * You should have received a copy of the GNU General Public License version
fparain@3329 16 * 2 along with this work; if not, write to the Free Software Foundation,
fparain@3329 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fparain@3329 18 *
fparain@3329 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fparain@3329 20 * or visit www.oracle.com if you need additional information or have any
fparain@3329 21 * questions.
fparain@3329 22 *
fparain@3329 23 */
fparain@3329 24
fparain@3329 25 #include "precompiled.hpp"
fparain@3402 26 #include "gc_implementation/shared/vmGCOperations.hpp"
fparain@3402 27 #include "runtime/javaCalls.hpp"
fparain@3329 28 #include "services/diagnosticArgument.hpp"
fparain@3329 29 #include "services/diagnosticCommand.hpp"
fparain@3329 30 #include "services/diagnosticFramework.hpp"
fparain@3402 31 #include "services/heapDumper.hpp"
fparain@3402 32 #include "services/management.hpp"
fparain@3329 33
dsamersoff@3478 34 void DCmdRegistrant::register_dcmds(){
dsamersoff@3478 35 // Registration of the diagnostic commands
dsamersoff@3478 36 // First boolean argument specifies if the command is enabled
dsamersoff@3478 37 // Second boolean argument specifies if the command is hidden
dsamersoff@3478 38 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(true, false));
dsamersoff@3478 39 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(true, false));
dsamersoff@3478 40 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(true, false));
dsamersoff@3478 41 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(true, false));
dsamersoff@3478 42 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(true, false));
dsamersoff@3478 43 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(true, false));
dsamersoff@3478 44 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(true, false));
dsamersoff@3478 45 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(true, false));
jprovino@4165 46 #if INCLUDE_SERVICES // Heap dumping supported
dsamersoff@3478 47 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(true, false));
jprovino@4165 48 #endif // INCLUDE_SERVICES
dsamersoff@3478 49 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(true, false));
dsamersoff@3478 50 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(true, false));
dsamersoff@3478 51
dsamersoff@3598 52 //Enhanced JMX Agent Support
dsamersoff@3598 53 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(true,false));
dsamersoff@3598 54 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(true,false));
dsamersoff@3598 55 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(true,false));
dsamersoff@3598 56
dsamersoff@3478 57 }
dsamersoff@3478 58
dsamersoff@3478 59 #ifndef HAVE_EXTRA_DCMD
dsamersoff@3478 60 void DCmdRegistrant::register_dcmds_ext(){
dsamersoff@3478 61 // Do nothing here
dsamersoff@3478 62 }
dsamersoff@3478 63 #endif
dsamersoff@3478 64
dsamersoff@3478 65
fparain@3402 66 HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
fparain@3329 67 _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),
fparain@3329 68 _cmd("command name", "The name of the command for which we want help",
fparain@3329 69 "STRING", false) {
fparain@3329 70 _dcmdparser.add_dcmd_option(&_all);
fparain@3329 71 _dcmdparser.add_dcmd_argument(&_cmd);
fparain@3329 72 };
fparain@3329 73
fparain@3329 74 void HelpDCmd::execute(TRAPS) {
fparain@3329 75 if (_all.value()) {
fparain@3329 76 GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list();
fparain@3329 77 for (int i = 0; i < cmd_list->length(); i++) {
fparain@3329 78 DCmdFactory* factory = DCmdFactory::factory(cmd_list->at(i),
fparain@3329 79 strlen(cmd_list->at(i)));
fparain@3329 80 if (!factory->is_hidden()) {
fparain@3329 81 output()->print_cr("%s%s", factory->name(),
fparain@3329 82 factory->is_enabled() ? "" : " [disabled]");
fparain@3329 83 output()->print_cr("\t%s", factory->description());
fparain@3329 84 output()->cr();
fparain@3329 85 }
fparain@3329 86 factory = factory->next();
fparain@3329 87 }
fparain@3329 88 } else if (_cmd.has_value()) {
fparain@3329 89 DCmd* cmd = NULL;
fparain@3329 90 DCmdFactory* factory = DCmdFactory::factory(_cmd.value(),
fparain@3329 91 strlen(_cmd.value()));
fparain@3329 92 if (factory != NULL) {
fparain@3329 93 output()->print_cr("%s%s", factory->name(),
fparain@3329 94 factory->is_enabled() ? "" : " [disabled]");
fparain@3329 95 output()->print_cr(factory->description());
fparain@3329 96 output()->print_cr("\nImpact: %s", factory->impact());
fparain@3402 97 output()->cr();
fparain@3329 98 cmd = factory->create_resource_instance(output());
fparain@3329 99 if (cmd != NULL) {
fparain@3329 100 DCmdMark mark(cmd);
fparain@3402 101 cmd->print_help(factory->name());
fparain@3329 102 }
fparain@3329 103 } else {
fparain@3329 104 output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());
fparain@3329 105 }
fparain@3329 106 } else {
fparain@3329 107 output()->print_cr("The following commands are available:");
fparain@3329 108 GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list();
fparain@3329 109 for (int i = 0; i < cmd_list->length(); i++) {
fparain@3329 110 DCmdFactory* factory = DCmdFactory::factory(cmd_list->at(i),
fparain@3329 111 strlen(cmd_list->at(i)));
fparain@3329 112 if (!factory->is_hidden()) {
fparain@3329 113 output()->print_cr("%s%s", factory->name(),
fparain@3329 114 factory->is_enabled() ? "" : " [disabled]");
fparain@3329 115 }
fparain@3329 116 factory = factory->_next;
fparain@3329 117 }
fparain@3329 118 output()->print_cr("\nFor more information about a specific command use 'help <command>'.");
fparain@3329 119 }
fparain@3329 120 }
fparain@3329 121
fparain@3329 122 int HelpDCmd::num_arguments() {
fparain@3329 123 ResourceMark rm;
fparain@3329 124 HelpDCmd* dcmd = new HelpDCmd(NULL, false);
fparain@3329 125 if (dcmd != NULL) {
fparain@3329 126 DCmdMark mark(dcmd);
fparain@3329 127 return dcmd->_dcmdparser.num_arguments();
fparain@3329 128 } else {
fparain@3329 129 return 0;
fparain@3329 130 }
fparain@3329 131 }
fparain@3329 132
fparain@3329 133 void VersionDCmd::execute(TRAPS) {
fparain@3329 134 output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(),
fparain@3329 135 Abstract_VM_Version::vm_release());
fparain@3329 136 JDK_Version jdk_version = JDK_Version::current();
fparain@3329 137 if (jdk_version.update_version() > 0) {
fparain@3329 138 output()->print_cr("JDK %d.%d_%02d", jdk_version.major_version(),
fparain@3329 139 jdk_version.minor_version(), jdk_version.update_version());
fparain@3329 140 } else {
fparain@3329 141 output()->print_cr("JDK %d.%d", jdk_version.major_version(),
fparain@3329 142 jdk_version.minor_version());
fparain@3329 143 }
fparain@3329 144 }
fparain@3402 145
fparain@3402 146 PrintVMFlagsDCmd::PrintVMFlagsDCmd(outputStream* output, bool heap) :
fparain@3402 147 DCmdWithParser(output, heap),
fparain@3402 148 _all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") {
fparain@3402 149 _dcmdparser.add_dcmd_option(&_all);
fparain@3402 150 }
fparain@3402 151
fparain@3402 152 void PrintVMFlagsDCmd::execute(TRAPS) {
fparain@3402 153 if (_all.value()) {
fparain@3402 154 CommandLineFlags::printFlags(output(), true);
fparain@3402 155 } else {
fparain@3402 156 CommandLineFlags::printSetFlags(output());
fparain@3402 157 }
fparain@3402 158 }
fparain@3402 159
fparain@3402 160 int PrintVMFlagsDCmd::num_arguments() {
fparain@3402 161 ResourceMark rm;
fparain@3402 162 PrintVMFlagsDCmd* dcmd = new PrintVMFlagsDCmd(NULL, false);
fparain@3402 163 if (dcmd != NULL) {
fparain@3402 164 DCmdMark mark(dcmd);
fparain@3402 165 return dcmd->_dcmdparser.num_arguments();
fparain@3402 166 } else {
fparain@3402 167 return 0;
fparain@3402 168 }
fparain@3402 169 }
fparain@3402 170
fparain@3402 171 void PrintSystemPropertiesDCmd::execute(TRAPS) {
fparain@3402 172 // load sun.misc.VMSupport
fparain@3402 173 Symbol* klass = vmSymbols::sun_misc_VMSupport();
coleenp@4037 174 Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
fparain@3402 175 instanceKlassHandle ik (THREAD, k);
fparain@3402 176 if (ik->should_be_initialized()) {
fparain@3402 177 ik->initialize(THREAD);
fparain@3402 178 }
fparain@3402 179 if (HAS_PENDING_EXCEPTION) {
fparain@3402 180 java_lang_Throwable::print(PENDING_EXCEPTION, output());
fparain@3402 181 output()->cr();
fparain@3402 182 CLEAR_PENDING_EXCEPTION;
fparain@3402 183 return;
fparain@3402 184 }
fparain@3402 185
fparain@3402 186 // invoke the serializePropertiesToByteArray method
fparain@3402 187 JavaValue result(T_OBJECT);
fparain@3402 188 JavaCallArguments args;
fparain@3402 189
fparain@3402 190 Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature();
fparain@3402 191 JavaCalls::call_static(&result,
fparain@3402 192 ik,
fparain@3402 193 vmSymbols::serializePropertiesToByteArray_name(),
fparain@3402 194 signature,
fparain@3402 195 &args,
fparain@3402 196 THREAD);
fparain@3402 197 if (HAS_PENDING_EXCEPTION) {
fparain@3402 198 java_lang_Throwable::print(PENDING_EXCEPTION, output());
fparain@3402 199 output()->cr();
fparain@3402 200 CLEAR_PENDING_EXCEPTION;
fparain@3402 201 return;
fparain@3402 202 }
fparain@3402 203
fparain@3402 204 // The result should be a [B
fparain@3402 205 oop res = (oop)result.get_jobject();
fparain@3402 206 assert(res->is_typeArray(), "just checking");
coleenp@4142 207 assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
fparain@3402 208
fparain@3402 209 // copy the bytes to the output stream
fparain@3402 210 typeArrayOop ba = typeArrayOop(res);
fparain@3402 211 jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
fparain@3402 212 output()->print_raw((const char*)addr, ba->length());
fparain@3402 213 }
fparain@3402 214
fparain@3402 215 VMUptimeDCmd::VMUptimeDCmd(outputStream* output, bool heap) :
fparain@3402 216 DCmdWithParser(output, heap),
fparain@3402 217 _date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") {
fparain@3402 218 _dcmdparser.add_dcmd_option(&_date);
fparain@3402 219 }
fparain@3402 220
fparain@3402 221 void VMUptimeDCmd::execute(TRAPS) {
fparain@3402 222 if (_date.value()) {
fparain@3402 223 output()->date_stamp(true, "", ": ");
fparain@3402 224 }
fparain@3402 225 output()->time_stamp().update_to(tty->time_stamp().ticks());
fparain@3402 226 output()->stamp();
fparain@3402 227 output()->print_cr(" s");
fparain@3402 228 }
fparain@3402 229
fparain@3402 230 int VMUptimeDCmd::num_arguments() {
fparain@3402 231 ResourceMark rm;
fparain@3402 232 VMUptimeDCmd* dcmd = new VMUptimeDCmd(NULL, false);
fparain@3402 233 if (dcmd != NULL) {
fparain@3402 234 DCmdMark mark(dcmd);
fparain@3402 235 return dcmd->_dcmdparser.num_arguments();
fparain@3402 236 } else {
fparain@3402 237 return 0;
fparain@3402 238 }
fparain@3402 239 }
fparain@3402 240
fparain@3402 241 void SystemGCDCmd::execute(TRAPS) {
fparain@3402 242 Universe::heap()->collect(GCCause::_java_lang_system_gc);
fparain@3402 243 }
fparain@3402 244
fparain@3402 245 void RunFinalizationDCmd::execute(TRAPS) {
coleenp@4037 246 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(),
fparain@3402 247 true, CHECK);
fparain@3402 248 instanceKlassHandle klass(THREAD, k);
fparain@3402 249 JavaValue result(T_VOID);
fparain@3402 250 JavaCalls::call_static(&result, klass,
fparain@3402 251 vmSymbols::run_finalization_name(),
fparain@3402 252 vmSymbols::void_method_signature(), CHECK);
fparain@3402 253 }
fparain@3402 254
jprovino@4165 255 #if INCLUDE_SERVICES // Heap dumping supported
fparain@3402 256 HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :
fparain@3402 257 DCmdWithParser(output, heap),
fparain@3402 258 _filename("filename","Name of the dump file", "STRING",true),
fparain@3402 259 _all("-all", "Dump all objects, including unreachable objects",
fparain@3402 260 "BOOLEAN", false, "false") {
fparain@3402 261 _dcmdparser.add_dcmd_option(&_all);
fparain@3402 262 _dcmdparser.add_dcmd_argument(&_filename);
fparain@3402 263 }
fparain@3402 264
fparain@3402 265 void HeapDumpDCmd::execute(TRAPS) {
fparain@3402 266 // Request a full GC before heap dump if _all is false
fparain@3402 267 // This helps reduces the amount of unreachable objects in the dump
fparain@3402 268 // and makes it easier to browse.
fparain@3402 269 HeapDumper dumper(!_all.value() /* request GC if _all is false*/);
fparain@3402 270 int res = dumper.dump(_filename.value());
fparain@3402 271 if (res == 0) {
fparain@3402 272 output()->print_cr("Heap dump file created");
fparain@3402 273 } else {
fparain@3402 274 // heap dump failed
fparain@3402 275 ResourceMark rm;
fparain@3402 276 char* error = dumper.error_as_C_string();
fparain@3402 277 if (error == NULL) {
fparain@3402 278 output()->print_cr("Dump failed - reason unknown");
fparain@3402 279 } else {
fparain@3402 280 output()->print_cr("%s", error);
fparain@3402 281 }
fparain@3402 282 }
fparain@3402 283 }
fparain@3402 284
fparain@3402 285 int HeapDumpDCmd::num_arguments() {
fparain@3402 286 ResourceMark rm;
fparain@3402 287 HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
fparain@3402 288 if (dcmd != NULL) {
fparain@3402 289 DCmdMark mark(dcmd);
fparain@3402 290 return dcmd->_dcmdparser.num_arguments();
fparain@3402 291 } else {
fparain@3402 292 return 0;
fparain@3402 293 }
fparain@3402 294 }
jprovino@4165 295 #endif // INCLUDE_SERVICES
fparain@3402 296
fparain@3402 297 ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :
fparain@3402 298 DCmdWithParser(output, heap),
fparain@3402 299 _all("-all", "Inspect all objects, including unreachable objects",
fparain@3402 300 "BOOLEAN", false, "false") {
fparain@3402 301 _dcmdparser.add_dcmd_option(&_all);
fparain@3402 302 }
fparain@3402 303
fparain@3402 304 void ClassHistogramDCmd::execute(TRAPS) {
fparain@3402 305 VM_GC_HeapInspection heapop(output(),
fparain@3402 306 !_all.value() /* request full gc if false */,
fparain@3402 307 true /* need_prologue */);
fparain@3402 308 VMThread::execute(&heapop);
fparain@3402 309 }
fparain@3402 310
fparain@3402 311 int ClassHistogramDCmd::num_arguments() {
fparain@3402 312 ResourceMark rm;
fparain@3402 313 ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false);
fparain@3402 314 if (dcmd != NULL) {
fparain@3402 315 DCmdMark mark(dcmd);
fparain@3402 316 return dcmd->_dcmdparser.num_arguments();
fparain@3402 317 } else {
fparain@3402 318 return 0;
fparain@3402 319 }
fparain@3402 320 }
fparain@3402 321
fparain@3402 322 ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) :
fparain@3402 323 DCmdWithParser(output, heap),
fparain@3402 324 _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") {
fparain@3402 325 _dcmdparser.add_dcmd_option(&_locks);
fparain@3402 326 }
fparain@3402 327
fparain@3402 328 void ThreadDumpDCmd::execute(TRAPS) {
fparain@3402 329 // thread stacks
fparain@3402 330 VM_PrintThreads op1(output(), _locks.value());
fparain@3402 331 VMThread::execute(&op1);
fparain@3402 332
fparain@3402 333 // JNI global handles
fparain@3402 334 VM_PrintJNI op2(output());
fparain@3402 335 VMThread::execute(&op2);
fparain@3402 336
fparain@3402 337 // Deadlock detection
fparain@3402 338 VM_FindDeadlocks op3(output());
fparain@3402 339 VMThread::execute(&op3);
fparain@3402 340 }
fparain@3402 341
fparain@3402 342 int ThreadDumpDCmd::num_arguments() {
fparain@3402 343 ResourceMark rm;
fparain@3402 344 ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false);
fparain@3402 345 if (dcmd != NULL) {
fparain@3402 346 DCmdMark mark(dcmd);
fparain@3402 347 return dcmd->_dcmdparser.num_arguments();
fparain@3402 348 } else {
fparain@3402 349 return 0;
fparain@3402 350 }
fparain@3402 351 }
dsamersoff@3598 352
dsamersoff@3598 353 // Enhanced JMX Agent support
dsamersoff@3598 354
dsamersoff@3598 355 JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) :
dsamersoff@3598 356
dsamersoff@3598 357 DCmdWithParser(output, heap_allocated),
dsamersoff@3598 358
dsamersoff@3598 359 _config_file
dsamersoff@3598 360 ("config.file",
dsamersoff@3598 361 "set com.sun.management.config.file", "STRING", false),
dsamersoff@3598 362
dsamersoff@3598 363 _jmxremote_port
dsamersoff@3598 364 ("jmxremote.port",
dsamersoff@3598 365 "set com.sun.management.jmxremote.port", "STRING", false),
dsamersoff@3598 366
dsamersoff@3598 367 _jmxremote_rmi_port
dsamersoff@3598 368 ("jmxremote.rmi.port",
dsamersoff@3598 369 "set com.sun.management.jmxremote.rmi.port", "STRING", false),
dsamersoff@3598 370
dsamersoff@3598 371 _jmxremote_ssl
dsamersoff@3598 372 ("jmxremote.ssl",
dsamersoff@3598 373 "set com.sun.management.jmxremote.ssl", "STRING", false),
dsamersoff@3598 374
dsamersoff@3598 375 _jmxremote_registry_ssl
dsamersoff@3598 376 ("jmxremote.registry.ssl",
dsamersoff@3598 377 "set com.sun.management.jmxremote.registry.ssl", "STRING", false),
dsamersoff@3598 378
dsamersoff@3598 379 _jmxremote_authenticate
dsamersoff@3598 380 ("jmxremote.authenticate",
dsamersoff@3598 381 "set com.sun.management.jmxremote.authenticate", "STRING", false),
dsamersoff@3598 382
dsamersoff@3598 383 _jmxremote_password_file
dsamersoff@3598 384 ("jmxremote.password.file",
dsamersoff@3598 385 "set com.sun.management.jmxremote.password.file", "STRING", false),
dsamersoff@3598 386
dsamersoff@3598 387 _jmxremote_access_file
dsamersoff@3598 388 ("jmxremote.access.file",
dsamersoff@3598 389 "set com.sun.management.jmxremote.access.file", "STRING", false),
dsamersoff@3598 390
dsamersoff@3598 391 _jmxremote_login_config
dsamersoff@3598 392 ("jmxremote.login.config",
dsamersoff@3598 393 "set com.sun.management.jmxremote.login.config", "STRING", false),
dsamersoff@3598 394
dsamersoff@3598 395 _jmxremote_ssl_enabled_cipher_suites
dsamersoff@3598 396 ("jmxremote.ssl.enabled.cipher.suites",
dsamersoff@3598 397 "set com.sun.management.jmxremote.ssl.enabled.cipher.suite", "STRING", false),
dsamersoff@3598 398
dsamersoff@3598 399 _jmxremote_ssl_enabled_protocols
dsamersoff@3598 400 ("jmxremote.ssl.enabled.protocols",
dsamersoff@3598 401 "set com.sun.management.jmxremote.ssl.enabled.protocols", "STRING", false),
dsamersoff@3598 402
dsamersoff@3598 403 _jmxremote_ssl_need_client_auth
dsamersoff@3598 404 ("jmxremote.ssl.need.client.auth",
dsamersoff@3598 405 "set com.sun.management.jmxremote.need.client.auth", "STRING", false),
dsamersoff@3598 406
dsamersoff@3598 407 _jmxremote_ssl_config_file
dsamersoff@3598 408 ("jmxremote.ssl.config.file",
dsamersoff@3598 409 "set com.sun.management.jmxremote.ssl_config_file", "STRING", false)
dsamersoff@3598 410
dsamersoff@3598 411 {
dsamersoff@3598 412 _dcmdparser.add_dcmd_option(&_config_file);
dsamersoff@3598 413 _dcmdparser.add_dcmd_option(&_jmxremote_port);
dsamersoff@3598 414 _dcmdparser.add_dcmd_option(&_jmxremote_rmi_port);
dsamersoff@3598 415 _dcmdparser.add_dcmd_option(&_jmxremote_ssl);
dsamersoff@3598 416 _dcmdparser.add_dcmd_option(&_jmxremote_registry_ssl);
dsamersoff@3598 417 _dcmdparser.add_dcmd_option(&_jmxremote_authenticate);
dsamersoff@3598 418 _dcmdparser.add_dcmd_option(&_jmxremote_password_file);
dsamersoff@3598 419 _dcmdparser.add_dcmd_option(&_jmxremote_access_file);
dsamersoff@3598 420 _dcmdparser.add_dcmd_option(&_jmxremote_login_config);
dsamersoff@3598 421 _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_cipher_suites);
dsamersoff@3598 422 _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_protocols);
dsamersoff@3598 423 _dcmdparser.add_dcmd_option(&_jmxremote_ssl_need_client_auth);
dsamersoff@3598 424 _dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file);
dsamersoff@3598 425 }
dsamersoff@3598 426
dsamersoff@3598 427
dsamersoff@3598 428 int JMXStartRemoteDCmd::num_arguments() {
dsamersoff@3598 429 ResourceMark rm;
dsamersoff@3598 430 JMXStartRemoteDCmd* dcmd = new JMXStartRemoteDCmd(NULL, false);
dsamersoff@3598 431 if (dcmd != NULL) {
dsamersoff@3598 432 DCmdMark mark(dcmd);
dsamersoff@3598 433 return dcmd->_dcmdparser.num_arguments();
dsamersoff@3598 434 } else {
dsamersoff@3598 435 return 0;
dsamersoff@3598 436 }
dsamersoff@3598 437 }
dsamersoff@3598 438
dsamersoff@3598 439
dsamersoff@3598 440 void JMXStartRemoteDCmd::execute(TRAPS) {
dsamersoff@3598 441 ResourceMark rm(THREAD);
dsamersoff@3598 442 HandleMark hm(THREAD);
dsamersoff@3598 443
dsamersoff@3598 444 // Load and initialize the sun.management.Agent class
dsamersoff@3598 445 // invoke startRemoteManagementAgent(string) method to start
dsamersoff@3598 446 // the remote management server.
dsamersoff@3598 447 // throw java.lang.NoSuchMethodError if the method doesn't exist
dsamersoff@3598 448
dsamersoff@3598 449 Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
coleenp@4037 450 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
dsamersoff@3598 451 instanceKlassHandle ik (THREAD, k);
dsamersoff@3598 452
dsamersoff@3598 453 JavaValue result(T_VOID);
dsamersoff@3598 454
dsamersoff@3598 455 // Pass all command line arguments to java as key=value,...
dsamersoff@3598 456 // All checks are done on java side
dsamersoff@3598 457
dsamersoff@3598 458 int len = 0;
dsamersoff@3598 459 stringStream options;
dsamersoff@3598 460 char comma[2] = {0,0};
dsamersoff@3598 461
dsamersoff@3598 462 // Leave default values on Agent.class side and pass only
dsamersoff@3598 463 // agruments explicitly set by user. All arguments passed
dsamersoff@3598 464 // to jcmd override properties with the same name set by
dsamersoff@3598 465 // command line with -D or by managmenent.properties
dsamersoff@3598 466 // file.
dsamersoff@3598 467 #define PUT_OPTION(a) \
dsamersoff@3598 468 if ( (a).is_set() ){ \
dsamersoff@3598 469 options.print("%scom.sun.management.%s=%s", comma, (a).name(), (a).value()); \
dsamersoff@3598 470 comma[0] = ','; \
dsamersoff@3598 471 }
dsamersoff@3598 472
dsamersoff@3598 473 PUT_OPTION(_config_file);
dsamersoff@3598 474 PUT_OPTION(_jmxremote_port);
dsamersoff@3598 475 PUT_OPTION(_jmxremote_rmi_port);
dsamersoff@3598 476 PUT_OPTION(_jmxremote_ssl);
dsamersoff@3598 477 PUT_OPTION(_jmxremote_registry_ssl);
dsamersoff@3598 478 PUT_OPTION(_jmxremote_authenticate);
dsamersoff@3598 479 PUT_OPTION(_jmxremote_password_file);
dsamersoff@3598 480 PUT_OPTION(_jmxremote_access_file);
dsamersoff@3598 481 PUT_OPTION(_jmxremote_login_config);
dsamersoff@3598 482 PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);
dsamersoff@3598 483 PUT_OPTION(_jmxremote_ssl_enabled_protocols);
dsamersoff@3598 484 PUT_OPTION(_jmxremote_ssl_need_client_auth);
dsamersoff@3598 485 PUT_OPTION(_jmxremote_ssl_config_file);
dsamersoff@3598 486
dsamersoff@3598 487 #undef PUT_OPTION
dsamersoff@3598 488
dsamersoff@3598 489 Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
dsamersoff@3598 490 JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
dsamersoff@3598 491 }
dsamersoff@3598 492
dsamersoff@3598 493 JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
dsamersoff@3598 494 DCmd(output, heap_allocated)
dsamersoff@3598 495 {
dsamersoff@3598 496 // do nothing
dsamersoff@3598 497 }
dsamersoff@3598 498
dsamersoff@3598 499 void JMXStartLocalDCmd::execute(TRAPS) {
dsamersoff@3598 500 ResourceMark rm(THREAD);
dsamersoff@3598 501 HandleMark hm(THREAD);
dsamersoff@3598 502
dsamersoff@3598 503 // Load and initialize the sun.management.Agent class
dsamersoff@3598 504 // invoke startLocalManagementAgent(void) method to start
dsamersoff@3598 505 // the local management server
dsamersoff@3598 506 // throw java.lang.NoSuchMethodError if method doesn't exist
dsamersoff@3598 507
dsamersoff@3598 508 Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
coleenp@4037 509 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
dsamersoff@3598 510 instanceKlassHandle ik (THREAD, k);
dsamersoff@3598 511
dsamersoff@3598 512 JavaValue result(T_VOID);
dsamersoff@3598 513 JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
dsamersoff@3598 514 }
dsamersoff@3598 515
dsamersoff@3598 516
dsamersoff@3598 517 void JMXStopRemoteDCmd::execute(TRAPS) {
dsamersoff@3598 518 ResourceMark rm(THREAD);
dsamersoff@3598 519 HandleMark hm(THREAD);
dsamersoff@3598 520
dsamersoff@3598 521 // Load and initialize the sun.management.Agent class
dsamersoff@3598 522 // invoke stopRemoteManagementAgent method to stop the
dsamersoff@3598 523 // management server
dsamersoff@3598 524 // throw java.lang.NoSuchMethodError if method doesn't exist
dsamersoff@3598 525
dsamersoff@3598 526 Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
coleenp@4037 527 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
dsamersoff@3598 528 instanceKlassHandle ik (THREAD, k);
dsamersoff@3598 529
dsamersoff@3598 530 JavaValue result(T_VOID);
dsamersoff@3598 531 JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
dsamersoff@3598 532 }
dsamersoff@3598 533

mercurial