You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/01/11 14:57:34 UTC

[GitHub] tillrohrmann commented on a change in pull request #7459: [FLINK-10822] Make MetricFetcher update interval configurable

tillrohrmann commented on a change in pull request #7459:  [FLINK-10822] Make MetricFetcher update interval configurable
URL: https://github.com/apache/flink/pull/7459#discussion_r247116469
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/metrics/MetricFetcherTest.java
 ##########
 @@ -184,4 +193,52 @@ public String getValue() {
 
 		return dump;
 	}
+
+	@Test
+	public void testLongUpdateInterval() {
+		final long updateInterval = 1000L;
+		final AtomicInteger requestMetricQueryServicePathsCounter = new AtomicInteger(0);
+		final RestfulGateway restfulGateway = createRestfulGateway(requestMetricQueryServicePathsCounter);
+
+		final MetricFetcher<RestfulGateway> fetcher = createMetricFetcher(updateInterval, restfulGateway);
+
+		fetcher.update();
+		fetcher.update();
+
+		assertThat(requestMetricQueryServicePathsCounter.get(), is(1));
+	}
+
+	@Test
+	public void testShortUpdateInterval() throws InterruptedException {
+		final long updateInterval = 1L;
+		final AtomicInteger requestMetricQueryServicePathsCounter = new AtomicInteger(0);
+		final RestfulGateway restfulGateway = createRestfulGateway(requestMetricQueryServicePathsCounter);
+
+		final MetricFetcher<RestfulGateway> fetcher = createMetricFetcher(updateInterval, restfulGateway);
+
+		fetcher.update();
+		Thread.sleep(2L * updateInterval);
+		fetcher.update();
+
+		assertThat(requestMetricQueryServicePathsCounter.get(), is(2));
+	}
+
+	@Nonnull
+	private MetricFetcher<RestfulGateway> createMetricFetcher(long updateInterval, RestfulGateway restfulGateway) {
+		return new MetricFetcher<>(
+			() -> CompletableFuture.completedFuture(restfulGateway),
+			path -> new CompletableFuture<>(),
 
 Review comment:
   I didn't want to return a `MetricQueryServiceGateway` here.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services