Storage Engine API
mongo::ExtentManager Class Referenceabstract

ExtentManager basics. More...

#include <extent_manager.h>

Inheritance diagram for mongo::ExtentManager:
mongo::DummyExtentManager mongo::MmapV1ExtentManager

Detailed Description

ExtentManager basics.

  • one per database
  • responsible for managing <db>.# files
  • NOT responsible for .ns file
  • gives out extents
  • responsible for figuring out how to get a new extent
  • can use any method it wants to do so
  • this structure is NOT stored on disk
  • files will not be removed from the EM
  • extent size and loc are immutable
  • this class is thread safe, once constructed and init()-ialized

Classes

class  CacheHint
 
class  Factory
 

Public Types

enum  HintType { Sequential, Random }
 

Public Member Functions

 ExtentManager ()
 
virtual ~ExtentManager ()
 
virtual void close (OperationContext *opCtx)=0
 
virtual Status init (OperationContext *opCtx)=0
 opens all current files More...
 
virtual int numFiles () const =0
 
virtual long long fileSize () const =0
 
virtual DiskLoc allocateExtent (OperationContext *opCtx, bool capped, int size, bool enforceQuota)=0
 
virtual void freeExtents (OperationContext *opCtx, DiskLoc firstExt, DiskLoc lastExt)=0
 firstExt has to be == lastExt or a chain More...
 
virtual void freeExtent (OperationContext *opCtx, DiskLoc extent)=0
 frees a single extent ignores all fields in the Extent except: magic, myLoc, length More...
 
virtual void freeListStats (OperationContext *opCtx, int *numExtents, int64_t *totalFreeSizeBytes) const =0
 Retrieve statistics on the the free list managed by this ExtentManger. More...
 
virtual MmapV1RecordHeaderrecordForV1 (const DiskLoc &loc) const =0
 
virtual std::unique_ptr< RecordFetcherrecordNeedsFetch (const DiskLoc &loc) const =0
 The extent manager tracks accesses to DiskLocs. More...
 
virtual ExtentextentForV1 (const DiskLoc &loc) const =0
 
virtual DiskLoc extentLocForV1 (const DiskLoc &loc) const =0
 
virtual ExtentgetExtent (const DiskLoc &loc, bool doSanityCheck=true) const =0
 
virtual int maxSize () const =0
 
virtual int minSize () const
 
virtual int followupSize (int recordLen, int lastExtentLen) const
 
virtual int initialSize (int recordLen) const
 get a suggested size for the first extent in a namespace More...
 
virtual int quantizeExtentSize (int size) const
 quantizes extent size to >= min + page boundary More...
 
virtual CacheHintcacheHint (const DiskLoc &extentLoc, const HintType &hint)=0
 Tell the system that for this extent, it will have this kind of disk access. More...
 
virtual DataFileVersion getFileFormat (OperationContext *opCtx) const =0
 
virtual void setFileFormat (OperationContext *opCtx, DataFileVersion newVersion)=0
 
virtual const DataFilegetOpenFile (int n) const =0
 

Private Member Functions

 MONGO_DISALLOW_COPYING (ExtentManager)
 

Member Enumeration Documentation

◆ HintType

Enumerator
Sequential 
Random 

Constructor & Destructor Documentation

◆ ExtentManager()

mongo::ExtentManager::ExtentManager ( )
inline

◆ ~ExtentManager()

virtual mongo::ExtentManager::~ExtentManager ( )
inlinevirtual

Member Function Documentation

◆ allocateExtent()

virtual DiskLoc mongo::ExtentManager::allocateExtent ( OperationContext *  opCtx,
bool  capped,
int  size,
bool  enforceQuota 
)
pure virtual

◆ cacheHint()

virtual CacheHint* mongo::ExtentManager::cacheHint ( const DiskLoc extentLoc,
const HintType hint 
)
pure virtual

Tell the system that for this extent, it will have this kind of disk access.

Caller takes owernship of CacheHint

Implemented in mongo::MmapV1ExtentManager, and mongo::DummyExtentManager.

◆ close()

virtual void mongo::ExtentManager::close ( OperationContext *  opCtx)
pure virtual

◆ extentForV1()

virtual Extent* mongo::ExtentManager::extentForV1 ( const DiskLoc loc) const
pure virtual
Parameters
loc- has to be for a specific MmapV1RecordHeader (not an Extent) Note(erh) see comment on recordFor

Implemented in mongo::DummyExtentManager, and mongo::MmapV1ExtentManager.

◆ extentLocForV1()

virtual DiskLoc mongo::ExtentManager::extentLocForV1 ( const DiskLoc loc) const
pure virtual
Parameters
loc- has to be for a specific MmapV1RecordHeader (not an Extent) Note(erh) see comment on recordFor

Implemented in mongo::MmapV1ExtentManager, and mongo::DummyExtentManager.

◆ fileSize()

virtual long long mongo::ExtentManager::fileSize ( ) const
pure virtual

◆ followupSize()

int mongo::ExtentManager::followupSize ( int  recordLen,
int  lastExtentLen 
) const
virtual
Parameters
recordLenlength of record we need
lastExtsize of last extent which is a factor in next extent size

◆ freeExtent()

virtual void mongo::ExtentManager::freeExtent ( OperationContext *  opCtx,
DiskLoc  extent 
)
pure virtual

frees a single extent ignores all fields in the Extent except: magic, myLoc, length

Implemented in mongo::DummyExtentManager, and mongo::MmapV1ExtentManager.

◆ freeExtents()

virtual void mongo::ExtentManager::freeExtents ( OperationContext *  opCtx,
DiskLoc  firstExt,
DiskLoc  lastExt 
)
pure virtual

firstExt has to be == lastExt or a chain

Implemented in mongo::DummyExtentManager, and mongo::MmapV1ExtentManager.

◆ freeListStats()

virtual void mongo::ExtentManager::freeListStats ( OperationContext *  opCtx,
int *  numExtents,
int64_t *  totalFreeSizeBytes 
) const
pure virtual

Retrieve statistics on the the free list managed by this ExtentManger.

Parameters
numExtents- non-null pointer to an int that will receive the number of extents
totalFreeSizeBytes- non-null pointer to an int64_t receiving the total free space in the free list.

Implemented in mongo::DummyExtentManager, and mongo::MmapV1ExtentManager.

◆ getExtent()

virtual Extent* mongo::ExtentManager::getExtent ( const DiskLoc loc,
bool  doSanityCheck = true 
) const
pure virtual
Parameters
loc- has to be for a specific Extent

Implemented in mongo::MmapV1ExtentManager, and mongo::DummyExtentManager.

◆ getFileFormat()

virtual DataFileVersion mongo::ExtentManager::getFileFormat ( OperationContext *  opCtx) const
pure virtual

◆ getOpenFile()

virtual const DataFile* mongo::ExtentManager::getOpenFile ( int  n) const
pure virtual

◆ init()

virtual Status mongo::ExtentManager::init ( OperationContext *  opCtx)
pure virtual

opens all current files

Implemented in mongo::DummyExtentManager, and mongo::MmapV1ExtentManager.

◆ initialSize()

int mongo::ExtentManager::initialSize ( int  recordLen) const
virtual

get a suggested size for the first extent in a namespace

Parameters
recordLenlength of record we need to insert

◆ maxSize()

virtual int mongo::ExtentManager::maxSize ( ) const
pure virtual
Returns
maximum size of an Extent

Implemented in mongo::MmapV1ExtentManager, and mongo::DummyExtentManager.

◆ minSize()

virtual int mongo::ExtentManager::minSize ( ) const
inlinevirtual
Returns
minimum size of an Extent

◆ MONGO_DISALLOW_COPYING()

mongo::ExtentManager::MONGO_DISALLOW_COPYING ( ExtentManager  )
private

◆ numFiles()

virtual int mongo::ExtentManager::numFiles ( ) const
pure virtual

◆ quantizeExtentSize()

int mongo::ExtentManager::quantizeExtentSize ( int  size) const
virtual

quantizes extent size to >= min + page boundary

◆ recordForV1()

virtual MmapV1RecordHeader* mongo::ExtentManager::recordForV1 ( const DiskLoc loc) const
pure virtual
Parameters
loc- has to be for a specific MmapV1RecordHeader Note(erh): this sadly cannot be removed. A MmapV1RecordHeader DiskLoc has an offset from a file, while a RecordStore really wants an offset from an extent. This intrinsically links an original record store to the original extent manager.

Implemented in mongo::DummyExtentManager, and mongo::MmapV1ExtentManager.

◆ recordNeedsFetch()

virtual std::unique_ptr<RecordFetcher> mongo::ExtentManager::recordNeedsFetch ( const DiskLoc loc) const
pure virtual

The extent manager tracks accesses to DiskLocs.

This returns non-NULL if the DiskLoc has been recently accessed, and therefore has likely been paged into physical memory. Returns nullptr if the DiskLoc is Null.

Implemented in mongo::DummyExtentManager, and mongo::MmapV1ExtentManager.

◆ setFileFormat()

virtual void mongo::ExtentManager::setFileFormat ( OperationContext *  opCtx,
DataFileVersion  newVersion 
)
pure virtual

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