Storage Engine API
mongo::MongoFile Class Referenceabstract

#include <mmap.h>

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

Classes

class  Flushable
 Flushable has to fail nicely if the underlying object gets killed. More...
 

Public Types

enum  Options { NONE = 0, SEQUENTIAL = 1 << 0, READONLY = 1 << 1 }
 
using OptionSet = std::underlying_type< Options >::type
 

Public Member Functions

 MongoFile (OptionSet options)
 
virtual ~MongoFile ()=default
 
virtual bool isDurableMappedFile ()
 
std::string filename () const
 
void setFilename (OperationContext *opCtx, const std::string &fn)
 
virtual uint64_t getUniqueId () const =0
 

Static Public Member Functions

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)
 

Protected Member Functions

virtual void close (OperationContext *opCtx)=0
 Implementations may assume this is called from within LockMongoFilesExclusive. More...
 
virtual void flush (bool sync)=0
 
virtual FlushableprepareFlush ()=0
 returns a thread safe object that you can call flush on Flushable has to fail nicely if the underlying object gets killed More...
 
virtual bool isClosed ()=0
 Returns true iff the file is closed. More...
 
void created (OperationContext *opCtx)
 
void destroyed (OperationContext *opCtx)
 Implementations may assume this is called from within LockMongoFilesExclusive. More...
 
virtual unsigned long long length () const =0
 
bool isOptionSet (Options option) const
 

Private Member Functions

 MONGO_DISALLOW_COPYING (MongoFile)
 

Static Private Member Functions

static int _flushAll (OperationContext *opCtx, bool sync)
 

Private Attributes

std::string _filename
 
const OptionSet _options
 

Member Typedef Documentation

◆ OptionSet

using mongo::MongoFile::OptionSet = std::underlying_type<Options>::type

Member Enumeration Documentation

◆ Options

Enumerator
NONE 
SEQUENTIAL 
READONLY 

Constructor & Destructor Documentation

◆ MongoFile()

mongo::MongoFile::MongoFile ( OptionSet  options)

◆ ~MongoFile()

virtual mongo::MongoFile::~MongoFile ( )
virtualdefault

Member Function Documentation

◆ _flushAll()

int mongo::MongoFile::_flushAll ( OperationContext *  opCtx,
bool  sync 
)
staticprivate

◆ close()

virtual void mongo::MongoFile::close ( OperationContext *  opCtx)
protectedpure virtual

Implementations may assume this is called from within LockMongoFilesExclusive.

Implemented in mongo::MemoryMappedFile, and mongo::DurableMappedFile.

◆ closeAllFiles()

void mongo::MongoFile::closeAllFiles ( OperationContext *  opCtx,
std::stringstream &  message 
)
static

◆ created()

void mongo::MongoFile::created ( OperationContext *  opCtx)
protected

◆ destroyed()

void mongo::MongoFile::destroyed ( OperationContext *  opCtx)
protected

Implementations may assume this is called from within LockMongoFilesExclusive.

subclass must call in destructor (or at close). removes this from pathToFile and other maps safe to call more than once, albeit might be wasted work ideal to call close to the close, if the close is well before object destruction

◆ filename()

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

◆ flush()

virtual void mongo::MongoFile::flush ( bool  sync)
protectedpure virtual

◆ flushAll()

int mongo::MongoFile::flushAll ( OperationContext *  opCtx,
bool  sync 
)
static

◆ forEach()

template<class F >
void mongo::MongoFile::forEach ( OperationContext *  opCtx,
p 
)
inlinestatic

p is called from within a mutex that MongoFile uses.

Parameters
funis called for each MongoFile. called from within a mutex that MongoFile uses. so be careful not to deadlock.

so be careful not to deadlock.

◆ getAllFiles()

set< MongoFile * > & mongo::MongoFile::getAllFiles ( )
static

note: you need to be in mmmutex when using this.

forEach (above) handles that for you automatically.

◆ getUniqueId()

virtual uint64_t mongo::MongoFile::getUniqueId ( ) const
pure virtual

Implemented in mongo::MemoryMappedFile.

◆ isClosed()

virtual bool mongo::MongoFile::isClosed ( )
protectedpure virtual

Returns true iff the file is closed.

Implemented in mongo::MemoryMappedFile.

◆ isDurableMappedFile()

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

Reimplemented in mongo::DurableMappedFile.

◆ isOptionSet()

bool mongo::MongoFile::isOptionSet ( Options  option) const
inlineprotected

◆ length()

virtual unsigned long long mongo::MongoFile::length ( ) const
protectedpure virtual

◆ MONGO_DISALLOW_COPYING()

mongo::MongoFile::MONGO_DISALLOW_COPYING ( MongoFile  )
private

◆ prepareFlush()

virtual Flushable* mongo::MongoFile::prepareFlush ( )
protectedpure virtual

returns a thread safe object that you can call flush on Flushable has to fail nicely if the underlying object gets killed

Implemented in mongo::MemoryMappedFile.

◆ setFilename()

void mongo::MongoFile::setFilename ( OperationContext *  opCtx,
const std::string &  fn 
)

Member Data Documentation

◆ _filename

std::string mongo::MongoFile::_filename
private

◆ _options

const OptionSet mongo::MongoFile::_options
private

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