diff options
Diffstat (limited to 'src/mongo/db/write_concern.h')
-rw-r--r-- | src/mongo/db/write_concern.h | 135 |
1 files changed, 68 insertions, 67 deletions
diff --git a/src/mongo/db/write_concern.h b/src/mongo/db/write_concern.h index 0fa735aac4a..31e2bc6c588 100644 --- a/src/mongo/db/write_concern.h +++ b/src/mongo/db/write_concern.h @@ -33,73 +33,74 @@ namespace mongo { - class OperationContext; - template <typename T> class StatusWith; +class OperationContext; +template <typename T> +class StatusWith; - namespace repl { - class OpTime; +namespace repl { +class OpTime; +} + +/** + * If txn->getWriteConcern() indicates a durable commit level, + * marks the RecoveryUnit associated with "txn" appropriately. + * Provides a hint to the storage engine that + * particular operations will be waiting for their changes to become durable. + */ +void setupSynchronousCommit(OperationContext* txn); + +/** + * Attempts to extract a writeConcern from cmdObj. + * Verifies that the writeConcern is of type Object (BSON type) and + * that the resulting writeConcern is valid for this particular host. + */ +StatusWith<WriteConcernOptions> extractWriteConcern(const BSONObj& cmdObj); + +/** + * Verifies that a WriteConcern is valid for this particular host. + */ +Status validateWriteConcern(const WriteConcernOptions& writeConcern); + +struct WriteConcernResult { + WriteConcernResult() { + reset(); + } + + void reset() { + syncMillis = -1; + fsyncFiles = -1; + wTimedOut = false; + wTime = -1; + err = ""; } - /** - * If txn->getWriteConcern() indicates a durable commit level, - * marks the RecoveryUnit associated with "txn" appropriately. - * Provides a hint to the storage engine that - * particular operations will be waiting for their changes to become durable. - */ - void setupSynchronousCommit(OperationContext* txn); - - /** - * Attempts to extract a writeConcern from cmdObj. - * Verifies that the writeConcern is of type Object (BSON type) and - * that the resulting writeConcern is valid for this particular host. - */ - StatusWith<WriteConcernOptions> extractWriteConcern(const BSONObj& cmdObj); - - /** - * Verifies that a WriteConcern is valid for this particular host. - */ - Status validateWriteConcern( const WriteConcernOptions& writeConcern ); - - struct WriteConcernResult { - WriteConcernResult() { - reset(); - } - - void reset() { - syncMillis = -1; - fsyncFiles = -1; - wTimedOut = false; - wTime = -1; - err = ""; - } - - void appendTo( const WriteConcernOptions& writeConcern, BSONObjBuilder* result ) const; - - int syncMillis; - int fsyncFiles; - - bool wTimedOut; - int wTime; - std::vector<HostAndPort> writtenTo; - - std::string err; // this is the old err field, should deprecate - }; - - /** - * Blocks until the database is sure the specified user write concern has been fulfilled, or - * returns an error status if the write concern fails. Does no validation of the input write - * concern, it is an error to pass this function an invalid write concern for the host. - * - * Takes a user write concern as well as the replication opTime the write concern applies to - - * if this opTime.isNull() no replication-related write concern options will be enforced. - * - * Returns result of the write concern if successful. - * Returns NotMaster if the host steps down while waiting for replication - * Returns UnknownReplWriteConcern if the wMode specified was not enforceable - */ - Status waitForWriteConcern( OperationContext* txn, - const repl::OpTime& replOpTime, - WriteConcernResult* result ); - - -} // namespace mongo + void appendTo(const WriteConcernOptions& writeConcern, BSONObjBuilder* result) const; + + int syncMillis; + int fsyncFiles; + + bool wTimedOut; + int wTime; + std::vector<HostAndPort> writtenTo; + + std::string err; // this is the old err field, should deprecate +}; + +/** + * Blocks until the database is sure the specified user write concern has been fulfilled, or + * returns an error status if the write concern fails. Does no validation of the input write + * concern, it is an error to pass this function an invalid write concern for the host. + * + * Takes a user write concern as well as the replication opTime the write concern applies to - + * if this opTime.isNull() no replication-related write concern options will be enforced. + * + * Returns result of the write concern if successful. + * Returns NotMaster if the host steps down while waiting for replication + * Returns UnknownReplWriteConcern if the wMode specified was not enforceable + */ +Status waitForWriteConcern(OperationContext* txn, + const repl::OpTime& replOpTime, + WriteConcernResult* result); + + +} // namespace mongo |