Storage Engine API
dur.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <string>
32 #include <vector>
33 
34 #include "mongo/base/disallow_copying.h"
36 
37 namespace mongo {
38 
39 class ClockSource;
40 class OperationContext;
41 
42 namespace dur {
43 
44 // a smaller limit is likely better on 32 bit
45 const unsigned UncommittedBytesLimit = (sizeof(void*) == 4) ? 50 * 1024 * 1024 : 512 * 1024 * 1024;
46 
49 
50 public:
51  virtual ~DurableInterface();
52 
58  virtual void createdFile(const std::string& filename, unsigned long long len) = 0;
59 
60  // Declare write intents. Use these methods to declare "i'm about to write to x and it
61  // should be logged for redo."
62  //
63  // Failure to call declare write intents is checked in MONGO_CONFIG_DEBUG_BUILD mode by
64  // using a read only mapped view (i.e., you'll segfault if the code is covered in that
65  // situation). The debug check doesn't verify that your length is correct though.
66  virtual void declareWriteIntents(const std::vector<std::pair<void*, unsigned>>& intents) = 0;
67 
72  virtual bool waitUntilDurable() = 0;
73 
89  virtual bool commitNow(OperationContext* opCtx) = 0;
90 
98  virtual bool commitIfNeeded() = 0;
99 
100 
106  virtual void closingFileNotification() = 0;
107 
114  virtual void commitAndStopDurThread(OperationContext* opCtx) = 0;
115 
127  virtual void syncDataAndTruncateJournal(OperationContext* opCtx) = 0;
128 
129  virtual bool isDurable() const = 0;
130 
132  return *_impl;
133  }
134 
135 protected:
137 
138 private:
139  friend void startup(ClockSource* cs, int64_t serverStartMs);
140 
142 };
143 
144 
149 void startup(ClockSource* cs, int64_t serverStartMs);
150 
151 // Sets a new JournalListener, which is used to alert the rest of the system about
152 // journaled write progress.
154 
155 // Expose the JournalListener, needed for the journal writer thread.
157 
158 } // namespace dur
159 
160 
169 }
170 
171 } // namespace mongo
MONGO_DISALLOW_COPYING(DurableInterface)
void setJournalListener(JournalListener *jl)
Definition: dur.cpp:906
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
virtual void declareWriteIntents(const std::vector< std::pair< void *, unsigned >> &intents)=0
JournalListener * getJournalListener()
Definition: dur.cpp:911
const unsigned UncommittedBytesLimit
Definition: dur.h:45
DurableInterface()
Definition: dur.cpp:512
virtual void commitAndStopDurThread(OperationContext *opCtx)=0
Invoked at clean shutdown time.
virtual void closingFileNotification()=0
Called when a DurableMappedFile is closing.
This class allows for the storageEngine to alert the rest of the system about journaled write progres...
Definition: journal_listener.h:48
friend void startup(ClockSource *cs, int64_t serverStartMs)
Invoked at server startup.
Definition: dur.cpp:880
virtual bool waitUntilDurable()=0
Wait for acknowledgement of the next group commit.
Definition: dur.h:47
virtual ~DurableInterface()
Definition: dur.cpp:514
virtual bool commitIfNeeded()=0
Commit if enough bytes have been modified.
virtual void syncDataAndTruncateJournal(OperationContext *opCtx)=0
Commits pending changes, flushes all changes to main data files, then removes the journal...
virtual void createdFile(const std::string &filename, unsigned long long len)=0
Declare that a file has been created.
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
static DurableInterface * _impl
Definition: dur.h:141
static DurableInterface & getDur()
Definition: dur.h:131
virtual bool isDurable() const =0
virtual bool commitNow(OperationContext *opCtx)=0
Commit immediately.