@Test public void testGetBatches() { LookoutConfig config = new LookoutConfig(); AddressService addressService = new DefaultAddressService(); Registry registry = new DefaultRegistry(); HttpObserver observer = new HttpObserver(config, addressService, registry); List<LookoutMeasurement> measurements = new ArrayList<LookoutMeasurement>(); measurements.add(new LookoutMeasurement(new Date(), registry.createId("a"))); measurements.add(new LookoutMeasurement(new Date(), registry.createId("b"))); List list = observer.getBatches(measurements, 1); Assert.assertEquals(2, list.size()); }
public List<List<LookoutMeasurement>> getBatches(List<LookoutMeasurement> ms, int batchSize) { if (ms.size() <= batchSize) { return Collections.singletonList(ms); } List<List<LookoutMeasurement>> batches = new ArrayList(); for (int i = 0; i < ms.size(); i += batchSize) { List<LookoutMeasurement> batch = ms.subList(i, Math.min(ms.size(), i + batchSize)); batches.add(batch); } return batches; }
HttpObserver implements MetricObserver<LookoutMeasurement> { public List<List<LookoutMeasurement>> getBatches(List<LookoutMeasurement> ms, int batchSize) { if (ms.size() <= batchSize) { return Collections.singletonList(ms); } List<List<LookoutMeasurement>> batches = new ArrayList(); for (int i = 0; i < ms.size(); i += batchSize) { List<LookoutMeasurement> batch = ms.subList(i, Math.min(ms.size(), i + batchSize)); batches.add(batch); } return batches; } }
HttpObserver implements MetricObserver<LookoutMeasurement> { public List<List<LookoutMeasurement>> getBatches(List<LookoutMeasurement> ms, int batchSize) { if (ms.size() <= batchSize) { return Collections.singletonList(ms); } List<List<LookoutMeasurement>> batches = new ArrayList(); for (int i = 0; i < ms.size(); i += batchSize) { List<LookoutMeasurement> batch = ms.subList(i, Math.min(ms.size(), i + batchSize)); batches.add(batch); } return batches; } HttpObserver(LookoutConfig lookoutConfig, AddressService addrService);  HttpObserver(LookoutConfig lookoutConfig, AddressService addrService, Registry registry);  HttpObserver(LookoutConfig lookoutConfig, AddressService addrService, Registry registry,
                        HttpRequestProcessor requestProcessor); }
HttpObserver implements MetricObserver<LookoutMeasurement> { public List<List<LookoutMeasurement>> getBatches(List<LookoutMeasurement> ms, int batchSize) { if (ms.size() <= batchSize) { return Collections.singletonList(ms); } List<List<LookoutMeasurement>> batches = new ArrayList(); for (int i = 0; i < ms.size(); i += batchSize) { List<LookoutMeasurement> batch = ms.subList(i, Math.min(ms.size(), i + batchSize)); batches.add(batch); } return batches; } HttpObserver(LookoutConfig lookoutConfig, AddressService addrService);  HttpObserver(LookoutConfig lookoutConfig, AddressService addrService, Registry registry);  HttpObserver(LookoutConfig lookoutConfig, AddressService addrService, Registry registry,
                        HttpRequestProcessor requestProcessor); @Override boolean isEnable(); @Override void update(List<LookoutMeasurement> measures, Map<String, String> metadata); List<List<LookoutMeasurement>> getBatches(List<LookoutMeasurement> ms, int batchSize); }
HttpObserver implements MetricObserver<LookoutMeasurement> { public List<List<LookoutMeasurement>> getBatches(List<LookoutMeasurement> ms, int batchSize) { if (ms.size() <= batchSize) { return Collections.singletonList(ms); } List<List<LookoutMeasurement>> batches = new ArrayList(); for (int i = 0; i < ms.size(); i += batchSize) { List<LookoutMeasurement> batch = ms.subList(i, Math.min(ms.size(), i + batchSize)); batches.add(batch); } return batches; } HttpObserver(LookoutConfig lookoutConfig, AddressService addrService);  HttpObserver(LookoutConfig lookoutConfig, AddressService addrService, Registry registry);  HttpObserver(LookoutConfig lookoutConfig, AddressService addrService, Registry registry,
                        HttpRequestProcessor requestProcessor); @Override boolean isEnable(); @Override void update(List<LookoutMeasurement> measures, Map<String, String> metadata); List<List<LookoutMeasurement>> getBatches(List<LookoutMeasurement> ms, int batchSize); static final String UTF_8; static final String APPLICATION_OCTET_STREAM; static final String SNAPPY; }