Search in sources :

Example 31 with ResultDescriptor

use of org.opennms.newts.api.query.ResultDescriptor in project newts by OpenNMS.

the class PrimaryDataTest method testLeadingSamplesMiss.

@Test
public void testLeadingSamplesMiss() {
    // Missing a couple leading samples
    Iterator<Row<Sample>> testData = new SampleRowsBuilder(new Resource("localhost"), MetricType.GAUGE).row(900000300).element("m0", 0).row(900000600).element("m0", 1).row(900000900).element("m0", 2).row(900001200).element("m0", 3).build();
    ResultDescriptor rDescriptor = new ResultDescriptor(Duration.seconds(300)).datasource("m0", "m0", Duration.seconds(600), null);
    // Expected results
    Iterator<Row<Measurement>> expected = new MeasurementRowsBuilder(new Resource("localhost")).row(900000000).element("m0", Double.NaN).row(900000300).element("m0", Double.NaN).row(900000600).element("m0", 1).row(900000900).element("m0", 2).row(900001200).element("m0", 3).build();
    PrimaryData primaryData = new PrimaryData(new Resource("localhost"), Timestamp.fromEpochSeconds(900000000), Timestamp.fromEpochSeconds(900001200), rDescriptor, testData);
    assertRowsEqual(expected, primaryData);
}
Also used : MeasurementRowsBuilder(org.opennms.newts.aggregate.Utils.MeasurementRowsBuilder) Resource(org.opennms.newts.api.Resource) ResultDescriptor(org.opennms.newts.api.query.ResultDescriptor) Row(org.opennms.newts.api.Results.Row) SampleRowsBuilder(org.opennms.newts.aggregate.Utils.SampleRowsBuilder) Test(org.junit.Test)

Example 32 with ResultDescriptor

use of org.opennms.newts.api.query.ResultDescriptor in project newts by OpenNMS.

the class PrimaryDataTest method testOneToManySamples.

@Test
public void testOneToManySamples() {
    // Actual sample interval is smaller than step size; One sample is mapped to many measurements
    Iterator<Row<Sample>> testData = new SampleRowsBuilder(new Resource("localhost"), MetricType.GAUGE).row(0).element("m0", 0).element("m1", 1).row(900).element("m0", 1).element("m1", 2).row(1800).element("m0", 2).element("m1", 3).build();
    // Minimal result descriptor
    ResultDescriptor rDescriptor = new ResultDescriptor().step(Duration.seconds(300)).datasource("m0", "m0", Duration.seconds(1000), null).datasource("m1", "m1", Duration.seconds(1000), null);
    // Expected results
    Iterator<Row<Measurement>> expected = new MeasurementRowsBuilder(new Resource("localhost")).row(300).element("m0", 1).element("m1", 2).row(600).element("m0", 1).element("m1", 2).row(900).element("m0", 1).element("m1", 2).row(1200).element("m0", 2).element("m1", 3).row(1500).element("m0", 2).element("m1", 3).row(1800).element("m0", 2).element("m1", 3).build();
    PrimaryData primaryData = new PrimaryData(new Resource("localhost"), Timestamp.fromEpochSeconds(300), Timestamp.fromEpochSeconds(1800), rDescriptor, testData);
    assertRowsEqual(expected, primaryData);
}
Also used : MeasurementRowsBuilder(org.opennms.newts.aggregate.Utils.MeasurementRowsBuilder) Resource(org.opennms.newts.api.Resource) ResultDescriptor(org.opennms.newts.api.query.ResultDescriptor) Row(org.opennms.newts.api.Results.Row) SampleRowsBuilder(org.opennms.newts.aggregate.Utils.SampleRowsBuilder) Test(org.junit.Test)

Example 33 with ResultDescriptor

use of org.opennms.newts.api.query.ResultDescriptor in project newts by OpenNMS.

the class PrimaryDataTest method testVeryShortSamples.

@Test
public void testVeryShortSamples() {
    // Samples occur prior to the nearest step interval boundary.
    Iterator<Row<Sample>> testData = new SampleRowsBuilder(new Resource("localhost"), MetricType.GAUGE).row(000).element("m0", 0).element("m1", 1).row(250).element("m0", 1).element("m1", 2).row(550).element("m0", 2).element("m1", 3).row(850).element("m0", 3).element("m1", 4).build();
    // Minimal result descriptor
    ResultDescriptor rDescriptor = new ResultDescriptor().step(Duration.seconds(300)).datasource("m0", "m0", Duration.seconds(600), null).datasource("m1", "m1", Duration.seconds(600), null);
    // Expected results
    Iterator<Row<Measurement>> expected = new MeasurementRowsBuilder(new Resource("localhost")).row(300).element("m0", 1.16666667).element("m1", 2.16666667).row(600).element("m0", 2.16666667).element("m1", 3.16666667).row(900).element("m0", 3.0).element("m1", 4.0).row(1200).element("m0", Double.NaN).element("m1", Double.NaN).row(1500).element("m0", Double.NaN).element("m1", Double.NaN).build();
    PrimaryData primaryData = new PrimaryData(new Resource("localhost"), Timestamp.fromEpochSeconds(300), Timestamp.fromEpochSeconds(1500), rDescriptor, testData);
    assertRowsEqual(expected, primaryData);
}
Also used : MeasurementRowsBuilder(org.opennms.newts.aggregate.Utils.MeasurementRowsBuilder) Resource(org.opennms.newts.api.Resource) ResultDescriptor(org.opennms.newts.api.query.ResultDescriptor) Row(org.opennms.newts.api.Results.Row) SampleRowsBuilder(org.opennms.newts.aggregate.Utils.SampleRowsBuilder) Test(org.junit.Test)

Aggregations

ResultDescriptor (org.opennms.newts.api.query.ResultDescriptor)33 Resource (org.opennms.newts.api.Resource)30 Row (org.opennms.newts.api.Results.Row)29 Test (org.junit.Test)28 MeasurementRowsBuilder (org.opennms.newts.aggregate.Utils.MeasurementRowsBuilder)20 SampleRowsBuilder (org.opennms.newts.aggregate.Utils.SampleRowsBuilder)17 Measurement (org.opennms.newts.api.Measurement)11 MeasurementRowsBuilder (org.opennms.newts.persistence.cassandra.Utils.MeasurementRowsBuilder)5 SampleRowsBuilder (org.opennms.newts.persistence.cassandra.Utils.SampleRowsBuilder)5 Timed (com.codahale.metrics.annotation.Timed)1 Path (java.nio.file.Path)1 Callable (java.util.concurrent.Callable)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Source (org.opennms.netmgt.measurements.model.Source)1 OnmsResource (org.opennms.netmgt.model.OnmsResource)1 ResourcePath (org.opennms.netmgt.model.ResourcePath)1 Context (org.opennms.newts.api.Context)1 Duration (org.opennms.newts.api.Duration)1 Results (org.opennms.newts.api.Results)1