AbstractTSDBService extends DefaultService implements TSDBService { static void addToWrapperList(List<Map<String, AnnotationWrapper>> wrapperList, AnnotationWrapper wrapper) { Boolean addedWrapper = false; for(Map<String, AnnotationWrapper> wrapperMap : wrapperList) { if(!wrapperMap.containsKey(wrapper._uid)) { wrapperMap.put(wrapper._uid, wrapper); addedWrapper = true; break; } } if(!addedWrapper) { Map<String, AnnotationWrapper> wrapperMap = new HashMap<>(); wrapperMap.put(wrapper._uid, wrapper); wrapperList.add(wrapperMap); addedWrapper = true; } } @Inject  AbstractTSDBService(SystemConfiguration config, MonitorService monitorService); static String constructTSDBMetricName(Metric metric); static String constructTSDBMetricName(Histogram histogram); static String getMetricFromTSDBMetric(String tsdbMetricName); static String getScopeFromTSDBMetric(String tsdbMetricName); static String getNamespaceFromTSDBMetric(String tsdbMetricName); @Override void dispose(); @Override void putMetrics(List<Metric> metrics); @Override void putHistograms(List<Histogram> histograms); @Override void putAnnotations(List<Annotation> annotations); @Override Properties getServiceProperties(); @Override Map<MetricQuery, List<Metric>> getMetrics(List<MetricQuery> queries); @Override List<Annotation> getAnnotations(List<AnnotationQuery> queries);  }
@Test public void testWrapperListUsedInBatching() { List<Map<String, AbstractTSDBService.AnnotationWrapper>> wrapperList = new ArrayList<>(); AbstractTSDBService.AnnotationWrapper wrapper1 = new AbstractTSDBService.AnnotationWrapper("1", _constructAnnotation('1')); AbstractTSDBService.AnnotationWrapper wrapper2 = new AbstractTSDBService.AnnotationWrapper("1", _constructAnnotation('2')); AbstractTSDBService.AnnotationWrapper wrapper3 = new AbstractTSDBService.AnnotationWrapper("2", _constructAnnotation('3')); AbstractTSDBService.AnnotationWrapper wrapper4 = new AbstractTSDBService.AnnotationWrapper("3", _constructAnnotation('2')); AbstractTSDBService.addToWrapperList(wrapperList, wrapper1); AbstractTSDBService.addToWrapperList(wrapperList, wrapper2); AbstractTSDBService.addToWrapperList(wrapperList, wrapper3); AbstractTSDBService.addToWrapperList(wrapperList, wrapper4); assertEquals(wrapperList.get(0).size(), 3); assertEquals(wrapperList.get(1).size(), 1); }