summaryrefslogtreecommitdiff
path: root/src/mongo/db/range_deleter_mock_env.h
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/range_deleter_mock_env.h
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/range_deleter_mock_env.h')
-rw-r--r--src/mongo/db/range_deleter_mock_env.h242
1 files changed, 121 insertions, 121 deletions
diff --git a/src/mongo/db/range_deleter_mock_env.h b/src/mongo/db/range_deleter_mock_env.h
index bba49a360e4..307dbe2bd53 100644
--- a/src/mongo/db/range_deleter_mock_env.h
+++ b/src/mongo/db/range_deleter_mock_env.h
@@ -37,131 +37,131 @@
namespace mongo {
- struct DeletedRange {
- std::string ns;
- BSONObj min;
- BSONObj max;
- BSONObj shardKeyPattern;
- };
+struct DeletedRange {
+ std::string ns;
+ BSONObj min;
+ BSONObj max;
+ BSONObj shardKeyPattern;
+};
+
+/**
+ * Comparator function object compatible with set.
+ */
+struct DeletedRangeCmp {
+ bool operator()(const DeletedRange& lhs, const DeletedRange& rhs) const;
+};
+
+/**
+ * Mock environment for RangeDeleter with knobs for pausing/resuming
+ * deletes, setting open cursors IDs per namespace and the ability to
+ * record the history of deletes performed through this environment.
+ */
+class RangeDeleterMockEnv : public mongo::RangeDeleterEnv {
+public:
+ RangeDeleterMockEnv();
+
+ //
+ // Environment modification methods.
+ //
/**
- * Comparator function object compatible with set.
+ * Adds an id to the current set of cursors in the given namespace.
*/
- struct DeletedRangeCmp {
- bool operator()(const DeletedRange& lhs, const DeletedRange& rhs) const;
- };
+ void addCursorId(StringData ns, CursorId id);
+
+ /**
+ * Removes the id from the set of open cursors in the given namespace.
+ */
+ void removeCursorId(StringData ns, CursorId id);
+
+ //
+ // Environment synchronization methods.
+ //
/**
- * Mock environment for RangeDeleter with knobs for pausing/resuming
- * deletes, setting open cursors IDs per namespace and the ability to
- * record the history of deletes performed through this environment.
+ * Blocks all new deletes from proceeding.
*/
- class RangeDeleterMockEnv: public mongo::RangeDeleterEnv {
- public:
- RangeDeleterMockEnv();
-
- //
- // Environment modification methods.
- //
-
- /**
- * Adds an id to the current set of cursors in the given namespace.
- */
- void addCursorId(StringData ns, CursorId id);
-
- /**
- * Removes the id from the set of open cursors in the given namespace.
- */
- void removeCursorId(StringData ns, CursorId id);
-
- //
- // Environment synchronization methods.
- //
-
- /**
- * Blocks all new deletes from proceeding.
- */
- void pauseDeletes();
-
- /**
- * Unblocks one paused delete.
- */
- void resumeOneDelete();
-
- /**
- * Blocks until the getCursor method was called and terminated at least the
- * specified number of times for the entire lifetime of this deleter.
- */
- void waitForNthGetCursor(uint64_t nthCall);
-
- /**
- * Blocks until the deleteRange method was called and at the same time paused
- * at least the specified number of times for the entire lifetime of this deleter.
- */
- void waitForNthPausedDelete(uint64_t nthPause);
-
- //
- // Environment introspection methods.
- //
-
- /**
- * Returns true if deleteRange was called at least once.
- */
- bool deleteOccured() const;
-
- /**
- * Returns the last delete. Undefined if deleteOccured is false.
- */
- DeletedRange getLastDelete() const;
-
- //
- // Environment methods.
- //
-
- /**
- * Basic implementation of delete that matches the signature for
- * RangeDeleterEnv::deleteRange. This does not actually perform the delete
- * but simply keeps a record of it. Can also be paused by pauseDeletes and
- * resumed with resumeDeletes.
- */
- bool deleteRange(OperationContext* txn,
- const RangeDeleteEntry& taskDetails,
- long long int* deletedDocs,
- std::string* errMsg);
-
- /**
- * Basic implementation of gathering open cursors that matches the signature for
- * RangeDeleterEnv::getCursorIds. The cursors returned can be modified with
- * the setCursorId and clearCursorMap methods.
- */
- void getCursorIds(OperationContext* txn, StringData ns, std::set<CursorId>* in);
-
- private:
- // mutex acquisition ordering:
- // _envStatMutex -> _pauseDeleteMutex -> _deleteListMutex -> _cursorMapMutex
-
- mutable stdx::mutex _deleteListMutex;
- std::vector<DeletedRange> _deleteList;
-
- stdx::mutex _cursorMapMutex;
- std::map<std::string, std::set<CursorId> > _cursorMap;
-
- // Protects _pauseDelete & _pausedCount
- stdx::mutex _pauseDeleteMutex;
- stdx::condition_variable _pausedCV;
- bool _pauseDelete;
-
- // Number of times a delete gets paused.
- uint64_t _pausedCount;
- // _pausedCount < nthPause (used by waitForNthPausedDelete)
- stdx::condition_variable _pausedDeleteChangeCV;
-
- // Protects all variables below this line.
- stdx::mutex _envStatMutex;
-
- // Keeps track of the number of times getCursorIds was called.
- uint64_t _getCursorsCallCount;
- // _getCursorsCallCount < nthCall (used by waitForNthGetCursor)
- stdx::condition_variable _cursorsCallCountUpdatedCV;
- };
+ void pauseDeletes();
+
+ /**
+ * Unblocks one paused delete.
+ */
+ void resumeOneDelete();
+
+ /**
+ * Blocks until the getCursor method was called and terminated at least the
+ * specified number of times for the entire lifetime of this deleter.
+ */
+ void waitForNthGetCursor(uint64_t nthCall);
+
+ /**
+ * Blocks until the deleteRange method was called and at the same time paused
+ * at least the specified number of times for the entire lifetime of this deleter.
+ */
+ void waitForNthPausedDelete(uint64_t nthPause);
+
+ //
+ // Environment introspection methods.
+ //
+
+ /**
+ * Returns true if deleteRange was called at least once.
+ */
+ bool deleteOccured() const;
+
+ /**
+ * Returns the last delete. Undefined if deleteOccured is false.
+ */
+ DeletedRange getLastDelete() const;
+
+ //
+ // Environment methods.
+ //
+
+ /**
+ * Basic implementation of delete that matches the signature for
+ * RangeDeleterEnv::deleteRange. This does not actually perform the delete
+ * but simply keeps a record of it. Can also be paused by pauseDeletes and
+ * resumed with resumeDeletes.
+ */
+ bool deleteRange(OperationContext* txn,
+ const RangeDeleteEntry& taskDetails,
+ long long int* deletedDocs,
+ std::string* errMsg);
+
+ /**
+ * Basic implementation of gathering open cursors that matches the signature for
+ * RangeDeleterEnv::getCursorIds. The cursors returned can be modified with
+ * the setCursorId and clearCursorMap methods.
+ */
+ void getCursorIds(OperationContext* txn, StringData ns, std::set<CursorId>* in);
+
+private:
+ // mutex acquisition ordering:
+ // _envStatMutex -> _pauseDeleteMutex -> _deleteListMutex -> _cursorMapMutex
+
+ mutable stdx::mutex _deleteListMutex;
+ std::vector<DeletedRange> _deleteList;
+
+ stdx::mutex _cursorMapMutex;
+ std::map<std::string, std::set<CursorId>> _cursorMap;
+
+ // Protects _pauseDelete & _pausedCount
+ stdx::mutex _pauseDeleteMutex;
+ stdx::condition_variable _pausedCV;
+ bool _pauseDelete;
+
+ // Number of times a delete gets paused.
+ uint64_t _pausedCount;
+ // _pausedCount < nthPause (used by waitForNthPausedDelete)
+ stdx::condition_variable _pausedDeleteChangeCV;
+
+ // Protects all variables below this line.
+ stdx::mutex _envStatMutex;
+
+ // Keeps track of the number of times getCursorIds was called.
+ uint64_t _getCursorsCallCount;
+ // _getCursorsCallCount < nthCall (used by waitForNthGetCursor)
+ stdx::condition_variable _cursorsCallCountUpdatedCV;
+};
}