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;
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations