use of javax.management.openmbean.TabularData in project hibernate-orm by hibernate.
the class HibernateStatsImpl method getCacheRegionStats.
@Override
public TabularData getCacheRegionStats() {
final List<CompositeData> list = new ArrayList<CompositeData>();
final Statistics statistics = getStatistics();
for (String region : statistics.getSecondLevelCacheRegionNames()) {
final CacheRegionStats l2CacheStats = new CacheRegionStats(region, statistics.getSecondLevelCacheStatistics(region));
list.add(l2CacheStats.toCompositeData());
}
final TabularData td = CacheRegionStats.newTabularDataInstance();
td.putAll(list.toArray(new CompositeData[list.size()]));
return td;
}
use of javax.management.openmbean.TabularData in project cassandra by apache.
the class FailureDetectorInfo method execute.
@Override
public void execute(NodeProbe probe) {
TabularData data = probe.getFailureDetectorPhilValues();
System.out.printf("%10s,%16s%n", "Endpoint", "Phi");
for (Object o : data.keySet()) {
@SuppressWarnings({ "rawtypes", "unchecked" }) CompositeData datum = data.get(((List) o).toArray(new Object[((List) o).size()]));
System.out.printf("%10s,%16.8f%n", datum.get("Endpoint"), datum.get("PHI"));
}
}
use of javax.management.openmbean.TabularData in project cassandra by apache.
the class ListSnapshots method execute.
@Override
public void execute(NodeProbe probe) {
try {
System.out.println("Snapshot Details: ");
final Map<String, TabularData> snapshotDetails = probe.getSnapshotDetails();
if (snapshotDetails.isEmpty()) {
System.out.printf("There are no snapshots");
return;
}
final long trueSnapshotsSize = probe.trueSnapshotsSize();
TableBuilder table = new TableBuilder();
// display column names only once
final List<String> indexNames = snapshotDetails.entrySet().iterator().next().getValue().getTabularType().getIndexNames();
table.add(indexNames.toArray(new String[indexNames.size()]));
for (final Map.Entry<String, TabularData> snapshotDetail : snapshotDetails.entrySet()) {
Set<?> values = snapshotDetail.getValue().keySet();
for (Object eachValue : values) {
final List<?> value = (List<?>) eachValue;
table.add(value.toArray(new String[value.size()]));
}
}
table.printTo(System.out);
System.out.println("\nTotal TrueDiskSpaceUsed: " + FileUtils.stringifyFileSize(trueSnapshotsSize) + "\n");
} catch (Exception e) {
throw new RuntimeException("Error during list snapshot", e);
}
}
use of javax.management.openmbean.TabularData in project cassandra by apache.
the class CompactionHistoryHolder method convert2Map.
@Override
public Map<String, Object> convert2Map() {
HashMap<String, Object> result = new HashMap<>();
ArrayList<Map<String, Object>> compactions = new ArrayList<>();
TabularData tabularData = probe.getCompactionHistory();
this.indexNames = tabularData.getTabularType().getIndexNames();
if (tabularData.isEmpty())
return result;
List<CompactionHistoryHolder.CompactionHistoryRow> chrList = new ArrayList<>();
Set<?> values = tabularData.keySet();
for (Object eachValue : values) {
List<?> value = (List<?>) eachValue;
CompactionHistoryHolder.CompactionHistoryRow chr = new CompactionHistoryHolder.CompactionHistoryRow((String) value.get(0), (String) value.get(1), (String) value.get(2), (Long) value.get(3), (Long) value.get(4), (Long) value.get(5), (String) value.get(6));
chrList.add(chr);
}
Collections.sort(chrList);
for (CompactionHistoryHolder.CompactionHistoryRow chr : chrList) {
compactions.add(chr.getAllAsMap());
}
result.put("CompactionHistory", compactions);
return result;
}
use of javax.management.openmbean.TabularData in project twitter4j by yusuke.
the class MBeansTest method testAPIStatisticsOpenMBean.
/**
* Tests exposure of API statistics via a dynamic MBean
*/
public void testAPIStatisticsOpenMBean() throws Exception {
APIStatistics stats = new APIStatistics(5);
APIStatisticsOpenMBean openMBean = new APIStatisticsOpenMBean(stats);
// sanity check to ensure metadata accurately describes dynamic attributes
MBeanInfo info = openMBean.getMBeanInfo();
assertEquals(5, info.getAttributes().length);
assertEquals(1, info.getOperations().length);
List<String> attrNames = new ArrayList<String>();
for (MBeanAttributeInfo attr : info.getAttributes()) {
assertNotNull(openMBean.getAttribute(attr.getName()));
attrNames.add(attr.getName());
}
AttributeList attrList = openMBean.getAttributes(attrNames.toArray(new String[attrNames.size()]));
assertNotNull(attrList);
assertEquals(5, attrList.size());
// check stats (empty case)
Long callCount = (Long) openMBean.getAttribute("callCount");
assertEquals(0, callCount.longValue());
Long errorCount = (Long) openMBean.getAttribute("errorCount");
assertEquals(0, callCount.longValue());
Long totalTime = (Long) openMBean.getAttribute("totalTime");
assertEquals(0, totalTime.longValue());
Long averageTime = (Long) openMBean.getAttribute("averageTime");
assertEquals(0, averageTime.longValue());
// check table (empty case)
TabularData table = (TabularData) openMBean.getAttribute("statisticsTable");
assertTrue(table.isEmpty());
stats.methodCalled("foo", 100, true);
// check stats (populated case)
callCount = (Long) openMBean.getAttribute("callCount");
assertEquals(1, callCount.longValue());
errorCount = (Long) openMBean.getAttribute("errorCount");
assertEquals(0, errorCount.longValue());
totalTime = (Long) openMBean.getAttribute("totalTime");
assertEquals(100, totalTime.longValue());
averageTime = (Long) openMBean.getAttribute("averageTime");
assertEquals(100, averageTime.longValue());
// check table (populated case)
table = (TabularData) openMBean.getAttribute("statisticsTable");
assertFalse(table.isEmpty());
assertEquals(1, table.keySet().size());
CompositeData data = table.get(new Object[] { "foo" });
assertNotNull(data);
String[] columnNames = new String[] { "methodName", "callCount", "totalTime", "avgTime" };
Object[] columnValues = data.getAll(columnNames);
assertEquals(columnNames.length, columnValues.length);
assertEquals("foo", columnValues[0]);
assertEquals(1, ((Long) columnValues[1]).longValue());
assertEquals(100, ((Long) columnValues[2]).longValue());
assertEquals(100, ((Long) columnValues[3]).longValue());
// check reset
openMBean.invoke("reset", new Object[0], new String[0]);
checkCalculator(stats, 0, 0, 0, 0);
assertFalse(stats.getInvocationStatistics().iterator().hasNext());
}
Aggregations