use of com.shulie.instrument.simulator.module.model.vmoption.VmOption in project LinkAgent by shulieTech.
the class VMOptionModule method info.
@Command(value = "info", description = "查看虚拟机参数")
public CommandResponse info(final Map<String, String> args) {
String name = args.get("name");
try {
HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
if (StringUtils.isBlank(name)) {
// show all options
final List<VMOption> diagnosticOptions = hotSpotDiagnosticMXBean.getDiagnosticOptions();
List<VmOption> vmOptions = new ArrayList<VmOption>();
for (VMOption vmOption : diagnosticOptions) {
vmOptions.add(new VmOption(vmOption));
}
return CommandResponse.success(vmOptions);
} else {
// view the specified option
VMOption option = hotSpotDiagnosticMXBean.getVMOption(name);
if (option == null) {
return CommandResponse.failure("In order to change the system properties, you must specify the property value.");
} else {
List<VmOption> vmOptions = new ArrayList<VmOption>();
vmOptions.add(new VmOption(option));
return CommandResponse.success(vmOptions);
}
}
} catch (Throwable t) {
return CommandResponse.failure(t);
}
}
Aggregations