This is an automated email from the ASF dual-hosted git repository.
CRZbulabula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 647e5363152 Remove Ratis region migration rate limiting (#18365)
647e5363152 is described below
commit 647e536315266dfa0b312d071ee434cc5005d949
Author: Yongzao <[email protected]>
AuthorDate: Fri Jul 31 09:47:54 2026 +0800
Remove Ratis region migration rate limiting (#18365)
---
.../consensus/ratis/RateLimitedGrpcFactory.java | 40 ------------
.../ratis/RateLimitedGrpcLogAppender.java | 76 ----------------------
.../consensus/ratis/RateLimitedGrpcRpcType.java | 37 -----------
.../iotdb/consensus/ratis/RatisConsensus.java | 2 -
.../ratis/RateLimitedGrpcLogAppenderTest.java | 66 -------------------
5 files changed, 221 deletions(-)
diff --git
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcFactory.java
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcFactory.java
deleted file mode 100644
index 1124d04b865..00000000000
---
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.iotdb.consensus.ratis;
-
-import org.apache.ratis.conf.Parameters;
-import org.apache.ratis.grpc.GrpcFactory;
-import org.apache.ratis.server.RaftServer;
-import org.apache.ratis.server.leader.FollowerInfo;
-import org.apache.ratis.server.leader.LeaderState;
-import org.apache.ratis.server.leader.LogAppender;
-
-class RateLimitedGrpcFactory extends GrpcFactory {
-
- RateLimitedGrpcFactory(Parameters parameters) {
- super(parameters);
- }
-
- @Override
- public LogAppender newLogAppender(
- RaftServer.Division server, LeaderState leaderState, FollowerInfo
follower) {
- return new RateLimitedGrpcLogAppender(server, leaderState, follower);
- }
-}
diff --git
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcLogAppender.java
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcLogAppender.java
deleted file mode 100644
index 41830c85dc2..00000000000
---
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcLogAppender.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.iotdb.consensus.ratis;
-
-import org.apache.iotdb.commons.utils.RegionMigrationRateLimiter;
-
-import org.apache.ratis.grpc.server.GrpcLogAppender;
-import org.apache.ratis.proto.RaftProtos.FileChunkProto;
-import org.apache.ratis.proto.RaftProtos.InstallSnapshotRequestProto;
-import org.apache.ratis.server.RaftServer;
-import org.apache.ratis.server.leader.FollowerInfo;
-import org.apache.ratis.server.leader.LeaderState;
-import org.apache.ratis.statemachine.SnapshotInfo;
-
-import java.util.Iterator;
-
-class RateLimitedGrpcLogAppender extends GrpcLogAppender {
-
- private final RegionMigrationRateLimiter rateLimiter =
RegionMigrationRateLimiter.getInstance();
-
- RateLimitedGrpcLogAppender(
- RaftServer.Division server, LeaderState leaderState, FollowerInfo
follower) {
- super(server, leaderState, follower);
- }
-
- @Override
- public Iterable<InstallSnapshotRequestProto> newInstallSnapshotRequests(
- String requestId, SnapshotInfo snapshot) {
- final Iterable<InstallSnapshotRequestProto> requests =
- super.newInstallSnapshotRequests(requestId, snapshot);
- return () -> {
- final Iterator<InstallSnapshotRequestProto> iterator =
requests.iterator();
- return new Iterator<InstallSnapshotRequestProto>() {
- @Override
- public boolean hasNext() {
- return iterator.hasNext();
- }
-
- @Override
- public InstallSnapshotRequestProto next() {
- final InstallSnapshotRequestProto request = iterator.next();
- rateLimiter.acquire(getSnapshotChunkDataSize(request));
- return request;
- }
- };
- };
- }
-
- static long getSnapshotChunkDataSize(InstallSnapshotRequestProto request) {
- if (!request.hasSnapshotChunk()) {
- return 0;
- }
-
- return request.getSnapshotChunk().getFileChunksList().stream()
- .map(FileChunkProto::getData)
- .mapToLong(data -> data == null ? 0 : data.size())
- .sum();
- }
-}
diff --git
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcRpcType.java
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcRpcType.java
deleted file mode 100644
index 391ec2faef6..00000000000
---
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcRpcType.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.iotdb.consensus.ratis;
-
-import org.apache.ratis.conf.Parameters;
-import org.apache.ratis.rpc.RpcFactory;
-import org.apache.ratis.rpc.RpcType;
-
-public class RateLimitedGrpcRpcType implements RpcType {
-
- @Override
- public String name() {
- return RateLimitedGrpcRpcType.class.getName();
- }
-
- @Override
- public RpcFactory newFactory(Parameters parameters) {
- return new RateLimitedGrpcFactory(parameters);
- }
-}
diff --git
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
index 4cac559646f..b7369546e7c 100644
---
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
+++
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
@@ -56,7 +56,6 @@ import org.apache.iotdb.consensus.ratis.utils.Utils;
import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
-import org.apache.ratis.RaftConfigKeys;
import org.apache.ratis.client.RaftClientRpc;
import org.apache.ratis.conf.Parameters;
import org.apache.ratis.conf.RaftProperties;
@@ -160,7 +159,6 @@ class RatisConsensus implements IConsensus {
this.storageDir = new File(config.getStorageDir());
RaftServerConfigKeys.setStorageDir(properties,
Collections.singletonList(storageDir));
- RaftConfigKeys.Rpc.setType(properties, new RateLimitedGrpcRpcType());
GrpcConfigKeys.Server.setHost(properties,
config.getThisNodeEndPoint().getIp());
GrpcConfigKeys.Server.setPort(properties,
config.getThisNodeEndPoint().getPort());
diff --git
a/iotdb-core/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcLogAppenderTest.java
b/iotdb-core/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcLogAppenderTest.java
deleted file mode 100644
index 8b93bdcdd1a..00000000000
---
a/iotdb-core/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RateLimitedGrpcLogAppenderTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.iotdb.consensus.ratis;
-
-import org.apache.ratis.RaftConfigKeys;
-import org.apache.ratis.conf.Parameters;
-import org.apache.ratis.conf.RaftProperties;
-import org.apache.ratis.proto.RaftProtos.FileChunkProto;
-import org.apache.ratis.proto.RaftProtos.InstallSnapshotRequestProto;
-import org.apache.ratis.rpc.RpcType;
-import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class RateLimitedGrpcLogAppenderTest {
-
- @Test
- public void testGetSnapshotChunkDataSize() {
- final InstallSnapshotRequestProto request =
- InstallSnapshotRequestProto.newBuilder()
- .setSnapshotChunk(
- InstallSnapshotRequestProto.SnapshotChunkProto.newBuilder()
- .addFileChunks(
- FileChunkProto.newBuilder()
- .setData(ByteString.copyFrom(new byte[3]))
- .build())
- .addFileChunks(
- FileChunkProto.newBuilder()
- .setData(ByteString.copyFrom(new byte[5]))
- .build()))
- .build();
-
- Assert.assertEquals(8,
RateLimitedGrpcLogAppender.getSnapshotChunkDataSize(request));
- Assert.assertEquals(
- 0,
- RateLimitedGrpcLogAppender.getSnapshotChunkDataSize(
- InstallSnapshotRequestProto.newBuilder().buildPartial()));
- }
-
- @Test
- public void testRateLimitedGrpcRpcTypeIsResolvedByRatis() {
- final RaftProperties properties = new RaftProperties();
-
- RaftConfigKeys.Rpc.setType(properties, new RateLimitedGrpcRpcType());
- final RpcType rpcType = RaftConfigKeys.Rpc.type(properties, ignored -> {});
-
- Assert.assertTrue(rpcType instanceof RateLimitedGrpcRpcType);
- Assert.assertTrue(rpcType.newFactory(new Parameters()) instanceof
RateLimitedGrpcFactory);
- }
-}