You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2023/02/23 03:50:57 UTC
[rocketmq] branch develop updated: [ISSUE #6057] Modify magic number code
This is an automated email from the ASF dual-hosted git repository.
jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new bf1131113 [ISSUE #6057] Modify magic number code
bf1131113 is described below
commit bf1131113596582b76d0e3172c2de544a54cf2c7
Author: hardyfish <85...@users.noreply.github.com>
AuthorDate: Thu Feb 23 11:50:35 2023 +0800
[ISSUE #6057] Modify magic number code
---
.../remoting/protocol/body/RegisterBrokerBody.java | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/RegisterBrokerBody.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/RegisterBrokerBody.java
index 6b9a28d74..99557b1d3 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/RegisterBrokerBody.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/RegisterBrokerBody.java
@@ -45,6 +45,7 @@ public class RegisterBrokerBody extends RemotingSerializable {
private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
private TopicConfigAndMappingSerializeWrapper topicConfigSerializeWrapper = new TopicConfigAndMappingSerializeWrapper();
private List<String> filterServerList = new ArrayList<>();
+ private static final long MINIMUM_TAKE_TIME_MILLISECOND = 50;
public byte[] encode(boolean compress) {
@@ -99,9 +100,9 @@ public class RegisterBrokerBody extends RemotingSerializable {
}
outputStream.finish();
- long interval = System.currentTimeMillis() - start;
- if (interval > 50) {
- LOGGER.info("Compressing takes {}ms", interval);
+ long takeTime = System.currentTimeMillis() - start;
+ if (takeTime > MINIMUM_TAKE_TIME_MILLISECOND) {
+ LOGGER.info("Compressing takes {}ms", takeTime);
}
return byteArrayOutputStream.toByteArray();
} catch (IOException e) {
@@ -163,9 +164,9 @@ public class RegisterBrokerBody extends RemotingSerializable {
registerBrokerBody.getTopicConfigSerializeWrapper().setTopicQueueMappingInfoMap(topicQueueMappingInfoMap);
}
- long interval = System.currentTimeMillis() - start;
- if (interval > 50) {
- LOGGER.info("Decompressing takes {}ms", interval);
+ long takeTime = System.currentTimeMillis() - start;
+ if (takeTime > MINIMUM_TAKE_TIME_MILLISECOND) {
+ LOGGER.info("Decompressing takes {}ms", takeTime);
}
return registerBrokerBody;
}
@@ -212,12 +213,13 @@ public class RegisterBrokerBody extends RemotingSerializable {
this.filterServerList = filterServerList;
}
- public static ConcurrentMap<String, TopicConfig> cloneTopicConfigTable(
+ private ConcurrentMap<String, TopicConfig> cloneTopicConfigTable(
ConcurrentMap<String, TopicConfig> topicConfigConcurrentMap) {
- ConcurrentHashMap<String, TopicConfig> result = new ConcurrentHashMap<>();
- if (topicConfigConcurrentMap != null) {
- result.putAll(topicConfigConcurrentMap);
+ if (topicConfigConcurrentMap == null) {
+ return null;
}
+ ConcurrentHashMap<String, TopicConfig> result = new ConcurrentHashMap<>(topicConfigConcurrentMap.size());
+ result.putAll(topicConfigConcurrentMap);
return result;
}
}