Java Code Examples for javax.management.openmbean.TabularData#keySet()

The following examples show how to use javax.management.openmbean.TabularData#keySet() . 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: JobSchedulerJmxManagementTests.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testRemvoeJob() throws Exception {
   JobSchedulerViewMBean view = getJobSchedulerMBean();
   assertNotNull(view);
   assertTrue(view.getAllJobs().isEmpty());
   scheduleMessage(60000, -1, -1);
   assertFalse(view.getAllJobs().isEmpty());
   TabularData jobs = view.getAllJobs();
   assertEquals(1, jobs.size());
   for (Object key : jobs.keySet()) {
      String jobId = ((List<?>) key).get(0).toString();
      LOG.info("Attempting to remove Job: {}", jobId);
      view.removeJob(jobId);
   }
   assertTrue(view.getAllJobs().isEmpty());
}
 
Example 2
Source File: JobSchedulerJmxManagementTests.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetExecutionCount() throws Exception {
   final JobSchedulerViewMBean view = getJobSchedulerMBean();
   assertNotNull(view);
   assertTrue(view.getAllJobs().isEmpty());
   scheduleMessage(10000, 1000, 10);
   assertFalse(view.getAllJobs().isEmpty());
   TabularData jobs = view.getAllJobs();
   assertEquals(1, jobs.size());
   String jobId = null;
   for (Object key : jobs.keySet()) {
      jobId = ((List<?>) key).get(0).toString();
   }

   final String fixedJobId = jobId;
   LOG.info("Attempting to get execution count for Job: {}", jobId);
   assertEquals(0, view.getExecutionCount(jobId));

   assertTrue("Should execute again", Wait.waitFor(new Wait.Condition() {

      @Override
      public boolean isSatisified() throws Exception {
         return view.getExecutionCount(fixedJobId) > 0;
      }
   }));
}
 
Example 3
Source File: NodeTool.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(NodeProbe probe)
{
    System.out.println("Compaction History: ");

    TabularData tabularData = probe.getCompactionHistory();
    if (tabularData.isEmpty())
    {
        System.out.printf("There is no compaction history");
        return;
    }

    String format = "%-41s%-19s%-29s%-26s%-15s%-15s%s%n";
    List<String> indexNames = tabularData.getTabularType().getIndexNames();
    System.out.printf(format, toArray(indexNames, Object.class));

    Set<?> values = tabularData.keySet();
    for (Object eachValue : values)
    {
        List<?> value = (List<?>) eachValue;
        System.out.printf(format, toArray(value, Object.class));
    }
}
 
Example 4
Source File: MBeans.java    From boon with Apache License 2.0 6 votes vote down vote up
private static Object convertFromTabularDataToMap( Object value ) {
    final TabularData data = ( TabularData ) value;

    final Set<List<?>> keys = ( Set<List<?>> ) data.keySet();

    final Map<String, Object> map = new HashMap<>();
    for ( final List<?> key : keys ) {
        final Object subValue = convertValue( data.get( key.toArray() ) );

        if ( key.size() == 1 ) {
            map.put( convertValue( key.get( 0 ) ).toString(), subValue );
        } else {
            map.put( convertValue( key ).toString(), subValue );
        }
    }

    value = map;
    return value;
}
 
Example 5
Source File: RecordingInfo.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private RecordingInfo(CompositeData cd) {
    id = (int) cd.get("id");
    name = (String) cd.get("name");
    state = (String) cd.get("state");
    dumpOnExit = (boolean) cd.get("dumpOnExit");
    size = (long) cd.get("size");
    disk = (boolean) cd.get("disk");
    maxAge = (Long) cd.get("maxAge");
    maxSize = (Long) cd.get("maxSize");
    startTime = (Long) cd.get("startTime");
    stopTime = (Long) cd.get("stopTime");
    destination = (String) cd.get("destination");
    durationInSeconds = (long) cd.get("duration");
    settings = new LinkedHashMap<>();
    Object map = cd.get("settings");
    if (map instanceof TabularData) {
        TabularData td = (TabularData) map;
        List<String> keyNames = td.getTabularType().getIndexNames();
        int size = keyNames.size();
        for (Object keys : td.keySet()) {
            Object[] keyValues = ((List<?>) keys).toArray();
            for (int i = 0; i < size; i++) {
                String key = keyNames.get(i);
                Object value = keyValues[i];
                if (value instanceof String) {
                    settings.put(key, (String) value);
                }
            }
        }
    }
}
 
Example 6
Source File: RecordingInfo.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private RecordingInfo(CompositeData cd) {
    id = (int) cd.get("id");
    name = (String) cd.get("name");
    state = (String) cd.get("state");
    dumpOnExit = (boolean) cd.get("dumpOnExit");
    size = (long) cd.get("size");
    disk = (boolean) cd.get("disk");
    maxAge = (Long) cd.get("maxAge");
    maxSize = (Long) cd.get("maxSize");
    startTime = (Long) cd.get("startTime");
    stopTime = (Long) cd.get("stopTime");
    destination = (String) cd.get("destination");
    durationInSeconds = (long) cd.get("duration");
    settings = new LinkedHashMap<>();
    Object map = cd.get("settings");
    if (map instanceof TabularData) {
        TabularData td = (TabularData) map;
        List<String> keyNames = td.getTabularType().getIndexNames();
        int size = keyNames.size();
        for (Object keys : td.keySet()) {
            Object[] keyValues = ((List<?>) keys).toArray();
            for (int i = 0; i < size; i++) {
                String key = keyNames.get(i);
                Object value = keyValues[i];
                if (value instanceof String) {
                    settings.put(key, (String) value);
                }
            }
        }
    }
}
 
Example 7
Source File: RecordingInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private RecordingInfo(CompositeData cd) {
    id = (int) cd.get("id");
    name = (String) cd.get("name");
    state = (String) cd.get("state");
    dumpOnExit = (boolean) cd.get("dumpOnExit");
    size = (long) cd.get("size");
    disk = (boolean) cd.get("disk");
    maxAge = (Long) cd.get("maxAge");
    maxSize = (Long) cd.get("maxSize");
    startTime = (Long) cd.get("startTime");
    stopTime = (Long) cd.get("stopTime");
    destination = (String) cd.get("destination");
    durationInSeconds = (long) cd.get("duration");
    settings = new LinkedHashMap<>();
    Object map = cd.get("settings");
    if (map instanceof TabularData) {
        TabularData td = (TabularData) map;
        List<String> keyNames = td.getTabularType().getIndexNames();
        int size = keyNames.size();
        for (Object keys : td.keySet()) {
            Object[] keyValues = ((List<?>) keys).toArray();
            for (int i = 0; i < size; i++) {
                String key = keyNames.get(i);
                Object value = keyValues[i];
                if (value instanceof String) {
                    settings.put(key, (String) value);
                }
            }
        }
    }
}
 
Example 8
Source File: JmxValueFunctions.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
public static Map<List<?>, Map<String, Object>> tabularDataToMapOfMaps(TabularData table) {
    Map<List<?>, Map<String, Object>> result = Maps.newLinkedHashMap();
    for (Object k : table.keySet()) {
        final Object[] kValues = ((List<?>)k).toArray();
        CompositeData v = table.get(kValues);
        result.put((List<?>)k, compositeDataToMap(v));
    }
    return result;
}
 
Example 9
Source File: LiveJvmServiceImpl.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private static MBeanDump.MBeanValue getTabularDataValue(TabularData tabularData) {
    // linked hash map used to preserve row ordering
    List<MBeanDump.MBeanValueMapEntry> outerEntries = Lists.newArrayList();
    Set<String> attributeNames = tabularData.getTabularType().getRowType().keySet();
    for (Object key : tabularData.keySet()) {
        // TabularData.keySet() returns "Set<List<?>> but is declared Set<?> for
        // compatibility reasons" (see javadocs) so safe to cast to List<?>
        List<?> keyList = (List<?>) key;
        @SuppressWarnings("argument.type.incompatible")
        String keyString = Joiner.on(", ").join(keyList);
        @SuppressWarnings("argument.type.incompatible")
        CompositeData compositeData = tabularData.get(keyList.toArray());
        // linked hash map used to preserve attribute ordering
        List<MBeanDump.MBeanValueMapEntry> innerEntries = Lists.newArrayList();
        for (String attributeName : attributeNames) {
            innerEntries.add(MBeanDump.MBeanValueMapEntry.newBuilder()
                    .setKey(attributeName)
                    .setValue(getMBeanAttributeValue(compositeData.get(attributeName)))
                    .build());
        }
        outerEntries.add(MBeanDump.MBeanValueMapEntry.newBuilder()
                .setKey(keyString)
                .setValue(MBeanDump.MBeanValue.newBuilder()
                        .setMap(MBeanDump.MBeanValueMap.newBuilder()
                                .addAllEntry(innerEntries))
                        .build())
                .build());
    }
    return MBeanDump.MBeanValue.newBuilder()
            .setMap(MBeanDump.MBeanValueMap.newBuilder()
                    .addAllEntry(outerEntries))
            .build();
}