You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by in...@apache.org on 2019/08/29 21:18:46 UTC
[hadoop] branch trunk updated: HDFS-14104. Review
getImageTxIdToRetain. Contributed by David Mollitor.
This is an automated email from the ASF dual-hosted git repository.
inigoiri pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new ffca734 HDFS-14104. Review getImageTxIdToRetain. Contributed by David Mollitor.
ffca734 is described below
commit ffca734c62fba26211f22232ddb5e80eae4b5d51
Author: Inigo Goiri <in...@apache.org>
AuthorDate: Thu Aug 29 14:18:35 2019 -0700
HDFS-14104. Review getImageTxIdToRetain. Contributed by David Mollitor.
---
.../server/namenode/NNStorageRetentionManager.java | 27 +++++++++++-----------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NNStorageRetentionManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NNStorageRetentionManager.java
index fc54dfc..d0fa003 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NNStorageRetentionManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NNStorageRetentionManager.java
@@ -184,27 +184,26 @@ public class NNStorageRetentionManager {
* @return the transaction ID corresponding to the oldest checkpoint
* that should be retained.
*/
- private long getImageTxIdToRetain(FSImageTransactionalStorageInspector inspector) {
-
- List<FSImageFile> images = inspector.getFoundImages();
- TreeSet<Long> imageTxIds = Sets.newTreeSet();
+ private long getImageTxIdToRetain(
+ FSImageTransactionalStorageInspector inspector) {
+
+ final List<FSImageFile> images = inspector.getFoundImages();
+ if (images.isEmpty()) {
+ return 0L;
+ }
+
+ TreeSet<Long> imageTxIds = Sets.newTreeSet(Collections.reverseOrder());
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());
+ int toRetain = Math.min(numCheckpointsToRetain, imageTxIdsList.size());
long minTxId = imageTxIdsList.get(toRetain - 1);
- LOG.info("Going to retain " + toRetain + " images with txid >= " +
- minTxId);
+ LOG.info("Going to retain {} images with txid >= {}", toRetain, minTxId);
return minTxId;
}
-
+
/**
* Interface responsible for disposing of old checkpoints and edit logs.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org