Tencent / TubeMQ

TubeMQ has been donated to the Apache Software Foundation and renamed to InLong, please visit the new Apache repository: https://github.com/apache/incubator-inlong

Home Page:https://inlong.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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!