blob: a255e11be6b53b4da30d6d8b26465f409bb9cf5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// @file dur.h durability support
#pragma once
#include <boost/filesystem/operations.hpp>
#include <list>
#include "mongo/db/dur_journalformat.h"
#include "mongo/util/concurrency/mutex.h"
#include "mongo/util/file.h"
namespace mongo {
class MongoMMF;
namespace dur {
struct ParsedJournalEntry;
/** call go() to execute a recovery from existing journal files.
*/
class RecoveryJob : boost::noncopyable {
static class Last {
public:
Last();
MongoMMF* newEntry(const ParsedJournalEntry&, RecoveryJob&);
private:
MongoMMF *mmf;
string dbName;
int fileNo;
} last;
public:
RecoveryJob() : _lastDataSyncedFromLastRun(0),
_mx("recovery"), _recovering(false) { _lastSeqMentionedInConsoleLog = 1; }
void go(vector<boost::filesystem::path>& files);
~RecoveryJob();
/** @param data data between header and footer. compressed if recovering. */
void processSection(const JSectHeader *h, const void *data, unsigned len, const JSectFooter *f);
void close(); // locks and calls _close()
static RecoveryJob & get() { return _instance; }
private:
void write(Last& last, const ParsedJournalEntry& entry); // actually writes to the file
void applyEntry(Last& last, const ParsedJournalEntry& entry, bool apply, bool dump);
void applyEntries(const vector<ParsedJournalEntry> &entries);
bool processFileBuffer(const void *, unsigned len);
bool processFile(boost::filesystem::path journalfile);
void _close(); // doesn't lock
MongoMMF* getMongoMMF(const ParsedJournalEntry& entry);
list<boost::shared_ptr<MongoMMF> > _mmfs;
unsigned long long _lastDataSyncedFromLastRun;
unsigned long long _lastSeqMentionedInConsoleLog;
public:
mongo::mutex _mx; // protects _mmfs
private:
bool _recovering; // are we in recovery or WRITETODATAFILES
static RecoveryJob &_instance;
};
}
}
|