/** {@inheritDoc} */ @Override public ResourcePath getPath() { return m_wrapped.getPath(); }
/** * Sets the last timestamp. * * @param resource the resource * @param timestamp the timestamp */ private void setLastTimestamp(CollectionResource resource, long timestamp) { ResourcePath path = ResourceTypeUtils.getResourcePathWithRepository(m_repository, resource.getPath()); LOG.debug("Setting timestamp to {} at path {}", timestamp, path); m_resourceStorageDao.setStringAttribute(path, LAST_TIMESTAMP, Long.toString(timestamp)); } }
/** * Gets the last timestamp. * * @param resource the TCA resource * @return the last timestamp */ private long getLastTimestamp(CollectionResource resource) { long timestamp = 0; ResourcePath path = ResourceTypeUtils.getResourcePathWithRepository(m_repository, resource.getPath()); try { LOG.debug("Retrieving timestamp from path {}", path); String ts = m_resourceStorageDao.getStringAttribute(path, LAST_TIMESTAMP); if (ts != null) { timestamp = Long.parseLong(ts); } } catch (Exception e) { LOG.error("Failed to retrieve timestamp from path {}", path, e); } return timestamp; }
@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())); } });
/** {@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); } }
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; }
/** {@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); } }