Storage Engine API
recovery_unit_noop.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <memory>
32 #include <vector>
33 
35 
36 namespace mongo {
37 
38 class OperationContext;
39 
41 public:
42  void beginUnitOfWork(OperationContext* opCtx) final {}
43  void commitUnitOfWork() final {
44  for (auto& change : _changes) {
45  try {
46  change->commit(boost::none);
47  } catch (...) {
48  std::terminate();
49  }
50  }
51  _changes.clear();
52  }
53  void abortUnitOfWork() final {
54  for (auto it = _changes.rbegin(); it != _changes.rend(); ++it) {
55  try {
56  (*it)->rollback();
57  } catch (...) {
58  std::terminate();
59  }
60  }
61  _changes.clear();
62  }
63 
64  virtual void abandonSnapshot() {}
65 
66  virtual bool waitUntilDurable() {
67  return true;
68  }
69 
70  virtual void registerChange(Change* change) {
71  _changes.push_back(std::unique_ptr<Change>(change));
72  }
73 
74  virtual void* writingPtr(void* data, size_t len) {
75  return data;
76  }
77  virtual void setRollbackWritesDisabled() {}
78 
79  virtual SnapshotId getSnapshotId() const {
80  return SnapshotId();
81  }
82 
83  virtual void setOrderedCommit(bool orderedCommit) {}
84 
85 private:
86  std::vector<std::unique_ptr<Change>> _changes;
87 };
88 
89 } // namespace mongo
Definition: recovery_unit_noop.h:40
virtual void setRollbackWritesDisabled()
Sets a flag that declares this RecoveryUnit will skip rolling back writes, for the duration of the cu...
Definition: recovery_unit_noop.h:77
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
virtual void abandonSnapshot()
If there is an open transaction, it is closed.
Definition: recovery_unit_noop.h:64
virtual void setOrderedCommit(bool orderedCommit)
Definition: recovery_unit_noop.h:83
std::shared_ptr< void > data
Definition: ephemeral_for_test_record_store_test.cpp:74
virtual void registerChange(Change *change)
The RecoveryUnit takes ownership of the change.
Definition: recovery_unit_noop.h:70
virtual void * writingPtr(void *data, size_t len)
Declare that the data at [x, x + len) is being written.
Definition: recovery_unit_noop.h:74
IndexSet::const_iterator it
Definition: ephemeral_for_test_btree_impl.cpp:458
void commitUnitOfWork() final
Marks the end of a unit of work and commits all changes registered by calls to onCommit or registerCh...
Definition: recovery_unit_noop.h:43
A RecoveryUnit is responsible for ensuring that data is persisted.
Definition: recovery_unit.h:51
std::vector< std::unique_ptr< Change > > _changes
Definition: recovery_unit_noop.h:86
void abortUnitOfWork() final
Marks the end of a unit of work and rolls back all changes registered by calls to onRollback or regis...
Definition: recovery_unit_noop.h:53
virtual bool waitUntilDurable()
Waits until all commits that happened before this call are durable in the journal.
Definition: recovery_unit_noop.h:66
A Change is an action that is registerChange()&#39;d while a WriteUnitOfWork exists.
Definition: recovery_unit.h:281
void beginUnitOfWork(OperationContext *opCtx) final
Marks the beginning of a unit of work.
Definition: recovery_unit_noop.h:42
Definition: snapshot.h:37
virtual SnapshotId getSnapshotId() const
Gets the local SnapshotId.
Definition: recovery_unit_noop.h:79
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80