use of org.opennms.newts.api.search.SearchResults.Result in project opennms by OpenNMS.
the class NewtsResourceStorageDao method getAttributes.
@Override
public Set<OnmsAttribute> getAttributes(ResourcePath path) {
Set<OnmsAttribute> attributes = Sets.newHashSet();
// Fetch the resource-level attributes in parallel
Future<Map<String, String>> stringAttributes = ForkJoinPool.commonPool().submit(getResourceAttributesCallable(path));
// Gather the list of metrics available under the resource path
SearchResults results = searchFor(path, 0, true);
for (Result result : results) {
final String resourceId = result.getResource().getId();
final ResourcePath resultPath = toResourcePath(resourceId);
if (!path.equals(resultPath)) {
// This shouldn't happen
LOG.warn("Encountered non-child resource {} when searching for {} with depth {}. Ignoring resource.", result.getResource(), path, 0);
continue;
}
for (String metric : result.getMetrics()) {
// Use the metric name as the dsName
// Store the resource id in the rrdFile field
attributes.add(new RrdGraphAttribute(metric, "", resourceId));
}
}
// Add the resource level attributes to the result set
try {
stringAttributes.get().entrySet().stream().map(e -> new StringPropertyAttribute(e.getKey(), e.getValue())).forEach(attr -> attributes.add(attr));
} catch (InterruptedException | ExecutionException e) {
throw Throwables.propagate(e);
}
return attributes;
}
use of org.opennms.newts.api.search.SearchResults.Result in project opennms by OpenNMS.
the class NewtsResourceStorageDao method delete.
@Override
public boolean delete(ResourcePath path) {
final SearchResults results = searchFor(path, 0, true);
if (results.isEmpty()) {
return false;
}
for (final Result result : results) {
m_sampleRepository.delete(m_context, result.getResource());
m_indexer.delete(m_context, result.getResource());
}
return true;
}
Aggregations