@Test public void testRunAndStop() throws Exception { AbstractMetricPublisher publisherMock = createMockBuilder(RawMetricsPublisher.class) .withConstructor(TimelineMetricsHolder.getInstance(), new Configuration(), 1) .addMockedMethod("processAndPublishMetrics").createStrictMock(); publisherMock.processAndPublishMetrics(anyObject(Map.class)); expectLastCall().times(1); Thread t = createMockBuilder(Thread.class) .withConstructor(publisherMock) .addMockedMethod("isInterrupted").createStrictMock(); expect(t.isInterrupted()).andReturn(false).once(); expect(t.isInterrupted()).andReturn(true).once(); replay(publisherMock, t); t.start(); Thread.sleep(2222); verify(publisherMock, t); }
protected void processAndPublishMetrics(Map<String, TimelineMetrics> metricsFromCache) throws Exception { if (metricsFromCache.size()==0) return; LOG.info(String.format("Preparing %s timeline metrics for publishing", metricsFromCache.size())); emitMetricsJson(getCollectorUri(getCurrentCollectorHost()), processMetrics(metricsFromCache)); }
AbstractMetricPublisher extends AbstractTimelineMetricsSink implements Runnable { protected void processAndPublishMetrics(Map<String, TimelineMetrics> metricsFromCache) throws Exception { if (metricsFromCache.size()==0) return; LOG.info(String.format("Preparing %s timeline metrics for publishing", metricsFromCache.size())); emitMetricsJson(getCollectorUri(getCurrentCollectorHost()), processMetrics(metricsFromCache)); } }
AbstractMetricPublisher extends AbstractTimelineMetricsSink implements Runnable { protected void processAndPublishMetrics(Map<String, TimelineMetrics> metricsFromCache) throws Exception { if (metricsFromCache.size()==0) return; LOG.info(String.format("Preparing %s timeline metrics for publishing", metricsFromCache.size())); emitMetricsJson(getCollectorUri(getCurrentCollectorHost()), processMetrics(metricsFromCache)); } AbstractMetricPublisher(TimelineMetricsHolder timelineMetricsHolder, Configuration configuration, int publishIntervalInSeconds); }
AbstractMetricPublisher extends AbstractTimelineMetricsSink implements Runnable { protected void processAndPublishMetrics(Map<String, TimelineMetrics> metricsFromCache) throws Exception { if (metricsFromCache.size()==0) return; LOG.info(String.format("Preparing %s timeline metrics for publishing", metricsFromCache.size())); emitMetricsJson(getCollectorUri(getCurrentCollectorHost()), processMetrics(metricsFromCache)); } AbstractMetricPublisher(TimelineMetricsHolder timelineMetricsHolder, Configuration configuration, int publishIntervalInSeconds); @Override void run(); }
AbstractMetricPublisher extends AbstractTimelineMetricsSink implements Runnable { protected void processAndPublishMetrics(Map<String, TimelineMetrics> metricsFromCache) throws Exception { if (metricsFromCache.size()==0) return; LOG.info(String.format("Preparing %s timeline metrics for publishing", metricsFromCache.size())); emitMetricsJson(getCollectorUri(getCurrentCollectorHost()), processMetrics(metricsFromCache)); } AbstractMetricPublisher(TimelineMetricsHolder timelineMetricsHolder, Configuration configuration, int publishIntervalInSeconds); @Override void run();  }