RongtongJin commented on code in PR #5601:
URL: https://github.com/apache/rocketmq/pull/5601#discussion_r1033050750
##########
controller/src/main/java/org/apache/rocketmq/controller/impl/manager/ReplicasInfoManager.java:
##########
@@ -466,4 +472,61 @@ private void handleCleanBrokerDataEvent(final
CleanBrokerDataEvent event) {
private boolean isContainsBroker(final String brokerName) {
return this.replicaInfoTable.containsKey(brokerName) &&
this.syncStateSetInfoTable.containsKey(brokerName);
}
+
+ @Override
+ public byte[] encodeMetadata() {
+ byte[] replicaInfoTableBytes =
this.serializer.serialize(this.replicaInfoTable);
+ byte[] syncStateSetInfoTableBytes =
this.serializer.serialize(this.syncStateSetInfoTable);
+
+ int replicaInfoTableLength = replicaInfoTableBytes == null ? 0 :
replicaInfoTableBytes.length;
+ int syncStateSetInfoTableLength = syncStateSetInfoTableBytes == null ?
0 : syncStateSetInfoTableBytes.length;
+
+ ByteBuffer buffer = ByteBuffer.allocate(8 + replicaInfoTableLength +
syncStateSetInfoTableLength);
+ buffer.putInt(replicaInfoTableLength);
+ buffer.putInt(syncStateSetInfoTableLength);
+ if (replicaInfoTableBytes != null) {
+ buffer.put(replicaInfoTableBytes);
+ }
+ if (syncStateSetInfoTableBytes != null) {
+ buffer.put(syncStateSetInfoTableBytes);
+ }
+ buffer.flip();
+
+ return buffer.array();
+ }
Review Comment:
It would be better to directly serialize into readable strings, just like
topics.json
--
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]