Search in sources :

Example 16 with OpenDataException

use of javax.management.openmbean.OpenDataException in project jackrabbit-oak by apache.

the class LuceneIndexMBeanImpl method getBadIndexStats.

@Override
public TabularData getBadIndexStats() {
    TabularDataSupport tds;
    try {
        TabularType tt = new TabularType(LuceneIndexMBeanImpl.class.getName(), "Lucene Bad Index Stats", BadIndexStats.TYPE, new String[] { "path" });
        tds = new TabularDataSupport(tt);
        Set<String> indexes = indexTracker.getBadIndexTracker().getIndexPaths();
        for (String path : indexes) {
            BadIndexInfo info = indexTracker.getBadIndexTracker().getInfo(path);
            if (info != null) {
                BadIndexStats stats = new BadIndexStats(info);
                tds.put(stats.toCompositeData());
            }
        }
    } catch (OpenDataException e) {
        throw new IllegalStateException(e);
    }
    return tds;
}
Also used : BadIndexInfo(org.apache.jackrabbit.oak.plugins.index.lucene.BadIndexTracker.BadIndexInfo) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType)

Example 17 with OpenDataException

use of javax.management.openmbean.OpenDataException in project karaf by apache.

the class PackagesMBeanImpl method getImports.

@Override
public TabularData getImports() {
    try {
        String[] names = new String[] { "PackageName", "Filter", "Optional", "ID", "Bundle Name", "Resolvable" };
        CompositeType bundleType = new CompositeType("PackageImports", "Imported packages", names, names, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.LONG, SimpleType.STRING, SimpleType.BOOLEAN });
        TabularType tableType = new TabularType("PackageImports", "Imported packages", bundleType, new String[] { "Filter", "ID" });
        TabularData table = new TabularDataSupport(tableType);
        List<PackageRequirement> imports = packageService.getImports();
        for (PackageRequirement req : imports) {
            Object[] data = new Object[] { req.getPackageName(), req.getFilter(), req.isOptional(), req.getBundle().getBundleId(), req.getBundle().getSymbolicName(), req.isResolveable() };
            CompositeData comp = new CompositeDataSupport(bundleType, names, data);
            try {
                table.put(comp);
            } catch (KeyAlreadyExistsException e) {
                throw new RuntimeException("Id: " + req.getBundle().getBundleId() + ", filter: " + req.getFilter(), e);
            }
        }
        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 : PackageRequirement(org.apache.karaf.packages.core.PackageRequirement) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) KeyAlreadyExistsException(javax.management.openmbean.KeyAlreadyExistsException) TabularData(javax.management.openmbean.TabularData) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 18 with OpenDataException

use of javax.management.openmbean.OpenDataException in project karaf by apache.

the class JmxReference method createReferenceType.

private static CompositeType createReferenceType() {
    try {
        String description = "This type encapsulates Scr references";
        String[] itemNames = ScrServiceMBean.REFERENCE;
        OpenType[] itemTypes = new OpenType[itemNames.length];
        String[] itemDescriptions = new String[itemNames.length];
        itemTypes[0] = SimpleType.STRING;
        itemTypes[1] = SimpleType.BOOLEAN;
        itemTypes[2] = SimpleType.STRING;
        itemTypes[3] = SimpleType.STRING;
        itemTypes[4] = SimpleType.STRING;
        itemTypes[5] = new ArrayType(1, SimpleType.STRING);
        itemDescriptions[0] = "The name of the reference";
        itemDescriptions[1] = "The state of the reference";
        itemDescriptions[2] = "The cardinality of the reference";
        itemDescriptions[3] = "The availability of the reference";
        itemDescriptions[4] = "The policy of the reference";
        itemDescriptions[5] = "The bound services";
        return new CompositeType("Reference", description, itemNames, itemDescriptions, itemTypes);
    } catch (OpenDataException e) {
        throw new IllegalStateException("Unable to build reference type", e);
    }
}
Also used : ArrayType(javax.management.openmbean.ArrayType) OpenType(javax.management.openmbean.OpenType) OpenDataException(javax.management.openmbean.OpenDataException) CompositeType(javax.management.openmbean.CompositeType)

Example 19 with OpenDataException

use of javax.management.openmbean.OpenDataException in project jdk8u_jdk by JetBrains.

the class MonitorInfoCompositeData method getCompositeData.

protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // monitorInfoItemNames!
    int len = monitorInfoItemNames.length;
    Object[] values = new Object[len];
    CompositeData li = LockInfoCompositeData.toCompositeData(lock);
    for (int i = 0; i < len; i++) {
        String item = monitorInfoItemNames[i];
        if (item.equals(LOCKED_STACK_FRAME)) {
            StackTraceElement ste = lock.getLockedStackFrame();
            values[i] = (ste != null ? StackTraceElementCompositeData.toCompositeData(ste) : null);
        } else if (item.equals(LOCKED_STACK_DEPTH)) {
            values[i] = new Integer(lock.getLockedStackDepth());
        } else {
            values[i] = li.get(item);
        }
    }
    try {
        return new CompositeDataSupport(monitorInfoCompositeType, monitorInfoItemNames, values);
    } catch (OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport)

Example 20 with OpenDataException

use of javax.management.openmbean.OpenDataException in project jdk8u_jdk by JetBrains.

the class GarbageCollectionNotifInfoCompositeData method getBaseGcNotifInfoCompositeType.

private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, GcInfoCompositeData.getBaseGcInfoCompositeType() };
            baseGcNotifInfoCompositeType = new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType", "CompositeType for Base GarbageCollectionNotificationInfo", gcNotifInfoItemNames, gcNotifInfoItemNames, baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
Also used : OpenType(javax.management.openmbean.OpenType) OpenDataException(javax.management.openmbean.OpenDataException) 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