Пример #1
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);
  }
Пример #2
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");
   }
 }