HxpSerein commented on code in PR #13559:
URL: https://github.com/apache/iotdb/pull/13559#discussion_r1778229388
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/node/RemoveDataNodesProcedure.java:
##########
@@ -212,22 +249,54 @@ protected RemoveDataNodeState getInitialState() {
public void serialize(DataOutputStream stream) throws IOException {
stream.writeShort(ProcedureType.REMOVE_DATA_NODE_PROCEDURE.getTypeCode());
super.serialize(stream);
- ThriftCommonsSerDeUtils.serializeTDataNodeLocation(removedDataNode,
stream);
- stream.writeInt(migratedDataNodeRegions.size());
- migratedDataNodeRegions.forEach(
- tid -> ThriftCommonsSerDeUtils.serializeTConsensusGroupId(tid,
stream));
+ stream.writeInt(removedDataNodes.size());
+ removedDataNodes.forEach(
+ dataNode ->
ThriftCommonsSerDeUtils.serializeTDataNodeLocation(dataNode, stream));
+ stream.writeInt(regionMigrationPlans.size());
+ regionMigrationPlans.forEach(
Review Comment:
refactored
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/node/RemoveDataNodesProcedure.java:
##########
@@ -212,22 +249,54 @@ protected RemoveDataNodeState getInitialState() {
public void serialize(DataOutputStream stream) throws IOException {
stream.writeShort(ProcedureType.REMOVE_DATA_NODE_PROCEDURE.getTypeCode());
super.serialize(stream);
- ThriftCommonsSerDeUtils.serializeTDataNodeLocation(removedDataNode,
stream);
- stream.writeInt(migratedDataNodeRegions.size());
- migratedDataNodeRegions.forEach(
- tid -> ThriftCommonsSerDeUtils.serializeTConsensusGroupId(tid,
stream));
+ stream.writeInt(removedDataNodes.size());
+ removedDataNodes.forEach(
+ dataNode ->
ThriftCommonsSerDeUtils.serializeTDataNodeLocation(dataNode, stream));
+ stream.writeInt(regionMigrationPlans.size());
+ regionMigrationPlans.forEach(
+ regionMigrationPlan -> {
+ ThriftCommonsSerDeUtils.serializeTConsensusGroupId(
+ regionMigrationPlan.getRegionId(), stream);
+ ThriftCommonsSerDeUtils.serializeTDataNodeLocation(
+ regionMigrationPlan.getFromDataNode(), stream);
+ ThriftCommonsSerDeUtils.serializeTDataNodeLocation(
+ regionMigrationPlan.getToDataNode(), stream);
+ });
+ stream.writeInt(nodeStatusMap.size());
+ for (Map.Entry<Integer, NodeStatus> entry : nodeStatusMap.entrySet()) {
+ stream.writeInt(entry.getKey());
+ stream.writeByte(entry.getValue().ordinal());
+ }
}
@Override
public void deserialize(ByteBuffer byteBuffer) {
super.deserialize(byteBuffer);
try {
- removedDataNode =
ThriftCommonsSerDeUtils.deserializeTDataNodeLocation(byteBuffer);
- int regionSize = byteBuffer.getInt();
- migratedDataNodeRegions = new ArrayList<>(regionSize);
- for (int i = 0; i < regionSize; i++) {
- migratedDataNodeRegions.add(
- ThriftCommonsSerDeUtils.deserializeTConsensusGroupId(byteBuffer));
+ int removedDataNodeSize = byteBuffer.getInt();
+ removedDataNodes = new ArrayList<>(removedDataNodeSize);
+ for (int i = 0; i < removedDataNodeSize; i++) {
+
removedDataNodes.add(ThriftCommonsSerDeUtils.deserializeTDataNodeLocation(byteBuffer));
+ }
+ int regionMigrationPlanSize = byteBuffer.getInt();
+ regionMigrationPlans = new ArrayList<>(regionMigrationPlanSize);
+ for (int i = 0; i < regionMigrationPlanSize; i++) {
+ TConsensusGroupId regionId =
+ ThriftCommonsSerDeUtils.deserializeTConsensusGroupId(byteBuffer);
+ TDataNodeLocation fromDataNode =
+ ThriftCommonsSerDeUtils.deserializeTDataNodeLocation(byteBuffer);
+ RegionMigrationPlan regionMigrationPlan =
+ RegionMigrationPlan.create(regionId, fromDataNode);
+ regionMigrationPlan.setToDataNode(
+ ThriftCommonsSerDeUtils.deserializeTDataNodeLocation(byteBuffer));
Review Comment:
refactored
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]