Details
Description
NNStorageRetentionManager.java
private long getImageTxIdToRetain(FSImageTransactionalStorageInspector inspector) { List<FSImageFile> images = inspector.getFoundImages(); TreeSet<Long> imageTxIds = Sets.newTreeSet(); for (FSImageFile image : images) { imageTxIds.add(image.getCheckpointTxId()); } List<Long> imageTxIdsList = Lists.newArrayList(imageTxIds); if (imageTxIdsList.isEmpty()) { return 0; } Collections.reverse(imageTxIdsList); int toRetain = Math.min(numCheckpointsToRetain, imageTxIdsList.size()); long minTxId = imageTxIdsList.get(toRetain - 1); LOG.info("Going to retain " + toRetain + " images with txid >= " + minTxId); return minTxId; }
- Fix check style issues
- Use SLF4J paramaterized logging
- A lot of work gets done before checking if the list actually contains any entries and returning a 0. That should be the first thing that happens
- Instead of building up the TreeSet in its natural order, then reversing the collection, simply use a reverse natural ordering to begin with and save a step.