ElasticSearchAnnotationService extends DefaultService implements AnnotationStorageService { protected void convertTimestampToMillis(AnnotationQuery query) { long queryStart = query.getStartTimestamp(); long queryEnd = query.getEndTimestamp(); if (queryStart < 100000000000L) query.setStartTimestamp(queryStart * 1000); if (queryEnd < 100000000000L) query.setEndTimestamp(queryEnd * 1000); } @Inject  ElasticSearchAnnotationService(SystemConfiguration config, MonitorService monitorService, ElasticSearchUtils esUtils); @Override void dispose(); @Override void putAnnotations(List<Annotation> annotations); @Override List<Annotation> getAnnotations(List<AnnotationQuery> queries); static final int ANNOTATION_INDEX_MAX_RESULT_WINDOW; static String ANNOTATION_INDEX_TEMPLATE_PATTERN_START; }
@Test public void testConvertTimestampToMillis(){ AnnotationQuery annotationQuery = new AnnotationQuery("scope1", "metric1", null, "unittest", 1557809359073L, 1557809599073L); esAnnotationService.convertTimestampToMillis(annotationQuery); assertEquals(1557809359073L, annotationQuery.getStartTimestamp().longValue()); assertEquals(1557809599073L, annotationQuery.getEndTimestamp().longValue()); annotationQuery = new AnnotationQuery("scope1", "metric1", null, "unittest", 1557809359L, 1557809599L); esAnnotationService.convertTimestampToMillis(annotationQuery); assertEquals(1557809359000L, annotationQuery.getStartTimestamp().longValue()); assertEquals(1557809599000L, annotationQuery.getEndTimestamp().longValue()); annotationQuery = new AnnotationQuery("scope1", "metric1", null, "unittest", 1557809359123L, 1557809599L); esAnnotationService.convertTimestampToMillis(annotationQuery); assertEquals(1557809359123L, annotationQuery.getStartTimestamp().longValue()); assertEquals(1557809599000L, annotationQuery.getEndTimestamp().longValue()); annotationQuery = new AnnotationQuery("scope1", "metric1", null, "unittest", 1557809359L, 1557809599456L); esAnnotationService.convertTimestampToMillis(annotationQuery); assertEquals(1557809359000L, annotationQuery.getStartTimestamp().longValue()); assertEquals(1557809599456L, annotationQuery.getEndTimestamp().longValue()); }