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

 ##########
 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:
   Returning an already completed future should be a safer default 
implementation.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to