/** {@inheritDoc} */ @Override public String getStringValue() { return m_wrapped.getStringValue(); }
/** * 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; }
/** * 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; }
@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); } }
/** {@inheritDoc} */ @Override public void persistStringAttribute(CollectionAttribute attribute) { LOG.debug("Persisting {}", attribute); CollectionResource resource = attribute.getResource(); String value = attribute.getStringValue(); if (value == null) { LOG.info("No data collected for attribute {}. Skipping.", attribute); return; } try { ResourcePath path = ResourceTypeUtils.getResourcePathWithRepository(m_repository, resource.getPath()); persistStringAttribute(path, attribute.getName(), value); } catch(PersistException e) { LOG.error("Unable to save string attribute {}.", attribute, e); } }
if (groupType != null) { MibPropertyAttributeType type = new MibPropertyAttributeType(targetResource.getResourceType(), property, groupType); SnmpValue value = SnmpUtils.getValueFactory().getOctetString(target.get().getStringValue().getBytes()); return new SnmpAttribute(targetResource, type, value);
@Override public void visitAttribute(CollectionAttribute attribute) { if (!attribute.getType().isNumeric()) { context.setVariable(attribute.getName(), attribute.getStringValue()); } }
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()); } } }
@Override public void visitAttribute(CollectionAttribute attribute) { if (attribute.getType().equals(AttributeType.STRING)) { CollectionSetProtos.StringAttribute.Builder attributeBuilder = CollectionSetProtos.StringAttribute .newBuilder(); attributeBuilder.setValue(attribute.getStringValue()); attributeBuilder.setName(attribute.getName()); collectionSetResourceBuilder.addString(attributeBuilder); } else { CollectionSetProtos.NumericAttribute.Builder attributeBuilder = CollectionSetProtos.NumericAttribute .newBuilder(); attributeBuilder.setGroup(lastGroupName); attributeBuilder.setName(attribute.getName()); attributeBuilder.setValue(attribute.getNumericValue().longValue()); attributeBuilder.setType((attribute.getType() == AttributeType.GAUGE) ? Type.GAUGE : Type.COUNTER); collectionSetResourceBuilder.addNumeric(attributeBuilder); } }
@Override public void visitAttribute(CollectionAttribute attribute) { if (attribute.getType().equals(AttributeType.STRING)) { CollectionSetProtos.StringAttribute.Builder attributeBuilder = CollectionSetProtos.StringAttribute .newBuilder(); attributeBuilder.setValue(attribute.getStringValue()); attributeBuilder.setName(attribute.getName()); collectionSetResourceBuilder.addString(attributeBuilder); } else { CollectionSetProtos.NumericAttribute.Builder attributeBuilder = CollectionSetProtos.NumericAttribute .newBuilder(); attributeBuilder.setGroup(lastGroupName); attributeBuilder.setName(attribute.getName()); attributeBuilder.setValue(attribute.getNumericValue().longValue()); attributeBuilder.setType((attribute.getType() == AttributeType.GAUGE) ? Type.GAUGE : Type.COUNTER); collectionSetResourceBuilder.addNumeric(attributeBuilder); } }