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