00001 // @file dur.h durability support 00002 00003 #pragma once 00004 00005 #include "../util/concurrency/mutex.h" 00006 #include "../util/file.h" 00007 00008 namespace mongo { 00009 class MongoMMF; 00010 00011 namespace dur { 00012 struct ParsedJournalEntry; 00013 00016 class RecoveryJob : boost::noncopyable { 00017 public: 00018 RecoveryJob() :_lastDataSyncedFromLastRun(0), _mx("recovery"), _recovering(false) { _lastSeqMentionedInConsoleLog = 1; } 00019 void go(vector<path>& files); 00020 ~RecoveryJob(); 00021 void processSection(const void *, unsigned len); 00022 void close(); // locks and calls _close() 00023 00024 static RecoveryJob & get() { return _instance; } 00025 private: 00026 void write(const ParsedJournalEntry& entry); // actually writes to the file 00027 void applyEntry(const ParsedJournalEntry& entry, bool apply, bool dump); 00028 void applyEntries(const vector<ParsedJournalEntry> &entries); 00029 bool processFileBuffer(const void *, unsigned len); 00030 bool processFile(path journalfile); 00031 void _close(); // doesn't lock 00032 00033 list<boost::shared_ptr<MongoMMF> > _mmfs; 00034 00035 unsigned long long _lastDataSyncedFromLastRun; 00036 unsigned long long _lastSeqMentionedInConsoleLog; 00037 00038 mongo::mutex _mx; // protects _mmfs 00039 00040 bool _recovering; // are we in recovery or WRITETODATAFILES 00041 00042 static RecoveryJob &_instance; 00043 }; 00044 } 00045 }