diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/repl/handshake_args.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/repl/handshake_args.cpp')
-rw-r--r-- | src/mongo/db/repl/handshake_args.cpp | 118 |
1 files changed, 54 insertions, 64 deletions
diff --git a/src/mongo/db/repl/handshake_args.cpp b/src/mongo/db/repl/handshake_args.cpp index db815ee3aa2..2ceae3df86e 100644 --- a/src/mongo/db/repl/handshake_args.cpp +++ b/src/mongo/db/repl/handshake_args.cpp @@ -40,75 +40,65 @@ namespace repl { namespace { - const std::string kRIDFieldName = "handshake"; - // TODO(danneberg) remove after 3.0 since this field is only allowed for backwards compatibility - const std::string kOldMemberConfigFieldName = "config"; - const std::string kMemberIdFieldName = "member"; - - const std::string kLegalHandshakeFieldNames[] = { - kRIDFieldName, - kOldMemberConfigFieldName, - kMemberIdFieldName - }; - -} // namespace - - HandshakeArgs::HandshakeArgs() : - _hasRid(false), - _hasMemberId(false), - _rid(OID()), - _memberId(-1) {} - - Status HandshakeArgs::initialize(const BSONObj& argsObj) { - Status status = bsonCheckOnlyHasFields("HandshakeArgs", - argsObj, - kLegalHandshakeFieldNames); - if (!status.isOK()) +const std::string kRIDFieldName = "handshake"; +// TODO(danneberg) remove after 3.0 since this field is only allowed for backwards compatibility +const std::string kOldMemberConfigFieldName = "config"; +const std::string kMemberIdFieldName = "member"; + +const std::string kLegalHandshakeFieldNames[] = { + kRIDFieldName, kOldMemberConfigFieldName, kMemberIdFieldName}; + +} // namespace + +HandshakeArgs::HandshakeArgs() : _hasRid(false), _hasMemberId(false), _rid(OID()), _memberId(-1) {} + +Status HandshakeArgs::initialize(const BSONObj& argsObj) { + Status status = bsonCheckOnlyHasFields("HandshakeArgs", argsObj, kLegalHandshakeFieldNames); + if (!status.isOK()) + return status; + + BSONElement oid; + status = bsonExtractTypedField(argsObj, kRIDFieldName, jstOID, &oid); + if (!status.isOK()) + return status; + _rid = oid.OID(); + _hasRid = true; + + status = bsonExtractIntegerField(argsObj, kMemberIdFieldName, &_memberId); + if (!status.isOK()) { + // field not necessary for master slave, do not return NoSuchKey Error + if (status != ErrorCodes::NoSuchKey) { return status; - - BSONElement oid; - status = bsonExtractTypedField(argsObj, kRIDFieldName, jstOID, &oid); - if (!status.isOK()) - return status; - _rid = oid.OID(); - _hasRid = true; - - status = bsonExtractIntegerField(argsObj, kMemberIdFieldName, &_memberId); - if (!status.isOK()) { - // field not necessary for master slave, do not return NoSuchKey Error - if (status != ErrorCodes::NoSuchKey) { - return status; - } - _memberId = -1; - } - else { - _hasMemberId = true; } - - return Status::OK(); - } - - bool HandshakeArgs::isInitialized() const { - return _hasRid; - } - - void HandshakeArgs::setRid(const OID& newVal) { - _rid = newVal; - _hasRid = true; - } - - void HandshakeArgs::setMemberId(long long newVal) { - _memberId = newVal; + _memberId = -1; + } else { _hasMemberId = true; } - BSONObj HandshakeArgs::toBSON() const { - invariant(isInitialized()); - BSONObjBuilder builder; - builder.append(kRIDFieldName, _rid); - builder.append(kMemberIdFieldName, _memberId); - return builder.obj(); - } + return Status::OK(); +} + +bool HandshakeArgs::isInitialized() const { + return _hasRid; +} + +void HandshakeArgs::setRid(const OID& newVal) { + _rid = newVal; + _hasRid = true; +} + +void HandshakeArgs::setMemberId(long long newVal) { + _memberId = newVal; + _hasMemberId = true; +} + +BSONObj HandshakeArgs::toBSON() const { + invariant(isInitialized()); + BSONObjBuilder builder; + builder.append(kRIDFieldName, _rid); + builder.append(kMemberIdFieldName, _memberId); + return builder.obj(); +} } // namespace repl } // namespace mongo |