You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ta...@apache.org on 2024/03/21 09:31:49 UTC
(iotdb) branch master updated: [IOTDB-6301] Optimize insert first for single replica (#12209)
This is an automated email from the ASF dual-hosted git repository.
tanxinyu 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 3324a81aa2e [IOTDB-6301] Optimize insert first for single replica (#12209)
3324a81aa2e is described below
commit 3324a81aa2e0fc72ba54a2d0078786f36df3d121
Author: Xiangpeng Hu <65...@users.noreply.github.com>
AuthorDate: Thu Mar 21 17:31:42 2024 +0800
[IOTDB-6301] Optimize insert first for single replica (#12209)
---
.../manager/load/balancer/RouteBalancer.java | 25 ++++++++++++++++------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java
index 1f3fb4efb55..d5b88260505 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java
@@ -194,7 +194,8 @@ public class RouteBalancer {
requestId,
clientHandler,
regionGroupId,
- getNodeManager().getRegisteredDataNode(newLeaderId).getLocation());
+ getNodeManager().getRegisteredDataNode(newLeaderId).getLocation(),
+ regionGroupType);
differentRegionLeaderMap.put(
regionGroupId, new Pair<>(currentLeaderMap.get(regionGroupId), newLeaderId));
}
@@ -234,7 +235,8 @@ public class RouteBalancer {
AtomicInteger requestId,
AsyncClientHandler<TRegionLeaderChangeReq, TSStatus> clientHandler,
TConsensusGroupId regionGroupId,
- TDataNodeLocation newLeader) {
+ TDataNodeLocation newLeader,
+ TConsensusGroupType regionGroupType) {
switch (consensusProtocolClass) {
case ConsensusFactory.IOT_CONSENSUS:
case ConsensusFactory.SIMPLE_CONSENSUS:
@@ -248,11 +250,20 @@ public class RouteBalancer {
// leader.
// And the RegionRouteMap will be updated by Cluster-Heartbeat-Service later if change
// leader success.
- TRegionLeaderChangeReq regionLeaderChangeReq =
- new TRegionLeaderChangeReq(regionGroupId, newLeader);
- int requestIndex = requestId.getAndIncrement();
- clientHandler.putRequest(requestIndex, regionLeaderChangeReq);
- clientHandler.putDataNodeLocation(requestIndex, newLeader);
+ // Force update region leader for ratis consensus when replication factor is 1.
+ if (TConsensusGroupType.SchemaRegion.equals(regionGroupType)
+ && CONF.getSchemaReplicationFactor() == 1) {
+ getLoadManager().forceUpdateRegionLeader(regionGroupId, newLeader.getDataNodeId());
+ } else if (TConsensusGroupType.DataRegion.equals(regionGroupType)
+ && CONF.getDataReplicationFactor() == 1) {
+ getLoadManager().forceUpdateRegionLeader(regionGroupId, newLeader.getDataNodeId());
+ } else {
+ TRegionLeaderChangeReq regionLeaderChangeReq =
+ new TRegionLeaderChangeReq(regionGroupId, newLeader);
+ int requestIndex = requestId.getAndIncrement();
+ clientHandler.putRequest(requestIndex, regionLeaderChangeReq);
+ clientHandler.putDataNodeLocation(requestIndex, newLeader);
+ }
break;
}
}