Storage Engine API
ephemeral_for_test_recovery_unit.h
Go to the documentation of this file.
1 // ephemeral_for_test_recovery_unit.h
2 
31 #pragma once
32 
33 #include <vector>
34 
35 #include "mongo/db/record_id.h"
37 #include "mongo/stdx/functional.h"
38 
39 namespace mongo {
40 
41 class SortedDataInterface;
42 
44 public:
45  EphemeralForTestRecoveryUnit(stdx::function<void()> cb = nullptr)
47 
48  void beginUnitOfWork(OperationContext* opCtx) final{};
49  void commitUnitOfWork() final;
50  void abortUnitOfWork() final;
51 
52  virtual bool waitUntilDurable() {
55  }
56  return true;
57  }
58 
59  virtual void abandonSnapshot() {}
60 
62 
63  virtual void registerChange(Change* change) {
64  _changes.push_back(ChangePtr(change));
65  }
66 
67  virtual void* writingPtr(void* data, size_t len) {
68  MONGO_UNREACHABLE;
69  }
70 
71  virtual void setRollbackWritesDisabled() {}
72 
73  virtual SnapshotId getSnapshotId() const {
74  return SnapshotId();
75  }
76 
77  virtual void setOrderedCommit(bool orderedCommit) {}
78 
79  virtual void setPrepareTimestamp(Timestamp) {}
80 
81 private:
82  typedef std::shared_ptr<Change> ChangePtr;
83  typedef std::vector<ChangePtr> Changes;
84 
85  Changes _changes;
86  stdx::function<void()> _waitUntilDurableCallback;
87 };
88 
89 } // namespace mongo
virtual void * writingPtr(void *data, size_t len)
Declare that the data at [x, x + len) is being written.
Definition: ephemeral_for_test_recovery_unit.h:67
virtual void setOrderedCommit(bool orderedCommit)
Definition: ephemeral_for_test_recovery_unit.h:77
Changes _changes
Definition: ephemeral_for_test_recovery_unit.h:85
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
virtual void setRollbackWritesDisabled()
Sets a flag that declares this RecoveryUnit will skip rolling back writes, for the duration of the cu...
Definition: ephemeral_for_test_recovery_unit.h:71
std::shared_ptr< void > data
Definition: ephemeral_for_test_record_store_test.cpp:74
void commitUnitOfWork() final
Marks the end of a unit of work and commits all changes registered by calls to onCommit or registerCh...
Definition: ephemeral_for_test_recovery_unit.cpp:40
virtual void abandonSnapshot()
If there is an open transaction, it is closed.
Definition: ephemeral_for_test_recovery_unit.h:59
A RecoveryUnit is responsible for ensuring that data is persisted.
Definition: recovery_unit.h:51
std::shared_ptr< Change > ChangePtr
Definition: ephemeral_for_test_recovery_unit.h:82
void abortUnitOfWork() final
Marks the end of a unit of work and rolls back all changes registered by calls to onRollback or regis...
Definition: ephemeral_for_test_recovery_unit.cpp:56
virtual SnapshotId getSnapshotId() const
Gets the local SnapshotId.
Definition: ephemeral_for_test_recovery_unit.h:73
stdx::function< void()> _waitUntilDurableCallback
Definition: ephemeral_for_test_recovery_unit.h:86
A Change is an action that is registerChange()&#39;d while a WriteUnitOfWork exists.
Definition: recovery_unit.h:281
std::vector< ChangePtr > Changes
Definition: ephemeral_for_test_recovery_unit.h:83
virtual void setPrepareTimestamp(Timestamp)
Sets a prepare timestamp for the current transaction.
Definition: ephemeral_for_test_recovery_unit.h:79
Definition: snapshot.h:37
EphemeralForTestRecoveryUnit(stdx::function< void()> cb=nullptr)
Definition: ephemeral_for_test_recovery_unit.h:45
void beginUnitOfWork(OperationContext *opCtx) final
Marks the beginning of a unit of work.
Definition: ephemeral_for_test_recovery_unit.h:48
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
Status obtainMajorityCommittedSnapshot() final
Obtains a majority committed snapshot.
Definition: ephemeral_for_test_recovery_unit.cpp:70
Definition: ephemeral_for_test_recovery_unit.h:43
virtual void registerChange(Change *change)
The RecoveryUnit takes ownership of the change.
Definition: ephemeral_for_test_recovery_unit.h:63
virtual bool waitUntilDurable()
Waits until all commits that happened before this call are durable in the journal.
Definition: ephemeral_for_test_recovery_unit.h:52