azagrebin commented on a change in pull request #13316:
URL: https://github.com/apache/flink/pull/13316#discussion_r492749100
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerMetricsInfo.java
##########
@@ -206,9 +301,9 @@ public int hashCode() {
@JsonCreator
public GarbageCollectorInfo(
- @JsonProperty(FIELD_NAME_NAME) String name,
- @JsonProperty(FIELD_NAME_COUNT) long count,
- @JsonProperty(FIELD_NAME_TIME) long time) {
+ @JsonProperty(FIELD_NAME_NAME) String name,
Review comment:
formatting is off
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerDetailsHandlerTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.taskmanager;
+
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
+import org.apache.flink.runtime.instance.HardwareDescription;
+import org.apache.flink.runtime.metrics.dump.MetricDump;
+import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
+import
org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.HandlerRequestException;
+import org.apache.flink.runtime.rest.handler.RestHandlerException;
+import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher;
+import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsHeaders;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsInfo;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerFileMessageParameters;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerIdPathParameter;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMetricsInfo;
+import org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration;
+import org.apache.flink.runtime.testingUtils.TestingUtils;
+import org.apache.flink.util.TestLogger;
+
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Tests the {@link TaskManagerDetailsHandler} implementation.
+ */
+public class TaskManagerDetailsHandlerTest extends TestLogger {
+
+ private static final Random random = new Random();
+
+ private ResourceID taskManagerId = ResourceID.generate();
+
+ private TestingResourceManagerGateway resourceManagerGateway;
+ private TaskManagerDetailsHandler testInstance;
+
+ private HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters>
handlerRequest;
+
+ public void initializeMetricStore(MetricStore metricStore) {
+ QueryScopeInfo.TaskManagerQueryScopeInfo tmScope = new
QueryScopeInfo.TaskManagerQueryScopeInfo(taskManagerId.toString(), "Status");
Review comment:
```suggestion
private static void initializeMetricStore(MetricStore metricStore) {
QueryScopeInfo.TaskManagerQueryScopeInfo tmScope = new
QueryScopeInfo.TaskManagerQueryScopeInfo(TASK_MANAGER_ID.toString(), "Status");
```
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerDetailsHandlerTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.taskmanager;
+
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
+import org.apache.flink.runtime.instance.HardwareDescription;
+import org.apache.flink.runtime.metrics.dump.MetricDump;
+import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
+import
org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.HandlerRequestException;
+import org.apache.flink.runtime.rest.handler.RestHandlerException;
+import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher;
+import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsHeaders;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsInfo;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerFileMessageParameters;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerIdPathParameter;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMetricsInfo;
+import org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration;
+import org.apache.flink.runtime.testingUtils.TestingUtils;
+import org.apache.flink.util.TestLogger;
+
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Tests the {@link TaskManagerDetailsHandler} implementation.
+ */
+public class TaskManagerDetailsHandlerTest extends TestLogger {
+
+ private static final Random random = new Random();
+
+ private ResourceID taskManagerId = ResourceID.generate();
+
+ private TestingResourceManagerGateway resourceManagerGateway;
+ private TaskManagerDetailsHandler testInstance;
+
+ private HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters>
handlerRequest;
+
+ public void initializeMetricStore(MetricStore metricStore) {
+ QueryScopeInfo.TaskManagerQueryScopeInfo tmScope = new
QueryScopeInfo.TaskManagerQueryScopeInfo(taskManagerId.toString(), "Status");
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Heap.Used", 1));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Heap.Committed", 2));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Heap.Max", 3));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.NonHeap.Used", 4));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.NonHeap.Committed", 5));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.NonHeap.Max", 6));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Direct.Count", 7));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Direct.MemoryUsed", 8));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Direct.TotalCapacity", 9));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Mapped.Count", 10));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Mapped.MemoryUsed", 11));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Mapped.TotalCapacity", 12));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Network.AvailableMemorySegments", 13));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Network.TotalMemorySegments", 14));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.AvailableMemorySegments", 15));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.UsedMemorySegments", 16));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.TotalMemorySegments", 17));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.AvailableMemory", 18));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.UsedMemory", 19));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.TotalMemory", 20));
+ }
+
+ private HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters>
createRequest() throws HandlerRequestException {
+ Map<String, String> pathParamaters = new HashMap<>();
+ pathParamaters.put(TaskManagerIdPathParameter.KEY,
taskManagerId.toString());
Review comment:
```suggestion
private static HandlerRequest<EmptyRequestBody,
TaskManagerMessageParameters> createRequest() throws HandlerRequestException {
Map<String, String> pathParamaters = new HashMap<>();
pathParamaters.put(TaskManagerIdPathParameter.KEY,
TASK_MANAGER_ID.toString());
```
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerDetailsHandlerTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.taskmanager;
+
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
+import org.apache.flink.runtime.instance.HardwareDescription;
+import org.apache.flink.runtime.metrics.dump.MetricDump;
+import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
+import
org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.HandlerRequestException;
+import org.apache.flink.runtime.rest.handler.RestHandlerException;
+import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher;
+import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsHeaders;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsInfo;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerFileMessageParameters;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerIdPathParameter;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMetricsInfo;
+import org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration;
+import org.apache.flink.runtime.testingUtils.TestingUtils;
+import org.apache.flink.util.TestLogger;
+
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Tests the {@link TaskManagerDetailsHandler} implementation.
+ */
+public class TaskManagerDetailsHandlerTest extends TestLogger {
+
+ private static final Random random = new Random();
+
+ private ResourceID taskManagerId = ResourceID.generate();
+
+ private TestingResourceManagerGateway resourceManagerGateway;
+ private TaskManagerDetailsHandler testInstance;
+
+ private HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters>
handlerRequest;
+
+ public void initializeMetricStore(MetricStore metricStore) {
+ QueryScopeInfo.TaskManagerQueryScopeInfo tmScope = new
QueryScopeInfo.TaskManagerQueryScopeInfo(taskManagerId.toString(), "Status");
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Heap.Used", 1));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Heap.Committed", 2));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Heap.Max", 3));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.NonHeap.Used", 4));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.NonHeap.Committed", 5));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.NonHeap.Max", 6));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Direct.Count", 7));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Direct.MemoryUsed", 8));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Direct.TotalCapacity", 9));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Mapped.Count", 10));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Mapped.MemoryUsed", 11));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"JVM.Memory.Mapped.TotalCapacity", 12));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Network.AvailableMemorySegments", 13));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Network.TotalMemorySegments", 14));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.AvailableMemorySegments", 15));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.UsedMemorySegments", 16));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.TotalMemorySegments", 17));
+
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.AvailableMemory", 18));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.UsedMemory", 19));
+ metricStore.add(new MetricDump.CounterDump(tmScope,
"Shuffle.Netty.TotalMemory", 20));
+ }
+
+ private HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters>
createRequest() throws HandlerRequestException {
+ Map<String, String> pathParamaters = new HashMap<>();
+ pathParamaters.put(TaskManagerIdPathParameter.KEY,
taskManagerId.toString());
+
+ return new HandlerRequest<>(
+ EmptyRequestBody.getInstance(),
+ new TaskManagerFileMessageParameters(),
+ pathParamaters,
+ Collections.emptyMap()
+ );
+ }
+
+ @Before
+ public void setup() throws HandlerRequestException {
+ resourceManagerGateway = new TestingResourceManagerGateway();
+
+ MetricFetcher metricFetcher = new TestingMetricFetcher();
+ initializeMetricStore(metricFetcher.getMetricStore());
Review comment:
the called method `initializeMetricStore` declaration proceeds the
calling method
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerDetailsHandlerTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.taskmanager;
+
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
+import org.apache.flink.runtime.instance.HardwareDescription;
+import org.apache.flink.runtime.metrics.dump.MetricDump;
+import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
+import
org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.HandlerRequestException;
+import org.apache.flink.runtime.rest.handler.RestHandlerException;
+import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher;
+import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsHeaders;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsInfo;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerFileMessageParameters;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerIdPathParameter;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters;
+import
org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMetricsInfo;
+import org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration;
+import org.apache.flink.runtime.testingUtils.TestingUtils;
+import org.apache.flink.util.TestLogger;
+
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Tests the {@link TaskManagerDetailsHandler} implementation.
+ */
+public class TaskManagerDetailsHandlerTest extends TestLogger {
+
+ private static final Random random = new Random();
+
+ private ResourceID taskManagerId = ResourceID.generate();
Review comment:
```suggestion
private static final ResourceID TASK_MANAGER_ID = ResourceID.generate();
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]