本文整理汇总了Java中com.sun.management.VMOption类的典型用法代码示例。如果您正苦于以下问题:Java VMOption类的具体用法?Java VMOption怎么用?Java VMOption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VMOption类属于com.sun.management包,在下文中一共展示了VMOption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: main
import com.sun.management.VMOption; //导入依赖的package包/类
public static void main(String... args) throws Exception {
MBeanServerConnection msc = ManagementFactory.getPlatformMBeanServer();
HotSpotDiagnosticMXBean mxbean =
ManagementFactory.getPlatformMXBean(msc, HotSpotDiagnosticMXBean.class);
String[] signatures = new String[] {
String.class.getName()
};
Object obj = msc.invoke(mxbean.getObjectName(), "getVMOption",
new String[] { "PrintVMOptions"}, signatures);
CompositeData data = (CompositeData)obj;
validateType(data);
VMOption option = mxbean.getVMOption("PrintVMOptions");
VMOption o = VMOption.from(data);
assertEquals(option, o);
}
示例3: 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");
}
}
示例4: main
import com.sun.management.VMOption; //导入依赖的package包/类
public static void main(String[] args) {
List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
for (BufferPoolMXBean pool:pools) {
System.out.println(String.format(
"%s %d/%d",
pool.getName(),
pool.getMemoryUsed(),
pool.getTotalCapacity()));
}
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
for (String arg:RuntimemxBean.getInputArguments()) {
System.out.println(arg);
}
HotSpotDiagnosticMXBean hsdiag = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
for (VMOption i:hsdiag.getDiagnosticOptions()) {
System.out.println(i.getName() + ":" + i.getValue());
}
System.out.println(hsdiag.getVMOption("MaxDirectMemorySize"));
System.out.println(sun.misc.VM.maxDirectMemory());
System.out.println(ByteBuffer.allocateDirect(1000000000));
System.out.println(ByteBuffer.allocateDirect(1000000000));
System.out.println(ByteBuffer.allocateDirect(1000000000));
System.out.println(getDirectMemoryUsed());
}
示例5: getDiagnosticOptions
import com.sun.management.VMOption; //导入依赖的package包/类
public List<VMOption> getDiagnosticOptions() {
List<Flag> allFlags = Flag.getAllFlags();
List<VMOption> result = new ArrayList<>();
for (Flag flag : allFlags) {
if (flag.isWriteable() && flag.isExternal()) {
result.add(flag.getVMOption());
}
}
return result;
}
示例6: getVMOption
import com.sun.management.VMOption; //导入依赖的package包/类
public VMOption getVMOption(String name) {
if (name == null) {
throw new NullPointerException("name cannot be null");
}
Flag f = Flag.getFlag(name);
if (f == null) {
throw new IllegalArgumentException("VM option \"" +
name + "\" does not exist");
}
return f.getVMOption();
}
示例7: toOpenTypeData
import com.sun.management.VMOption; //导入依赖的package包/类
Object toOpenTypeData(Object data) throws OpenDataException {
if (data instanceof MemoryUsage) {
return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
}
if (data instanceof ThreadInfo) {
return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
}
if (data instanceof LockInfo) {
if (data instanceof java.lang.management.MonitorInfo) {
return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
}
return LockInfoCompositeData.toCompositeData((LockInfo) data);
}
if (data instanceof MemoryNotificationInfo) {
return MemoryNotifInfoCompositeData.
toCompositeData((MemoryNotificationInfo) data);
}
if (data instanceof VMOption) {
return VMOptionCompositeData.toCompositeData((VMOption) data);
}
if (isCompositeData) {
// Classes that implement CompositeData
//
// construct a new CompositeDataSupport object
// so that no other classes are sent over the wire
CompositeData cd = (CompositeData) data;
CompositeType ct = cd.getCompositeType();
String[] itemNames = ct.keySet().toArray(new String[0]);
Object[] itemValues = cd.getAll(itemNames);
return new CompositeDataSupport(ct, itemNames, itemValues);
}
throw new OpenDataException(javaClass.getName() +
" is not supported for platform MXBeans");
}
示例8: 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());
}
示例9: findPrintGCDetailsOption
import com.sun.management.VMOption; //导入依赖的package包/类
public static VMOption findPrintGCDetailsOption() {
List<VMOption> options = mbean.getDiagnosticOptions();
VMOption gcDetails = null;
for (VMOption o : options) {
if (o.getName().equals(PRINT_GC_DETAILS)) {
gcDetails = o;
break;
}
}
if (gcDetails == null) {
throw new RuntimeException("VM option " + PRINT_GC_DETAILS +
" not found");
}
return gcDetails;
}
示例10: 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);
}
}
示例11: getCompressedClassSpaceSize
import com.sun.management.VMOption; //导入依赖的package包/类
private static long getCompressedClassSpaceSize() {
HotSpotDiagnosticMXBean diagnostic =
ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize");
return Long.parseLong(option.getValue());
}
示例12: getDiagnosticOptions
import com.sun.management.VMOption; //导入依赖的package包/类
@Override
public List<VMOption> getDiagnosticOptions() {
List<Flag> allFlags = Flag.getAllFlags();
List<VMOption> result = new ArrayList<>();
for (Flag flag : allFlags) {
if (flag.isWriteable() && flag.isExternal()) {
result.add(flag.getVMOption());
}
}
return result;
}
示例13: getVMOption
import com.sun.management.VMOption; //导入依赖的package包/类
@Override
public VMOption getVMOption(String name) {
if (name == null) {
throw new NullPointerException("name cannot be null");
}
Flag f = Flag.getFlag(name);
if (f == null) {
throw new IllegalArgumentException("VM option \"" +
name + "\" does not exist");
}
return f.getVMOption();
}
示例14: assertEquals
import com.sun.management.VMOption; //导入依赖的package包/类
private static void assertEquals(VMOption o1, VMOption o2) {
if (!o1.getName().equals(o2.getName()) ||
!o1.getOrigin().equals(o2.getOrigin()) ||
!o1.getValue().equals(o2.getValue()) ||
o1.isWriteable() != o2.isWriteable()) {
throw new AssertionError(o1 + " != " + o2);
}
}
示例15: findHeapDumpOnOomOption
import com.sun.management.VMOption; //导入依赖的package包/类
public static VMOption findHeapDumpOnOomOption() {
List<VMOption> options = mbean.getDiagnosticOptions();
VMOption gcDetails = null;
for (VMOption o : options) {
if (o.getName().equals(HEAP_DUMP_ON_OOM)) {
gcDetails = o;
break;
}
}
if (gcDetails == null) {
throw new RuntimeException("VM option " + HEAP_DUMP_ON_OOM +
" not found");
}
return gcDetails;
}