use of javax.management.openmbean.TabularDataSupport in project sling by apache.
the class HealthCheckMBean method logData.
private TabularData logData(final Result er) throws OpenDataException {
final TabularDataSupport result = new TabularDataSupport(LOG_TABLE_TYPE);
int i = 1;
for (final ResultLog.Entry e : er) {
final Map<String, Object> data = new HashMap<String, Object>();
data.put(INDEX_COLUMN, i++);
data.put(LEVEL_COLUMN, e.getStatus().toString());
data.put(MESSAGE_COLUMN, e.getMessage());
result.put(new CompositeDataSupport(LOG_ROW_TYPE, data));
}
return result;
}
use of javax.management.openmbean.TabularDataSupport in project cassandra by apache.
the class StorageService method getSnapshotDetails.
public Map<String, TabularData> getSnapshotDetails() {
Map<String, TabularData> snapshotMap = new HashMap<>();
for (Keyspace keyspace : Keyspace.all()) {
if (SchemaConstants.isSystemKeyspace(keyspace.getName()))
continue;
for (ColumnFamilyStore cfStore : keyspace.getColumnFamilyStores()) {
for (Map.Entry<String, Pair<Long, Long>> snapshotDetail : cfStore.getSnapshotDetails().entrySet()) {
TabularDataSupport data = (TabularDataSupport) snapshotMap.get(snapshotDetail.getKey());
if (data == null) {
data = new TabularDataSupport(SnapshotDetailsTabularData.TABULAR_TYPE);
snapshotMap.put(snapshotDetail.getKey(), data);
}
SnapshotDetailsTabularData.from(snapshotDetail.getKey(), keyspace.getName(), cfStore.getTableName(), snapshotDetail, data);
}
}
}
return snapshotMap;
}
use of javax.management.openmbean.TabularDataSupport in project jmxtrans by jmxtrans.
the class JmxResultProcessor method getResult.
/**
* Used when the object is effectively a java type
*/
private void getResult(Builder<Result> accumulator, Attribute attribute) {
Object value = attribute.getValue();
if (value == null) {
return;
}
if (value instanceof CompositeData) {
getResult(accumulator, attribute.getName(), (CompositeData) value);
} else if (value instanceof CompositeData[]) {
for (CompositeData cd : (CompositeData[]) value) {
getResult(accumulator, attribute.getName(), cd);
}
} else if (value instanceof ObjectName[]) {
Map<String, Object> values = newHashMap();
for (ObjectName obj : (ObjectName[]) value) {
values.put(obj.getCanonicalName(), obj.getKeyPropertyListString());
}
Result r = getNewResultObject(attribute.getName(), values);
accumulator.add(r);
} else if (value.getClass().isArray()) {
// OMFG: this is nutty. some of the items in the array can be
// primitive! great interview question!
Map<String, Object> values = newHashMap();
for (int i = 0; i < Array.getLength(value); i++) {
Object val = Array.get(value, i);
values.put(attribute.getName() + "." + i, val);
}
accumulator.add(getNewResultObject(attribute.getName(), values));
} else if (value instanceof TabularDataSupport) {
TabularDataSupport tds = (TabularDataSupport) value;
Map<String, Object> values = Collections.emptyMap();
Result r = getNewResultObject(attribute.getName(), values);
processTabularDataSupport(accumulator, attribute.getName(), tds);
accumulator.add(r);
} else if (value instanceof Map) {
Result r = getNewResultObject(attribute.getName(), convertKeysToString((Map<Object, Object>) value));
accumulator.add(r);
} else {
Map<String, Object> values = newHashMap();
values.put(attribute.getName(), value);
Result r = getNewResultObject(attribute.getName(), values);
accumulator.add(r);
}
}
use of javax.management.openmbean.TabularDataSupport in project camel by apache.
the class ManagedAsyncProcessorAwaitManager method browse.
@Override
public TabularData browse() {
try {
TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listAwaitThreadsTabularType());
Collection<AsyncProcessorAwaitManager.AwaitThread> threads = manager.browse();
for (AsyncProcessorAwaitManager.AwaitThread entry : threads) {
CompositeType ct = CamelOpenMBeanTypes.listAwaitThreadsCompositeType();
String id = "" + entry.getBlockedThread().getId();
String name = entry.getBlockedThread().getName();
String exchangeId = entry.getExchange().getExchangeId();
String routeId = entry.getRouteId();
String nodeId = entry.getNodeId();
String duration = "" + entry.getWaitDuration();
CompositeData data = new CompositeDataSupport(ct, new String[] { "id", "name", "exchangeId", "routeId", "nodeId", "duration" }, new Object[] { id, name, exchangeId, routeId, nodeId, duration });
answer.put(data);
}
return answer;
} catch (Exception e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
}
use of javax.management.openmbean.TabularDataSupport in project camel by apache.
the class ManagedCamelContext method listEips.
public TabularData listEips() throws Exception {
try {
// find all EIPs
Map<String, Properties> eips = context.findEips();
TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listEipsTabularType());
// gather EIP detail for each eip
for (Map.Entry<String, Properties> entry : eips.entrySet()) {
String name = entry.getKey();
String title = (String) entry.getValue().get("title");
String description = (String) entry.getValue().get("description");
String label = (String) entry.getValue().get("label");
String type = (String) entry.getValue().get("class");
String status = CamelContextHelper.isEipInUse(context, name) ? "in use" : "on classpath";
CompositeType ct = CamelOpenMBeanTypes.listEipsCompositeType();
CompositeData data = new CompositeDataSupport(ct, new String[] { "name", "title", "description", "label", "status", "type" }, new Object[] { name, title, description, label, status, type });
answer.put(data);
}
return answer;
} catch (Exception e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
}
Aggregations