Storage Engine API
mongo::DurableMappedFile Class Reference

DurableMappedFile adds some layers atop memory mapped files - specifically our handling of private views & such. More...

#include <durable_mapped_file.h>

Inheritance diagram for mongo::DurableMappedFile:
mongo::MemoryMappedFile

Detailed Description

DurableMappedFile adds some layers atop memory mapped files - specifically our handling of private views & such.

if you don't care about journaling/durability (temp sort files & such) use MemoryMappedFile class, not this.

Public Member Functions

 DurableMappedFile (OperationContext *opCtx, OptionSet options=NONE)
 
virtual ~DurableMappedFile ()
 
virtual void close (OperationContext *opCtx)
 Callers must be holding a LockMongoFilesExclusive. More...
 
bool open (OperationContext *opCtx, const std::string &fname)
 
unsigned long long length () const
 
std::string filename () const
 
void flush (bool sync)
 
bool create (OperationContext *opCtx, const std::string &fname, unsigned long long &len)
 
voidgetView () const
 
voidview_write () const
 
const RelativePathrelativePath () const
 for a filename a/b/c.3 filePath() is "a/b/c" fileSuffixNo() is 3 if the suffix is "ns", fileSuffixNo -1 More...
 
int fileSuffixNo () const
 
HANDLE getFd ()
 
bool willNeedRemap ()
 true if we have written. More...
 
void setWillNeedRemap ()
 
void remapThePrivateView (OperationContext *opCtx)
 
virtual bool isDurableMappedFile ()
 

Protected Member Functions

virtual voidviewForFlushing ()
 

Private Member Functions

void setPath (const std::string &pathAndFileName)
 
bool finishOpening ()
 
- Private Member Functions inherited from mongo::MemoryMappedFile
 MemoryMappedFile (OperationContext *opCtx, OptionSet options=NONE)
 
virtual ~MemoryMappedFile ()
 
voidmap (OperationContext *opCtx, const char *filename)
 uasserts if file doesn't exist. More...
 
voidcreate (OperationContext *opCtx, const std::string &filename, unsigned long long len, bool zero)
 uasserts if file exists. More...
 
void flush (bool sync)
 
virtual bool isClosed ()
 Returns true iff the file is closed. More...
 
virtual FlushableprepareFlush ()
 returns a thread safe object that you can call flush on Flushable has to fail nicely if the underlying object gets killed More...
 
long shortLength () const
 
unsigned long long length () const
 
HANDLE getFd () const
 
voidcreatePrivateMap ()
 Creates a new view with the specified properties. More...
 
virtual uint64_t getUniqueId () const
 
voidmap (OperationContext *opCtx, const char *filename, unsigned long long &length)
 Creates with length if DNE, otherwise validates input length. More...
 
voidremapPrivateView (OperationContext *opCtx, void *oldPrivateAddr)
 Close the current private view and open a new replacement. More...
 
- Private Member Functions inherited from mongo::MongoFile
 MongoFile (OptionSet options)
 
virtual ~MongoFile ()=default
 
std::string filename () const
 
void setFilename (OperationContext *opCtx, const std::string &fn)
 
void created (OperationContext *opCtx)
 
void destroyed (OperationContext *opCtx)
 Implementations may assume this is called from within LockMongoFilesExclusive. More...
 
bool isOptionSet (Options option) const
 

Private Attributes

void_view_write
 
void_view_private
 
bool _willNeedRemap
 
RelativePath _p
 
int _fileSuffixNo
 

Additional Inherited Members

- Private Types inherited from mongo::MongoFile
enum  Options { NONE = 0, SEQUENTIAL = 1 << 0, READONLY = 1 << 1 }
 
using OptionSet = std::underlying_type< Options >::type
 
- Static Private Member Functions inherited from mongo::MemoryMappedFile
static int totalMappedLengthInMB ()
 
- Static Private Member Functions inherited from mongo::MongoFile
template<class F >
static void forEach (OperationContext *opCtx, F fun)
 p is called from within a mutex that MongoFile uses. More...
 
static std::set< MongoFile * > & getAllFiles ()
 note: you need to be in mmmutex when using this. More...
 
static int flushAll (OperationContext *opCtx, bool sync)
 
static void closeAllFiles (OperationContext *opCtx, std::stringstream &message)
 

Constructor & Destructor Documentation

◆ DurableMappedFile()

mongo::DurableMappedFile::DurableMappedFile ( OperationContext *  opCtx,
OptionSet  options = NONE 
)
explicit

◆ ~DurableMappedFile()

mongo::DurableMappedFile::~DurableMappedFile ( )
virtual

Member Function Documentation

◆ close()

void mongo::DurableMappedFile::close ( OperationContext *  opCtx)
virtual

Callers must be holding a LockMongoFilesExclusive.

Reimplemented from mongo::MemoryMappedFile.

◆ create()

bool mongo::DurableMappedFile::create ( OperationContext *  opCtx,
const std::string &  fname,
unsigned long long &  len 
)

◆ filename()

std::string mongo::DurableMappedFile::filename ( ) const
inline

◆ fileSuffixNo()

int mongo::DurableMappedFile::fileSuffixNo ( ) const
inline

◆ finishOpening()

bool mongo::DurableMappedFile::finishOpening ( )
private

◆ flush()

void mongo::DurableMappedFile::flush ( bool  sync)
inlinevirtual

Implements mongo::MongoFile.

◆ getFd()

HANDLE mongo::DurableMappedFile::getFd ( )
inline

◆ getView()

void* mongo::DurableMappedFile::getView ( ) const
inline

◆ isDurableMappedFile()

virtual bool mongo::DurableMappedFile::isDurableMappedFile ( )
inlinevirtual

Reimplemented from mongo::MongoFile.

◆ length()

unsigned long long mongo::DurableMappedFile::length ( ) const
inlinevirtual
Returns
file length

Implements mongo::MongoFile.

◆ open()

bool mongo::DurableMappedFile::open ( OperationContext *  opCtx,
const std::string &  fname 
)
Returns
true if opened ok.

◆ relativePath()

const RelativePath& mongo::DurableMappedFile::relativePath ( ) const
inline

for a filename a/b/c.3 filePath() is "a/b/c" fileSuffixNo() is 3 if the suffix is "ns", fileSuffixNo -1

◆ remapThePrivateView()

void mongo::DurableMappedFile::remapThePrivateView ( OperationContext *  opCtx)

◆ setPath()

void mongo::DurableMappedFile::setPath ( const std::string &  pathAndFileName)
private

◆ setWillNeedRemap()

void mongo::DurableMappedFile::setWillNeedRemap ( )
inline

◆ view_write()

void* mongo::DurableMappedFile::view_write ( ) const
inline

◆ viewForFlushing()

virtual void* mongo::DurableMappedFile::viewForFlushing ( )
inlineprotectedvirtual

Reimplemented from mongo::MemoryMappedFile.

◆ willNeedRemap()

bool mongo::DurableMappedFile::willNeedRemap ( )
inline

true if we have written.

set in PREPLOGBUFFER, it is NOT set immediately on write intent declaration. reset to false in REMAPPRIVATEVIEW

Member Data Documentation

◆ _fileSuffixNo

int mongo::DurableMappedFile::_fileSuffixNo
private

◆ _p

RelativePath mongo::DurableMappedFile::_p
private

◆ _view_private

void* mongo::DurableMappedFile::_view_private
private

◆ _view_write

void* mongo::DurableMappedFile::_view_write
private

◆ _willNeedRemap

bool mongo::DurableMappedFile::_willNeedRemap
private

The documentation for this class was generated from the following files: