CompositeMetricPoller implements MetricPoller { public final List<Metric> poll(MetricFilter filter) { return poll(filter, false); } CompositeMetricPoller(
      Map<String, MetricPoller> pollers, ExecutorService executor, long timeout); final List<Metric> poll(MetricFilter filter); final List<Metric> poll(MetricFilter filter, boolean reset);  }
@Test public void testBasic() throws Exception { Map<String, MetricPoller> pollers = new HashMap<>(); pollers.put("p1", newPoller(0)); ExecutorService exec = Executors.newFixedThreadPool(1); MetricPoller poller = new CompositeMetricPoller(pollers, exec, 10000); assertEquals(poller.poll(MATCH_ALL), mkList()); }
@Test public void testMultiple() throws Exception { Map<String, MetricPoller> pollers = new HashMap<>(); pollers.put("p1", newPoller(0)); pollers.put("p2", newPoller(0)); ExecutorService exec = Executors.newFixedThreadPool(1); MetricPoller poller = new CompositeMetricPoller(pollers, exec, 10000); assertEquals(poller.poll(MATCH_ALL), UnmodifiableList.copyOf(Iterables.concat(mkList(), mkList()))); }
@Test public void testTimeout() throws Exception { Map<String, MetricPoller> pollers = new HashMap<>(); pollers.put("p1", newPoller(120000)); pollers.put("p2", newPoller(0)); pollers.put("p3", newPoller(120000)); pollers.put("p4", newPoller(120000)); pollers.put("p5", newPoller(120000)); ExecutorService exec = Executors.newFixedThreadPool(1); MetricPoller poller = new CompositeMetricPoller(pollers, exec, 500); assertEquals(poller.poll(MATCH_ALL), mkList()); }
@Test public void testException() throws Exception { MockMetricPoller mock = new MockMetricPoller(); mock.setDie(true); Map<String, MetricPoller> pollers = new HashMap<>(); pollers.put("p1", mock); pollers.put("p2", newPoller(0)); ExecutorService exec = Executors.newFixedThreadPool(1); MetricPoller poller = new CompositeMetricPoller(pollers, exec, 10000); assertEquals(poller.poll(MATCH_ALL), mkList()); }