Search in sources :

Example 31 with TabularDataSupport

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

the class LuceneIndexMBeanImpl method getBadPersistedIndexStats.

@Override
public TabularData getBadPersistedIndexStats() {
    TabularDataSupport tds;
    try {
        TabularType tt = new TabularType(LuceneIndexMBeanImpl.class.getName(), "Lucene Bad Persisted Index Stats", BadIndexStats.TYPE, new String[] { "path" });
        tds = new TabularDataSupport(tt);
        Set<String> indexes = indexTracker.getBadIndexTracker().getBadPersistedIndexPaths();
        for (String path : indexes) {
            BadIndexInfo info = indexTracker.getBadIndexTracker().getPersistedIndexInfo(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 32 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport 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 33 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport 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 34 with TabularDataSupport

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

the class JMXSecurityMBeanImpl method canInvoke.

public TabularData canInvoke(Map<String, List<String>> bulkQuery) throws Exception {
    TabularData table = new TabularDataSupport(CAN_INVOKE_TABULAR_TYPE);
    BulkRequestContext context = BulkRequestContext.newContext(guard.getConfigAdmin());
    for (Map.Entry<String, List<String>> entry : bulkQuery.entrySet()) {
        String objectName = entry.getKey();
        List<String> methods = entry.getValue();
        if (methods.size() == 0) {
            boolean res = canInvoke(context, objectName);
            CompositeData data = new CompositeDataSupport(CAN_INVOKE_RESULT_ROW_TYPE, CAN_INVOKE_RESULT_COLUMNS, new Object[] { objectName, "", res });
            table.put(data);
        } else {
            for (String method : methods) {
                List<String> argTypes = new ArrayList<>();
                String name = parseMethodName(method, argTypes);
                boolean res;
                if (name.equals(method)) {
                    res = canInvoke(context, objectName, name);
                } else {
                    res = canInvoke(context, objectName, name, argTypes.toArray(new String[] {}));
                }
                CompositeData data = new CompositeDataSupport(CAN_INVOKE_RESULT_ROW_TYPE, CAN_INVOKE_RESULT_COLUMNS, new Object[] { objectName, method, res });
                try {
                    table.put(data);
                } catch (KeyAlreadyExistsException e) {
                    // KeyAlreadyExistsException can happen only when methods are not empty
                    LOG.warn("{} (objectName = \"{}\", method = \"{}\")", e, objectName, method);
                }
            }
        }
    }
    return table;
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ArrayList(java.util.ArrayList) KeyAlreadyExistsException(javax.management.openmbean.KeyAlreadyExistsException) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 35 with TabularDataSupport

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

the class HttpMBeanImpl method getServlets.

public TabularData getServlets() throws MBeanException {
    try {
        CompositeType servletType = new CompositeType("Servlet", "HTTP Servlet", new String[] { "Bundle-ID", "Servlet", "Servlet Name", "State", "Alias", "URL" }, new String[] { "ID of the bundle that registered the servlet", "Class name of the servlet", "Servlet Name", "Current state of the servlet", "Aliases of the servlet", "URL of the servlet" }, new OpenType[] { SimpleType.LONG, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
        TabularType tableType = new TabularType("Servlets", "Table of all HTTP servlets", servletType, new String[] { "Bundle-ID", "Servlet Name", "State" });
        TabularData table = new TabularDataSupport(tableType);
        List<ServletInfo> servletInfos = servletService.getServlets();
        for (ServletInfo info : servletInfos) {
            CompositeData data = new CompositeDataSupport(servletType, new String[] { "Bundle-ID", "Servlet", "Servlet Name", "State", "Alias", "URL" }, new Object[] { info.getBundleId(), info.getClassName(), info.getName(), info.getStateString(), info.getAlias(), Arrays.toString(info.getUrls()) });
            table.put(data);
        }
        return table;
    } catch (Exception e) {
        throw new MBeanException(null, e.toString());
    }
}
Also used : ServletInfo(org.apache.karaf.http.core.ServletInfo) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

Aggregations

TabularDataSupport (javax.management.openmbean.TabularDataSupport)103 TabularData (javax.management.openmbean.TabularData)67 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)60 CompositeData (javax.management.openmbean.CompositeData)51 CompositeType (javax.management.openmbean.CompositeType)50 TabularType (javax.management.openmbean.TabularType)36 Map (java.util.Map)27 OpenDataException (javax.management.openmbean.OpenDataException)24 HashMap (java.util.HashMap)11 Bundle (org.osgi.framework.Bundle)10 IOException (java.io.IOException)7 ObjectName (javax.management.ObjectName)7 OpenType (javax.management.openmbean.OpenType)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 Test (org.junit.Test)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4 Dictionary (java.util.Dictionary)4