Re: [PR] [IOTDB-6309] Lager interval for auto ratis leader balance [iotdb]

2024-03-08 Thread via GitHub


OneSizeFitsQuorum merged PR #12116:
URL: https://github.com/apache/iotdb/pull/12116


-- 
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-unsubscr...@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [IOTDB-6309] Lager interval for auto ratis leader balance [iotdb]

2024-03-06 Thread via GitHub


CRZbulabula commented on code in PR #12116:
URL: https://github.com/apache/iotdb/pull/12116#discussion_r1514256772


##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java:
##
@@ -127,10 +133,16 @@ public RouteBalancer(IManager configManager) {
   public synchronized Map> 
balanceRegionLeader() {
 Map> differentRegionLeaderMap =
 new ConcurrentHashMap<>();
-if (IS_ENABLE_AUTO_LEADER_BALANCE_FOR_SCHEMA_REGION) {
+if (IS_ENABLE_AUTO_LEADER_BALANCE_FOR_SCHEMA_REGION
+&& 
(!ConsensusFactory.RATIS_CONSENSUS.equals(SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS)
+|| System.currentTimeMillis() - 
lastFailedTimeForBalanceRatisSchemaLeader
+> BALANCE_RATIS_LEADER_FAILED_INTERVAL)) {
   
differentRegionLeaderMap.putAll(balanceRegionLeader(TConsensusGroupType.SchemaRegion));
 }
-if (IS_ENABLE_AUTO_LEADER_BALANCE_FOR_DATA_REGION) {
+if (IS_ENABLE_AUTO_LEADER_BALANCE_FOR_DATA_REGION
+&& 
(!ConsensusFactory.RATIS_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS)
+|| System.currentTimeMillis() - 
lastFailedTimeForBalanceRatisDataLeader
+> BALANCE_RATIS_LEADER_FAILED_INTERVAL)) {

Review Comment:
   It's impossible to simplify those `if`, since the target of this PR is to 
distinguish the Ratis and IoT consensus protocol QAQ



-- 
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-unsubscr...@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [IOTDB-6309] Lager interval for auto ratis leader balance [iotdb]

2024-03-05 Thread via GitHub


liyuheng5 commented on code in PR #12116:
URL: https://github.com/apache/iotdb/pull/12116#discussion_r1512345944


##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java:
##
@@ -127,10 +133,16 @@ public RouteBalancer(IManager configManager) {
   public synchronized Map> 
balanceRegionLeader() {
 Map> differentRegionLeaderMap =
 new ConcurrentHashMap<>();
-if (IS_ENABLE_AUTO_LEADER_BALANCE_FOR_SCHEMA_REGION) {
+if (IS_ENABLE_AUTO_LEADER_BALANCE_FOR_SCHEMA_REGION
+&& 
(!ConsensusFactory.RATIS_CONSENSUS.equals(SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS)
+|| System.currentTimeMillis() - 
lastFailedTimeForBalanceRatisSchemaLeader
+> BALANCE_RATIS_LEADER_FAILED_INTERVAL)) {
   
differentRegionLeaderMap.putAll(balanceRegionLeader(TConsensusGroupType.SchemaRegion));
 }
-if (IS_ENABLE_AUTO_LEADER_BALANCE_FOR_DATA_REGION) {
+if (IS_ENABLE_AUTO_LEADER_BALANCE_FOR_DATA_REGION
+&& 
(!ConsensusFactory.RATIS_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS)
+|| System.currentTimeMillis() - 
lastFailedTimeForBalanceRatisDataLeader
+> BALANCE_RATIS_LEADER_FAILED_INTERVAL)) {

Review Comment:
   Those `if` check are somewhat annoying... Is it possible to optimize or 
simplify ?



##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java:
##
@@ -199,6 +211,14 @@ private Map> 
balanceRegionLeader(
   
clientHandler.getRequest(i).getNewLeaderNode().getDataNodeId());
 } else {
   
differentRegionLeaderMap.remove(clientHandler.getRequest(i).getRegionId());
+  if (TConsensusGroupType.SchemaRegion.equals(regionGroupType)
+  && 
ConsensusFactory.RATIS_CONSENSUS.equals(SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS))
 {
+lastFailedTimeForBalanceRatisSchemaLeader = 
System.currentTimeMillis();
+  }
+  if (TConsensusGroupType.DataRegion.equals(regionGroupType)
+  && 
ConsensusFactory.RATIS_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS)) {
+lastFailedTimeForBalanceRatisDataLeader = 
System.currentTimeMillis();
+  }

Review Comment:
   Here too



-- 
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-unsubscr...@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [IOTDB-6309] Lager interval for auto ratis leader balance [iotdb]

2024-03-04 Thread via GitHub


sonarcloud[bot] commented on PR #12116:
URL: https://github.com/apache/iotdb/pull/12116#issuecomment-1976529218

   ## [![Quality Gate 
Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png
 'Quality Gate 
Failed')](https://sonarcloud.io/dashboard?id=apache_iotdb=12116) 
**Quality Gate failed**  
   Failed conditions  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png
 '') [0.0% Coverage on New 
Code](https://sonarcloud.io/component_measures?id=apache_iotdb=12116=new_coverage=list)
 (required ≥ 80%)  
 
   [See analysis details on 
SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb=12116)
   
   


-- 
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-unsubscr...@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org