@Test public void testProcessAndPublishMetrics() throws Exception { AbstractMetricPublisher publisherMock = createMockBuilder(RawMetricsPublisher.class) .withConstructor(TimelineMetricsHolder.getInstance(), new Configuration(), 60) .addMockedMethod("processMetrics") .addMockedMethod("getCollectorUri") .addMockedMethod("emitMetricsJson") .addMockedMethod("getCurrentCollectorHost").createStrictMock(); TimelineMetricsHolder.getInstance().putMetricsForRawPublishing(TimelineMetricsHolderTest.getTimelineMetricsWithAppID("raw")); expect(publisherMock.getCurrentCollectorHost()).andReturn("collectorhost").once(); expect(publisherMock.getCollectorUri(anyString())).andReturn("https: expect(publisherMock.processMetrics(anyObject(Map.class))).andReturn("{metrics}").once(); expect(publisherMock.emitMetricsJson("https: replay(publisherMock); publisherMock.processAndPublishMetrics(TimelineMetricsHolder.getInstance().extractMetricsForRawPublishing()); verify(publisherMock); }
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();  }