use of javax.management.openmbean.OpenDataException in project jackrabbit-oak by apache.
the class AbstractCheckpointMBean method listCheckpoints.
@Override
public TabularData listCheckpoints() {
try {
TabularDataSupport tab = new TabularDataSupport(new TabularType(getTypeName(), "Checkpoints", createCompositeType(), new String[] { "id" }));
collectCheckpoints(tab);
return tab;
} catch (OpenDataException e) {
throw new IllegalStateException(e);
}
}
use of javax.management.openmbean.OpenDataException in project jackrabbit-oak by apache.
the class ConsolidatedCacheStats method getCacheStats.
@Override
public TabularData getCacheStats() {
TabularDataSupport tds;
try {
TabularType tt = new TabularType(CacheStatsData.class.getName(), "Consolidated Cache Stats", CacheStatsData.TYPE, new String[] { "name" });
tds = new TabularDataSupport(tt);
for (CacheStatsMBean stats : cacheStats.getServices()) {
tds.put(new CacheStatsData(stats).toCompositeData());
}
for (CacheStatsMBean stats : persistentCacheStats.getServices()) {
tds.put(new CacheStatsData(stats).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 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 jdk8u_jdk by JetBrains.
the class MXBeanRefTest method main.
public static void main(String[] args) throws Exception {
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
ObjectName productName = new ObjectName("d:type=Product,n=1");
ObjectName product2Name = new ObjectName("d:type=Product,n=2");
ObjectName moduleName = new ObjectName("d:type=Module");
mbs.registerMBean(product, productName);
mbs.registerMBean(product2, product2Name);
mbs.registerMBean(module, moduleName);
ModuleMXBean moduleProxy = JMX.newMXBeanProxy(mbs, moduleName, ModuleMXBean.class);
ObjectName on;
on = (ObjectName) mbs.getAttribute(moduleName, "Product");
check("ObjectName attribute value", on.equals(productName));
ProductMXBean productProxy = moduleProxy.getProduct();
MBeanServerInvocationHandler mbsih = (MBeanServerInvocationHandler) Proxy.getInvocationHandler(productProxy);
check("ObjectName in proxy", mbsih.getObjectName().equals(productName));
mbs.setAttribute(moduleName, new Attribute("Product", product2Name));
ProductMXBean product2Proxy = module.getProduct();
mbsih = (MBeanServerInvocationHandler) Proxy.getInvocationHandler(product2Proxy);
check("Proxy after setAttribute", mbsih.getObjectName().equals(product2Name));
moduleProxy.setProduct(productProxy);
ProductMXBean productProxyAgain = module.getProduct();
mbsih = (MBeanServerInvocationHandler) Proxy.getInvocationHandler(productProxyAgain);
check("Proxy after proxied set", mbsih.getObjectName().equals(productName));
MBeanServer mbs2 = MBeanServerFactory.createMBeanServer();
ProductMXBean productProxy2 = JMX.newMXBeanProxy(mbs2, productName, ProductMXBean.class);
try {
moduleProxy.setProduct(productProxy2);
check("Proxy for wrong MBeanServer worked but shouldn't", false);
} catch (Exception e) {
if (e instanceof UndeclaredThrowableException && e.getCause() instanceof OpenDataException)
check("Proxy for wrong MBeanServer correctly rejected", true);
else {
e.printStackTrace(System.out);
check("Proxy for wrong MBeanServer got wrong exception", false);
}
}
// Test 6283873
ObjectName dup = new ObjectName("a:b=c");
mbs.registerMBean(new MBeanServerDelegate(), dup);
try {
mbs.registerMBean(new ProductImpl(), dup);
check("Duplicate register succeeded but should fail", false);
} catch (InstanceAlreadyExistsException e) {
check("Got correct exception from duplicate name", true);
} catch (Exception e) {
e.printStackTrace(System.out);
check("Got wrong exception from duplicate name", false);
}
if (failure != null)
throw new Exception("TEST FAILED: " + failure);
System.out.println("TEST PASSED");
}
Aggregations