Search in sources :

Example 46 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 47 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 48 with OpenDataException

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);
    }
}
Also used : Instance(org.apache.karaf.instance.core.Instance) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 49 with OpenDataException

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);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) PackageVersion(org.apache.karaf.packages.core.PackageVersion) TabularData(javax.management.openmbean.TabularData) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 50 with OpenDataException

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

Aggregations

OpenDataException (javax.management.openmbean.OpenDataException)51 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)24 TabularDataSupport (javax.management.openmbean.TabularDataSupport)22 TabularType (javax.management.openmbean.TabularType)22 CompositeType (javax.management.openmbean.CompositeType)21 CompositeData (javax.management.openmbean.CompositeData)17 OpenType (javax.management.openmbean.OpenType)15 ObjectName (javax.management.ObjectName)8 HashMap (java.util.HashMap)6 Map (java.util.Map)5 MBeanServer (javax.management.MBeanServer)5 TabularData (javax.management.openmbean.TabularData)5 ArrayType (javax.management.openmbean.ArrayType)4 InvalidObjectException (java.io.InvalidObjectException)3 SortedMap (java.util.SortedMap)3 JMException (javax.management.JMException)3 StandardMBean (javax.management.StandardMBean)3 IOException (java.io.IOException)2 GenericArrayType (java.lang.reflect.GenericArrayType)2 Method (java.lang.reflect.Method)2