Example #1
0
  private static void checkEnum() throws Exception {
    String type = (String) server.getAttribute(heapPool, "Type");
    if (!type.equals("HEAP")) {
      throw new RuntimeException("TEST FAILED: " + " incorrect memory type for " + heapPool);
    }

    type = (String) server.getAttribute(nonHeapPool, "Type");
    if (!type.equals("NON_HEAP")) {
      throw new RuntimeException("TEST FAILED: " + " incorrect memory type for " + nonHeapPool);
    }
  }
Example #2
0
  private static void checkThreadInfo() throws Exception {
    // assume all threads stay alive
    long[] ids = (long[]) server.getAttribute(thread, "AllThreadIds");
    Object result = server.invoke(thread, "getThreadInfo", new Object[] {ids}, new String[] {"[J"});
    for (CompositeData cd : (CompositeData[]) result) {
      printThreadInfo(cd);
    }

    result =
        server.invoke(
            thread,
            "getThreadInfo",
            new Object[] {ids, new Integer(2)},
            new String[] {"[J", "int"});
    for (CompositeData cd : (CompositeData[]) result) {
      printThreadInfo(cd);
    }

    long id = Thread.currentThread().getId();
    result =
        server.invoke(thread, "getThreadInfo", new Object[] {new Long(id)}, new String[] {"long"});
    printThreadInfo((CompositeData) result);

    result =
        server.invoke(
            thread,
            "getThreadInfo",
            new Object[] {new Long(id), new Integer(2)},
            new String[] {"long", "int"});
    printThreadInfo((CompositeData) result);
  }
Example #3
0
 private static void checkMemoryUsage() throws Exception {
   // sanity check to have non-zero usage
   Object u1 = server.getAttribute(memory, "HeapMemoryUsage");
   Object u2 = server.getAttribute(memory, "NonHeapMemoryUsage");
   Object u3 = server.getAttribute(heapPool, "Usage");
   Object u4 = server.getAttribute(nonHeapPool, "Usage");
   if (getCommitted(u1) <= 0
       || getCommitted(u2) <= 0
       || getCommitted(u3) <= 0
       || getCommitted(u4) <= 0) {
     throw new RuntimeException("TEST FAILED: " + " expected non-zero committed usage");
   }
   server.invoke(memory, "gc", new Object[0], new String[0]);
   Object u5 = server.getAttribute(heapPool, "CollectionUsage");
   if (getCommitted(u5) <= 0) {
     throw new RuntimeException("TEST FAILED: " + " expected non-zero committed collected usage");
   }
 }
Example #4
0
 private static void checkSunGC() throws Exception {
   // Test com.sun.management proxy
   List<GarbageCollectorMXBean> gcs = getGarbageCollectorMXBeans();
   for (GarbageCollectorMXBean gc : gcs) {
     ObjectName sunGc =
         new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=" + gc.getName());
     CompositeData cd = (CompositeData) server.getAttribute(sunGc, "LastGcInfo");
     if (cd != null) {
       System.out.println("GC statistic for : " + gc.getName());
       printGcInfo(cd);
     }
   }
 }
Example #5
0
 private static void checkList() throws Exception {
   String[] args = (String[]) server.getAttribute(runtime, "InputArguments");
   if (args.length < 1) {
     throw new RuntimeException("TEST FAILED: " + " empty input arguments");
   }
   // check if -verbose:gc exists
   boolean found = false;
   for (String option : args) {
     if (option.equals(OPTION)) {
       found = true;
       break;
     }
   }
   if (!found) {
     throw new RuntimeException("TEST FAILED: " + "VM option " + OPTION + " not found");
   }
 }
Example #6
0
  private static void checkMap() throws Exception {
    // Add new system properties
    System.setProperty(KEY1, VALUE1);
    System.setProperty(KEY2, VALUE2);

    TabularData props1 = (TabularData) server.getAttribute(runtime, "SystemProperties");

    String value1 = getProperty(props1, KEY1);
    if (value1 == null || !value1.equals(VALUE1)) {
      throw new RuntimeException(
          "TEST FAILED: "
              + KEY1
              + " property found"
              + " with value = "
              + value1
              + " but expected to be "
              + VALUE1);
    }

    String value2 = getProperty(props1, KEY2);
    if (value2 == null || !value2.equals(VALUE2)) {
      throw new RuntimeException(
          "TEST FAILED: "
              + KEY2
              + " property found"
              + " with value = "
              + value2
              + " but expected to be "
              + VALUE2);
    }

    String value3 = getProperty(props1, KEY3);
    if (value3 != null) {
      throw new RuntimeException(
          "TEST FAILED: " + KEY3 + " property found" + " but should not exist");
    }
  }
Example #7
0
 private static void checkOS() throws Exception {
   Integer cpus = (Integer) server.getAttribute(os, "AvailableProcessors");
   System.out.println("# CPUs = " + cpus);
   Long vmem = (Long) server.getAttribute(os, "CommittedVirtualMemorySize");
   System.out.println("Committed virtual memory = " + vmem);
 }