Search in sources :

Example 81 with OpenDataException

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);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) UnionTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition) UnionTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition) IdentityrefTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition) EnumTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition) TypeDefinition(org.opendaylight.yangtools.yang.model.api.TypeDefinition) CompositeType(javax.management.openmbean.CompositeType) Type(org.opendaylight.mdsal.binding.model.api.Type) SimpleType(javax.management.openmbean.SimpleType) OpenType(javax.management.openmbean.OpenType) ArrayType(javax.management.openmbean.ArrayType) OpenDataException(javax.management.openmbean.OpenDataException) CompositeType(javax.management.openmbean.CompositeType)

Example 82 with OpenDataException

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);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) OpenDataException(javax.management.openmbean.OpenDataException) CompositeType(javax.management.openmbean.CompositeType)

Example 83 with OpenDataException

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;
}
Also used : TimeSeries(org.apache.jackrabbit.api.stats.TimeSeries) CompositeType(javax.management.openmbean.CompositeType) OpenDataException(javax.management.openmbean.OpenDataException) CounterStats(org.apache.jackrabbit.oak.stats.CounterStats) TimeSeriesStatsUtil.asCompositeData(org.apache.jackrabbit.stats.TimeSeriesStatsUtil.asCompositeData) SimpleType(javax.management.openmbean.SimpleType) StatsOptions(org.apache.jackrabbit.oak.stats.StatsOptions) CompositeData(javax.management.openmbean.CompositeData) HashMap(java.util.HashMap) TabularData(javax.management.openmbean.TabularData) TimerStats(org.apache.jackrabbit.oak.stats.TimerStats) TimeUnit(java.util.concurrent.TimeUnit) OpenType(javax.management.openmbean.OpenType) TabularType(javax.management.openmbean.TabularType) Map(java.util.Map) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Entry(java.util.Map.Entry) Comparator(java.util.Comparator) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) MeterStats(org.apache.jackrabbit.oak.stats.MeterStats) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) HashMap(java.util.HashMap) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeType(javax.management.openmbean.CompositeType)

Example 84 with OpenDataException

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;
}
Also used : TimeSeries(org.apache.jackrabbit.api.stats.TimeSeries) CompositeType(javax.management.openmbean.CompositeType) OpenDataException(javax.management.openmbean.OpenDataException) CounterStats(org.apache.jackrabbit.oak.stats.CounterStats) Iterator(java.util.Iterator) PathUtils(org.apache.jackrabbit.oak.commons.PathUtils) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) TimeSeriesStatsUtil.asCompositeData(org.apache.jackrabbit.stats.TimeSeriesStatsUtil.asCompositeData) SimpleType(javax.management.openmbean.SimpleType) StatsOptions(org.apache.jackrabbit.oak.stats.StatsOptions) HistogramStats(org.apache.jackrabbit.oak.stats.HistogramStats) CompositeData(javax.management.openmbean.CompositeData) TabularData(javax.management.openmbean.TabularData) OpenType(javax.management.openmbean.OpenType) TabularType(javax.management.openmbean.TabularType) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Map(java.util.Map) Entry(java.util.Map.Entry) Mount(org.apache.jackrabbit.oak.spi.mount.Mount) Comparator(java.util.Comparator) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeType(javax.management.openmbean.CompositeType)

Example 85 with OpenDataException

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;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) Map(java.util.Map)

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