use of javax.management.openmbean.OpenDataException in project jackrabbit-oak by apache.
the class ConsolidatedListenerMBeanImpl method getListenerStats.
@Override
public TabularData getListenerStats() {
TabularDataSupport tds;
try {
int id = 0;
TabularType tt = new TabularType(ListenerStatsData.class.getName(), "Consolidated Listener Stats", ListenerStatsData.TYPE, new String[] { "index" });
tds = new TabularDataSupport(tt);
for (ListenerMBeans beans : getListenerMBeans()) {
tds.put(new ListenerStatsData(++id, beans).toCompositeData());
}
} catch (OpenDataException e) {
throw new IllegalStateException(e);
}
return tds;
}
use of javax.management.openmbean.OpenDataException in project jackrabbit-oak by apache.
the class ConsolidatedListenerMBeanImpl method getLeaderBoard.
@Override
public TabularData getLeaderBoard() {
TabularDataSupport tds;
try {
int id = 0;
TabularType tt = new TabularType(LeaderBoardData.class.getName(), "Leaderboard", LeaderBoardData.TYPE, new String[] { "index" });
tds = new TabularDataSupport(tt);
List<LeaderBoardData> leaderBoard = Lists.newArrayList();
for (Map.Entry<ObjectName, EventListenerMBean> e : eventListeners.entrySet()) {
String listenerId = getListenerId(e.getKey());
EventListenerMBean mbean = e.getValue();
FilterConfigMBean filterConfigMBean = null;
for (Map.Entry<ObjectName, FilterConfigMBean> ef : filterConfigs.entrySet()) {
if (Objects.equal(getListenerId(ef.getKey()), listenerId)) {
filterConfigMBean = ef.getValue();
break;
}
}
leaderBoard.add(new LeaderBoardData(++id, mbean, filterConfigMBean));
}
sort(leaderBoard);
for (LeaderBoardData data : leaderBoard) {
tds.put(data.toCompositeData());
}
} catch (OpenDataException e) {
throw new IllegalStateException(e);
}
return tds;
}
use of javax.management.openmbean.OpenDataException in project karaf by apache.
the class InstanceToTableMapper method tableFrom.
public static TabularData tableFrom(List<Instance> instances) {
try {
CompositeType rowType = createRowType();
TabularType tableType = new TabularType("Instances", "Table of all Karaf instances", rowType, new String[] { InstancesMBean.INSTANCE_NAME });
TabularDataSupport table = new TabularDataSupport(tableType);
for (Instance instance : instances) {
CompositeDataSupport row = mapInstance(instance, rowType);
table.put(row);
}
return table;
} catch (OpenDataException e) {
throw new IllegalStateException("Error building instance table", e);
}
}
use of javax.management.openmbean.OpenDataException in project karaf by apache.
the class PackagesMBeanImpl method getExports.
public TabularData getExports() {
try {
String[] names = new String[] { "Name", "Version", "ID", "Bundle Name" };
CompositeType bundleType = new CompositeType("PackageExport", "Exported packages", names, new String[] { "Package name", "Version of the Package", "ID of the Bundle", "Bundle symbolic name" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.LONG, SimpleType.STRING });
TabularType tableType = new TabularType("PackageExports", "Exported packages", bundleType, new String[] { "Name", "Version", "ID" });
TabularData table = new TabularDataSupport(tableType);
List<PackageVersion> exports = packageService.getExports();
for (PackageVersion export : exports) {
for (Bundle bundle : export.getBundles()) {
Object[] data = new Object[] { export.getPackageName(), export.getVersion().toString(), bundle.getBundleId(), bundle.getSymbolicName() };
CompositeData comp = new CompositeDataSupport(bundleType, names, data);
LOGGER.debug("Adding CompositeDataSupport {}", comp);
table.put(comp);
}
}
return table;
} catch (RuntimeException e) {
// To avoid the exception gets swallowed by jmx
LOGGER.error(e.getMessage(), e);
throw e;
} catch (OpenDataException e) {
LOGGER.error(e.getMessage(), e);
throw new RuntimeException(e.getMessage(), e);
}
}
use of javax.management.openmbean.OpenDataException in project tomee by apache.
the class LocalMBeanServer method tabularData.
public static TabularData tabularData(final String typeName, final String typeDescription, final String[] names, final Object[] values) {
if (names.length == 0) {
return null;
}
final OpenType<?>[] types = new OpenType<?>[names.length];
for (int i = 0; i < types.length; i++) {
types[i] = SimpleType.STRING;
}
try {
final CompositeType ct = new CompositeType(typeName, typeDescription, names, names, types);
final TabularType type = new TabularType(typeName, typeDescription, ct, names);
final TabularDataSupport data = new TabularDataSupport(type);
final CompositeData line = new CompositeDataSupport(ct, names, values);
data.put(line);
return data;
} catch (final OpenDataException e) {
return null;
}
}
Aggregations