Search in sources :

Example 66 with Resource

use of org.opennms.newts.api.Resource in project opennms by OpenNMS.

the class NewtsResourceStorageDao method setStringAttribute.

@Override
public void setStringAttribute(ResourcePath path, String key, String value) {
    // Create a mock sample referencing the resource
    Map<String, String> attributes = new ImmutableMap.Builder<String, String>().put(key, value).build();
    Resource resource = new Resource(toResourceId(path), Optional.of(attributes));
    Sample sample = NewtsUtils.createSampleForIndexingStrings(m_context, resource);
    // Index, but do not insert the sample(s)
    // The key/value pair specified in the attributes map will be merged with the others.
    m_newtsWriter.index(Lists.newArrayList(sample));
}
Also used : Sample(org.opennms.newts.api.Sample) Resource(org.opennms.newts.api.Resource)

Example 67 with Resource

use of org.opennms.newts.api.Resource in project opennms by OpenNMS.

the class NewtsPersistOperationBuilder method getSamplesToIndex.

public List<Sample> getSamplesToIndex() {
    final List<Sample> samples = Lists.newLinkedList();
    // Convert string attributes to samples
    for (Entry<ResourcePath, Map<String, String>> entry : m_stringAttributesByPath.entrySet()) {
        Resource resource = new Resource(toResourceId(entry.getKey()), Optional.of(entry.getValue()));
        samples.add(NewtsUtils.createSampleForIndexingStrings(m_context, resource));
    }
    return samples;
}
Also used : ResourcePath(org.opennms.netmgt.model.ResourcePath) Sample(org.opennms.newts.api.Sample) Resource(org.opennms.newts.api.Resource) Map(java.util.Map)

Aggregations

Resource (org.opennms.newts.api.Resource)67 Test (org.junit.Test)50 Row (org.opennms.newts.api.Results.Row)35 ResultDescriptor (org.opennms.newts.api.query.ResultDescriptor)31 MeasurementRowsBuilder (org.opennms.newts.aggregate.Utils.MeasurementRowsBuilder)20 SampleRowsBuilder (org.opennms.newts.aggregate.Utils.SampleRowsBuilder)20 Sample (org.opennms.newts.api.Sample)19 Measurement (org.opennms.newts.api.Measurement)14 Context (org.opennms.newts.api.Context)12 MetricRegistry (com.codahale.metrics.MetricRegistry)9 SearchResults (org.opennms.newts.api.search.SearchResults)8 Timestamp (org.opennms.newts.api.Timestamp)7 ResourcePath (org.opennms.netmgt.model.ResourcePath)6 ContextConfigurations (org.opennms.newts.cassandra.ContextConfigurations)6 Map (java.util.Map)5 Results (org.opennms.newts.api.Results)5 CassandraSession (org.opennms.newts.cassandra.CassandraSession)5 ResultSetFuture (com.datastax.driver.core.ResultSetFuture)4 List (java.util.List)4 Result (org.opennms.newts.api.search.SearchResults.Result)4