Exemple #1
0
 private void PurgeCheckpointsOlderThan(FSImageTransactionalStorageInspector inspector
                                        , long minTxId)
 {
     foreach (FSImageStorageInspector.FSImageFile image in inspector.GetFoundImages())
     {
         if (image.GetCheckpointTxId() < minTxId)
         {
             purger.PurgeImage(image);
         }
     }
 }
Exemple #2
0
        /// <exception cref="System.IO.IOException"/>
        internal virtual void PurgeCheckpoinsAfter(NNStorage.NameNodeFile nnf, long fromTxId
                                                   )
        {
            FSImageTransactionalStorageInspector inspector = new FSImageTransactionalStorageInspector
                                                                 (EnumSet.Of(nnf));

            storage.InspectStorageDirs(inspector);
            foreach (FSImageStorageInspector.FSImageFile image in inspector.GetFoundImages())
            {
                if (image.GetCheckpointTxId() > fromTxId)
                {
                    purger.PurgeImage(image);
                }
            }
        }
Exemple #3
0
        /// <param name="inspector">inspector that has already inspected all storage dirs</param>
        /// <returns>
        /// the transaction ID corresponding to the oldest checkpoint
        /// that should be retained.
        /// </returns>
        private long GetImageTxIdToRetain(FSImageTransactionalStorageInspector inspector)
        {
            IList <FSImageStorageInspector.FSImageFile> images = inspector.GetFoundImages();
            TreeSet <long> imageTxIds = Sets.NewTreeSet();

            foreach (FSImageStorageInspector.FSImageFile image in images)
            {
                imageTxIds.AddItem(image.GetCheckpointTxId());
            }
            IList <long> imageTxIdsList = Lists.NewArrayList(imageTxIds);

            if (imageTxIdsList.IsEmpty())
            {
                return(0);
            }
            Sharpen.Collections.Reverse(imageTxIdsList);
            int  toRetain = Math.Min(numCheckpointsToRetain, imageTxIdsList.Count);
            long minTxId  = imageTxIdsList[toRetain - 1];

            Log.Info("Going to retain " + toRetain + " images with txid >= " + minTxId);
            return(minTxId);
        }