diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/PartitionBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/PartitionBalancer.java index 86bb000ca05b..ccf2f5caaed8 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/PartitionBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/PartitionBalancer.java @@ -123,12 +123,13 @@ public Map allocateDataPartition( // Filter available DataRegionGroups and // sort them by the number of allocated DataPartitions - BalanceTreeMap counter = new BalanceTreeMap<>(); + BalanceTreeMap availableDataRegionGroupCounter = + new BalanceTreeMap<>(); List> regionSlotsCounter = getPartitionManager() .getSortedRegionGroupSlotsCounter(database, TConsensusGroupType.DataRegion); for (Pair pair : regionSlotsCounter) { - counter.put(pair.getRight(), pair.getLeft().intValue()); + availableDataRegionGroupCounter.put(pair.getRight(), pair.getLeft().intValue()); } DataPartitionTable dataPartitionTable = new DataPartitionTable(); @@ -152,18 +153,20 @@ public Map allocateDataPartition( TConsensusGroupId successor = getPartitionManager() .getSuccessorDataPartition(database, seriesPartitionSlot, timePartitionSlot); - if (successor != null && counter.containsKey(successor)) { + if (successor != null && availableDataRegionGroupCounter.containsKey(successor)) { seriesPartitionTable.putDataPartition(timePartitionSlot, successor); - counter.put(successor, counter.get(successor) + 1); + availableDataRegionGroupCounter.put( + successor, availableDataRegionGroupCounter.get(successor) + 1); continue; } // 2. Assign DataPartition base on the DataAllotTable TConsensusGroupId allotGroupId = allotTable.getRegionGroupIdOrActivateIfNecessary(seriesPartitionSlot); - if (counter.containsKey(allotGroupId)) { + if (availableDataRegionGroupCounter.containsKey(allotGroupId)) { seriesPartitionTable.putDataPartition(timePartitionSlot, allotGroupId); - counter.put(allotGroupId, counter.get(allotGroupId) + 1); + availableDataRegionGroupCounter.put( + allotGroupId, availableDataRegionGroupCounter.get(allotGroupId) + 1); continue; } @@ -172,17 +175,25 @@ public Map allocateDataPartition( TConsensusGroupId predecessor = getPartitionManager() .getPredecessorDataPartition(database, seriesPartitionSlot, timePartitionSlot); - if (predecessor != null && counter.containsKey(predecessor)) { + if (predecessor != null && availableDataRegionGroupCounter.containsKey(predecessor)) { seriesPartitionTable.putDataPartition(timePartitionSlot, predecessor); - counter.put(predecessor, counter.get(predecessor) + 1); + availableDataRegionGroupCounter.put( + predecessor, availableDataRegionGroupCounter.get(predecessor) + 1); continue; } // 4. Assign the DataPartition to DataRegionGroup with the least DataPartitions // If the above DataRegionGroups are unavailable - TConsensusGroupId greedyGroupId = counter.getKeyWithMinValue(); + TConsensusGroupId greedyGroupId = availableDataRegionGroupCounter.getKeyWithMinValue(); seriesPartitionTable.putDataPartition(timePartitionSlot, greedyGroupId); - counter.put(greedyGroupId, counter.get(greedyGroupId) + 1); + availableDataRegionGroupCounter.put( + greedyGroupId, availableDataRegionGroupCounter.get(greedyGroupId) + 1); + LOGGER.warn( + "[PartitionBalancer] The SeriesSlot: {} in TimeSlot: {} will be allocated to DataRegionGroup: {}, because the original target: {} is currently unavailable.", + seriesPartitionSlot, + timePartitionSlot, + greedyGroupId, + allotGroupId); } dataPartitionTable