Java Code Examples for java.lang.management.MemoryNotificationInfo.getUsage()

The following are Jave code examples for showing how to use getUsage() of the java.lang.management.MemoryNotificationInfo class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: cn1   File: MemoryNotificationInfoTest.java   View Source Code Vote up 6 votes
public void test_from() {
    final MemoryUsage memoryUsage = new MemoryUsage(1, 2, 3, 4);
    final MemoryNotificationInfo memoryNotifyInfo = new MemoryNotificationInfo("Lloyd", memoryUsage, 42);
    
    CompositeData compositeData = ManagementUtils
            .toMemoryNotificationInfoCompositeData(memoryNotifyInfo);
    MemoryNotificationInfo fromInfo = MemoryNotificationInfo
            .from(compositeData);
    assertEquals(memoryNotifyInfo.getPoolName(), fromInfo.getPoolName());
    assertEquals(memoryNotifyInfo.getCount(), fromInfo.getCount());

    MemoryUsage fromUsage = fromInfo.getUsage();
    assertEquals(memoryUsage.getInit(), fromUsage.getInit());
    assertEquals(memoryUsage.getMax(), fromUsage.getMax());
    assertEquals(memoryUsage.getUsed(), fromUsage.getUsed());
    assertEquals(memoryUsage.getCommitted(), fromUsage.getCommitted());
}
 
Example 2
Project: cn1   File: MemoryNotificationInfoTest.java   View Source Code Vote up 6 votes
public void test_from_scenario4() throws Exception { // add
    String[] names = { "poolName", "usage", "count" };
    Object[] values = { "TestPoolName", memoryCompositeData, new Long(-42) };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    MemoryNotificationInfo info = MemoryNotificationInfo.from(data);
    assertEquals(values[0], info.getPoolName());
    assertEquals(values[2], info.getCount());
    MemoryUsage usage = info.getUsage();
    assertEquals(1, usage.getInit());
    assertEquals(2, usage.getUsed());
    assertEquals(3, usage.getCommitted());
    assertEquals(4, usage.getMax());
}
 
Example 3
Project: cn1   File: MemoryNotificationInfoTest.java   View Source Code Vote up 6 votes
public void test_from_scenario12() throws Exception {
    String[] names = { "poolName", "usage", "count", "extention" };
    Object[] values = { "TestPoolName", memoryCompositeData, new Long(42),
            null };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG, SimpleType.LONG };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    MemoryNotificationInfo info = MemoryNotificationInfo.from(data);
    assertEquals(values[0], info.getPoolName());
    assertEquals(values[2], info.getCount());
    MemoryUsage usage = info.getUsage();
    assertEquals(1, usage.getInit());
    assertEquals(2, usage.getUsed());
    assertEquals(3, usage.getCommitted());
    assertEquals(4, usage.getMax());
}
 
Example 4
Project: cn1   File: MemoryNotificationInfoTest.java   View Source Code Vote up 6 votes
public void test_from_scenario13() throws Exception {
    String[] names = { "poolName", "usage", "count", "extention" };
    Object[] values = { "TestPoolName", memoryCompositeData, new Long(42),
            "Extention" };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG, SimpleType.STRING };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    MemoryNotificationInfo info = MemoryNotificationInfo.from(data);
    assertEquals(values[0], info.getPoolName());
    assertEquals(values[2], info.getCount());
    MemoryUsage usage = info.getUsage();
    assertEquals(1, usage.getInit());
    assertEquals(2, usage.getUsed());
    assertEquals(3, usage.getCommitted());
    assertEquals(4, usage.getMax());
}
 
Example 5
Project: freeVM   File: MemoryNotificationInfoTest.java   View Source Code Vote up 6 votes
public void test_from() {
    final MemoryUsage memoryUsage = new MemoryUsage(1, 2, 3, 4);
    final MemoryNotificationInfo memoryNotifyInfo = new MemoryNotificationInfo("Lloyd", memoryUsage, 42);
    
    CompositeData compositeData = ManagementUtils
            .toMemoryNotificationInfoCompositeData(memoryNotifyInfo);
    MemoryNotificationInfo fromInfo = MemoryNotificationInfo
            .from(compositeData);
    assertEquals(memoryNotifyInfo.getPoolName(), fromInfo.getPoolName());
    assertEquals(memoryNotifyInfo.getCount(), fromInfo.getCount());

    MemoryUsage fromUsage = fromInfo.getUsage();
    assertEquals(memoryUsage.getInit(), fromUsage.getInit());
    assertEquals(memoryUsage.getMax(), fromUsage.getMax());
    assertEquals(memoryUsage.getUsed(), fromUsage.getUsed());
    assertEquals(memoryUsage.getCommitted(), fromUsage.getCommitted());
}
 
Example 6
Project: freeVM   File: MemoryNotificationInfoTest.java   View Source Code Vote up 6 votes
public void test_from_scenario4() throws Exception { // add
    String[] names = { "poolName", "usage", "count" };
    Object[] values = { "TestPoolName", memoryCompositeData, new Long(-42) };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    MemoryNotificationInfo info = MemoryNotificationInfo.from(data);
    assertEquals(values[0], info.getPoolName());
    assertEquals(values[2], info.getCount());
    MemoryUsage usage = info.getUsage();
    assertEquals(1, usage.getInit());
    assertEquals(2, usage.getUsed());
    assertEquals(3, usage.getCommitted());
    assertEquals(4, usage.getMax());
}
 
Example 7
Project: freeVM   File: MemoryNotificationInfoTest.java   View Source Code Vote up 6 votes
public void test_from_scenario12() throws Exception {
    String[] names = { "poolName", "usage", "count", "extention" };
    Object[] values = { "TestPoolName", memoryCompositeData, new Long(42),
            null };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG, SimpleType.LONG };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    MemoryNotificationInfo info = MemoryNotificationInfo.from(data);
    assertEquals(values[0], info.getPoolName());
    assertEquals(values[2], info.getCount());
    MemoryUsage usage = info.getUsage();
    assertEquals(1, usage.getInit());
    assertEquals(2, usage.getUsed());
    assertEquals(3, usage.getCommitted());
    assertEquals(4, usage.getMax());
}
 
Example 8
Project: freeVM   File: MemoryNotificationInfoTest.java   View Source Code Vote up 6 votes
public void test_from_scenario13() throws Exception {
    String[] names = { "poolName", "usage", "count", "extention" };
    Object[] values = { "TestPoolName", memoryCompositeData, new Long(42),
            "Extention" };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG, SimpleType.STRING };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    MemoryNotificationInfo info = MemoryNotificationInfo.from(data);
    assertEquals(values[0], info.getPoolName());
    assertEquals(values[2], info.getCount());
    MemoryUsage usage = info.getUsage();
    assertEquals(1, usage.getInit());
    assertEquals(2, usage.getUsed());
    assertEquals(3, usage.getCommitted());
    assertEquals(4, usage.getMax());
}