Storage Engine API
mongo::StorageEngineLockFile Class Reference

#include <storage_engine_lock_file.h>

Classes

class  LockFileHandle
 

Public Member Functions

 StorageEngineLockFile (const std::string &dbpath)
 Checks existing lock file, if present, to see if it contains data from a previous unclean shutdown. More...
 
virtual ~StorageEngineLockFile ()
 
std::string getFilespec () const
 Returns the path to the lock file. More...
 
bool createdByUncleanShutdown () const
 Returns true if lock file was not zeroed out due to previous unclean shutdown. More...
 
Status open ()
 Opens and locks 'mongod.lock' in 'dbpath' directory. More...
 
void close ()
 Closes lock file handles. More...
 
Status writePid ()
 Writes current process ID to file. More...
 
void clearPidAndUnlock ()
 Truncates file contents and releases file locks. More...
 

Static Public Member Functions

static boost::optional< StorageEngineLockFile > & get (ServiceContext *service)
 

Private Member Functions

 MONGO_DISALLOW_COPYING (StorageEngineLockFile)
 

Private Attributes

std::string _dbpath
 
std::string _filespec
 
bool _uncleanShutdown
 
std::unique_ptr< LockFileHandle_lockFileHandle
 

Constructor & Destructor Documentation

◆ StorageEngineLockFile()

mongo::StorageEngineLockFile::StorageEngineLockFile ( const std::string &  dbpath)

Checks existing lock file, if present, to see if it contains data from a previous unclean shutdown.

A clean shutdown should have produced a zero length lock file. Uses open() to read existing lock file or create new file. Uses boost::filesystem to check lock file so may throw boost::exception.

◆ ~StorageEngineLockFile()

mongo::StorageEngineLockFile::~StorageEngineLockFile ( )
virtual

Member Function Documentation

◆ clearPidAndUnlock()

void mongo::StorageEngineLockFile::clearPidAndUnlock ( )

Truncates file contents and releases file locks.

◆ close()

void mongo::StorageEngineLockFile::close ( )

Closes lock file handles.

◆ createdByUncleanShutdown()

bool mongo::StorageEngineLockFile::createdByUncleanShutdown ( ) const

Returns true if lock file was not zeroed out due to previous unclean shutdown.

This state is evaluated at object initialization to allow storage engine to make decisions on recovery based on this information after open() has been called.

◆ get()

boost::optional< StorageEngineLockFile > & mongo::StorageEngineLockFile::get ( ServiceContext *  service)
static

◆ getFilespec()

std::string mongo::StorageEngineLockFile::getFilespec ( ) const

Returns the path to the lock file.

◆ MONGO_DISALLOW_COPYING()

mongo::StorageEngineLockFile::MONGO_DISALLOW_COPYING ( StorageEngineLockFile  )
private

◆ open()

Status mongo::StorageEngineLockFile::open ( )

Opens and locks 'mongod.lock' in 'dbpath' directory.

◆ writePid()

Status mongo::StorageEngineLockFile::writePid ( )

Writes current process ID to file.

Fails if lock file has not been opened.

Member Data Documentation

◆ _dbpath

std::string mongo::StorageEngineLockFile::_dbpath
private

◆ _filespec

std::string mongo::StorageEngineLockFile::_filespec
private

◆ _lockFileHandle

std::unique_ptr<LockFileHandle> mongo::StorageEngineLockFile::_lockFileHandle
private

◆ _uncleanShutdown

bool mongo::StorageEngineLockFile::_uncleanShutdown
private

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