summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/sync_tail.h
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-10-29 17:02:55 -0400
committerMathias Stearn <mathias@10gen.com>2015-11-06 12:52:01 -0500
commit6543f0dea026b6ff9ad6f701a8f6ca62f0679613 (patch)
tree86b8ee65176bf28f33288c476b53e1f1d30b49d1 /src/mongo/db/repl/sync_tail.h
parentfe47eb4896be4e2a1b2df65dbcb0cb33841bd6e2 (diff)
downloadmongo-6543f0dea026b6ff9ad6f701a8f6ca62f0679613.tar.gz
SERVER-21154 Batch and parse oplog entries in parallel with applying them
This includes the start of SERVER-21155.
Diffstat (limited to 'src/mongo/db/repl/sync_tail.h')
-rw-r--r--src/mongo/db/repl/sync_tail.h40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/mongo/db/repl/sync_tail.h b/src/mongo/db/repl/sync_tail.h
index 254f0182bd5..e3edacaed2a 100644
--- a/src/mongo/db/repl/sync_tail.h
+++ b/src/mongo/db/repl/sync_tail.h
@@ -95,38 +95,58 @@ public:
void oplogApplication();
bool peek(BSONObj* obj);
+ /**
+ * A parsed oplog entry.
+ *
+ * This only includes the fields used by the code using this object at the time this was
+ * written. As more code uses this, more fields should be added.
+ *
+ * All unowned members (such as StringDatas and BSONElements) point into the raw BSON.
+ * All StringData members are guaranteed to be NUL terminated.
+ */
+ struct OplogEntry {
+ explicit OplogEntry(const BSONObj& raw);
+
+ BSONObj raw; // Owned.
+
+ StringData ns = "";
+ StringData opType = "";
+
+ BSONElement version;
+ BSONElement o;
+ BSONElement o2;
+ };
+
class OpQueue {
public:
OpQueue() : _size(0) {}
size_t getSize() const {
return _size;
}
- const std::deque<BSONObj>& getDeque() const {
+ const std::deque<OplogEntry>& getDeque() const {
return _deque;
}
- void push_back(BSONObj& op) {
- _deque.push_back(op);
- _size += op.objsize();
+ void push_back(OplogEntry&& op) {
+ _size += op.raw.objsize();
+ _deque.push_back(std::move(op));
}
bool empty() const {
return _deque.empty();
}
- BSONObj back() const {
+ const OplogEntry& back() const {
invariant(!_deque.empty());
return _deque.back();
}
private:
- std::deque<BSONObj> _deque;
+ std::deque<OplogEntry> _deque;
size_t _size;
};
// returns true if we should continue waiting for BSONObjs, false if we should
// stop waiting and apply the queue we have. Only returns false if !ops.empty().
- bool tryPopAndWaitForMore(OperationContext* txn,
- OpQueue* ops,
- ReplicationCoordinator* replCoord);
+ bool tryPopAndWaitForMore(OperationContext* txn, OpQueue* ops);
/**
* Fetch a single document referenced in the operation from the sync source.
@@ -158,6 +178,8 @@ protected:
OpTime multiApply(OperationContext* txn, const OpQueue& ops);
private:
+ class OpQueueBatcher;
+
std::string _hostname;
BackgroundSyncInterface* _networkQueue;