/** {@inheritDoc} */ @Override public String getName() { return m_wrapped.getName(); }
@Override public void visitAttribute(CollectionAttribute attribute) { attributesByName.put(attribute.getName(), attribute); } });
@Override public void visitAttribute(CollectionAttribute attribute) { attributesByName.put(attribute.getName(), attribute); } });
@Override public void visitAttribute(CollectionAttribute attribute) { attributesByName.put(attribute.getName(), attribute); }
@Override public void visitAttribute(CollectionAttribute attribute) { attributesByName.put(attribute.getName(), attribute); }
/** * Matches. * * @param sourceType the source type * @param sourceAlias the source alias * @param index the resource index to check * @param a the collection attribute to check * @return true, if successful */ private boolean matches(final String sourceType, final String sourceAlias, final String index, final CollectionAttribute a) { final CollectionResource r = a.getResource(); return a.getName().equals(sourceAlias) && r.getResourceTypeName().equals(sourceType) && r.getInstance().equals(index); }
@Override public void visitAttribute(CollectionAttribute attribute) { if (AttributeType.STRING.equals(attribute.getType()) && attributeName.equals(attribute.getName())) attributeValue = attribute.getStringValue(); } }
@Override public void visitAttribute(CollectionAttribute attribute) { strings.add(String.format("%s/%s/%s[%s,%s]", resource.getPath(), group.getName(), attribute.getName(),attribute.getStringValue(),attribute.getNumericValue())); } });
@Override public void visitAttribute(CollectionAttribute attribute) { strings.add(String.format("%s/%s/%s[%s,%s]", resource.getPath(), group.getName(), attribute.getName(),attribute.getStringValue(),attribute.getNumericValue())); } });
/** * Add/Update required attributes for thresholds on m_attributeMap. * This is used because {@link CollectionResource} does not have direct reference to their attributes. * (The way to get attribute is against {@link AttributeGroup} object contained on {@link CollectionResource} * implementations). */ @Override public void visitAttribute(CollectionAttribute attribute) { if (m_thresholdingSet.hasThresholds(attribute)) { String name = attribute.getName(); m_attributesMap.put(name, attribute); LOG.debug("visitAttribute: storing value {} for attribute named {}", attribute.getNumericValue() != null ? attribute.getNumericValue() : attribute.getStringValue(), name); } }
@Override public void visitAttribute(CollectionAttribute attribute) { if (!attribute.getType().isNumeric()) { context.setVariable(attribute.getName(), attribute.getStringValue()); } }
@Override public void visitAttribute(CollectionAttribute attribute) { pushShouldPersist(attribute); if (shouldPersist()) { setBuilder(createBuilder(attribute.getResource(), attribute.getName(), Collections.singleton(attribute.getAttributeType()))); storeAttribute(attribute); } }
/** * <p>hasThresholds</p> * * @param attribute a {@link org.opennms.netmgt.collection.api.CollectionAttribute} object. * @return a boolean. */ public boolean hasThresholds(CollectionAttribute attribute) { CollectionResource resource = attribute.getResource(); if (!isCollectionEnabled(attribute.getResource())) return false; if (resource instanceof AliasedResource && !storeByIfAlias) return false; return hasThresholds(resource.getResourceTypeName(), attribute.getName()); }
/** {@inheritDoc} */ @Override public void persistNumericAttribute(CollectionAttribute attribute) { boolean shouldIgnorePersist = isIgnorePersist() && AttributeType.COUNTER.equals(attribute.getType()); LOG.debug("Persisting {} {}", attribute, (shouldIgnorePersist ? ". Ignoring value because of sysUpTime changed." : "")); Number value = shouldIgnorePersist ? Double.NaN : attribute.getNumericValue(); m_builder.setAttributeValue(attribute.getAttributeType(), value); m_builder.setAttributeMetadata(attribute.getMetricIdentifier(), attribute.getName()); }
/** {@inheritDoc} */ @Override public void visitAttribute(CollectionAttribute attribute) { pushShouldPersist(attribute); if (shouldPersist()) { final RrdPersistOperationBuilder builder = createBuilder(attribute.getResource(), attribute.getName(), Collections.singleton(attribute.getAttributeType())); builder.setAttributeMetadata("GROUP", m_group); setBuilder(builder); storeAttribute(attribute); } }
/** {@inheritDoc} */ @Override public void visitAttribute(CollectionAttribute attribute) { pushShouldPersist(attribute); if (shouldPersist()) { final RrdPersistOperationBuilder builder = createBuilder(attribute.getResource(), attribute.getName(), Collections.singleton(attribute.getAttributeType())); builder.setAttributeMetadata("GROUP", m_group); setBuilder(builder); storeAttribute(attribute); } }
private void addGroupToBuilder(CollectionSetBuilder builder, Resource resource, AttributeGroup group) { for (CollectionAttribute attribute : group.getAttributes()) { String value; if(!attribute.shouldPersist(params)){ continue; } else if (attribute.getAttributeType() instanceof HexStringAttributeType) { value = ((SnmpAttribute) attribute).getValue().toHexString(); } else { value = attribute.getStringValue(); } builder.withAttribute(resource, group.getName(), attribute.getName(), value, attribute.getType()); } } }
/** {@inheritDoc} */ @Override public void visitGroup(AttributeGroup group) { pushShouldPersist(group); if (shouldPersist()) { Map<String, String> dsNamesToRrdNames = new LinkedHashMap<String , String>(); for (CollectionAttribute a : group.getAttributes()) { if (a.getType().isNumeric()) { dsNamesToRrdNames.put(a.getName(), group.getName()); } } setBuilder(createBuilder(group.getResource(), group.getName(), group.getGroupType().getAttributeTypes())); ResourcePath path = ResourceTypeUtils.getResourcePathWithRepository(getRepository(), group.getResource().getPath()); m_resourceStorageDao.updateMetricToResourceMappings(path, dsNamesToRrdNames); } }
/** {@inheritDoc} */ @Override public void visitGroup(AttributeGroup group) { pushShouldPersist(group); if (shouldPersist()) { Map<String, String> dsNamesToRrdNames = new LinkedHashMap<String , String>(); for (CollectionAttribute a : group.getAttributes()) { if (a.getType().isNumeric()) { dsNamesToRrdNames.put(a.getName(), group.getName()); } } setBuilder(createBuilder(group.getResource(), group.getName(), group.getGroupType().getAttributeTypes())); ResourcePath path = ResourceTypeUtils.getResourcePathWithRepository(getRepository(), group.getResource().getPath()); m_resourceStorageDao.updateMetricToResourceMappings(path, dsNamesToRrdNames); } }
/** * Test for bug #1817 where a string attribute will get persisted to * both strings.properties and an RRD file if it is a numeric value. */ @Test public void testPersistStringAttributeUsingBuilder() throws Exception { initPersister(); File nodeDir = m_fileAnticipator.expecting(getSnmpRrdDirectory(), m_node.getId().toString()); m_fileAnticipator.expecting(nodeDir, RrdResourceAttributeUtils.STRINGS_PROPERTIES_FILE_NAME); CollectionAttribute attribute = buildStringAttribute(); m_persister.pushShouldPersist(attribute.getResource()); m_persister.pushShouldPersist(attribute); m_persister.setBuilder(m_persister.createBuilder(attribute.getResource(), attribute.getName(), Sets.newHashSet(attribute.getAttributeType()))); // This will end up calling m_persister.persistStringAttribute(attribute); m_persister.storeAttribute(attribute); m_persister.commitBuilder(); m_persister.popShouldPersist(); }