Skip to content

Commit

Permalink
[ISSUE #6057] Modify magic number code
Browse files Browse the repository at this point in the history
  • Loading branch information
hardyfish committed Feb 23, 2023
1 parent 0ec8c92 commit bf11311
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -99,9 +100,9 @@ public byte[] encode(boolean compress) {
}

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) {
Expand Down Expand Up @@ -163,9 +164,9 @@ public static RegisterBrokerBody decode(byte[] data, boolean compressed, MQVersi
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;
}
Expand Down Expand Up @@ -212,12 +213,13 @@ public void setFilterServerList(List<String> filterServerList) {
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;
}
}

0 comments on commit bf11311

Please sign in to comment.