use of wavefront.report.ReportPoint in project java by wavefrontHQ.
the class PreprocessorRulesTest method testPointInRangeCorrectForTimeRanges.
@Test
public void testPointInRangeCorrectForTimeRanges() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
long millisPerYear = 31536000000L;
long millisPerDay = 86400000L;
long millisPerHour = 3600000L;
AnnotatedPredicate<ReportPoint> pointInRange1year = new ReportPointTimestampInRangeFilter(8760, 24);
// not in range if over a year ago
ReportPoint rp = new ReportPoint("some metric", System.currentTimeMillis() - millisPerYear, 10L, "host", "table", new HashMap<>());
Assert.assertFalse(pointInRange1year.apply(rp));
rp.setTimestamp(System.currentTimeMillis() - millisPerYear - 1);
Assert.assertFalse(pointInRange1year.apply(rp));
// in range if within a year ago
rp.setTimestamp(System.currentTimeMillis() - (millisPerYear / 2));
Assert.assertTrue(pointInRange1year.apply(rp));
// in range for right now
rp.setTimestamp(System.currentTimeMillis());
Assert.assertTrue(pointInRange1year.apply(rp));
// in range if within a day in the future
rp.setTimestamp(System.currentTimeMillis() + millisPerDay - 1);
Assert.assertTrue(pointInRange1year.apply(rp));
// out of range for over a day in the future
rp.setTimestamp(System.currentTimeMillis() + (millisPerDay * 2));
Assert.assertFalse(pointInRange1year.apply(rp));
// now test with 1 day limit
AnnotatedPredicate<ReportPoint> pointInRange1day = new ReportPointTimestampInRangeFilter(24, 24);
rp.setTimestamp(System.currentTimeMillis() - millisPerDay - 1);
Assert.assertFalse(pointInRange1day.apply(rp));
// in range if within 1 day ago
rp.setTimestamp(System.currentTimeMillis() - (millisPerDay / 2));
Assert.assertTrue(pointInRange1day.apply(rp));
// in range for right now
rp.setTimestamp(System.currentTimeMillis());
Assert.assertTrue(pointInRange1day.apply(rp));
// assert for future range within 12 hours
AnnotatedPredicate<ReportPoint> pointInRange12hours = new ReportPointTimestampInRangeFilter(12, 12);
rp.setTimestamp(System.currentTimeMillis() + (millisPerHour * 10));
Assert.assertTrue(pointInRange12hours.apply(rp));
rp.setTimestamp(System.currentTimeMillis() - (millisPerHour * 10));
Assert.assertTrue(pointInRange12hours.apply(rp));
rp.setTimestamp(System.currentTimeMillis() + (millisPerHour * 20));
Assert.assertFalse(pointInRange12hours.apply(rp));
rp.setTimestamp(System.currentTimeMillis() - (millisPerHour * 20));
Assert.assertFalse(pointInRange12hours.apply(rp));
AnnotatedPredicate<ReportPoint> pointInRange10Days = new ReportPointTimestampInRangeFilter(240, 240);
rp.setTimestamp(System.currentTimeMillis() + (millisPerDay * 9));
Assert.assertTrue(pointInRange10Days.apply(rp));
rp.setTimestamp(System.currentTimeMillis() - (millisPerDay * 9));
Assert.assertTrue(pointInRange10Days.apply(rp));
rp.setTimestamp(System.currentTimeMillis() + (millisPerDay * 20));
Assert.assertFalse(pointInRange10Days.apply(rp));
rp.setTimestamp(System.currentTimeMillis() - (millisPerDay * 20));
Assert.assertFalse(pointInRange10Days.apply(rp));
}
use of wavefront.report.ReportPoint in project java by wavefrontHQ.
the class PreprocessorRulesTest method applyAllTransformers.
private String applyAllTransformers(String pointLine, String strPort) {
String transformedPointLine = config.forPort(strPort).forPointLine().transform(pointLine);
ReportPoint point = parsePointLine(transformedPointLine);
config.forPort(strPort).forReportPoint().transform(point);
return referencePointToStringImpl(point);
}
use of wavefront.report.ReportPoint in project java by wavefrontHQ.
the class PreprocessorRulesTest method parsePointLine.
private ReportPoint parsePointLine(String pointLine) {
List<ReportPoint> points = Lists.newArrayListWithExpectedSize(1);
decoder.decodeReportPoints(pointLine, points, "dummy");
ReportPoint point = points.get(0);
// convert annotations to TreeMap so the result is deterministic
point.setAnnotations(new TreeMap<>(point.getAnnotations()));
return point;
}
use of wavefront.report.ReportPoint in project java by wavefrontHQ.
the class PointHandlerDispatcherTest method setup.
@Before
public void setup() {
timeMillis = new AtomicLong(0L);
backingStore = new ConcurrentHashMap<>();
in = new AccumulationCache(backingStore, 0, timeMillis::get);
pointOut = new LinkedList<>();
debugLineOut = new LinkedList<>();
blockedOut = new LinkedList<>();
digestA = new AgentDigest(COMPRESSION, 100L);
digestB = new AgentDigest(COMPRESSION, 1000L);
subject = new PointHandlerDispatcher(in, new PointHandler() {
@Override
public void reportPoint(ReportPoint point, String debugLine) {
pointOut.add(point);
debugLineOut.add(debugLine);
}
@Override
public void reportPoints(List<ReportPoint> points) {
pointOut.addAll(points);
}
@Override
public void handleBlockedPoint(String pointLine) {
blockedOut.add(pointLine);
}
}, timeMillis::get, null);
}
use of wavefront.report.ReportPoint in project java by wavefrontHQ.
the class TapeDispatcherTest method testOnlyRipeEntriesAreDispatched.
@Test
public void testOnlyRipeEntriesAreDispatched() {
in.put(keyA, digestA);
in.put(keyB, digestB);
timeMillis.set(101L);
subject.run();
assertThat(out.size()).isEqualTo(1);
assertThat(in).containsEntry(keyB, digestB);
ReportPoint point = out.peek();
TestUtils.testKeyPointMatch(keyA, point);
}
Aggregations