Storage Engine API
mobile_kv_engine.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <memory>
32 
36 #include "mongo/stdx/mutex.h"
37 #include "mongo/util/string_map.h"
38 
39 namespace mongo {
40 
41 class JournalListener;
42 
43 class MobileKVEngine : public KVEngine {
44 public:
45  MobileKVEngine(const std::string& path);
46 
47  RecoveryUnit* newRecoveryUnit() override;
48 
49  Status createRecordStore(OperationContext* opCtx,
50  StringData ns,
51  StringData ident,
52  const CollectionOptions& options) override;
53 
54  std::unique_ptr<RecordStore> getRecordStore(OperationContext* opCtx,
55  StringData ns,
56  StringData ident,
57  const CollectionOptions& options) override;
58 
59  Status createSortedDataInterface(OperationContext* opCtx,
60  StringData ident,
61  const IndexDescriptor* desc) override;
62 
63  SortedDataInterface* getSortedDataInterface(OperationContext* opCtx,
64  StringData ident,
65  const IndexDescriptor* desc) override;
66 
67  Status beginBackup(OperationContext* opCtx) override {
68  return Status::OK();
69  }
70 
71  void endBackup(OperationContext* opCtx) override {}
72 
73  Status dropIdent(OperationContext* opCtx, StringData ident) override;
74 
75  bool supportsDocLocking() const override {
76  return false;
77  }
78 
79  bool supportsDBLocking() const override {
80  return false;
81  }
82 
83  bool supportsCappedCollections() const override {
84  return false;
85  }
86 
87  bool supportsDirectoryPerDB() const override {
88  return false;
89  }
90 
91  bool isDurable() const override {
92  return true;
93  }
94 
98  int flushAllFiles(OperationContext* opCtx, bool sync) override {
99  return 0;
100  }
101 
102  bool isEphemeral() const override {
103  return false;
104  }
105 
106  int64_t getIdentSize(OperationContext* opCtx, StringData ident) override;
107 
108  Status repairIdent(OperationContext* opCtx, StringData ident) override {
109  return Status::OK();
110  }
111 
112  void cleanShutdown() override{};
113 
114  bool hasIdent(OperationContext* opCtx, StringData ident) const override;
115 
116  std::vector<std::string> getAllIdents(OperationContext* opCtx) const override;
117 
118  void setJournalListener(JournalListener* jl) override {
119  stdx::unique_lock<stdx::mutex> lk(_mutex);
120  _journalListener = jl;
121  }
122 
123  virtual Timestamp getAllCommittedTimestamp() const override {
124  MONGO_UNREACHABLE;
125  }
126 
127 private:
128  mutable stdx::mutex _mutex;
129  void _initDBPath(const std::string& path);
130 
131  std::unique_ptr<MobileSessionPool> _sessionPool;
132 
133  // Notified when we write as everything is considered "journalled" since repl depends on it.
135 
136  std::string _path;
137 };
138 } // namespace mongo
static NoOpJournalListener instance
Definition: journal_listener.h:70
Definition: kv_engine.h:53
std::string _path
Definition: mobile_kv_engine.h:136
Collection *const const NamespaceString & ns
Definition: collection_info_cache_impl.cpp:53
Definition: collection_options.h:57
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
bool supportsDocLocking() const override
This must not change over the lifetime of the engine.
Definition: mobile_kv_engine.h:75
bool isDurable() const override
Definition: mobile_kv_engine.h:91
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
bool supportsDBLocking() const override
This must not change over the lifetime of the engine.
Definition: mobile_kv_engine.h:79
bool supportsDirectoryPerDB() const override
Returns true if storage engine supports –directoryperdb.
Definition: mobile_kv_engine.h:87
void setJournalListener(JournalListener *jl) override
Sets a new JournalListener, which is used to alert the rest of the system about journaled write progr...
Definition: mobile_kv_engine.h:118
std::unique_ptr< MobileSessionPool > _sessionPool
Definition: mobile_kv_engine.h:131
std::vector< std::string > getAllIdents(OperationContext *opCtx) const override
Definition: mobile_kv_engine.cpp:221
Status dropIdent(OperationContext *opCtx, StringData ident) override
Definition: mobile_kv_engine.cpp:162
Status createRecordStore(OperationContext *opCtx, StringData ns, StringData ident, const CollectionOptions &options) override
The create and drop methods on KVEngine are not transactional.
Definition: mobile_kv_engine.cpp:124
This class allows for the storageEngine to alert the rest of the system about journaled write progres...
Definition: journal_listener.h:48
JournalListener * _journalListener
Definition: mobile_kv_engine.h:134
Status repairIdent(OperationContext *opCtx, StringData ident) override
Definition: mobile_kv_engine.h:108
A RecoveryUnit is responsible for ensuring that data is persisted.
Definition: recovery_unit.h:51
int flushAllFiles(OperationContext *opCtx, bool sync) override
Flush is a no-op since SQLite transactions are durable by default after each commit.
Definition: mobile_kv_engine.h:98
int64_t getIdentSize(OperationContext *opCtx, StringData ident) override
Note: this counts the total number of bytes in the key and value columns, not the actual number of by...
Definition: mobile_kv_engine.cpp:182
Status beginBackup(OperationContext *opCtx) override
See StorageEngine::beginBackup for details.
Definition: mobile_kv_engine.h:67
bool supportsCappedCollections() const override
This must not change over the lifetime of the engine.
Definition: mobile_kv_engine.h:83
void endBackup(OperationContext *opCtx) override
See StorageEngine::endBackup for details.
Definition: mobile_kv_engine.h:71
OperationContext Database StringData BSONObj options
Definition: database_impl.cpp:949
bool isEphemeral() const override
Returns true if the KVEngine is ephemeral – that is, it is NOT persistent and all data is lost after...
Definition: mobile_kv_engine.h:102
SortedDataInterface * getSortedDataInterface(OperationContext *opCtx, StringData ident, const IndexDescriptor *desc) override
Definition: mobile_kv_engine.cpp:153
MobileKVEngine(const std::string &path)
Definition: mobile_kv_engine.cpp:57
virtual Timestamp getAllCommittedTimestamp() const override
See StorageEngine::getAllCommittedTimestamp
Definition: mobile_kv_engine.h:123
RecoveryUnit * newRecoveryUnit() override
Definition: mobile_kv_engine.cpp:120
std::unique_ptr< RecordStore > getRecordStore(OperationContext *opCtx, StringData ns, StringData ident, const CollectionOptions &options) override
Having multiple out for the same ns is a rules violation; Calling on a non-created ident is invalid a...
Definition: mobile_kv_engine.cpp:140
void cleanShutdown() override
This method will be called before there is a clean shutdown.
Definition: mobile_kv_engine.h:112
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
Status createSortedDataInterface(OperationContext *opCtx, StringData ident, const IndexDescriptor *desc) override
Definition: mobile_kv_engine.cpp:147
Definition: mobile_kv_engine.h:43
OperationContext const IndexDescriptor * desc
Definition: index_catalog_impl.cpp:97
bool hasIdent(OperationContext *opCtx, StringData ident) const override
Definition: mobile_kv_engine.cpp:205
stdx::mutex _mutex
Definition: mobile_kv_engine.h:128
void _initDBPath(const std::string &path)
Definition: mobile_kv_engine.cpp:85
This interface is a work in progress.
Definition: sorted_data_interface.h:64