Example usage for javax.management.openmbean CompositeData getCompositeType

List of usage examples for javax.management.openmbean CompositeData getCompositeType

Introduction

In this page you can find the example usage for javax.management.openmbean CompositeData getCompositeType.

Prototype

public CompositeType getCompositeType();

Source Link

Document

Returns the composite type of this composite data instance.

Usage

From source file:com.heliosapm.opentsdb.TSDBSubmitterImpl.java

/**
 * Decomposes a composite data type so it can be traced
 * @param objectName The ObjectName of the MBean the composite data came from
 * @param cd The composite data instance
 * @return A map of values keyed by synthesized ObjectNames that represent the structure down to the numeric composite data items
 *///from  w w  w  .  j  av  a  2  s  .  co  m
protected Map<ObjectName, Number> fromOpenType(final ObjectName objectName, final CompositeData cd) {
    if (objectName == null)
        throw new IllegalArgumentException("The passed ObjectName was null");
    if (cd == null)
        throw new IllegalArgumentException("The passed CompositeData was null");
    final Map<ObjectName, Number> map = new HashMap<ObjectName, Number>();
    final CompositeType ct = cd.getCompositeType();
    for (final String key : ct.keySet()) {
        final Object value = cd.get(key);
        if (value == null || !(value instanceof Number))
            continue;
        StringBuilder b = new StringBuilder(objectName.toString());
        b.append(",ctype=").append(simpleName(ct.getTypeName()));
        b.append(",metric=").append(key);
        ObjectName on = JMXHelper.objectName(clean(b));
        map.put(on, (Number) value);

    }
    return map;
}