redundancy encoding when loading meta-data from BDB-JE
aloyszhang opened this issue · comments
There are some redundancy encoding when loading meta-data from BDB-JE like this :
if (logger.isDebugEnabled()) {
StringBuilder sBuilder = new StringBuilder(512);
logger.debug("[Load topic config] load broker topic record start:");
for (BdbTopicConfEntity bdbEntity : cursor) {
if (bdbEntity == null) {
logger.warn("[BDB Error] Found Null data while loading from topicConfIndex!");
continue;
}
ConcurrentHashMap<String/* topicName */, BdbTopicConfEntity> brokerTopicMap =
brokerIdTopicEntityMap.get(bdbEntity.getBrokerId());
if (brokerTopicMap == null) {
brokerTopicMap =
new ConcurrentHashMap<String, BdbTopicConfEntity>();
brokerIdTopicEntityMap.put(bdbEntity.getBrokerId(), brokerTopicMap);
}
brokerTopicMap.put(bdbEntity.getTopicName(), bdbEntity);
count++;
logger.debug(bdbEntity.toJsonString(sBuilder).toString());
sBuilder.delete(0, sBuilder.length());
}
logger.debug("[Load topic config] load broker topic record finished!");
} else {
for (BdbTopicConfEntity bdbEntity : cursor) {
if (bdbEntity == null) {
logger.warn("[BDB Error] Found Null data while loading from topicConfIndex!");
continue;
}
ConcurrentHashMap<String/* topicName */, BdbTopicConfEntity> brokerTopicMap =
brokerIdTopicEntityMap.get(bdbEntity.getBrokerId());
if (brokerTopicMap == null) {
brokerTopicMap =
new ConcurrentHashMap<String, BdbTopicConfEntity>();
brokerIdTopicEntityMap.put(bdbEntity.getBrokerId(), brokerTopicMap);
}
brokerTopicMap.put(bdbEntity.getTopicName(), bdbEntity);
count++;
}
}
I think we can make some condense about this.
@gosonzhang
Yes, these codes are more concise after this modification, thank you!