Search in sources :

Example 96 with OpenDataException

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

the class SimpleRouter method getActiveRoutes.

@ManagedAttribute
public TabularData getActiveRoutes() {
    if (routes.length == 0) {
        return null;
    }
    final OpenType<?>[] types = new OpenType<?>[routes.length];
    final String[] keys = new String[types.length];
    final String[] values = new String[types.length];
    for (int i = 0; i < types.length; i++) {
        types[i] = SimpleType.STRING;
        keys[i] = routes[i].getOrigin().substring(prefix.length());
        values[i] = routes[i].getRawDestination().substring(prefix.length());
    }
    try {
        final CompositeType ct = new CompositeType("routes", "routes", keys, keys, types);
        final TabularType type = new TabularType("router", "routes", ct, keys);
        final TabularDataSupport data = new TabularDataSupport(type);
        final CompositeData line = new CompositeDataSupport(ct, keys, 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) ManagedAttribute(javax.management.ManagedAttribute)

Example 97 with OpenDataException

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

the class DynamicMBeanWrapper method toTabularData.

private TabularData toTabularData(final String typeName, final String description, final Table table) {
    final OpenType<?>[] types = new OpenType<?>[table.getColumnNames().size()];
    for (int i = 0; i < types.length; i++) {
        types[i] = SimpleType.STRING;
    }
    try {
        final String[] keys = table.getColumnNames().toArray(new String[table.getColumnNames().size()]);
        final CompositeType ct = new CompositeType(typeName, description, keys, keys, types);
        final TabularType type = new TabularType(typeName, description, ct, keys);
        final TabularDataSupport data = new TabularDataSupport(type);
        for (final Collection<String> line : table.getLines()) {
            data.put(new CompositeDataSupport(ct, keys, line.toArray(new Object[line.size()])));
        }
        return data;
    } catch (final OpenDataException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) 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 98 with OpenDataException

use of javax.management.openmbean.OpenDataException in project scylla-jmx by scylladb.

the class SnapshotDetailsTabularData method from.

public static void from(final String snapshot, final String ks, final String cf, long total, long live, TabularDataSupport result) {
    try {
        final String totalSize = FileUtils.stringifyFileSize(total);
        final String liveSize = FileUtils.stringifyFileSize(live);
        result.put(new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES, new Object[] { snapshot, ks, cf, liveSize, totalSize }));
    } catch (OpenDataException e) {
        throw new RuntimeException(e);
    }
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport)

Example 99 with OpenDataException

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

the class PendingStat method toComposite.

public CompositeData toComposite() {
    Map<String, Object> values = new HashMap<>();
    values.put(COMPOSITE_NAMES[0], dataSize);
    values.put(COMPOSITE_NAMES[1], numSSTables);
    String[] sessionIds = new String[sessions.size()];
    int idx = 0;
    for (UUID session : sessions) sessionIds[idx++] = session.toString();
    values.put(COMPOSITE_NAMES[2], sessionIds);
    try {
        return new CompositeDataSupport(COMPOSITE_TYPE, values);
    } catch (OpenDataException e) {
        throw Throwables.propagate(e);
    }
}
Also used : HashMap(java.util.HashMap) OpenDataException(javax.management.openmbean.OpenDataException) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) UUID(java.util.UUID)

Example 100 with OpenDataException

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

the class ProfileLoad method execute.

@Override
public void execute(NodeProbe probe) {
    checkArgument(args.size() == 3 || args.size() == 1 || args.size() == 0, "Invalid arguments, either [keyspace table duration] or [duration] or no args");
    checkArgument(topCount < capacity, "TopK count (-k) option must be smaller then the summary capacity (-s)");
    String keyspace = null;
    String table = null;
    Integer durationMillis = 10000;
    if (args.size() == 3) {
        keyspace = args.get(0);
        table = args.get(1);
        durationMillis = Integer.valueOf(args.get(2));
    } else if (args.size() == 1) {
        durationMillis = Integer.valueOf(args.get(0));
    }
    // generate the list of samplers
    List<String> targets = Lists.newArrayList();
    List<String> available = Arrays.stream(SamplerType.values()).map(Enum::toString).collect(Collectors.toList());
    for (String s : samplers.split(",")) {
        String sampler = s.trim().toUpperCase();
        checkArgument(available.contains(sampler), String.format("'%s' sampler is not available from: %s", s, Arrays.toString(SamplerType.values())));
        targets.add(sampler);
    }
    Map<String, List<CompositeData>> results;
    try {
        if (keyspace == null)
            results = probe.getPartitionSample(capacity, durationMillis, topCount, targets);
        else
            results = probe.getPartitionSample(keyspace, table, capacity, durationMillis, topCount, targets);
    } catch (OpenDataException e) {
        throw new RuntimeException(e);
    }
    AtomicBoolean first = new AtomicBoolean(true);
    ResultBuilder rb = new ResultBuilder(first, results, targets);
    for (String sampler : Lists.newArrayList("READS", "WRITES", "CAS_CONTENTIONS")) {
        rb.forType(SamplerType.valueOf(sampler), "Frequency of " + sampler.toLowerCase().replaceAll("_", " ") + " by partition").addColumn("Table", "table").addColumn("Partition", "value").addColumn("Count", "count").addColumn("+/-", "error").print(probe.output().out);
    }
    rb.forType(SamplerType.WRITE_SIZE, "Max mutation size by partition").addColumn("Table", "table").addColumn("Partition", "value").addColumn("Bytes", "count").print(probe.output().out);
    rb.forType(SamplerType.LOCAL_READ_TIME, "Longest read query times").addColumn("Query", "value").addColumn("Microseconds", "count").print(probe.output().out);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OpenDataException(javax.management.openmbean.OpenDataException) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

OpenDataException (javax.management.openmbean.OpenDataException)139 CompositeType (javax.management.openmbean.CompositeType)94 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)67 CompositeData (javax.management.openmbean.CompositeData)54 OpenType (javax.management.openmbean.OpenType)52 TabularType (javax.management.openmbean.TabularType)33 TabularDataSupport (javax.management.openmbean.TabularDataSupport)32 HashMap (java.util.HashMap)14 Map (java.util.Map)12 TabularData (javax.management.openmbean.TabularData)11 ObjectName (javax.management.ObjectName)8 ArrayType (javax.management.openmbean.ArrayType)8 Type (java.lang.reflect.Type)5 ArrayList (java.util.ArrayList)5 Method (java.lang.reflect.Method)4 Comparator (java.util.Comparator)4 MBeanServer (javax.management.MBeanServer)4 SimpleType (javax.management.openmbean.SimpleType)4 IOException (java.io.IOException)3 InvalidObjectException (java.io.InvalidObjectException)3