Storage Engine API
durop.h
Go to the documentation of this file.
1
// @file durop.h class DurOp and descendants
2
31
#pragma once
32
33
34
#include "
mongo/db/storage/mmap_v1/dur_journalformat.h
"
35
#include "
mongo/db/storage/mmap_v1/paths.h
"
36
#include "mongo/util/bufreader.h"
37
38
namespace
mongo
{
39
40
class
AlignedBuilder;
41
42
namespace
dur {
43
52
class
DurOp
{
/* copyable */
53
public
:
54
// @param opcode a sentinel value near max unsigned which uniquely identifies the operation.
55
// @see dur::JEntry
56
DurOp
(
unsigned
opcode) :
_opcode
(opcode) {}
57
58
virtual
~DurOp
() {}
59
61
void
serialize
(
AlignedBuilder
& ab);
62
66
static
std::shared_ptr<DurOp>
read
(
unsigned
opcode, BufReader& br);
67
74
virtual
void
replay
() = 0;
75
76
virtual
std::string
toString
() = 0;
77
79
virtual
bool
needFilesClosed
() {
80
return
false
;
81
}
82
83
protected
:
85
virtual
void
_serialize
(
AlignedBuilder
& ab) = 0;
86
87
private
:
88
const
unsigned
_opcode
;
89
};
90
92
class
FileCreatedOp
:
public
DurOp
{
93
public
:
94
FileCreatedOp
(BufReader& log);
96
FileCreatedOp
(
const
std::string& f,
unsigned
long
long
l);
97
virtual
void
replay
();
98
virtual
std::string
toString
();
99
virtual
bool
needFilesClosed
();
100
101
protected
:
102
virtual
void
_serialize
(
AlignedBuilder
& ab);
103
104
private
:
105
RelativePath
_p
;
106
unsigned
long
long
_len
;
// size of file, not length of name
107
};
108
110
class
DropDbOp
:
public
DurOp
{
111
public
:
112
DropDbOp
(BufReader& log);
113
DropDbOp
(
const
std::string&
db
) :
DurOp
(
JEntry
::OpCode_DropDb), _db(db) {}
114
virtual
void
replay
();
115
virtual
std::string
toString
() {
116
return
std::string(
"DropDbOp "
) + _db;
117
}
118
virtual
bool
needFilesClosed
() {
119
return
true
;
120
}
121
122
protected
:
123
virtual
void
_serialize
(
AlignedBuilder
& ab);
124
125
private
:
126
std::string
_db
;
127
};
128
}
129
}
mongo::dur::DurOp::_serialize
virtual void _serialize(AlignedBuilder &ab)=0
DurOp will have already written the opcode for you.
mongo::dur::FileCreatedOp::_len
unsigned long long _len
Definition:
durop.h:106
mongo::dur::JEntry
an individual write operation within a group commit section.
Definition:
dur_journalformat.h:119
mongo
Copyright (C) 2014 MongoDB Inc.
Definition:
bson_collection_catalog_entry.cpp:38
mongo::dur::DurOp::needFilesClosed
virtual bool needFilesClosed()
if the op requires all file to be closed before doing its work, returns true.
Definition:
durop.h:79
mongo::dur::DurOp::DurOp
DurOp(unsigned opcode)
Definition:
durop.h:56
mongo::dur::DropDbOp::_db
std::string _db
Definition:
durop.h:126
mongo::dur::DurOp::replay
virtual void replay()=0
replay the operation (during recovery) throws
mongo::dur::DropDbOp::DropDbOp
DropDbOp(const std::string &db)
Definition:
durop.h:113
mongo::dur::DurOp::~DurOp
virtual ~DurOp()
Definition:
durop.h:58
paths.h
mongo::dur::DurOp
DurOp - Operations we journal that aren't just basic writes.
Definition:
durop.h:52
mongo::dur::DurOp::_opcode
const unsigned _opcode
Definition:
durop.h:88
mongo::AlignedBuilder
a page-aligned BufBuilder.
Definition:
aligned_builder.h:37
mongo::dur::DropDbOp
record drop of a database
Definition:
durop.h:110
mongo::dur::DropDbOp::toString
virtual std::string toString()
Definition:
durop.h:115
mongo::dur::DurOp::read
static std::shared_ptr< DurOp > read(unsigned opcode, BufReader &br)
read a durop from journal file referenced by br.
Definition:
durop.cpp:60
mongo::dur::DurOp::toString
virtual std::string toString()=0
mongo::db
OperationContext Database * db
Definition:
database_impl.cpp:949
dur_journalformat.h
mongo::dur::DropDbOp::needFilesClosed
virtual bool needFilesClosed()
if the op requires all file to be closed before doing its work, returns true.
Definition:
durop.h:118
mongo::dur::FileCreatedOp
indicates creation of a new file
Definition:
durop.h:92
mongo::dur::FileCreatedOp::_p
RelativePath _p
Definition:
durop.h:105
mongo::dur::DurOp::serialize
void serialize(AlignedBuilder &ab)
serialize the op out to a builder which will then be written (presumably) to the journal ...
Definition:
durop.cpp:77
mongo::RelativePath
this is very much like a boost::path.
Definition:
paths.h:49
src
mongo
db
storage
mmap_v1
durop.h
Generated by
1.8.13