Search in sources :

Example 1 with RrdAttributeType

use of org.opennms.netmgt.rrd.RrdAttributeType in project opennms by OpenNMS.

the class RrdPersistOperationBuilder method getDataSources.

private List<RrdDataSource> getDataSources() {
    List<RrdDataSource> dataSources = new ArrayList<RrdDataSource>(m_declarations.size());
    for (CollectionAttributeType attrDef : m_declarations.keySet()) {
        String minval = "U";
        String maxval = "U";
        if (attrDef instanceof NumericCollectionAttributeType) {
            minval = ((NumericCollectionAttributeType) attrDef).getMinval() != null ? ((NumericCollectionAttributeType) attrDef).getMinval() : "U";
            maxval = ((NumericCollectionAttributeType) attrDef).getMaxval() != null ? ((NumericCollectionAttributeType) attrDef).getMaxval() : "U";
        }
        final RrdAttributeType type = RrdPersistOperationBuilder.mapType(attrDef.getType());
        // If the type is supported by RRD...
        if (type != null) {
            if (attrDef.getName().length() > MAX_DS_NAME_LENGTH) {
                LOG.warn("Mib object name/alias '{}' exceeds 19 char maximum for RRD data source names, truncating.", attrDef.getName());
            }
            RrdDataSource rrdDataSource = new RrdDataSource(StringUtils.truncate(attrDef.getName(), RrdPersistOperationBuilder.MAX_DS_NAME_LENGTH), type, getRepository().getHeartBeat(), minval, maxval);
            dataSources.add(rrdDataSource);
        }
    }
    return dataSources;
}
Also used : RrdAttributeType(org.opennms.netmgt.rrd.RrdAttributeType) ArrayList(java.util.ArrayList) RrdDataSource(org.opennms.netmgt.rrd.RrdDataSource) NumericCollectionAttributeType(org.opennms.netmgt.collection.api.NumericCollectionAttributeType) CollectionAttributeType(org.opennms.netmgt.collection.api.CollectionAttributeType) NumericCollectionAttributeType(org.opennms.netmgt.collection.api.NumericCollectionAttributeType)

Aggregations

ArrayList (java.util.ArrayList)1 CollectionAttributeType (org.opennms.netmgt.collection.api.CollectionAttributeType)1 NumericCollectionAttributeType (org.opennms.netmgt.collection.api.NumericCollectionAttributeType)1 RrdAttributeType (org.opennms.netmgt.rrd.RrdAttributeType)1 RrdDataSource (org.opennms.netmgt.rrd.RrdDataSource)1