/** {@inheritDoc} */ @Override public ResourcePath getParent() { return m_wrapped.getParent(); }
/** * <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()); } }
private String getNodeCriteriaFromResource(CollectionResource resource) { String nodeCriteria = null; if (resource.getParent() != null) { String[] resourcePathArray = resource.getParent().elements(); if (ResourceTypeUtils.FOREIGN_SOURCE_DIRECTORY.equals(resourcePathArray[0]) && resourcePathArray.length == 3) { // parent denotes nodeCriteria, form fs:fid nodeCriteria = resourcePathArray[1] + ":" + resourcePathArray[2]; } else if (checkNumeric(resourcePathArray[0])) { // parent denotes nodeId nodeCriteria = resourcePathArray[0]; } } return nodeCriteria; }
private String getNodeCriteriaFromResource(CollectionResource resource) { String nodeCriteria = null; if (resource.getParent() != null) { String[] resourcePathArray = resource.getParent().elements(); if (ResourceTypeUtils.FOREIGN_SOURCE_DIRECTORY.equals(resourcePathArray[0]) && resourcePathArray.length == 3) { // parent denotes nodeCriteria, form fs:fid nodeCriteria = resourcePathArray[1] + ":" + resourcePathArray[2]; } else if (checkNumeric(resourcePathArray[0])) { // parent denotes nodeId nodeCriteria = resourcePathArray[0]; } } return nodeCriteria; }
/** * Gets the resource id. * * @param resource the resource * @return the resource id */ protected String getResourceId(CollectionResource resource) { final StringBuilder sb = new StringBuilder(); sb.append(resource.getParent()); sb.append('/').append(resource.getResourceTypeName()); if (!CollectionResource.RESOURCE_TYPE_NODE.equals(resource.getResourceTypeName())) { sb.append('/').append(resource.getInterfaceLabel()); } return sb.toString(); } }
/** {@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; }
String parentResourceName = Integer.toString(getNodeId()); if (m_resource.getParent() != null && m_resource.getParent().toString().startsWith(ResourceTypeUtils.FOREIGN_SOURCE_DIRECTORY)) { String[] parts = m_resource.getParent().toString().split(File.separatorChar == '\\' ? "\\\\" : File.separator); if (parts.length == 3) { parentResourceTypeName = "nodeSource";
/** {@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); }
private CollectionSetProtos.ResponseTimeResource.Builder buildResponseTimeResource(CollectionResource resource) { boolean validIp = false; // Check if resource parent is an IpAddress. if (resource.getParent() != null && resource.getParent().elements().length == 1) { String[] resourcePathArray = resource.getParent().elements(); validIp = checkForValidIpAddress(resourcePathArray[0]); } if (resource.getPath() != null && validIp) { // extract path which consists of location and IpAddress. String[] resourcePathArray = resource.getPath().elements(); CollectionSetProtos.ResponseTimeResource.Builder responseTimeResourceBuilder = CollectionSetProtos.ResponseTimeResource .newBuilder(); if (resourcePathArray.length == 2) { // first element is location, 2nd IpAddress. responseTimeResourceBuilder.setLocation(resourcePathArray[0]); responseTimeResourceBuilder.setInstance(resourcePathArray[1]); } else if (resourcePathArray.length == 1) { responseTimeResourceBuilder.setInstance(resourcePathArray[0]); } return responseTimeResourceBuilder; } return null; }
private CollectionSetProtos.ResponseTimeResource.Builder buildResponseTimeResource(CollectionResource resource) { boolean validIp = false; // Check if resource parent is an IpAddress. if (resource.getParent() != null && resource.getParent().elements().length == 1) { String[] resourcePathArray = resource.getParent().elements(); validIp = checkForValidIpAddress(resourcePathArray[0]); } if (resource.getPath() != null && validIp) { // extract path which consists of location and IpAddress. String[] resourcePathArray = resource.getPath().elements(); CollectionSetProtos.ResponseTimeResource.Builder responseTimeResourceBuilder = CollectionSetProtos.ResponseTimeResource .newBuilder(); if (resourcePathArray.length == 2) { // first element is location, 2nd IpAddress. responseTimeResourceBuilder.setLocation(resourcePathArray[0]); responseTimeResourceBuilder.setInstance(resourcePathArray[1]); } else if (resourcePathArray.length == 1) { responseTimeResourceBuilder.setInstance(resourcePathArray[0]); } return responseTimeResourceBuilder; } return null; }
@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()); } }
@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()); } }