use of org.spf4j.tsdb2.avro.Observation in project spf4j by zolyfarkas.
the class RecorderFactoryTest method testCreateScalableQuantizedRecorder.
/**
* Test of createScalableQuantizedRecorder method, of class RecorderFactory.
*/
@Test
public void testCreateScalableQuantizedRecorder() throws IOException, InterruptedException {
String forWhat = "test1";
String unitOfMeasurement = "ms";
int sampleTime = 1000;
int factor = 10;
int lowerMagnitude = 0;
int higherMagnitude = 3;
int quantasPerMagnitude = 10;
CloseableMeasurementRecorder result = RecorderFactory.createScalableQuantizedRecorder2(forWhat, unitOfMeasurement, sampleTime, factor, lowerMagnitude, higherMagnitude, quantasPerMagnitude);
for (int i = 0; i < 500; i++) {
result.record(i);
Thread.sleep(20);
}
result.close();
assertData(forWhat, 124750);
MeasurementStore store = ProcessMeasurementStore.getMeasurementStore();
MeasurementStoreQuery query = store.query();
Collection<Schema> measurements = query.getMeasurements((x) -> forWhat.equals(x));
Schema m = measurements.iterator().next();
try (AvroCloseableIterable<Observation> observations = query.getObservations(m, Instant.EPOCH, Instant.now())) {
for (Observation o : observations) {
LOG.debug("RAW Obeservation", o);
}
}
try (AvroCloseableIterable<Observation> observations = query.getAggregatedObservations(m, Instant.EPOCH, Instant.now(), 2, TimeUnit.SECONDS)) {
for (Observation o : observations) {
LOG.debug("AGG Obeservation", o);
}
}
}
Aggregations