Java Code Examples for com.sun.management.HotSpotDiagnosticMXBean#setVMOption()

The following examples show how to use com.sun.management.HotSpotDiagnosticMXBean#setVMOption() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetAllVMOptions.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 2
Source File: SetAllVMOptions.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 3
Source File: SetAllVMOptions.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 4
Source File: SetAllVMOptions.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 5
Source File: SetAllVMOptions.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 6
Source File: JmxSupport.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
void setFlagValue(String name, String value) {
    try {
    HotSpotDiagnosticMXBean hsDiagnostic = getHotSpotDiagnostic();
        if (hsDiagnostic != null) {
            hsDiagnostic.setVMOption(name,value);
        }
    } catch (Exception ex) {
        LOGGER.log(Level.INFO,"setFlagValue", ex); // NOI18N
    }
}
 
Example 7
Source File: SetAllVMOptions.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 8
Source File: SetAllVMOptions.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 9
Source File: SetAllVMOptions.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 10
Source File: SetAllVMOptions.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 11
Source File: VMOptionCommand.java    From arthas with Apache License 2.0 5 votes vote down vote up
private static void run(CommandProcess process, String name, String value) {
    try {
        HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean = ManagementFactory
                        .getPlatformMXBean(HotSpotDiagnosticMXBean.class);

        if (StringUtils.isBlank(name) && StringUtils.isBlank(value)) {
            // show all options
            process.appendResult(new VMOptionModel(hotSpotDiagnosticMXBean.getDiagnosticOptions()));
        } else if (StringUtils.isBlank(value)) {
            // view the specified option
            VMOption option = hotSpotDiagnosticMXBean.getVMOption(name);
            if (option == null) {
                process.end(-1, "In order to change the system properties, you must specify the property value.");
            } else {
                process.appendResult(new VMOptionModel(Arrays.asList(option)));
            }
        } else {
            VMOption vmOption = hotSpotDiagnosticMXBean.getVMOption(name);
            String originValue = vmOption.getValue();

            // change vm option
            hotSpotDiagnosticMXBean.setVMOption(name, value);
            process.appendResult(new MessageModel("Successfully updated the vm option."));
            process.appendResult(new VMOptionModel(new ChangeResultVO(name, originValue,
                    hotSpotDiagnosticMXBean.getVMOption(name).getValue())));
        }
    } catch (Throwable t) {
        logger.error("Error during setting vm option", t);
        process.end(-1, "Error during setting vm option: " + t.getMessage());
    } finally {
        process.end();
    }
}
 
Example 12
Source File: SetAllVMOptions.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 13
Source File: SetAllVMOptions.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 14
Source File: SetAllVMOptions.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 15
Source File: SetAllVMOptions.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example 16
Source File: TestVmFlagChangedEvent.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
void update(HotSpotDiagnosticMXBean mbean) {
    this.oldValue = mbean.getVMOption(eventLabel).getValue();
    mbean.setVMOption(eventLabel, newValue);
}
 
Example 17
Source File: TestVmFlagChangedEvent.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void update(HotSpotDiagnosticMXBean mbean) {
    this.oldValue = mbean.getVMOption(eventLabel).getValue();
    mbean.setVMOption(eventLabel, newValue);
}
 
Example 18
Source File: TestVmFlagChangedEvent.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
void update(HotSpotDiagnosticMXBean mbean) {
    this.oldValue = mbean.getVMOption(eventLabel).getValue();
    mbean.setVMOption(eventLabel, newValue);
}