#include <dur.h>
Public Member Functions | |
template<typename T > | |
T * | alreadyDeclared (T *x) |
virtual bool | awaitCommit ()=0 |
virtual bool | commitIfNeeded ()=0 |
virtual bool | commitNow ()=0 |
virtual void | createdFile (string filename, unsigned long long len)=0 |
virtual void | declareWriteIntent (void *x, unsigned len)=0 |
virtual void | setNoJournal (void *dst, void *src, unsigned len)=0 |
virtual void | syncDataAndTruncateJournal ()=0 |
template<typename T > | |
T * | writing (T *x) |
virtual void * | writingAtOffset (void *buf, unsigned ofs, unsigned len)=0 |
DiskLoc & | writingDiskLoc (DiskLoc &d) |
int & | writingInt (const int &d) |
virtual void * | writingPtr (void *x, unsigned len)=0 |
virtual void * | writingRangesAtOffsets (void *buf, const vector< pair< long long, unsigned > > &ranges)=0 |
virtual | ~DurableInterface () |
Static Public Member Functions | |
static DurableInterface & | getDur () |
Private Member Functions | |
NamespaceDetails * | writing (NamespaceDetails *) |
BtreeBucket * | writing (BtreeBucket *) |
Record * | writing (Record *r) |
Static Private Member Functions | |
static void | disableDurability () |
static void | enableDurability () |
Static Private Attributes | |
static DurableInterface * | _impl |
Friends | |
void | startup () |
class | TempDisableDurability |
Definition at line 27 of file dur.h.
virtual mongo::dur::DurableInterface::~DurableInterface | ( | ) | [inline, virtual] |
T* mongo::dur::DurableInterface::alreadyDeclared | ( | T * | x | ) | [inline] |
virtual bool mongo::dur::DurableInterface::awaitCommit | ( | ) | [pure virtual] |
Wait for acknowledgement of the next group commit.
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
virtual bool mongo::dur::DurableInterface::commitIfNeeded | ( | ) | [pure virtual] |
Commit if enough bytes have been modified. Current threshold is 50MB
The idea is that long running write operations that dont yield (like creating an index or update with $atomic) can call this whenever the db is in a sane state and it will prevent commits from growing too large.
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
virtual bool mongo::dur::DurableInterface::commitNow | ( | ) | [pure virtual] |
Commit immediately.
Generally, you do not want to do this often, as highly granular committing may affect performance.
Does not return until the commit is complete.
You must be at least read locked when you call this. Ideally, you are not write locked and then read operations can occur concurrently.
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
virtual void mongo::dur::DurableInterface::createdFile | ( | string | filename, | |
unsigned long long | len | |||
) | [pure virtual] |
Declare that a file has been created Normally writes are applied only after journaling, for safety. But here the file is created first, and the journal will just replay the creation if the create didn't happen because of crashing.
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
virtual void mongo::dur::DurableInterface::declareWriteIntent | ( | void * | x, | |
unsigned | len | |||
) | [pure virtual] |
declare write intent; should already be in the write view to work correctly when testIntent is true. if you aren't, use writingPtr() instead.
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
static void mongo::dur::DurableInterface::disableDurability | ( | ) | [static, private] |
static void mongo::dur::DurableInterface::enableDurability | ( | ) | [static, private] |
static DurableInterface& mongo::dur::DurableInterface::getDur | ( | ) | [inline, static] |
virtual void mongo::dur::DurableInterface::setNoJournal | ( | void * | dst, | |
void * | src, | |||
unsigned | len | |||
) | [pure virtual] |
write something that doesn't have to be journaled, as this write is "unimportant". a good example is paddingFactor. can be thought of as memcpy(dst,src,len) the dur implementation acquires a mutex in this method, so do not assume it is faster without measuring!
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
virtual void mongo::dur::DurableInterface::syncDataAndTruncateJournal | ( | ) | [pure virtual] |
Commits pending changes, flushes all changes to main data files, then removes the journal.
This is useful as a "barrier" to ensure that writes before this call will never go through recovery and be applied to files that have had changes made after this call applied.
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
NamespaceDetails* mongo::dur::DurableInterface::writing | ( | NamespaceDetails * | ) | [private] |
Intentionally unimplemented method. NamespaceDetails may be based on references to 'Extra' objects.
BtreeBucket* mongo::dur::DurableInterface::writing | ( | BtreeBucket * | ) | [private] |
Intentionally unimplemented method. BtreeBuckets are allocated in buffers larger than sizeof( BtreeBucket ).
Intentionally unimplemented method. It's very easy to manipulate Record::data open ended. Thus a call to writing(Record*) is suspect. This will override the templated version and yield an unresolved external.
T* mongo::dur::DurableInterface::writing | ( | T * | x | ) | [inline] |
virtual void* mongo::dur::DurableInterface::writingAtOffset | ( | void * | buf, | |
unsigned | ofs, | |||
unsigned | len | |||
) | [pure virtual] |
declare intent to write
ofs | offset within buf at which we will write | |
len | the length at ofs we will write |
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
Declare write intent for a DiskLoc.
int& mongo::dur::DurableInterface::writingInt | ( | const int & | d | ) | [inline] |
virtual void* mongo::dur::DurableInterface::writingPtr | ( | void * | x, | |
unsigned | len | |||
) | [pure virtual] |
Declarations of write intent.
Use these methods to declare "i'm about to write to x and it should be logged for redo."
Failure to call writing...() is checked in _DEBUG mode by using a read only mapped view (i.e., you'll segfault if the code is covered in that situation). The _DEBUG check doesn't verify that your length is correct though. declare intent to write to x for up to len
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
virtual void* mongo::dur::DurableInterface::writingRangesAtOffsets | ( | void * | buf, | |
const vector< pair< long long, unsigned > > & | ranges | |||
) | [pure virtual] |
declare intent to write
ranges | vector of pairs representing ranges. Each pair comprises an offset from buf where a range begins, then the range length. |
Implemented in mongo::dur::NonDurableImpl, and mongo::dur::DurableImpl.
void startup | ( | ) | [friend] |
Call during startup so durability module can initialize Throws if fatal error Does nothing if cmdLine.dur is false
DurableInterface* mongo::dur::DurableInterface::_impl [static, private] |