@Override public final AttributeType getType() { return m_attribType.getType(); }
@Override public final String getName() { return m_attribType.getName(); }
/** {@inheritDoc} */ @Override public void storeAttribute(Persister persister) { getAttributeType().storeAttribute(this, persister); }
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; }
/** * Adds the given attribute into the collection for this resource * * @param attr The Attribute to add */ public final void addAttribute(CollectionAttribute attr) { AttributeGroup group = getGroup(attr.getAttributeType().getGroupType()); LOG.debug("Adding attribute {}: {} to group {}", attr.getClass().getName(), attr, group); group.addAttribute(attr); }
/** * <p>hashCode</p> * * @return a int. */ @Override public int hashCode() { return (m_resource.hashCode() ^ m_attribType.hashCode()); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (obj instanceof SnmpAttribute) { SnmpAttribute attr = (SnmpAttribute) obj; return (m_resource.equals(attr.m_resource) && m_attribType.equals(attr.m_attribType)); } return false; }
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; }
private void addAttribute(final SnmpAttribute attr) { AttributeGroup group = getGroup(attr.getAttributeType().getGroupType()); LOG.debug("Adding attribute {}: {} to group {}", attr.getClass().getName(), attr, group); group.addAttribute(attr); }
public List<CollectionAttribute> getStringAttributes() { return m_groups.values().stream() .flatMap(g -> g.getAttributes().stream()) .filter(a -> a.getAttributeType() instanceof NumericCollectionAttributeType == false || AttributeType.STRING.equals(a.getAttributeType().getType())) .collect(Collectors.toList()); }
/** * <p>compare</p> * * @param type0 a {@link org.opennms.netmgt.collection.api.CollectionAttributeType} object. * @param type1 a {@link org.opennms.netmgt.collection.api.CollectionAttributeType} object. * @return a int. */ @Override public int compare(final CollectionAttributeType type0, final CollectionAttributeType type1) { return type0.getName().compareTo(type1.getName()); }
/** * Adds the given attribute into the collection for this resource * * @param attr The Attribute to add */ public void addAttribute(CollectionAttribute attr) { AttributeGroup group = getGroup(attr.getAttributeType().getGroupType()); group.addAttribute(attr); }
/** {@inheritDoc} */ @Override public void storeAttribute(Persister persister) { getAttributeType().storeAttribute(this, persister); }
@Override public void visitGroup(AttributeGroup group) { pushShouldPersist(group); if (shouldPersist()) { final String resourceId = getResourceId(group.getResource()); final String groupId = resourceId + '/' + group.getName(); LOG.debug("visitGroup: {} = {}", groupId, group.getAttributes().size()); stats.checkNode(group.getResource().getParent().getName()); stats.checkGroup(groupId); stats.checkResource(resourceId); group.getAttributes().forEach(a -> { final String attribId = resourceId + '/' + a.getName(); if (a.getAttributeType().getType().isNumeric()) { LOG.debug("visitGroup: attribute {}", attribId); stats.checkAttribute(attribId, true); stats.markNumericSamplesMeter(); } else { stats.checkAttribute(attribId, false); } }); setBuilder(new EvaluatorPersistOperationBuilder()); } }
/** * Gets the attribute value. * * @param sourceAttributes the source attributes * @param index the index * @param type the resource type * @param attrName the attribute name * @return the attribute value */ private String getAttributeValue(List<CollectionAttribute> sourceAttributes, String index, String type, String attrName) { Optional<CollectionAttribute> attr = sourceAttributes.stream().filter(a -> attrName.equals(a.getAttributeType().getName()) && type.equals(a.getResource().getResourceTypeName()) && index.equals(a.getResource().getInstance())).findFirst(); return attr.isPresent() ? attr.get().getStringValue() : null; }
/** * Adds the given attribute into the collection for this resource * * @param attr The Attribute to add */ public void addAttribute(CollectionAttribute attr) { AttributeGroup group = getGroup(attr.getAttributeType().getGroupType()); group.addAttribute(attr); }
@Override public void visitAttribute(CollectionAttribute attribute) { pushShouldPersist(attribute); if (shouldPersist()) { final String resourceId = getResourceId(attribute.getResource()); final String attribId = resourceId + '/' + attribute.getName(); LOG.debug("visitAttribute: {}", attribId); stats.checkNode(attribute.getResource().getParent().getName()); stats.checkResource(resourceId); if (attribute.getAttributeType().getType().isNumeric()) { stats.checkAttribute(attribId, true); stats.markNumericSamplesMeter(); } else { stats.checkAttribute(attribId, false); } setBuilder(new EvaluatorPersistOperationBuilder()); } }
/** * Gets the attribute map. * * @param sourceAttributes the source attributes * @param type the resource type * @param objName the object name * @return the attribute map */ private Map<String, String> getAttributeMap(List<CollectionAttribute> sourceAttributes, String type, String objName) { Map<String,String> attributes = new HashMap<String,String>(); sourceAttributes.stream().filter(a -> objName.equals(a.getAttributeType().getName()) && type.equals(a.getResource().getResourceTypeName())).forEach(a -> attributes.put(a.getResource().getInstance(), a.getStringValue())); return attributes; }