1 2 /** 3 * Copyright (C) 2018-present MongoDB, Inc. 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the Server Side Public License, version 1, 7 * as published by MongoDB, Inc. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * Server Side Public License for more details. 13 * 14 * You should have received a copy of the Server Side Public License 15 * along with this program. If not, see 16 * <http://www.mongodb.com/licensing/server-side-public-license>. 17 * 18 * As a special exception, the copyright holders give permission to link the 19 * code of portions of this program with the OpenSSL library under certain 20 * conditions as described in each individual source file and distribute 21 * linked combinations including the program with the OpenSSL library. You 22 * must comply with the Server Side Public License in all respects for 23 * all of the code used other than as permitted herein. If you modify file(s) 24 * with this exception, you may extend this exception to your version of the 25 * file(s), but you are not obligated to do so. If you do not wish to do so, 26 * delete this exception statement from your version. If you delete this 27 * exception statement from all source files in the program, then also delete 28 * it in the license file. 29 */ 30 31 #pragma once 32 33 #include <vector> 34 35 #include "mongo/db/jsobj.h" 36 #include "mongo/db/repl/optime.h" 37 38 namespace mongo { 39 40 class Status; 41 42 namespace repl { 43 44 /** 45 * Arguments to the update position command. 46 */ 47 class UpdatePositionArgs { 48 public: 49 static const char kCommandFieldName[]; 50 static const char kUpdateArrayFieldName[]; 51 static const char kAppliedOpTimeFieldName[]; 52 static const char kDurableOpTimeFieldName[]; 53 static const char kMemberIdFieldName[]; 54 static const char kConfigVersionFieldName[]; 55 56 struct UpdateInfo { 57 UpdateInfo(const OpTime& applied, 58 const OpTime& durable, 59 long long aCfgver, 60 long long aMemberId); 61 62 OpTime appliedOpTime; 63 OpTime durableOpTime; 64 long long cfgver; 65 long long memberId; 66 }; 67 68 typedef std::vector<UpdateInfo>::const_iterator UpdateIterator; 69 70 /** 71 * Initializes this UpdatePositionArgs from the contents of "argsObj". 72 */ 73 Status initialize(const BSONObj& argsObj); 74 75 /** 76 * Gets a begin iterator over the UpdateInfos stored in this UpdatePositionArgs. 77 */ updatesBegin()78 UpdateIterator updatesBegin() const { 79 return _updates.begin(); 80 } 81 82 /** 83 * Gets an end iterator over the UpdateInfos stored in this UpdatePositionArgs. 84 */ updatesEnd()85 UpdateIterator updatesEnd() const { 86 return _updates.end(); 87 } 88 89 /** 90 * Returns a BSONified version of the object. 91 * _updates is only included if it is not empty. 92 */ 93 BSONObj toBSON() const; 94 95 private: 96 std::vector<UpdateInfo> _updates; 97 }; 98 99 } // namespace repl 100 } // namespace mongo 101