Search in sources :

Example 41 with CompositeDataSupport

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

the class GarbageCollectionNotifInfoCompositeData method getCompositeData.

protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // gcNotifInfoItemNames!
    final Object[] gcNotifInfoItemValues;
    gcNotifInfoItemValues = new Object[] { gcNotifInfo.getGcName(), gcNotifInfo.getGcAction(), gcNotifInfo.getGcCause(), GcInfoCompositeData.toCompositeData(gcNotifInfo.getGcInfo()) };
    CompositeType gict = getCompositeTypeByBuilder();
    try {
        return new CompositeDataSupport(gict, gcNotifInfoItemNames, gcNotifInfoItemValues);
    } catch (OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 42 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project ddf by codice.

the class UndeliveredMessages method getMessages.

@Override
public List<CompositeData> getMessages(String address, String module) {
    List<CompositeData> undeliveredMessages = new ArrayList<>();
    Object compositeDatas = invokeMbean(createArtemisObjectName(address, module), GET_MESSAGES_OPERATION, new Object[] { "" }, new String[] { String.class.getName() });
    if (!(compositeDatas instanceof CompositeData[])) {
        return undeliveredMessages;
    }
    CompositeData[] messages = (CompositeData[]) compositeDatas;
    for (CompositeData message : messages) {
        Set<String> setMessageKeys = message.getCompositeType().keySet();
        String[] messageKeysArray = setMessageKeys.toArray(new String[setMessageKeys.size()]);
        Object[] messageValues = message.getAll(messageKeysArray);
        CompositeType messageCompositeType = message.getCompositeType();
        String[] itemDescription = new String[messageKeysArray.length];
        OpenType<?>[] itemTypes = new OpenType[messageKeysArray.length];
        try {
            for (int i = 0; i < messageKeysArray.length; i++) {
                String messageKey = messageKeysArray[i];
                itemDescription[i] = messageCompositeType.getDescription(messageKey);
                if (messageKeysArray[i].equals("body")) {
                    byte[] messageBodyBytes = (byte[]) message.get("body");
                    // Remove unprintable characters from the beginning of the string
                    messageValues[i] = removeNullCharacters(new String(Arrays.copyOfRange(messageBodyBytes, 5, messageBodyBytes.length), StandardCharsets.UTF_8));
                    itemTypes[i] = SimpleType.STRING;
                } else {
                    itemTypes[i] = messageCompositeType.getType(messageKey);
                }
            }
            undeliveredMessages.add(new CompositeDataSupport(new CompositeType(messageCompositeType.getTypeName(), messageCompositeType.getDescription(), messageKeysArray, itemDescription, itemTypes), messageKeysArray, messageValues));
        } catch (OpenDataException e) {
            LOGGER.warn("Unable to retrieve messages from the broker. For more information, set " + "logging level to DEBUG.");
            LOGGER.debug("Unable to retrieve messages from the broker.", e);
        }
    }
    return undeliveredMessages;
}
Also used : OpenType(javax.management.openmbean.OpenType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ArrayList(java.util.ArrayList) OpenDataException(javax.management.openmbean.OpenDataException) CompositeType(javax.management.openmbean.CompositeType)

Example 43 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project hazelcast by hazelcast.

the class JVMUtil method isHotSpotCompressedOopsOrNull.

// not private for testing
@SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL")
static Boolean isHotSpotCompressedOopsOrNull() {
    try {
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        ObjectName mbean = new ObjectName("com.sun.management:type=HotSpotDiagnostic");
        Object[] objects = { "UseCompressedOops" };
        String[] strings = { "java.lang.String" };
        String operation = "getVMOption";
        CompositeDataSupport compressedOopsValue = (CompositeDataSupport) server.invoke(mbean, operation, objects, strings);
        return Boolean.valueOf(compressedOopsValue.get("value").toString());
    } catch (Exception e) {
        getLogger(JVMUtil.class).fine("Failed to read HotSpot specific configuration: " + e.getMessage());
    }
    return null;
}
Also used : CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 44 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 45 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)

Aggregations

CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)92 CompositeData (javax.management.openmbean.CompositeData)68 TabularDataSupport (javax.management.openmbean.TabularDataSupport)60 CompositeType (javax.management.openmbean.CompositeType)55 TabularData (javax.management.openmbean.TabularData)43 OpenDataException (javax.management.openmbean.OpenDataException)25 HashMap (java.util.HashMap)21 Map (java.util.Map)19 TabularType (javax.management.openmbean.TabularType)19 OpenType (javax.management.openmbean.OpenType)10 Test (org.junit.Test)8 ObjectName (javax.management.ObjectName)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 MBeanServer (javax.management.MBeanServer)6 IOException (java.io.IOException)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)3 MBeanInfo (javax.management.MBeanInfo)3 Bundle (org.osgi.framework.Bundle)3