Search in sources :

Example 86 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project nhin-d by DirectProject.

the class RDBMSAuditor method getEvents.

/**
	 * {@inheritDoc}
	 */
@Override
public CompositeData[] getEvents(Integer eventCount) {
    if (eventType == null || eventCount == 0)
        return null;
    final Vector<CompositeData> retVal = new Vector<CompositeData>();
    final Collection<org.nhindirect.common.audit.impl.entity.AuditEvent> rs = this.dao.getRDBMSEvents(eventCount);
    if (rs.size() == 0)
        return null;
    for (org.nhindirect.common.audit.impl.entity.AuditEvent event : rs) {
        String[] contexts = null;
        if (event.getAuditContexts() != null && !event.getAuditContexts().isEmpty()) {
            contexts = new String[event.getAuditContexts().size()];
            int idx = 0;
            for (org.nhindirect.common.audit.impl.entity.AuditContext ctx : event.getAuditContexts()) {
                contexts[idx++] = ctx.getContextName() + ":" + ctx.getContextValue();
            }
        }
        if (contexts == null)
            contexts = new String[] { " " };
        try {
            final Object[] eventValues = { event.getUUID(), event.getEventTime().toString(), event.getPrincipal(), event.getEventName(), event.getEventType(), contexts };
            retVal.add(new CompositeDataSupport(eventType, itemNames, eventValues));
        } catch (OpenDataException e) {
            LOGGER.error("Error create composit data for audit event.", e);
        }
    }
    return retVal.toArray(new CompositeData[retVal.size()]);
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) OpenDataException(javax.management.openmbean.OpenDataException) AuditEvent(org.nhindirect.common.audit.AuditEvent) Vector(java.util.Vector)

Example 87 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project camel by apache.

the class ManagedAsyncProcessorAwaitManager method browse.

@Override
public TabularData browse() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listAwaitThreadsTabularType());
        Collection<AsyncProcessorAwaitManager.AwaitThread> threads = manager.browse();
        for (AsyncProcessorAwaitManager.AwaitThread entry : threads) {
            CompositeType ct = CamelOpenMBeanTypes.listAwaitThreadsCompositeType();
            String id = "" + entry.getBlockedThread().getId();
            String name = entry.getBlockedThread().getName();
            String exchangeId = entry.getExchange().getExchangeId();
            String routeId = entry.getRouteId();
            String nodeId = entry.getNodeId();
            String duration = "" + entry.getWaitDuration();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "id", "name", "exchangeId", "routeId", "nodeId", "duration" }, new Object[] { id, name, exchangeId, routeId, nodeId, duration });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) AsyncProcessorAwaitManager(org.apache.camel.spi.AsyncProcessorAwaitManager) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 88 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project camel by apache.

the class ManagedCamelContext method listEips.

public TabularData listEips() throws Exception {
    try {
        // find all EIPs
        Map<String, Properties> eips = context.findEips();
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listEipsTabularType());
        // gather EIP detail for each eip
        for (Map.Entry<String, Properties> entry : eips.entrySet()) {
            String name = entry.getKey();
            String title = (String) entry.getValue().get("title");
            String description = (String) entry.getValue().get("description");
            String label = (String) entry.getValue().get("label");
            String type = (String) entry.getValue().get("class");
            String status = CamelContextHelper.isEipInUse(context, name) ? "in use" : "on classpath";
            CompositeType ct = CamelOpenMBeanTypes.listEipsCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "name", "title", "description", "label", "status", "type" }, new Object[] { name, title, description, label, status, type });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Properties(java.util.Properties) Map(java.util.Map) IOException(java.io.IOException) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 89 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project camel by apache.

the class ManagedCamelContext method listComponents.

@Override
public TabularData listComponents() throws Exception {
    try {
        // find all components
        Map<String, Properties> components = context.findComponents();
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listComponentsTabularType());
        // gather component detail for each component
        for (Map.Entry<String, Properties> entry : components.entrySet()) {
            String name = entry.getKey();
            String title = null;
            String syntax = null;
            String description = null;
            String label = null;
            String deprecated = null;
            String secret = null;
            String status = context.hasComponent(name) != null ? "in use" : "on classpath";
            String type = (String) entry.getValue().get("class");
            String groupId = null;
            String artifactId = null;
            String version = null;
            // a component may have been given a different name, so resolve its default name by its java type
            // as we can find the component json information from the default component name
            String defaultName = context.resolveComponentDefaultName(type);
            String target = defaultName != null ? defaultName : name;
            // load component json data, and parse it to gather the component meta-data
            String json = context.getComponentParameterJsonSchema(target);
            List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema("component", json, false);
            for (Map<String, String> row : rows) {
                if (row.containsKey("title")) {
                    title = row.get("title");
                } else if (row.containsKey("syntax")) {
                    syntax = row.get("syntax");
                } else if (row.containsKey("description")) {
                    description = row.get("description");
                } else if (row.containsKey("label")) {
                    label = row.get("label");
                } else if (row.containsKey("deprecated")) {
                    deprecated = row.get("deprecated");
                } else if (row.containsKey("secret")) {
                    secret = row.get("secret");
                } else if (row.containsKey("javaType")) {
                    type = row.get("javaType");
                } else if (row.containsKey("groupId")) {
                    groupId = row.get("groupId");
                } else if (row.containsKey("artifactId")) {
                    artifactId = row.get("artifactId");
                } else if (row.containsKey("version")) {
                    version = row.get("version");
                }
            }
            CompositeType ct = CamelOpenMBeanTypes.listComponentsCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "name", "title", "syntax", "description", "label", "deprecated", "secret", "status", "type", "groupId", "artifactId", "version" }, new Object[] { name, title, syntax, description, label, deprecated, secret, status, type, groupId, artifactId, version });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Properties(java.util.Properties) IOException(java.io.IOException) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Map(java.util.Map) CompositeType(javax.management.openmbean.CompositeType)

Example 90 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project camel by apache.

the class ManagedChoice method choiceStatistics.

@Override
public TabularData choiceStatistics() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.choiceTabularType());
        List<WhenDefinition> whens = getDefinition().getWhenClauses();
        List<FilterProcessor> filters = processor.getFilters();
        for (int i = 0; i < filters.size(); i++) {
            WhenDefinition when = whens.get(i);
            FilterProcessor filter = filters.get(i);
            CompositeType ct = CamelOpenMBeanTypes.choiceCompositeType();
            String predicate = when.getExpression().getExpression();
            String language = when.getExpression().getLanguage();
            Long matches = filter.getFilteredCount();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "predicate", "language", "matches" }, new Object[] { predicate, language, matches });
            answer.put(data);
        }
        if (getDefinition().getOtherwise() != null) {
            CompositeType ct = CamelOpenMBeanTypes.choiceCompositeType();
            String predicate = "otherwise";
            String language = "";
            Long matches = processor.getNotFilteredCount();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "predicate", "language", "matches" }, new Object[] { predicate, language, matches });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : FilterProcessor(org.apache.camel.processor.FilterProcessor) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) WhenDefinition(org.apache.camel.model.WhenDefinition) CompositeType(javax.management.openmbean.CompositeType)

Aggregations

CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)166 CompositeData (javax.management.openmbean.CompositeData)107 CompositeType (javax.management.openmbean.CompositeType)105 TabularDataSupport (javax.management.openmbean.TabularDataSupport)78 OpenDataException (javax.management.openmbean.OpenDataException)66 TabularData (javax.management.openmbean.TabularData)46 HashMap (java.util.HashMap)36 TabularType (javax.management.openmbean.TabularType)30 Map (java.util.Map)26 OpenType (javax.management.openmbean.OpenType)15 ObjectName (javax.management.ObjectName)12 MBeanServer (javax.management.MBeanServer)8 Test (org.junit.Test)8 IOException (java.io.IOException)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 MBeanException (javax.management.MBeanException)6 JsonArray (javax.json.JsonArray)5 JsonObject (javax.json.JsonObject)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4