use of javax.management.openmbean.OpenDataException in project controller by opendaylight.
the class JavaAttribute method getCompositeTypeForUnion.
private OpenType<?> getCompositeTypeForUnion(final TypeDefinition<?> baseTypeDefinition) {
Preconditions.checkArgument(baseTypeDefinition instanceof UnionTypeDefinition, "Expected %s instance but was %s", UnionTypeDefinition.class, baseTypeDefinition);
final List<TypeDefinition<?>> types = ((UnionTypeDefinition) baseTypeDefinition).getTypes();
final String[] itemNames = new String[types.size() + 1];
final OpenType<?>[] itemTypes = new OpenType[itemNames.length];
addArtificialPropertyToUnionCompositeType(baseTypeDefinition, itemNames, itemTypes);
final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
int i = 1;
for (final TypeDefinition<?> innerTypeDefinition : types) {
final Type innerType = this.typeProviderWrapper.getType(innerTypeDefinition, innerTypeDefinition);
final TypeDefinition<?> baseInnerTypeDefinition = getBaseType(this.typeProviderWrapper, innerTypeDefinition);
final Type innerTypeBaseType = this.typeProviderWrapper.getType(baseInnerTypeDefinition, baseInnerTypeDefinition);
OpenType<?> innerCompositeType;
if (isDerivedType(innerTypeBaseType, innerType)) {
innerCompositeType = baseInnerTypeDefinition instanceof UnionTypeDefinition ? getCompositeTypeForUnion(baseInnerTypeDefinition) : getCompositeType(innerTypeBaseType, baseInnerTypeDefinition);
} else {
innerCompositeType = SimpleTypeResolver.getSimpleType(innerType);
}
itemNames[i] = this.typeProviderWrapper.getJMXParamForUnionInnerType(innerTypeDefinition);
itemTypes[i++] = innerCompositeType;
}
final String[] descriptions = itemNames.clone();
descriptions[0] = DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION;
try {
return new CompositeType(getUpperCaseCammelCase(), description, itemNames, descriptions, itemTypes);
} catch (final OpenDataException e) {
throw new RuntimeException("Unable to create " + CompositeType.class + " with inner elements " + Arrays.toString(itemTypes), e);
}
}
use of javax.management.openmbean.OpenDataException in project controller by opendaylight.
the class FunctionImpl method getOpenType.
@Override
public CompositeType getOpenType() {
final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
final FunctionImpl functionImpl = new FunctionImpl();
final Map<String, AttributeIfc> jmxPropertiesToTypesMap = getJmxPropertiesToTypesMap();
final OpenType<?>[] itemTypes = Collections2.transform(jmxPropertiesToTypesMap.entrySet(), functionImpl).toArray(new OpenType<?>[] {});
final String[] itemNames = functionImpl.getItemNames();
try {
// TODO add package name to create fully qualified name for this
// type
final CompositeType compositeType = new CompositeType(getUpperCaseCammelCase(), description, itemNames, itemNames, itemTypes);
return compositeType;
} catch (final OpenDataException e) {
throw new RuntimeException("Unable to create CompositeType for " + this, e);
}
}
use of javax.management.openmbean.OpenDataException in project jackrabbit-oak by apache.
the class SegmentNodeStoreStats method createTabularDataFromCountMap.
private TabularData createTabularDataFromCountMap(Map<String, Long> commitsCountMap, String typeName, String writerDescription) throws OpenDataException {
CompositeType commitsPerWriterRowType = new CompositeType(typeName, typeName, new String[] { "count", writerDescription }, new String[] { "count", writerDescription }, new OpenType[] { SimpleType.LONG, SimpleType.STRING });
TabularDataSupport tabularData = new TabularDataSupport(new TabularType(typeName, "Most active writers", commitsPerWriterRowType, new String[] { writerDescription }));
if (commitsCountMap.isEmpty()) {
commitsCountMap.put("N/A", 0L);
}
commitsCountMap.entrySet().stream().sorted(Comparator.<Entry<String, Long>>comparingLong(Entry::getValue).reversed()).map(e -> {
Map<String, Object> m = new HashMap<>();
m.put("count", e.getValue());
m.put(writerDescription, e.getKey());
return m;
}).map(d -> mapToCompositeData(commitsPerWriterRowType, d)).forEach(tabularData::put);
return tabularData;
}
use of javax.management.openmbean.OpenDataException in project jackrabbit-oak by apache.
the class CompositeNodeStoreStats method pathsTable.
private TabularData pathsTable(Map<String, Long> paths, String name, String description) throws OpenDataException {
CompositeType pathRowType = new CompositeType("compositePath", "Path", new String[] { "count", "path" }, new String[] { "count", "path" }, new OpenType[] { SimpleType.LONG, SimpleType.STRING });
TabularDataSupport tabularData = new TabularDataSupport(new TabularType(name, description, pathRowType, new String[] { "path" }));
paths.entrySet().stream().sorted(Comparator.<Entry<String, Long>>comparingLong(Entry::getValue).reversed()).map(e -> {
Map<String, Object> m = newHashMap();
m.put("count", e.getValue());
m.put("path", e.getKey());
return m;
}).map(d -> mapToCompositeData(pathRowType, d)).forEach(tabularData::put);
return tabularData;
}
use of javax.management.openmbean.OpenDataException in project jackrabbit-oak by apache.
the class TrackingCorruptIndexHandler method getFailingIndexStats.
// ~-----------------------------------------------------< MBean Support >
public TabularData getFailingIndexStats(String asyncName) {
TabularDataSupport tds;
try {
TabularType tt = new TabularType(TrackingCorruptIndexHandler.class.getName(), "Failing Index Stats", FailingIndexStats.TYPE, new String[] { "path" });
tds = new TabularDataSupport(tt);
Map<String, CorruptIndexInfo> infos = getFailingIndexData(asyncName);
for (Map.Entry<String, CorruptIndexInfo> e : infos.entrySet()) {
FailingIndexStats stats = new FailingIndexStats(e.getValue());
tds.put(stats.toCompositeData());
}
} catch (OpenDataException e) {
throw new IllegalStateException(e);
}
return tds;
}
Aggregations