-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[remove datanode] Load balancing for removing datanode #15022
base: master
Are you sure you want to change the base?
Conversation
...rc/main/java/org/apache/iotdb/confignode/manager/load/balancer/region/IDestNodeSelector.java
Show resolved
Hide resolved
fakeToRealIdMap.keySet().stream() | ||
.filter(fakeId -> !remainDataNodesFakeId.contains(fakeId)) | ||
.collect(Collectors.toSet()); | ||
return availableDataNodeMap.get(alternativeDataNodes.stream().findAny().orElse(null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the meaning of get(null) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
...test/java/org/apache/iotdb/confignode/manager/load/balancer/region/DestNodeSelectorTest.java
Show resolved
Hide resolved
allocatedRegionGroups.remove(replicaSet); | ||
List<TDataNodeLocation> dataNodeLocations = replicaSet.getDataNodeLocations(); | ||
dataNodeLocations.remove(replicaSetRemoved.get(replicaSet.getRegionId())); | ||
replicaSet.setDataNodeLocations(dataNodeLocations); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to do this as you just remove it from replicaSet.getDataNodeLocations()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now allocatedReplicaSets is HashSet
, and the hash value of ReplicaSets will change. Removing, updating, and adding them is a safer approach
for (TRegionReplicaSet replicaSet : replicaSets) { | ||
replicaSetRemoved.put(replicaSet.getRegionId(), dataNodeLocation); | ||
} | ||
migratedReplicas.addAll(replicaSets); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it might repeat when we support removing multiple nodes in the future, right? Maybe we should use a set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
.getClusterSchemaManager() | ||
.getReplicationFactor(database, consensusGroupType); | ||
} catch (DatabaseNotExistsException e) { | ||
LOGGER.error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use warn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
allocatedRegionGroups.remove(remainReplicaSet); | ||
List<TDataNodeLocation> dataNodeLocations = remainReplicaSet.getDataNodeLocations(); | ||
dataNodeLocations.add(selectedDestDataNode.getLocation()); | ||
remainReplicaSet.setDataNodeLocations(dataNodeLocations); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure the correctness and readability of the code, it is recommended to retain the remove and add operations.
return regionMigrationPlans; | ||
} | ||
|
||
public List<RegionMigrationPlan> selectMigrationPlans( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can use gpt to refactor and improve the code here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
...che/iotdb/confignode/manager/load/balancer/region/PartiteGraphPlacementDestNodeSelector.java
Show resolved
Hide resolved
break; | ||
} | ||
alternativeReplica[replicationFactor - 1] = dataNodeEntry.dataNodeId; | ||
Pair<Integer, Integer> currentValue = valuation(alternativeReplica); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should we consider the number of regions first instead of divergence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such is the case. Only dataNodeEntries that meet the criteria of dataNodeEntry.freeDiskSpace == minFreeDiskSpace
will be considered.
allocateResult.remove(remainReplicaSet); | ||
List<TDataNodeLocation> dataNodeLocations = remainReplicaSet.getDataNodeLocations(); | ||
dataNodeLocations.add(selectedNode.getLocation()); | ||
remainReplicaSet.setDataNodeLocations(dataNodeLocations); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
List<TDataNodeLocation> dataNodeLocations = replicaSet.getDataNodeLocations(); | ||
allocateResult.remove(replicaSet); | ||
dataNodeLocations.remove(REMOVE_DATANODE_LOCATION); | ||
replicaSet.setDataNodeLocations(dataNodeLocations); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
selectedNodeIds.add(selectedNode.getLocation().getDataNodeId()); | ||
} | ||
|
||
Assert.assertEquals(TEST_DATA_NODE_NUM - 1, selectedNodeIds.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
Description
Add region migration dest datanode selection algorithm for load balancing during removing datanode.
Please see https://apache-iotdb-project.feishu.cn/docx/G5aPdZJ4QozqmkxO9dsc7sEsnTe for detail design.