Java Code Examples for sun.management.ManagementFactoryHelper#getDiagnosticMXBean()

The following examples show how to use sun.management.ManagementFactoryHelper#getDiagnosticMXBean() . 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: CompilerWhiteBoxTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 2
Source File: TestSummarizeRSetStatsTools.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static boolean testingG1GC() {
    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 false;
    }
    return true;
}
 
Example 3
Source File: CompilerWhiteBoxTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 4
Source File: TestG1HeapRegionSize.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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());
  }
}
 
Example 5
Source File: Utils.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
public static String getVMOption(String name) {
    String result;
    HotSpotDiagnosticMXBean diagnostic
            = ManagementFactoryHelper.getDiagnosticMXBean();
    result = diagnostic.getVMOption(name).getValue();
    return result;
}
 
Example 6
Source File: Utils.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
public static String getVMOption(String name) {
    String result;
    HotSpotDiagnosticMXBean diagnostic
            = ManagementFactoryHelper.getDiagnosticMXBean();
    result = diagnostic.getVMOption(name).getValue();
    return result;
}
 
Example 7
Source File: TestG1HeapRegionSize.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
  HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();

  String expectedValue = getExpectedValue(args);
  VMOption option = diagnostic.getVMOption("UseG1GC");
  if (option.getValue().equals("false")) {
    System.out.println("Skipping this test. It is only a G1 test.");
    return;
  }

  option = diagnostic.getVMOption("G1HeapRegionSize");
  if (!expectedValue.equals(option.getValue())) {
    throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
  }
}
 
Example 8
Source File: TestGreyReclaimedHumongousObjects.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();

    System.out.println("Max memory= " + MAX_MEMORY + " bytes");

    int obj_size = 0;
    long seconds_to_run = 0;
    if (args.length != 2) {
        throw new RuntimeException("Object size argument must be supplied");
    } else {
        obj_size = Integer.parseInt(args[0]);
        seconds_to_run = Integer.parseInt(args[1]);
    }
    System.out.println("Objects size= " + obj_size + " bytes");
    System.out.println("Seconds to run=" + seconds_to_run);

    int region_size =
        Integer.parseInt(diagnostic.getVMOption("G1HeapRegionSize").getValue());
    if (obj_size < (region_size / 2)) {
        throw new RuntimeException("Object size " + obj_size +
                                   " is not humongous with region size " + region_size);
    }

    ExecutorService executor =
        Executors.newFixedThreadPool(THREAD_COUNT, new NamedThreadFactory());
    System.out.println("Starting " + THREAD_COUNT + " threads");

    for (int i = 0; i < THREAD_COUNT; i++) {
        executor.execute(new Runner(obj_size));
    }

    Thread.sleep(seconds_to_run * 1000);
    executor.shutdownNow();

    if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
        System.err.println("Thread pool did not terminate after 10 seconds after shutdown");
    }
}
 
Example 9
Source File: TestSummarizeRSetStatsTools.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean testingG1GC() {
    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 false;
    }
    return true;
}
 
Example 10
Source File: TestGreyReclaimedHumongousObjects.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();

    System.out.println("Max memory= " + MAX_MEMORY + " bytes");

    int obj_size = 0;
    long seconds_to_run = 0;
    if (args.length != 2) {
        throw new RuntimeException("Object size argument must be supplied");
    } else {
        obj_size = Integer.parseInt(args[0]);
        seconds_to_run = Integer.parseInt(args[1]);
    }
    System.out.println("Objects size= " + obj_size + " bytes");
    System.out.println("Seconds to run=" + seconds_to_run);

    int region_size =
        Integer.parseInt(diagnostic.getVMOption("G1HeapRegionSize").getValue());
    if (obj_size < (region_size / 2)) {
        throw new RuntimeException("Object size " + obj_size +
                                   " is not humongous with region size " + region_size);
    }

    ExecutorService executor =
        Executors.newFixedThreadPool(THREAD_COUNT, new NamedThreadFactory());
    System.out.println("Starting " + THREAD_COUNT + " threads");

    for (int i = 0; i < THREAD_COUNT; i++) {
        executor.execute(new Runner(obj_size));
    }

    Thread.sleep(seconds_to_run * 1000);
    executor.shutdownNow();

    if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
        System.err.println("Thread pool did not terminate after 10 seconds after shutdown");
    }
}
 
Example 11
Source File: CompilerWhiteBoxTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 12
Source File: TestG1HeapRegionSize.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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());
  }
}
 
Example 13
Source File: CompilerWhiteBoxTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 14
Source File: TestGreyReclaimedHumongousObjects.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();

    System.out.println("Max memory= " + MAX_MEMORY + " bytes");

    int obj_size = 0;
    long seconds_to_run = 0;
    if (args.length != 2) {
        throw new RuntimeException("Object size argument must be supplied");
    } else {
        obj_size = Integer.parseInt(args[0]);
        seconds_to_run = Integer.parseInt(args[1]);
    }
    System.out.println("Objects size= " + obj_size + " bytes");
    System.out.println("Seconds to run=" + seconds_to_run);

    int region_size =
        Integer.parseInt(diagnostic.getVMOption("G1HeapRegionSize").getValue());
    if (obj_size < (region_size / 2)) {
        throw new RuntimeException("Object size " + obj_size +
                                   " is not humongous with region size " + region_size);
    }

    ExecutorService executor =
        Executors.newFixedThreadPool(THREAD_COUNT, new NamedThreadFactory());
    System.out.println("Starting " + THREAD_COUNT + " threads");

    for (int i = 0; i < THREAD_COUNT; i++) {
        executor.execute(new Runner(obj_size));
    }

    Thread.sleep(seconds_to_run * 1000);
    executor.shutdownNow();

    if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
        System.err.println("Thread pool did not terminate after 10 seconds after shutdown");
    }
}
 
Example 15
Source File: TestGreyReclaimedHumongousObjects.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();

    System.out.println("Max memory= " + MAX_MEMORY + " bytes");

    int obj_size = 0;
    long seconds_to_run = 0;
    if (args.length != 2) {
        throw new RuntimeException("Object size argument must be supplied");
    } else {
        obj_size = Integer.parseInt(args[0]);
        seconds_to_run = Integer.parseInt(args[1]);
    }
    System.out.println("Objects size= " + obj_size + " bytes");
    System.out.println("Seconds to run=" + seconds_to_run);

    int region_size =
        Integer.parseInt(diagnostic.getVMOption("G1HeapRegionSize").getValue());
    if (obj_size < (region_size / 2)) {
        throw new RuntimeException("Object size " + obj_size +
                                   " is not humongous with region size " + region_size);
    }

    ExecutorService executor =
        Executors.newFixedThreadPool(THREAD_COUNT, new NamedThreadFactory());
    System.out.println("Starting " + THREAD_COUNT + " threads");

    for (int i = 0; i < THREAD_COUNT; i++) {
        executor.execute(new Runner(obj_size));
    }

    Thread.sleep(seconds_to_run * 1000);
    executor.shutdownNow();

    if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
        System.err.println("Thread pool did not terminate after 10 seconds after shutdown");
    }
}
 
Example 16
Source File: Utils.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
public static String getVMOption(String name) {
    String result;
    HotSpotDiagnosticMXBean diagnostic
            = ManagementFactoryHelper.getDiagnosticMXBean();
    result = diagnostic.getVMOption(name).getValue();
    return result;
}
 
Example 17
Source File: TestSummarizeRSetStatsTools.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static boolean testingG1GC() {
    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 false;
    }
    return true;
}
 
Example 18
Source File: TestG1HeapRegionSize.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
  HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();

  String expectedValue = getExpectedValue(args);
  VMOption option = diagnostic.getVMOption("UseG1GC");
  if (option.getValue().equals("false")) {
    System.out.println("Skipping this test. It is only a G1 test.");
    return;
  }

  option = diagnostic.getVMOption("G1HeapRegionSize");
  if (!expectedValue.equals(option.getValue())) {
    throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
  }
}
 
Example 19
Source File: Utils.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
public static String getVMOption(String name) {
    String result;
    HotSpotDiagnosticMXBean diagnostic
            = ManagementFactoryHelper.getDiagnosticMXBean();
    result = diagnostic.getVMOption(name).getValue();
    return result;
}
 
Example 20
Source File: TestUseCompressedOopsErgoTools.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static long getCompressedClassSpaceSize() {
  HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();

  VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize");
  return Long.parseLong(option.getValue());
}