You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/08/05 09:45:12 UTC
[GitHub] [iotdb] Beyyes commented on a diff in pull request #6880: [IOTDB-4029] Latent routing policy for MultiLeader protocol
Beyyes commented on code in PR #6880:
URL: https://github.com/apache/iotdb/pull/6880#discussion_r938414993
##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManager.java:
##########
@@ -284,21 +291,45 @@ private void updateNodeLoadStatistic() {
.forEach(
regionGroupCache -> {
boolean updateResult = regionGroupCache.updateLoadStatistic();
- if (conf.getRoutingPolicy().equals(RouteBalancer.leaderPolicy)) {
- // We need a broadcast when the leadership changed
- isNeedBroadcast.compareAndSet(false, updateResult);
+ switch (regionGroupCache.getConsensusGroupId().getType()) {
+ // Check if some RegionGroups change their leader
+ case SchemaRegion:
+ existChangeLeaderSchemaRegionGroup.compareAndSet(false, updateResult);
+ break;
+ case DataRegion:
+ existChangeLeaderDataRegionGroup.compareAndSet(false, updateResult);
+ break;
}
});
- if (isNeedBroadcast.get()) {
+ if (existFailDownDataNode.get()) {
+ // The RegionRouteMap must be broadcast if some DataNodes fail down
+ isNeedBroadcast = true;
+ }
+
+ if (conf.getRoutingPolicy().equals(RouteBalancer.leaderPolicy)) {
Review Comment:
static variable comparison, we can move the static variable to first, it can avoid npe sometimes.
##########
confignode/src/test/java/org/apache/iotdb/confignode/manager/load/balancer/router/LazyGreedyRouterTest.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.confignode.manager.load.balancer.router;
+
+import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
+import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class LazyGreedyRouterTest {
+
+ private final LazyGreedyRouter lazyGreedyRouter = new LazyGreedyRouter();
+
+ @Test
+ public void genLatestRegionRouteMap() {
Review Comment:
```suggestion
public void genLatestRegionRouteMapTest() {
```
##########
confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/DataNodeRemoveHandler.java:
##########
@@ -207,6 +207,8 @@ public void updateRegionLocationCache(
status,
originalDataNode.getInternalEndPoint().getIp(),
destDataNode.getInternalEndPoint().getIp());
+ // Broadcast the latest RegionRouteMap when Region migration finished
+ configManager.getLoadManager().broadcastLatestRegionRouteMap();
Review Comment:
What about the result status of `configManager.getPartitionManager().updateRegionLocation(req);` is not `Successful` .
##########
confignode/src/test/java/org/apache/iotdb/confignode/manager/load/balancer/router/LazyGreedyRouterTest.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.confignode.manager.load.balancer.router;
+
+import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
+import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class LazyGreedyRouterTest {
+
+ private final LazyGreedyRouter lazyGreedyRouter = new LazyGreedyRouter();
+
+ @Test
+ public void genLatestRegionRouteMap() {
+ /* Prepare TRegionReplicaSets */
+ List<TRegionReplicaSet> regionReplicaSetList = new ArrayList<>();
+ for (int i = 0; i < 12; i++) {
Review Comment:
If it's needed to add a new test in which regionReplicaSetList have different number TRegionReplicaSets
##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManager.java:
##########
@@ -284,21 +291,45 @@ private void updateNodeLoadStatistic() {
.forEach(
regionGroupCache -> {
boolean updateResult = regionGroupCache.updateLoadStatistic();
- if (conf.getRoutingPolicy().equals(RouteBalancer.leaderPolicy)) {
- // We need a broadcast when the leadership changed
- isNeedBroadcast.compareAndSet(false, updateResult);
+ switch (regionGroupCache.getConsensusGroupId().getType()) {
+ // Check if some RegionGroups change their leader
+ case SchemaRegion:
+ existChangeLeaderSchemaRegionGroup.compareAndSet(false, updateResult);
+ break;
+ case DataRegion:
+ existChangeLeaderDataRegionGroup.compareAndSet(false, updateResult);
+ break;
}
});
- if (isNeedBroadcast.get()) {
+ if (existFailDownDataNode.get()) {
+ // The RegionRouteMap must be broadcast if some DataNodes fail down
+ isNeedBroadcast = true;
+ }
+
+ if (conf.getRoutingPolicy().equals(RouteBalancer.leaderPolicy)) {
Review Comment:
```suggestion
if (RouteBalancer.leaderPolicy.equals(conf.getRoutingPolicy())) {
```
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org