本文整理汇总了Java中com.sun.management.VMOption.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java VMOption.getValue方法的具体用法?Java VMOption.getValue怎么用?Java VMOption.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.management.VMOption
的用法示例。
在下文中一共展示了VMOption.getValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkVMOption
import com.sun.management.VMOption; //导入方法依赖的package包/类
private static void checkVMOption(HotSpotDiagnosticMXBean mbean) {
VMOption option = mbean.getVMOption(PRINT_GC_DETAILS);
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + EXPECTED_VALUE);
}
boolean iae = false;
try {
mbean.getVMOption(BAD_OPTION);
} catch (IllegalArgumentException e) {
iae = true;
}
if (!iae) {
throw new RuntimeException("Invalid VM Option" +
" was not detected");
}
}
示例2: checkVMOption
import com.sun.management.VMOption; //导入方法依赖的package包/类
private static void checkVMOption(HotSpotDiagnosticMXBean mbean) {
VMOption option = mbean.getVMOption(HEAP_DUMP_ON_OOM);
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + EXPECTED_VALUE);
}
boolean iae = false;
try {
mbean.getVMOption(BAD_OPTION);
} catch (IllegalArgumentException e) {
iae = true;
}
if (!iae) {
throw new RuntimeException("Invalid VM Option" +
" was not detected");
}
}
示例3: getVMOption
import com.sun.management.VMOption; //导入方法依赖的package包/类
/**
* Returns value of VM option.
*
* @param name option's name
* @return value of option or {@code null}, if option doesn't exist
* @throws NullPointerException if name is null
*/
protected static String getVMOption(String name) {
Objects.requireNonNull(name);
HotSpotDiagnosticMXBean diagnostic
= ManagementFactoryHelper.getDiagnosticMXBean();
VMOption tmp;
try {
tmp = diagnostic.getVMOption(name);
} catch (IllegalArgumentException e) {
tmp = null;
}
return (tmp == null ? null : tmp.getValue());
}
示例4: setAllVMOptions
import com.sun.management.VMOption; //导入方法依赖的package包/类
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);
}
}
示例5: checkVMOption
import com.sun.management.VMOption; //导入方法依赖的package包/类
private static void checkVMOption(HotSpotDiagnosticMXBean mbean) {
VMOption option = mbean.getVMOption(COMPILE_THRESHOLD_SCALING);
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + EXPECTED_VALUE);
}
}
示例6: main
import com.sun.management.VMOption; //导入方法依赖的package包/类
public static void main(String[] args) {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
String expectedValue = getExpectedValue(args);
VMOption option = diagnostic.getVMOption("G1HeapRegionSize");
if (!expectedValue.equals(option.getValue())) {
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
}
}
示例7: main
import com.sun.management.VMOption; //导入方法依赖的package包/类
public static void main(String[] args) {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
VMOption option = diagnostic.getVMOption("UseG1GC");
if (option.getValue().equals("false")) {
System.out.println("Skipping this test. It is only a G1 test.");
return;
}
String expectedValue = getExpectedValue(args);
option = diagnostic.getVMOption("G1HeapRegionSize");
if (!expectedValue.equals(option.getValue())) {
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
}
}
示例8: main
import com.sun.management.VMOption; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
mbean =
ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
VMOption option = findPrintGCDetailsOption();
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + EXPECTED_VALUE);
}
if (option.getOrigin() != Origin.VM_CREATION) {
throw new RuntimeException("Unexpected origin: " +
option.getOrigin() + " expected: VM_CREATION");
}
if (!option.isWriteable()) {
throw new RuntimeException("Expected " + PRINT_GC_DETAILS +
" to be writeable");
}
// set VM option to a new value
mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE);
option = findPrintGCDetailsOption();
if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + NEW_VALUE);
}
if (option.getOrigin() != Origin.MANAGEMENT) {
throw new RuntimeException("Unexpected origin: " +
option.getOrigin() + " expected: MANAGEMENT");
}
VMOption o = mbean.getVMOption(PRINT_GC_DETAILS);
if (!option.getValue().equals(o.getValue())) {
throw new RuntimeException("Unmatched value: " +
option.getValue() + " expected: " + o.getValue());
}
if (!option.getValue().equals(o.getValue())) {
throw new RuntimeException("Unmatched value: " +
option.getValue() + " expected: " + o.getValue());
}
if (option.getOrigin() != o.getOrigin()) {
throw new RuntimeException("Unmatched origin: " +
option.getOrigin() + " expected: " + o.getOrigin());
}
if (option.isWriteable() != o.isWriteable()) {
throw new RuntimeException("Unmatched writeable: " +
option.isWriteable() + " expected: " + o.isWriteable());
}
// check if ManagementServer is not writeable
List<VMOption> options = mbean.getDiagnosticOptions();
VMOption mgmtServerOption = null;
for (VMOption o1 : options) {
if (o1.getName().equals(MANAGEMENT_SERVER)) {
mgmtServerOption = o1;
break;
}
}
if (mgmtServerOption != null) {
throw new RuntimeException(MANAGEMENT_SERVER +
" is not expected to be writeable");
}
mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
if (mgmtServerOption == null) {
throw new RuntimeException(MANAGEMENT_SERVER +
" should exist.");
}
if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
throw new RuntimeException(MANAGEMENT_SERVER +
" should have the default value.");
}
if (mgmtServerOption.isWriteable()) {
throw new RuntimeException(MANAGEMENT_SERVER +
" is not expected to be writeable");
}
}
示例9: main
import com.sun.management.VMOption; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
mbean =
ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
VMOption option = findHeapDumpOnOomOption();
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + EXPECTED_VALUE);
}
if (option.getOrigin() != Origin.VM_CREATION) {
throw new RuntimeException("Unexpected origin: " +
option.getOrigin() + " expected: VM_CREATION");
}
if (!option.isWriteable()) {
throw new RuntimeException("Expected " + HEAP_DUMP_ON_OOM +
" to be writeable");
}
// set VM option to a new value
mbean.setVMOption(HEAP_DUMP_ON_OOM, NEW_VALUE);
option = findHeapDumpOnOomOption();
if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + NEW_VALUE);
}
if (option.getOrigin() != Origin.MANAGEMENT) {
throw new RuntimeException("Unexpected origin: " +
option.getOrigin() + " expected: MANAGEMENT");
}
VMOption o = mbean.getVMOption(HEAP_DUMP_ON_OOM);
if (!option.getValue().equals(o.getValue())) {
throw new RuntimeException("Unmatched value: " +
option.getValue() + " expected: " + o.getValue());
}
if (!option.getValue().equals(o.getValue())) {
throw new RuntimeException("Unmatched value: " +
option.getValue() + " expected: " + o.getValue());
}
if (option.getOrigin() != o.getOrigin()) {
throw new RuntimeException("Unmatched origin: " +
option.getOrigin() + " expected: " + o.getOrigin());
}
if (option.isWriteable() != o.isWriteable()) {
throw new RuntimeException("Unmatched writeable: " +
option.isWriteable() + " expected: " + o.isWriteable());
}
// check if ManagementServer is not writeable
List<VMOption> options = mbean.getDiagnosticOptions();
VMOption mgmtServerOption = null;
for (VMOption o1 : options) {
if (o1.getName().equals(MANAGEMENT_SERVER)) {
mgmtServerOption = o1;
break;
}
}
if (mgmtServerOption != null) {
throw new RuntimeException(MANAGEMENT_SERVER +
" is not expected to be writeable");
}
mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
if (mgmtServerOption == null) {
throw new RuntimeException(MANAGEMENT_SERVER +
" should exist.");
}
if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
throw new RuntimeException(MANAGEMENT_SERVER +
" should have the default value.");
}
if (mgmtServerOption.isWriteable()) {
throw new RuntimeException(MANAGEMENT_SERVER +
" is not expected to be writeable");
}
}