/** * <p>getInstance</p> * * @return a {@link java.lang.String} object. */ public String getInstance() { return m_resource != null ? m_resource.getInstance() : null; }
/** {@inheritDoc} */ @Override public String getInstance() { return m_wrapped.getInstance(); }
/** {@inheritDoc} */ @Override public String getResourceNameFromIndex(CollectionResource resource) { // Use the instance value as the name of the resource return resource.getInstance(); }
@Override public String getResourceNameFromIndex(CollectionResource resource) { // Normalize the resource's instance and use it as resource's label return resource.getInstance().replaceAll("\\s+", "_").replaceAll(":", "_").replaceAll("\\\\", "_").replaceAll("[\\[\\]]", "_").replaceAll("[|/]", "_").replaceAll("=", "").replaceAll("[_]+$", "").replaceAll("___", "_"); }
@Override public String getResourceNameFromIndex(CollectionResource resource) { // Normalize the resource's instance and use it as resource's label return resource.getInstance().replaceAll("\\s+", "_").replaceAll(":", "_").replaceAll("\\\\", "_").replaceAll("[\\[\\]]", "_").replaceAll("[|/]", "_").replaceAll("=", "").replaceAll("[_]+$", "").replaceAll("___", "_"); }
/** * <p>toString</p> * * @return a {@link java.lang.String} object. */ @Override public String toString() { if (m_resource.getInstance() == null) { return String.format("%s for [%s]@%s", m_groupType, CollectionResource.RESOURCE_TYPE_NODE, m_resource.getParent()); } else { return String.format("%s for %s@%s", m_groupType, m_resource.getInstance(), m_resource.getParent()); } }
/** {@inheritDoc} */ @Override public String getResourceNameFromIndex(CollectionResource resource) { LOG.debug("Finding the value of sibling column {} for resource {}@{}", m_siblingColumnName, resource.getInstance(), resource.getParent()); StringAttributeVisitor visitor = new StringAttributeVisitor(m_siblingColumnName); resource.visit(visitor); String value = (visitor.getValue() != null ? visitor.getValue() : resource.getInstance()); // First remove all non-US-ASCII characters and turn all forward slashes into dashes String name = value.replaceAll("[^\\x00-\\x7F]", "").replaceAll("/", "-"); // Then perform all replacement operations specified in the parameters for (StringReplaceOperation op : m_replaceOps) { LOG.debug("Doing string replacement on instance name '{}' using {}", name, op); name = op.replace(name); } LOG.debug("Inbound instance name was '{}', outbound was '{}'", resource.getInstance(), ("".equals(name) ? resource.getInstance() : name)); return ("".equals(name) ? resource.getInstance() : name); }
/** {@inheritDoc} */ @Override public String getResourceNameFromIndex(CollectionResource resource) { StringTokenizer indexes = new StringTokenizer(resource.getInstance(), "."); String ifIndex = indexes.nextToken(); String ifName = getInterfaceName(resource.getParent().getName(), ifIndex); String dlci = indexes.nextToken(); return ifName + "." + dlci; }
/** * 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 updateContext(JexlContext context, CollectionResource resource) { try { ObjectName oname = new ObjectName(resource.getInstance()); context.set("ObjectName", oname); context.set("domain", oname.getDomain() == null ? "" : oname.getDomain()); oname.getKeyPropertyList().entrySet().forEach((entry) -> { final String value = entry.getValue(); if (value.startsWith(QUOTE) && value.endsWith(QUOTE)) { context.set(entry.getKey(), ObjectName.unquote(entry.getValue())); } else { context.set(entry.getKey(), entry.getValue()); } }); } catch (javax.management.MalformedObjectNameException e) { LOG.debug("getResourceNameFromIndex(): malformed object name: {}", resource.getInstance(), e); } } }
/** * 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; }
/** {@inheritDoc} */ @Override public String getResourceNameFromIndex(CollectionResource resource) { StringAttributeVisitor visitor = new StringAttributeVisitor(HR_STORAGE_DESC); resource.visit(visitor); String value = (visitor.getValue() != null ? visitor.getValue() : resource.getInstance()); /* * Use special translation for root (base) filesystem */ if (value.equals("/")) return "_root_fs"; /* * 1. Eliminate first slash character * 2. Eliminate tabs and spaces on filesystem names * 3. Replace slash (file separator) character with "-" * 4. Remove Additional Information on Windows Drives */ return value.replaceFirst("/", "").replaceAll("\\s", "").replaceAll("/", "-").replaceAll(":\\\\.*", ""); }
/** {@inheritDoc} */ @Override public String getResourceNameFromIndex(CollectionResource resource) { String resourceName = null; try { UnifiedJEXL.Expression expr = EL.parse( m_parameters.get(PARAM_INDEX_FORMAT) ); JexlContext context = new MapContext(); m_parameters.entrySet().forEach((entry) -> { context.set(entry.getKey(), entry.getValue()); }); updateContext(context, resource); resourceName = (String) expr.evaluate(new ReadonlyContext(context)); } catch (JexlException e) { LOG.error("getResourceNameFromIndex(): error evaluating index-format [{}] as a Jexl Expression", m_parameters.get(PARAM_INDEX_FORMAT), e); } finally { if (resourceName == null) { resourceName = resource.getInstance(); } } if ("true".equals(m_parameters.get(PARAM_CLEAN_OUTPUT)) && resourceName != null) { resourceName = resourceName.replaceAll("\\s+", "_").replaceAll(":", "_").replaceAll("\\\\", "_").replaceAll("[\\[\\]]", "_").replaceAll("[|/]", "_").replaceAll("=", "").replaceAll("[_]+$", "").replaceAll("___", "_"); } LOG.debug("getResourceNameFromIndex(): {}", resourceName); return resourceName; }
@Override public String getMetricIdentifier() { String instance = m_resource.getInstance(); SnmpAttributeType type = (SnmpAttributeType)m_attribType; if (instance == null) { instance = type.getInstance(); } return "SNMP_"+SnmpObjId.get(type.getSnmpObjId(), instance); }
m_ifInfo.putAll(IfLabelDaoImpl.getInstance().getInterfaceInfoFromIfLabel(getNodeId(), m_iflabel)); } else { LOG.info("Can't find ifLabel for latency resource {} on node {}", resource.getInstance(), getNodeId());
genericResourceBuilder.setNode(nodeResourceBuilder); genericResourceBuilder.setType(resource.getResourceTypeName()); genericResourceBuilder.setInstance(resource.getInstance()); collectionSetResourceBuilder.setGeneric(genericResourceBuilder);
genericResourceBuilder.setNode(nodeResourceBuilder); genericResourceBuilder.setType(resource.getResourceTypeName()); genericResourceBuilder.setInstance(resource.getInstance()); collectionSetResourceBuilder.setGeneric(genericResourceBuilder);