This is an automated email from the ASF dual-hosted git repository.
yongzao pushed a commit to branch Debug-SimpleConsensus-leader-not-elected
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to
refs/heads/Debug-SimpleConsensus-leader-not-elected by this push:
new a1eedf4a64 Update RegionRouteCache.java
a1eedf4a64 is described below
commit a1eedf4a644d40549f25446f931d117c2ec82996
Author: YongzaoDan <[email protected]>
AuthorDate: Mon May 8 21:50:45 2023 +0800
Update RegionRouteCache.java
---
.../manager/load/cache/route/RegionRouteCache.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/route/RegionRouteCache.java
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/route/RegionRouteCache.java
index a0eb5d8d8d..123c59e71c 100644
---
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/route/RegionRouteCache.java
+++
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/route/RegionRouteCache.java
@@ -26,11 +26,16 @@ import
org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
import org.apache.iotdb.consensus.ConsensusFactory;
import org.apache.iotdb.tsfile.utils.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
public class RegionRouteCache {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(RegionRouteCache.class);
+
private static final ConfigNodeConfig CONF =
ConfigNodeDescriptor.getInstance().getConf();
private static final String SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS =
CONF.getSchemaRegionConsensusProtocolClass();
@@ -49,7 +54,10 @@ public class RegionRouteCache {
private final AtomicInteger leaderId;
private final AtomicReference<TRegionReplicaSet> regionPriority;
+ private final TConsensusGroupId consensusGroupId;
+
public RegionRouteCache(TConsensusGroupId consensusGroupId) {
+ this.consensusGroupId = consensusGroupId;
switch (consensusGroupId.getType()) {
case SchemaRegion:
this.consensusProtocolClass = SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS;
@@ -77,6 +85,10 @@ public class RegionRouteCache {
// The leader of simple and ratis consensus is self-elected
if (leaderSample.getLeft() > this.leaderSample.get().getLeft()) {
this.leaderSample.set(leaderSample);
+ LOGGER.info(
+ "[NoElect] Cache leader sample: {} for region group: {}",
+ leaderSample,
+ consensusGroupId);
}
break;
case ConsensusFactory.IOT_CONSENSUS:
@@ -98,6 +110,10 @@ public class RegionRouteCache {
// The leader of simple and ratis consensus is self-elected
if (leaderSample.get().getRight() != leaderId.get()) {
leaderId.set(leaderSample.get().getRight());
+ LOGGER.info(
+ "[NoElect] Periodic update leaderId: {} for region group: {}",
+ leaderId.get(),
+ consensusGroupId);
return true;
}
return false;
@@ -126,6 +142,7 @@ public class RegionRouteCache {
*/
public void forceUpdateRegionPriority(TRegionReplicaSet regionPriority) {
this.regionPriority.set(regionPriority);
+ LOGGER.info("[NoElect] Force update region priority: {}", regionPriority);
}
public int getLeaderId() {