source: box/trunk/bin/bbstored/HousekeepStoreAccount.h @ 2586

Revision 2586, 3.0 KB checked in by chris, 3 years ago (diff)

Add methods to get the number of refcounts adjusted by the last
housekeeping, for testing.

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    HousekeepStoreAccount.h
5//              Purpose: Action class to perform housekeeping on a store account
6//              Created: 11/12/03
7//
8// --------------------------------------------------------------------------
9
10#ifndef HOUSEKEEPSTOREACCOUNT__H
11#define HOUSEKEEPSTOREACCOUNT__H
12
13#include <string>
14#include <set>
15#include <vector>
16
17class BackupStoreDaemon;
18class BackupStoreDirectory;
19
20class HousekeepingCallback
21{
22        public:
23        virtual ~HousekeepingCallback() {}
24        virtual bool CheckForInterProcessMsg(int AccountNum = 0, int MaximumWaitTime = 0) = 0;
25};
26
27// --------------------------------------------------------------------------
28//
29// Class
30//              Name:    HousekeepStoreAccount
31//              Purpose: Action class to perform housekeeping on a store account
32//              Created: 11/12/03
33//
34// --------------------------------------------------------------------------
35class HousekeepStoreAccount
36{
37public:
38        HousekeepStoreAccount(int AccountID, const std::string &rStoreRoot,
39                int StoreDiscSet, HousekeepingCallback* pHousekeepingCallback);
40        ~HousekeepStoreAccount();
41       
42        void DoHousekeeping(bool KeepTryingForever = false);
43        int GetRefCountsAdjusted() { return mRefCountsAdjusted; }
44       
45private:
46        // utility functions
47        void MakeObjectFilename(int64_t ObjectID, std::string &rFilenameOut);
48
49        bool ScanDirectory(int64_t ObjectID);
50        bool DeleteFiles();
51        bool DeleteEmptyDirectories();
52        void DeleteEmptyDirectory(int64_t dirId,
53                std::vector<int64_t>& rToExamine);
54        void DeleteFile(int64_t InDirectory, int64_t ObjectID, BackupStoreDirectory &rDirectory, const std::string &rDirectoryFilename, int64_t OriginalDirSizeInBlocks);
55
56private:
57        typedef struct
58        {
59                int64_t mObjectID;
60                int64_t mInDirectory;
61                int64_t mSizeInBlocks;
62                int32_t mMarkNumber;
63                int32_t mVersionAgeWithinMark;  // 0 == current, 1 latest old version, etc
64                bool    mIsFlagDeleted; // false for files flagged "Old"
65        } DelEn;
66       
67        struct DelEnCompare
68        {
69                bool operator()(const DelEn &x, const DelEn &y);
70        };
71       
72        int mAccountID;
73        std::string mStoreRoot;
74        int mStoreDiscSet;
75        HousekeepingCallback* mpHousekeepingCallback;
76       
77        int64_t mDeletionSizeTarget;
78       
79        std::set<DelEn, DelEnCompare> mPotentialDeletions;
80        int64_t mPotentialDeletionsTotalSize;
81        int64_t mMaxSizeInPotentialDeletions;
82       
83        // List of directories which are empty, and might be good for deleting
84        std::vector<int64_t> mEmptyDirectories;
85       
86        // The re-calculated blocks used stats
87        int64_t mBlocksUsed;
88        int64_t mBlocksInOldFiles;
89        int64_t mBlocksInDeletedFiles;
90        int64_t mBlocksInDirectories;
91
92        // Deltas from deletion
93        int64_t mBlocksUsedDelta;
94        int64_t mBlocksInOldFilesDelta;
95        int64_t mBlocksInDeletedFilesDelta;
96        int64_t mBlocksInDirectoriesDelta;
97       
98        // Deletion count
99        int64_t mFilesDeleted;
100        int64_t mEmptyDirectoriesDeleted;
101
102        // New reference count list
103        std::vector<uint32_t> mNewRefCounts;
104        bool mSuppressRefCountChangeWarnings;
105        int mRefCountsAdjusted;
106       
107        // Poll frequency
108        int mCountUntilNextInterprocessMsgCheck;
109};
110
111#endif // HOUSEKEEPSTOREACCOUNT__H
112
Note: See TracBrowser for help on using the repository browser.