Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-14104

Review getImageTxIdToRetain

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.0.0
    • 3.3.0
    • namenode
    • None
    • Reviewed
    • Patch

    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;
        }
      
      1. Fix check style issues
      2. Use SLF4J paramaterized logging
      3. 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
      4. 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.

      Attachments

        1. HDFS-14104.5.patch
          2 kB
          David Mollitor
        2. HDFS-14104.4.patch
          2 kB
          David Mollitor
        3. HDFS-14104.3.patch
          2 kB
          David Mollitor
        4. HDFS-14104.2.patch
          2 kB
          David Mollitor
        5. HDFS-14104.1.patch
          2 kB
          David Mollitor
        6. HDFS-14104.1.patch
          2 kB
          David Mollitor
        7. HDFS-14104.1.patch
          2 kB
          David Mollitor

        Activity

          People

            belugabehr David Mollitor
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: