Search in sources :

Example 71 with OpenDataException

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);
    }
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType)

Example 72 with OpenDataException

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;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) ConsolidatedCacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.ConsolidatedCacheStatsMBean) CacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean) PersistentCacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.PersistentCacheStatsMBean)

Example 73 with OpenDataException

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;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType)

Example 74 with OpenDataException

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;
}
Also used : TabularType(javax.management.openmbean.TabularType) FilterConfigMBean(org.apache.jackrabbit.oak.plugins.observation.filter.FilterConfigMBean) ObjectName(javax.management.ObjectName) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) EventListenerMBean(org.apache.jackrabbit.api.jmx.EventListenerMBean) Map(java.util.Map)

Example 75 with OpenDataException

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");
}
Also used : Attribute(javax.management.Attribute) OpenDataException(javax.management.openmbean.OpenDataException) MBeanServerDelegate(javax.management.MBeanServerDelegate) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanServerInvocationHandler(javax.management.MBeanServerInvocationHandler) OpenDataException(javax.management.openmbean.OpenDataException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

OpenDataException (javax.management.openmbean.OpenDataException)139 CompositeType (javax.management.openmbean.CompositeType)94 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)67 CompositeData (javax.management.openmbean.CompositeData)54 OpenType (javax.management.openmbean.OpenType)52 TabularType (javax.management.openmbean.TabularType)33 TabularDataSupport (javax.management.openmbean.TabularDataSupport)32 HashMap (java.util.HashMap)14 Map (java.util.Map)12 TabularData (javax.management.openmbean.TabularData)11 ObjectName (javax.management.ObjectName)8 ArrayType (javax.management.openmbean.ArrayType)8 Type (java.lang.reflect.Type)5 ArrayList (java.util.ArrayList)5 Method (java.lang.reflect.Method)4 Comparator (java.util.Comparator)4 MBeanServer (javax.management.MBeanServer)4 SimpleType (javax.management.openmbean.SimpleType)4 IOException (java.io.IOException)3 InvalidObjectException (java.io.InvalidObjectException)3