AbstractTSDBService extends DefaultService implements TSDBService { private <T> void put(List<T> objects, String endpoint, HttpMethod method, int chunkSize) throws IOException { if (objects != null) { int chunkEnd = 0; while (chunkEnd < objects.size()) { int chunkStart = chunkEnd; chunkEnd = Math.min(objects.size(), chunkStart + chunkSize); try { String createBody = fromEntity(objects.subList(chunkStart, chunkEnd)); StringEntity entity = new StringEntity(createBody); _logger.debug("createUrl {} createBody {}", endpoint, createBody); HttpResponse response = executeHttpRequest(method, endpoint, _writeHttpClient, entity); extractResponse(response); } catch (UnsupportedEncodingException ex) { throw new SystemException("Error posting data", ex); } } } } @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 testFractureMetrics() { TSDBService service = new AbstractTSDBService(system.getConfiguration(), system.getServiceFactory().getMonitorService()); Metric metric = new Metric("testscope", "testMetric"); Map<Long, Double> datapoints = new HashMap<>(); for (int i = 0; i <= 200; i++) { datapoints.put(System.currentTimeMillis() + (i * 60000L), (double)(TestUtils.random.nextInt(50))); } metric.setDatapoints(datapoints); try { Method method = AbstractTSDBService.class.getDeclaredMethod("fractureMetric", Metric.class); method.setAccessible(true); List<Metric> metricList = (List<Metric>) method.invoke(service, metric); assertEquals(3, metricList.size()); assertEquals(100, metricList.get(0).getDatapoints().size()); assertEquals(100, metricList.get(1).getDatapoints().size()); assertEquals(1, metricList.get(2).getDatapoints().size()); } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new SystemException("Failed to construct fracture metric method using reflection"); } }