Storage Engine API
storage_engine_lock_file.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <boost/optional.hpp>
32 #include <memory>
33 #include <string>
34 
35 #include "mongo/base/disallow_copying.h"
36 #include "mongo/base/status.h"
37 #include "mongo/db/service_context.h"
38 
39 namespace mongo {
40 
43 
44 public:
45  static boost::optional<StorageEngineLockFile>& get(ServiceContext* service);
46 
53  StorageEngineLockFile(const std::string& dbpath);
54 
55  virtual ~StorageEngineLockFile();
56 
60  std::string getFilespec() const;
61 
67  bool createdByUncleanShutdown() const;
68 
72  Status open();
73 
77  void close();
78 
83  Status writePid();
84 
88  void clearPidAndUnlock();
89 
90 private:
91  std::string _dbpath;
92  std::string _filespec;
94 
96  std::unique_ptr<LockFileHandle> _lockFileHandle;
97 };
98 
99 } // namespace mongo
std::unique_ptr< LockFileHandle > _lockFileHandle
Definition: storage_engine_lock_file.h:95
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
void clearPidAndUnlock()
Truncates file contents and releases file locks.
Definition: storage_engine_lock_file_posix.cpp:243
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
Status writePid()
Writes current process ID to file.
Definition: storage_engine_lock_file_posix.cpp:190
Status open()
Opens and locks &#39;mongod.lock&#39; in &#39;dbpath&#39; directory.
Definition: storage_engine_lock_file_posix.cpp:131
std::string _filespec
Definition: storage_engine_lock_file.h:92
ServiceContextNoop service
Definition: kv_engine_test_timestamps.cpp:203
std::string getFilespec() const
Returns the path to the lock file.
Definition: storage_engine_lock_file_posix.cpp:123
Definition: storage_engine_lock_file_posix.cpp:99
StorageEngineLockFile(const std::string &dbpath)
Checks existing lock file, if present, to see if it contains data from a previous unclean shutdown...
Definition: storage_engine_lock_file_posix.cpp:112
bool createdByUncleanShutdown() const
Returns true if lock file was not zeroed out due to previous unclean shutdown.
Definition: storage_engine_lock_file_posix.cpp:127
bool _uncleanShutdown
Definition: storage_engine_lock_file.h:93
std::string _dbpath
Definition: storage_engine_lock_file.h:91
Definition: storage_engine_lock_file.h:41
void close()
Closes lock file handles.
Definition: storage_engine_lock_file_posix.cpp:181
virtual ~StorageEngineLockFile()
Definition: storage_engine_lock_file_posix.cpp:119
MONGO_DISALLOW_COPYING(StorageEngineLockFile)