kr11 commented on a change in pull request #32: fix sonar issues URL: https://github.com/apache/incubator-iotdb/pull/32#discussion_r251009068
########## File path: iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeManager.java ########## @@ -127,57 +126,53 @@ public static FileNodeManager getInstance() { private void updateStatHashMapWhenFail(TSRecord tsRecord) { statParamsHashMap.get(MonitorConstants.FileNodeManagerStatConstants.TOTAL_REQ_FAIL.name()) - .incrementAndGet(); + .incrementAndGet(); statParamsHashMap.get(MonitorConstants.FileNodeManagerStatConstants.TOTAL_POINTS_FAIL.name()) - .addAndGet(tsRecord.dataPointList.size()); + .addAndGet(tsRecord.dataPointList.size()); } /** * get stats parameter hash map. * * @return the key represents the params' name, values is AtomicLong type */ - public HashMap<String, AtomicLong> getStatParamsHashMap() { + @Override + public Map<String, AtomicLong> getStatParamsHashMap() { return statParamsHashMap; } @Override public List<String> getAllPathForStatistic() { List<String> list = new ArrayList<>(); for (MonitorConstants.FileNodeManagerStatConstants statConstant : - MonitorConstants.FileNodeManagerStatConstants.values()) { + MonitorConstants.FileNodeManagerStatConstants.values()) { list.add( - statStorageDeltaName + MonitorConstants.MONITOR_PATH_SEPERATOR + statConstant.name()); + statStorageDeltaName + MonitorConstants.MONITOR_PATH_SEPERATOR + statConstant.name()); } return list; } @Override - public HashMap<String, TSRecord> getAllStatisticsValue() { + public Map<String, TSRecord> getAllStatisticsValue() { long curTime = System.currentTimeMillis(); TSRecord tsRecord = StatMonitor - .convertToTSRecord(getStatParamsHashMap(), statStorageDeltaName, curTime); - return new HashMap<String, TSRecord>() { - { - put(statStorageDeltaName, tsRecord); - } - }; + .convertToTSRecord(getStatParamsHashMap(), statStorageDeltaName, curTime); + HashMap<String, TSRecord> ret = new HashMap<>(); + ret.put(statStorageDeltaName, tsRecord); + return ret; } /** * Init Stat MetaDta TODO: Modify the throws operation. */ @Override public void registStatMetadata() { - HashMap<String, String> hashMap = new HashMap<String, String>() { - { - for (MonitorConstants.FileNodeManagerStatConstants statConstant : + HashMap<String, String> hashMap = new HashMap<>(); Review comment: maybe claim a variable with a generic interface? Map<> hashMap = new HashMap<>() ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services