You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by pn...@apache.org on 2024/09/30 15:21:09 UTC

(flink) branch f36260 created (now 4f48f020984)

This is an automated email from the ASF dual-hosted git repository.

pnowojski pushed a change to branch f36260
in repository https://gitbox.apache.org/repos/asf/flink.git


      at 4f48f020984 [FLINK-36260][metrics] Fix numBytesInLocal and numBuffersInLocal being reported as remote

This branch includes the following new commits:

     new 4f48f020984 [FLINK-36260][metrics] Fix numBytesInLocal and numBuffersInLocal being reported as remote

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(flink) 01/01: [FLINK-36260][metrics] Fix numBytesInLocal and numBuffersInLocal being reported as remote

Posted by pn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pnowojski pushed a commit to branch f36260
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 4f48f0209843008784ac26e9c9f56c656bc268d0
Author: Piotr Nowojski <pi...@gmail.com>
AuthorDate: Mon Sep 30 15:30:33 2024 +0200

    [FLINK-36260][metrics] Fix numBytesInLocal and numBuffersInLocal being reported as remote
---
 .../partition/consumer/UnknownInputChannel.java    |  4 +-
 .../consumer/UnknownInputChannelTest.java          | 51 ++++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/UnknownInputChannel.java b/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/UnknownInputChannel.java
index 6980ed507da..2ff8aa73bcd 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/UnknownInputChannel.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/UnknownInputChannel.java
@@ -196,8 +196,8 @@ class UnknownInputChannel extends InputChannel implements ChannelStateHolder {
                 taskEventPublisher,
                 initialBackoff,
                 maxBackoff,
-                metrics.getNumBytesInRemoteCounter(),
-                metrics.getNumBuffersInRemoteCounter(),
+                metrics.getNumBytesInLocalCounter(),
+                metrics.getNumBuffersInLocalCounter(),
                 channelStateWriter == null ? ChannelStateWriter.NO_OP : channelStateWriter);
     }
 
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/consumer/UnknownInputChannelTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/consumer/UnknownInputChannelTest.java
new file mode 100644
index 00000000000..c8b10f4657d
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/consumer/UnknownInputChannelTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.io.network.partition.consumer;
+
+import org.apache.flink.metrics.groups.UnregisteredMetricsGroup;
+import org.apache.flink.runtime.io.network.metrics.InputChannelMetrics;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionType;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link UnknownInputChannel}. */
+class UnknownInputChannelTest {
+    @Test
+    void testMetrics() {
+        SingleInputGateBuilder builder =
+                new SingleInputGateBuilder()
+                        .setNumberOfChannels(1)
+                        .setSingleInputGateIndex(0)
+                        .setResultPartitionType(ResultPartitionType.PIPELINED);
+
+        InputChannelMetrics metrics = new InputChannelMetrics(new UnregisteredMetricsGroup());
+        UnknownInputChannel unknownInputChannel =
+                InputChannelBuilder.newBuilder()
+                        .setMetrics(metrics)
+                        .buildUnknownChannel(builder.build());
+        metrics.getNumBuffersInLocalCounter().inc();
+        LocalInputChannel localInputChannel =
+                unknownInputChannel.toLocalInputChannel(new ResultPartitionID());
+        assertThat(localInputChannel.numBuffersIn.getCount())
+                .isEqualTo(metrics.getNumBuffersInLocalCounter().getCount());
+    }
+}