diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/repl/oplog_entry.cpp | 32 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_entry.h | 12 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_entry.idl | 49 | ||||
-rw-r--r-- | src/mongo/util/uuid.h | 2 |
4 files changed, 73 insertions, 22 deletions
diff --git a/src/mongo/db/repl/oplog_entry.cpp b/src/mongo/db/repl/oplog_entry.cpp index d70b518b795..3309862c877 100644 --- a/src/mongo/db/repl/oplog_entry.cpp +++ b/src/mongo/db/repl/oplog_entry.cpp @@ -136,6 +136,38 @@ BSONObj makeOplogEntryDoc(OpTime opTime, const int OplogEntry::kOplogVersion = 2; // Static +ReplOperation OplogEntry::makeInsertOperation(const NamespaceString& nss, + boost::optional<UUID> uuid, + const BSONObj& docToInsert) { + ReplOperation op; + op.setNamespace(nss); + op.setUuid(uuid); + op.setObject(docToInsert); + return op; +} + +ReplOperation OplogEntry::makeUpdateOperation(const NamespaceString nss, + boost::optional<UUID> uuid, + const BSONObj& update, + const BSONObj& criteria) { + ReplOperation op; + op.setNamespace(nss); + op.setUuid(uuid); + op.setObject(update); + op.setObject2(criteria); + return op; +} + +ReplOperation OplogEntry::makeDeleteOperation(const NamespaceString& nss, + boost::optional<UUID> uuid, + const BSONObj& docToDelete) { + ReplOperation op; + op.setNamespace(nss); + op.setUuid(uuid); + op.setObject(docToDelete); + return op; +} + StatusWith<OplogEntry> OplogEntry::parse(const BSONObj& object) { try { return OplogEntry(object); diff --git a/src/mongo/db/repl/oplog_entry.h b/src/mongo/db/repl/oplog_entry.h index d2ae43d65b4..1b3b15d1bae 100644 --- a/src/mongo/db/repl/oplog_entry.h +++ b/src/mongo/db/repl/oplog_entry.h @@ -61,6 +61,18 @@ public: // Current oplog version, should be the value of the v field in all oplog entries. static const int kOplogVersion; + // Helpers to generate ReplOperation. + static ReplOperation makeInsertOperation(const NamespaceString& nss, + boost::optional<UUID> uuid, + const BSONObj& docToInsert); + static ReplOperation makeUpdateOperation(const NamespaceString nss, + boost::optional<UUID> uuid, + const BSONObj& update, + const BSONObj& criteria); + static ReplOperation makeDeleteOperation(const NamespaceString& nss, + boost::optional<UUID> uuid, + const BSONObj& docToDelete); + static StatusWith<OplogEntry> parse(const BSONObj& object); OplogEntry(OpTime opTime, diff --git a/src/mongo/db/repl/oplog_entry.idl b/src/mongo/db/repl/oplog_entry.idl index 06b9dfe5ae7..c37f1a45fc0 100644 --- a/src/mongo/db/repl/oplog_entry.idl +++ b/src/mongo/db/repl/oplog_entry.idl @@ -46,12 +46,39 @@ enums: kNoop: "n" structs: + ReplOperation: + description: A document that represents an operation in transaction. + fields: + op: + cpp_name: opType + type: OpType + description: "The operation type" + ns: + cpp_name: namespace + type: namespacestring + description: "The namespace on which to apply the operation" + ui: + cpp_name: uuid + type: uuid + optional: true + description: "The UUID of the collection" + o: + cpp_name: object + type: object + description: "The operation applied" + o2: + cpp_name: object2 + type: object + optional: true + description: "Additional information about the operation applied" + OplogEntryBase: description: A document in which the server stores an oplog entry. immutable: true inline_chained_structs: true chained_structs: OperationSessionInfo : OperationSessionInfo + ReplOperation: ReplOperation fields: ts: cpp_name: timestamp @@ -71,32 +98,10 @@ structs: type: safeInt64 default: 1 description: "The version of the oplog" - op: - cpp_name: opType - type: OpType - description: "The operation type" - ns: - cpp_name: namespace - type: namespacestring - description: "The namespace on which to apply the operation" - ui: - cpp_name: uuid - type: uuid - optional: true - description: "The UUID of the collection" fromMigrate: type: bool optional: true description: "An operation caused by a chunk migration" - o: - cpp_name: object - type: object - description: "The operation applied" - o2: - cpp_name: object2 - type: object - optional: true - description: "Additional information about the operation applied" _id: type: objectid optional: true diff --git a/src/mongo/util/uuid.h b/src/mongo/util/uuid.h index bc0db1257d0..7e7a1886203 100644 --- a/src/mongo/util/uuid.h +++ b/src/mongo/util/uuid.h @@ -43,6 +43,7 @@ namespace mongo { namespace repl { class OplogEntryBase; +class ReplOperation; } // namespace repl namespace idl { @@ -68,6 +69,7 @@ class UUID { friend class LogicalSessionIdToClient; friend class LogicalSessionFromClient; friend class repl::OplogEntryBase; + friend class repl::ReplOperation; friend class ResumeTokenInternal; public: |