summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2015-04-06 09:10:57 -0400
committerEric Milkie <milkie@10gen.com>2015-04-07 16:25:34 -0400
commit0f58d1037bcbfbf932e73e623772c4f815c361ad (patch)
treeae7ea2cf29830f0dc39e326142ddc1b6bc468804
parent72543912dca4117e1deb45a56c599657a1bf747c (diff)
downloadmongo-0f58d1037bcbfbf932e73e623772c4f815c361ad.tar.gz
SERVER-17880 Rename OpTime to Timestamp
-rw-r--r--src/mongo/SConscript6
-rw-r--r--src/mongo/bson/bson_db.h111
-rw-r--r--src/mongo/bson/bson_validate.cpp2
-rw-r--r--src/mongo/bson/bsonelement.cpp14
-rw-r--r--src/mongo/bson/bsonelement.h10
-rw-r--r--src/mongo/bson/bsonobj.h3
-rw-r--r--src/mongo/bson/bsonobjbuilder.cpp8
-rw-r--r--src/mongo/bson/bsonobjbuilder.h64
-rw-r--r--src/mongo/bson/bsonobjbuilder_test.cpp9
-rw-r--r--src/mongo/bson/bsontypes.cpp2
-rw-r--r--src/mongo/bson/bsontypes.h6
-rw-r--r--src/mongo/bson/mutable/const_element-inl.h2
-rw-r--r--src/mongo/bson/mutable/const_element.h2
-rw-r--r--src/mongo/bson/mutable/document.cpp6
-rw-r--r--src/mongo/bson/mutable/document.h4
-rw-r--r--src/mongo/bson/mutable/element-inl.h6
-rw-r--r--src/mongo/bson/mutable/element.cpp2
-rw-r--r--src/mongo/bson/mutable/element.h6
-rw-r--r--src/mongo/bson/mutable/mutable_bson_test.cpp50
-rw-r--r--src/mongo/bson/timestamp.cpp (renamed from src/mongo/bson/optime.cpp)36
-rw-r--r--src/mongo/bson/timestamp.h (renamed from src/mongo/bson/optime.h)63
-rw-r--r--src/mongo/bson/util/bson_extract.cpp8
-rw-r--r--src/mongo/bson/util/bson_extract.h14
-rw-r--r--src/mongo/client/connpool.h1
-rw-r--r--src/mongo/client/dbclient_rs_test.cpp16
-rw-r--r--src/mongo/client/dbclientinterface.h4
-rw-r--r--src/mongo/client/replica_set_monitor.cpp1
-rw-r--r--src/mongo/client/replica_set_monitor_internal.h3
-rw-r--r--src/mongo/client/syncclusterconnection.h1
-rw-r--r--src/mongo/db/auth/privilege_parser.h1
-rw-r--r--src/mongo/db/clientcursor.h6
-rw-r--r--src/mongo/db/commands/fsync.cpp1
-rw-r--r--src/mongo/db/commands/get_last_error.cpp6
-rw-r--r--src/mongo/db/dbcommands.cpp4
-rw-r--r--src/mongo/db/field_parser.cpp12
-rw-r--r--src/mongo/db/field_parser.h9
-rw-r--r--src/mongo/db/field_parser_test.cpp1
-rw-r--r--src/mongo/db/global_timestamp.cpp (renamed from src/mongo/db/global_optime.cpp)38
-rw-r--r--src/mongo/db/global_timestamp.h (renamed from src/mongo/db/global_optime.h)12
-rw-r--r--src/mongo/db/hasher_test.cpp2
-rw-r--r--src/mongo/db/instance.cpp8
-rw-r--r--src/mongo/db/jsobj.h3
-rw-r--r--src/mongo/db/json.cpp4
-rw-r--r--src/mongo/db/lasterror.h1
-rw-r--r--src/mongo/db/ops/SConscript2
-rw-r--r--src/mongo/db/ops/insert.cpp8
-rw-r--r--src/mongo/db/ops/modifier_current_date.cpp6
-rw-r--r--src/mongo/db/ops/modifier_current_date_test.cpp10
-rw-r--r--src/mongo/db/ops/modifier_object_replace.cpp11
-rw-r--r--src/mongo/db/ops/modifier_object_replace_test.cpp2
-rw-r--r--src/mongo/db/pipeline/document_value_test.cpp36
-rw-r--r--src/mongo/db/pipeline/value.cpp30
-rw-r--r--src/mongo/db/pipeline/value.h10
-rw-r--r--src/mongo/db/pipeline/value_internal.h4
-rw-r--r--src/mongo/db/query/find.cpp12
-rw-r--r--src/mongo/db/query/get_executor.cpp4
-rw-r--r--src/mongo/db/repl/SConscript2
-rw-r--r--src/mongo/db/repl/bgsync.cpp10
-rw-r--r--src/mongo/db/repl/bgsync.h2
-rw-r--r--src/mongo/db/repl/freshness_checker.cpp10
-rw-r--r--src/mongo/db/repl/freshness_checker.h10
-rw-r--r--src/mongo/db/repl/freshness_checker_test.cpp90
-rw-r--r--src/mongo/db/repl/initial_sync.cpp2
-rw-r--r--src/mongo/db/repl/initial_sync.h2
-rw-r--r--src/mongo/db/repl/master_slave.cpp45
-rw-r--r--src/mongo/db/repl/master_slave.h10
-rw-r--r--src/mongo/db/repl/member_heartbeat_data.cpp12
-rw-r--r--src/mongo/db/repl/member_heartbeat_data.h6
-rw-r--r--src/mongo/db/repl/minvalid.cpp10
-rw-r--r--src/mongo/db/repl/minvalid.h8
-rw-r--r--src/mongo/db/repl/oplog.cpp28
-rw-r--r--src/mongo/db/repl/oplog.h10
-rw-r--r--src/mongo/db/repl/oplogreader.cpp14
-rw-r--r--src/mongo/db/repl/oplogreader.h6
-rw-r--r--src/mongo/db/repl/optime.h83
-rw-r--r--src/mongo/db/repl/repl_client_info.h8
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_response.cpp20
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_response.h14
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_response_test.cpp84
-rw-r--r--src/mongo/db/repl/replication_coordinator.h16
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state.h6
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp16
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.h4
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_mock.cpp6
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_mock.h12
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp60
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.h38
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect.cpp4
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp12
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp4
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp22
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp122
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.cpp16
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.h12
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp2
-rw-r--r--src/mongo/db/repl/replication_info.cpp2
-rw-r--r--src/mongo/db/repl/replset_commands.cpp2
-rw-r--r--src/mongo/db/repl/rs_initialsync.cpp12
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp22
-rw-r--r--src/mongo/db/repl/rs_rollback.h4
-rw-r--r--src/mongo/db/repl/sync_source_feedback.h2
-rw-r--r--src/mongo/db/repl/sync_tail.cpp22
-rw-r--r--src/mongo/db/repl/sync_tail.h6
-rw-r--r--src/mongo/db/repl/topology_coordinator.h24
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl.cpp72
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl.h48
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl_test.cpp634
-rw-r--r--src/mongo/db/repl/update_position_args.cpp6
-rw-r--r--src/mongo/db/repl/update_position_args.h4
-rw-r--r--src/mongo/db/storage/index_entry_comparison.h4
-rw-r--r--src/mongo/db/storage/key_string.cpp8
-rw-r--r--src/mongo/db/storage/key_string.h5
-rw-r--r--src/mongo/db/storage/key_string_test.cpp12
-rw-r--r--src/mongo/db/storage/mmap_v1/btree/key.cpp2
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp1
-rw-r--r--src/mongo/db/storage/oplog_hack.cpp8
-rw-r--r--src/mongo/db/storage/oplog_hack.h8
-rw-r--r--src/mongo/db/storage/record_store.h2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp20
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp1
-rw-r--r--src/mongo/db/write_concern.cpp2
-rw-r--r--src/mongo/db/write_concern.h2
-rw-r--r--src/mongo/db/write_concern_options.cpp2
-rw-r--r--src/mongo/dbtests/documentsourcetests.cpp1
-rw-r--r--src/mongo/dbtests/jsobjtests.cpp4
-rw-r--r--src/mongo/dbtests/jsontests.cpp14
-rw-r--r--src/mongo/dbtests/jstests.cpp18
-rw-r--r--src/mongo/dbtests/mock/mock_remote_db_server.h3
-rw-r--r--src/mongo/dbtests/pdfiletests.cpp12
-rw-r--r--src/mongo/dbtests/perftests.cpp1
-rw-r--r--src/mongo/dbtests/querytests.cpp10
-rw-r--r--src/mongo/dbtests/repltests.cpp42
-rw-r--r--src/mongo/s/catalog/type_chunk.h2
-rw-r--r--src/mongo/s/chunk_version.h2
-rw-r--r--src/mongo/s/client_info.cpp2
-rw-r--r--src/mongo/s/cluster_last_error_info.cpp2
-rw-r--r--src/mongo/s/config.h1
-rw-r--r--src/mongo/s/d_migrate.cpp12
-rw-r--r--src/mongo/s/type_database.h2
-rw-r--r--src/mongo/s/type_shard.h2
-rw-r--r--src/mongo/s/write_ops/batch_downconvert.cpp6
-rw-r--r--src/mongo/s/write_ops/batch_downconvert.h2
-rw-r--r--src/mongo/s/write_ops/batch_write_exec.cpp4
-rw-r--r--src/mongo/s/write_ops/batch_write_exec.h8
-rw-r--r--src/mongo/s/write_ops/batched_command_response.cpp8
-rw-r--r--src/mongo/s/write_ops/batched_command_response.h8
-rw-r--r--src/mongo/s/write_ops/batched_delete_request_test.cpp4
-rw-r--r--src/mongo/s/write_ops/batched_insert_request_test.cpp2
-rw-r--r--src/mongo/s/write_ops/batched_request_metadata.h2
-rw-r--r--src/mongo/s/write_ops/batched_request_metadata_test.cpp4
-rw-r--r--src/mongo/s/write_ops/batched_update_request_test.cpp4
-rw-r--r--src/mongo/scripting/engine_v8-3.25.cpp6
-rw-r--r--src/mongo/scripting/engine_v8.cpp6
-rw-r--r--src/mongo/scripting/v8_db.cpp2
-rw-r--r--src/mongo/shell/clientAndShell.cpp2
-rw-r--r--src/mongo/shell/shell_utils.h1
-rw-r--r--src/mongo/unittest/unittest_helpers.cpp4
-rw-r--r--src/mongo/unittest/unittest_helpers.h6
-rw-r--r--src/mongo/util/fail_point.cpp1
-rw-r--r--src/mongo/util/processinfo.h3
-rw-r--r--src/mongo/util/safe_num.h3
164 files changed, 1379 insertions, 1321 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index db4247b1fd5..40bfc918512 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -117,7 +117,7 @@ env.Library('bson', [
'util/safe_num.cpp',
'bson/bson_validate.cpp',
'bson/oid.cpp',
- "bson/optime.cpp",
+ "bson/timestamp.cpp",
'bson/bson_startuptest.cpp',
'bson/bsonelement.cpp',
'bson/bsonmisc.cpp',
@@ -283,7 +283,7 @@ env.CppUnitTest(
'range_arithmetic'
])
-env.Library('global_optime', ['db/global_optime.cpp'])
+env.Library('global_timestamp', ['db/global_timestamp.cpp'])
env.Library('spin_lock', ["util/concurrency/spin_lock.cpp"])
env.CppUnitTest('spin_lock_test', ['util/concurrency/spin_lock_test.cpp'],
@@ -1064,7 +1064,7 @@ serveronlyLibdeps = ["coreshard",
"db/concurrency/write_conflict_exception",
"db/ops/update_driver",
"defaultversion",
- "global_optime",
+ "global_timestamp",
"index_key_validate",
'range_deleter',
'scripting_server',
diff --git a/src/mongo/bson/bson_db.h b/src/mongo/bson/bson_db.h
deleted file mode 100644
index 941aea1935c..00000000000
--- a/src/mongo/bson/bson_db.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/** @file bson_db.h */
-
-/* Copyright 2009 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects
- * for all of the code used other than as permitted herein. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version. If you
- * delete this exception statement from all source files in the program,
- * then also delete it in the license file.
- */
-
-/*
- This file contains the implementation of BSON-related methods that are required
- by the MongoDB database server.
-
- Normally, for standalone BSON usage, you do not want this file - it will tend to
- pull in some other files from the MongoDB project. Thus, bson.h (the main file
- one would use) does not include this file.
-*/
-
-#pragma once
-
-#include "mongo/base/data_view.h"
-#include "mongo/bson/optime.h"
-#include "mongo/util/time_support.h"
-
-namespace mongo {
-
- inline BSONObjBuilder& BSONObjBuilder::append(StringData fieldName, OpTime optime) {
- optime.append(_b, fieldName);
- return *this;
- }
-
- inline BSONObjBuilder& BSONObjBuilder::appendTimestamp( StringData fieldName ) {
- return append(fieldName, OpTime());
- }
-
- inline BSONObjBuilder& BSONObjBuilder::appendTimestamp( StringData fieldName,
- unsigned long long val ) {
- return append(fieldName, OpTime(val));
- }
-
- inline OpTime BSONElement::_opTime() const {
- if( type() == mongo::Date || type() == Timestamp )
- return OpTime(ConstDataView(value()).readLE<unsigned long long>());
- return OpTime();
- }
-
- inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const DateNowLabeler& id) {
- _builder->appendDate(_fieldName, jsTime());
- _fieldName = StringData();
- return *_builder;
- }
-
- inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const NullLabeler& id) {
- _builder->appendNull(_fieldName);
- _fieldName = StringData();
- return *_builder;
- }
-
- inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const UndefinedLabeler& id) {
- _builder->appendUndefined(_fieldName);
- _fieldName = StringData();
- return *_builder;
- }
-
-
- inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const MinKeyLabeler& id) {
- _builder->appendMinKey(_fieldName);
- _fieldName = StringData();
- return *_builder;
- }
-
- inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const MaxKeyLabeler& id) {
- _builder->appendMaxKey(_fieldName);
- _fieldName = StringData();
- return *_builder;
- }
-
- template<class T> inline
- BSONObjBuilder& BSONObjBuilderValueStream::operator<<( T value ) {
- _builder->append(_fieldName, value);
- _fieldName = StringData();
- return *_builder;
- }
-
- template<class T>
- BSONObjBuilder& Labeler::operator<<( T value ) {
- s_->subobj()->append( l_.l_, value );
- return *s_->_builder;
- }
-
-}
diff --git a/src/mongo/bson/bson_validate.cpp b/src/mongo/bson/bson_validate.cpp
index 778a8d83018..b2b55bbe9f8 100644
--- a/src/mongo/bson/bson_validate.cpp
+++ b/src/mongo/bson/bson_validate.cpp
@@ -220,7 +220,7 @@ namespace mongo {
case NumberDouble:
case NumberLong:
- case Timestamp:
+ case bsonTimestamp:
case Date:
if ( !buffer->skip( sizeof(int64_t) ) )
return makeError("invalid bson", idElem);
diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp
index 6d3c9ac5c3d..c48e55f4e0a 100644
--- a/src/mongo/bson/bsonelement.cpp
+++ b/src/mongo/bson/bsonelement.cpp
@@ -264,7 +264,7 @@ namespace mongo {
s << "\"" << escape(_asCode()) << "\"";
break;
- case Timestamp:
+ case bsonTimestamp:
if ( format == TenGen ) {
s << "Timestamp( " << ( timestampTime() / 1000 ) << ", " << timestampInc() << " )";
}
@@ -461,7 +461,7 @@ namespace mongo {
case NumberInt:
x = 4;
break;
- case Timestamp:
+ case bsonTimestamp:
case mongo::Date:
case NumberDouble:
case NumberLong:
@@ -541,7 +541,7 @@ namespace mongo {
case NumberInt:
x = 4;
break;
- case Timestamp:
+ case bsonTimestamp:
case mongo::Date:
case NumberDouble:
case NumberLong:
@@ -700,7 +700,7 @@ namespace mongo {
}
}
break;
- case Timestamp:
+ case bsonTimestamp:
s << "Timestamp " << timestampTime() << "|" << timestampInc();
break;
default:
@@ -843,7 +843,7 @@ namespace mongo {
return f==0 ? 0 : 1;
case Bool:
return *l.value() - *r.value();
- case Timestamp:
+ case bsonTimestamp:
// unsigned compare for timestamps - note they are not really dates but (ordinal + time_t)
if ( l.date() < r.date() )
return -1;
@@ -963,8 +963,8 @@ namespace mongo {
boost::hash_combine(hash, elem.boolean());
break;
- case mongo::Timestamp:
- boost::hash_combine(hash, elem._opTime().asDate());
+ case mongo::bsonTimestamp:
+ boost::hash_combine(hash, elem.timestamp().asULL());
break;
case mongo::Date:
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h
index b79cc19d0cd..cc5c687f8d7 100644
--- a/src/mongo/bson/bsonelement.h
+++ b/src/mongo/bson/bsonelement.h
@@ -37,13 +37,14 @@
#include "mongo/base/data_view.h"
#include "mongo/bson/bsontypes.h"
#include "mongo/bson/oid.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/platform/cstdint.h"
namespace mongo {
- class OpTime;
class BSONObj;
class BSONElement;
class BSONObjBuilder;
+ class Timestamp;
typedef BSONElement be;
typedef BSONObj bo;
@@ -452,6 +453,12 @@ namespace mongo {
}
}
+ Timestamp timestamp() const {
+ if( type() == mongo::Date || type() == bsonTimestamp )
+ return Timestamp(ConstDataView(value()).readLE<unsigned long long>());
+ return Timestamp();
+ }
+
Date_t timestampTime() const {
unsigned long long t = ConstDataView(value() + 4).readLE<unsigned int>();
return t * 1000;
@@ -524,7 +531,6 @@ namespace mongo {
}
std::string _asCode() const;
- OpTime _opTime() const;
template<typename T> bool coerce( T* out ) const;
diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h
index d138658edb6..b8fc7501acf 100644
--- a/src/mongo/bson/bsonobj.h
+++ b/src/mongo/bson/bsonobj.h
@@ -36,6 +36,9 @@
#include <utility>
#include <vector>
+#include "mongo/bson/timestamp.h"
+#include "mongo/bson/bsontypes.h"
+#include "mongo/bson/oid.h"
#include "mongo/bson/bsonelement.h"
#include "mongo/base/data_view.h"
#include "mongo/base/disallow_copying.h"
diff --git a/src/mongo/bson/bsonobjbuilder.cpp b/src/mongo/bson/bsonobjbuilder.cpp
index ca3ac311527..d0fd2665ff3 100644
--- a/src/mongo/bson/bsonobjbuilder.cpp
+++ b/src/mongo/bson/bsonobjbuilder.cpp
@@ -33,7 +33,7 @@
#include <boost/lexical_cast.hpp>
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/util/log.h"
namespace mongo {
@@ -56,7 +56,7 @@ namespace mongo {
appendBool(fieldName, true);
//appendDate( fieldName , numeric_limits<long long>::min() );
return;
- case Timestamp:
+ case bsonTimestamp:
appendTimestamp( fieldName , 0 ); return;
case Undefined: // shared with EOO
appendUndefined( fieldName ); return;
@@ -110,8 +110,8 @@ namespace mongo {
appendMinForType( fieldName, Object ); return;
case Date:
appendDate( fieldName , std::numeric_limits<long long>::max() ); return;
- case Timestamp:
- append( fieldName , OpTime::max() ); return;
+ case bsonTimestamp:
+ append( fieldName , Timestamp::max() ); return;
case Undefined: // shared with EOO
appendUndefined( fieldName ); return;
diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h
index a679140dae0..2910e7da58a 100644
--- a/src/mongo/bson/bsonobjbuilder.h
+++ b/src/mongo/bson/bsonobjbuilder.h
@@ -458,16 +458,16 @@ namespace mongo {
return *this;
}
- // Append a Timestamp field -- will be updated to next OpTime on db insert.
+ // Append a Timestamp field -- will be updated to next server Timestamp
BSONObjBuilder& appendTimestamp( StringData fieldName );
BSONObjBuilder& appendTimestamp( StringData fieldName , unsigned long long val );
/**
- * To store an OpTime in BSON, use this function.
+ * To store a Timestamp in BSON, use this function.
* This captures both the secs and inc fields.
*/
- BSONObjBuilder& append(StringData fieldName, OpTime optime);
+ BSONObjBuilder& append(StringData fieldName, Timestamp timestamp);
/*
Append an element of the deprecated DBRef type.
@@ -905,4 +905,62 @@ namespace mongo {
inline BSONObj OR(const BSONObj& a, const BSONObj& b, const BSONObj& c, const BSONObj& d, const BSONObj& e, const BSONObj& f)
{ return BSON( "$or" << BSON_ARRAY(a << b << c << d << e << f) ); }
+ inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const DateNowLabeler& id) {
+ _builder->appendDate(_fieldName, jsTime());
+ _fieldName = StringData();
+ return *_builder;
+ }
+
+ inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const NullLabeler& id) {
+ _builder->appendNull(_fieldName);
+ _fieldName = StringData();
+ return *_builder;
+ }
+
+ inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const UndefinedLabeler& id) {
+ _builder->appendUndefined(_fieldName);
+ _fieldName = StringData();
+ return *_builder;
+ }
+
+
+ inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const MinKeyLabeler& id) {
+ _builder->appendMinKey(_fieldName);
+ _fieldName = StringData();
+ return *_builder;
+ }
+
+ inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const MaxKeyLabeler& id) {
+ _builder->appendMaxKey(_fieldName);
+ _fieldName = StringData();
+ return *_builder;
+ }
+
+ template<class T> inline
+ BSONObjBuilder& BSONObjBuilderValueStream::operator<<( T value ) {
+ _builder->append(_fieldName, value);
+ _fieldName = StringData();
+ return *_builder;
+ }
+
+ template<class T>
+ BSONObjBuilder& Labeler::operator<<( T value ) {
+ s_->subobj()->append( l_.l_, value );
+ return *s_->_builder;
+ }
+
+ inline BSONObjBuilder& BSONObjBuilder::append(StringData fieldName, Timestamp optime) {
+ optime.append(_b, fieldName);
+ return *this;
+ }
+
+ inline BSONObjBuilder& BSONObjBuilder::appendTimestamp( StringData fieldName ) {
+ return append(fieldName, Timestamp());
+ }
+
+ inline BSONObjBuilder& BSONObjBuilder::appendTimestamp( StringData fieldName,
+ unsigned long long val ) {
+ return append(fieldName, Timestamp(val));
+ }
+
}
diff --git a/src/mongo/bson/bsonobjbuilder_test.cpp b/src/mongo/bson/bsonobjbuilder_test.cpp
index f2b44c552f8..d18fb900537 100644
--- a/src/mongo/bson/bsonobjbuilder_test.cpp
+++ b/src/mongo/bson/bsonobjbuilder_test.cpp
@@ -44,7 +44,6 @@ namespace {
using mongo::BSONObj;
using mongo::BSONObjBuilder;
using mongo::BSONType;
- using mongo::OpTime;
const long long maxEncodableInt = (1 << 30) - 1;
const long long minEncodableInt = -maxEncodableInt;
@@ -249,16 +248,16 @@ namespace {
ASSERT_EQUALS(o1, o2);
}
- TEST(BSONObjBuilderTest, AppendMaxTimestampOpTimeConversion) {
+ TEST(BSONObjBuilderTest, AppendMaxTimestampConversion) {
BSONObjBuilder b;
- b.appendMaxForType("a", mongo::Timestamp);
+ b.appendMaxForType("a", mongo::bsonTimestamp);
BSONObj o1 = b.obj();
BSONElement e = o1.getField("a");
ASSERT_FALSE(e.eoo());
- OpTime opTime = e._opTime();
- ASSERT_FALSE(opTime.isNull());
+ mongo::Timestamp timestamp = e.timestamp();
+ ASSERT_FALSE(timestamp.isNull());
}
} // unnamed namespace
diff --git a/src/mongo/bson/bsontypes.cpp b/src/mongo/bson/bsontypes.cpp
index 3f83009ad1f..5fd15364d1d 100644
--- a/src/mongo/bson/bsontypes.cpp
+++ b/src/mongo/bson/bsontypes.cpp
@@ -94,7 +94,7 @@ namespace mongo {
case Symbol: return "Symbol";
case CodeWScope: return "CodeWScope";
case NumberInt: return "NumberInt32";
- case Timestamp: return "Timestamp";
+ case bsonTimestamp: return "Timestamp";
case NumberLong: return "NumberLong64";
// JSTypeMax doesn't make sense to turn into a string; overlaps with highest-valued type
case MaxKey: return "MaxKey";
diff --git a/src/mongo/bson/bsontypes.h b/src/mongo/bson/bsontypes.h
index 449c617f13c..3b7e98fee42 100644
--- a/src/mongo/bson/bsontypes.h
+++ b/src/mongo/bson/bsontypes.h
@@ -87,8 +87,8 @@ namespace mongo {
CodeWScope=15,
/** 32 bit signed integer */
NumberInt = 16,
- /** Updated to a Date with value next OpTime on insert */
- Timestamp = 17,
+ /** Two 32 bit signed integers */
+ bsonTimestamp = 17,
/** 64 bit integer */
NumberLong = 18,
/** max type that is not MaxKey */
@@ -150,7 +150,7 @@ namespace mongo {
return 40;
case mongo::Date:
return 45;
- case Timestamp:
+ case bsonTimestamp:
return 47;
case RegEx:
return 50;
diff --git a/src/mongo/bson/mutable/const_element-inl.h b/src/mongo/bson/mutable/const_element-inl.h
index 5988747a64b..af059fd37a2 100644
--- a/src/mongo/bson/mutable/const_element-inl.h
+++ b/src/mongo/bson/mutable/const_element-inl.h
@@ -141,7 +141,7 @@ namespace mutablebson {
return _basis.getValueInt();
}
- inline OpTime ConstElement::getValueTimestamp() const {
+ inline Timestamp ConstElement::getValueTimestamp() const {
return _basis.getValueTimestamp();
}
diff --git a/src/mongo/bson/mutable/const_element.h b/src/mongo/bson/mutable/const_element.h
index bbeb43ca5cf..c1c5d2f4da7 100644
--- a/src/mongo/bson/mutable/const_element.h
+++ b/src/mongo/bson/mutable/const_element.h
@@ -82,7 +82,7 @@ namespace mutablebson {
inline bool isValueNull() const;
inline StringData getValueSymbol() const;
inline int32_t getValueInt() const;
- inline OpTime getValueTimestamp() const;
+ inline Timestamp getValueTimestamp() const;
inline int64_t getValueLong() const;
inline bool isValueMinKey() const;
inline bool isValueMaxKey() const;
diff --git a/src/mongo/bson/mutable/document.cpp b/src/mongo/bson/mutable/document.cpp
index d2223a26500..db7fa0bec5e 100644
--- a/src/mongo/bson/mutable/document.cpp
+++ b/src/mongo/bson/mutable/document.cpp
@@ -1858,7 +1858,7 @@ namespace mutablebson {
return setValue(newValue._repIdx);
}
- Status Element::setValueTimestamp(const OpTime value) {
+ Status Element::setValueTimestamp(const Timestamp value) {
verify(ok());
Document::Impl& impl = getDocument().getImpl();
const ElementRep& thisRep = impl.getElementRep(_repIdx);
@@ -2477,13 +2477,13 @@ namespace mutablebson {
return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1));
}
- Element Document::makeElementTimestamp(StringData fieldName, const OpTime value) {
+ Element Document::makeElementTimestamp(StringData fieldName, const Timestamp value) {
Impl& impl = getImpl();
dassert(impl.doesNotAlias(fieldName));
BSONObjBuilder& builder = impl.leafBuilder();
const int leafRef = builder.len();
- builder.appendTimestamp(fieldName, value.asDate());
+ builder.append(fieldName, value);
return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1));
}
diff --git a/src/mongo/bson/mutable/document.h b/src/mongo/bson/mutable/document.h
index 293df8638f7..2abfc1ca527 100644
--- a/src/mongo/bson/mutable/document.h
+++ b/src/mongo/bson/mutable/document.h
@@ -375,8 +375,8 @@ namespace mutablebson {
/** Create a new integer Element with the given value and field name. */
Element makeElementInt(StringData fieldName, int32_t value);
- /** Create a new timetamp Element with the given value and field name. */
- Element makeElementTimestamp(StringData fieldName, OpTime value);
+ /** Create a new timestamp Element with the given value and field name. */
+ Element makeElementTimestamp(StringData fieldName, Timestamp value);
/** Create a new long integer Element with the given value and field name. */
Element makeElementLong(StringData fieldName, int64_t value);
diff --git a/src/mongo/bson/mutable/element-inl.h b/src/mongo/bson/mutable/element-inl.h
index ca8a5147b42..7e9249a5b15 100644
--- a/src/mongo/bson/mutable/element-inl.h
+++ b/src/mongo/bson/mutable/element-inl.h
@@ -91,9 +91,9 @@ namespace mutablebson {
return getValue()._numberInt();
}
- inline OpTime Element::getValueTimestamp() const {
- dassert(hasValue() && isType(mongo::Timestamp));
- return getValue()._opTime();
+ inline Timestamp Element::getValueTimestamp() const {
+ dassert(hasValue() && isType(mongo::bsonTimestamp));
+ return getValue().timestamp();
}
inline int64_t Element::getValueLong() const {
diff --git a/src/mongo/bson/mutable/element.cpp b/src/mongo/bson/mutable/element.cpp
index 73bdc02af42..407a27c3df7 100644
--- a/src/mongo/bson/mutable/element.cpp
+++ b/src/mongo/bson/mutable/element.cpp
@@ -129,7 +129,7 @@ namespace mutablebson {
return pushBack(getDocument().makeElementInt(fieldName, value));
}
- Status Element::appendTimestamp(StringData fieldName, OpTime value) {
+ Status Element::appendTimestamp(StringData fieldName, Timestamp value) {
return pushBack(getDocument().makeElementTimestamp(fieldName, value));
}
diff --git a/src/mongo/bson/mutable/element.h b/src/mongo/bson/mutable/element.h
index a84c29e92fd..f58771f2513 100644
--- a/src/mongo/bson/mutable/element.h
+++ b/src/mongo/bson/mutable/element.h
@@ -318,7 +318,7 @@ namespace mutablebson {
inline int32_t getValueInt() const;
/** Get the value from a timestamp valued Element. */
- inline OpTime getValueTimestamp() const;
+ inline Timestamp getValueTimestamp() const;
/** Get the value from a long valued Element. */
inline int64_t getValueLong() const;
@@ -438,7 +438,7 @@ namespace mutablebson {
Status setValueInt(int32_t value);
/** Set the value of this Element to the given timestamp. */
- Status setValueTimestamp(OpTime value);
+ Status setValueTimestamp(Timestamp value);
/** Set the value of this Element to the given long integer */
Status setValueLong(int64_t value);
@@ -562,7 +562,7 @@ namespace mutablebson {
Status appendInt(StringData fieldName, int32_t value);
/** Append the provided timestamp as a new field with the provided name. */
- Status appendTimestamp(StringData fieldName, OpTime value);
+ Status appendTimestamp(StringData fieldName, Timestamp value);
/** Append the provided long integer as a new field with the provided name. */
Status appendLong(StringData fieldName, int64_t value);
diff --git a/src/mongo/bson/mutable/mutable_bson_test.cpp b/src/mongo/bson/mutable/mutable_bson_test.cpp
index f2d4b289d3b..47cca65fb30 100644
--- a/src/mongo/bson/mutable/mutable_bson_test.cpp
+++ b/src/mongo/bson/mutable/mutable_bson_test.cpp
@@ -553,8 +553,8 @@ namespace {
t0.setValueLong(12345LL);
ASSERT_EQUALS(mongo::NumberLong, t0.getType());
- t0.setValueTimestamp(mongo::OpTime());
- ASSERT_EQUALS(mongo::Timestamp, t0.getType());
+ t0.setValueTimestamp(mongo::Timestamp());
+ ASSERT_EQUALS(mongo::bsonTimestamp, t0.getType());
t0.setValueDate(12345LL);
ASSERT_EQUALS(mongo::Date, t0.getType());
@@ -609,42 +609,42 @@ namespace {
TEST(TimestampType, createElement) {
mmb::Document doc;
- mmb::Element t0 = doc.makeElementTimestamp("t0", mongo::OpTime());
- ASSERT(mongo::OpTime() == t0.getValueTimestamp());
+ mmb::Element t0 = doc.makeElementTimestamp("t0", mongo::Timestamp());
+ ASSERT(mongo::Timestamp() == t0.getValueTimestamp());
- mmb::Element t1 = doc.makeElementTimestamp("t1", mongo::OpTime(123, 456));
- ASSERT(mongo::OpTime(123, 456) == t1.getValueTimestamp());
+ mmb::Element t1 = doc.makeElementTimestamp("t1", mongo::Timestamp(123, 456));
+ ASSERT(mongo::Timestamp(123, 456) == t1.getValueTimestamp());
}
TEST(TimestampType, setElement) {
mmb::Document doc;
- mmb::Element t0 = doc.makeElementTimestamp("t0", mongo::OpTime());
- t0.setValueTimestamp(mongo::OpTime(123, 456));
- ASSERT(mongo::OpTime(123, 456) == t0.getValueTimestamp());
+ mmb::Element t0 = doc.makeElementTimestamp("t0", mongo::Timestamp());
+ t0.setValueTimestamp(mongo::Timestamp(123, 456));
+ ASSERT(mongo::Timestamp(123, 456) == t0.getValueTimestamp());
- // Try setting to other types and back to OpTime
+ // Try setting to other types and back to Timestamp
t0.setValueLong(1234567890);
ASSERT_EQUALS(1234567890LL, t0.getValueLong());
- t0.setValueTimestamp(mongo::OpTime(789, 321));
- ASSERT(mongo::OpTime(789, 321) == t0.getValueTimestamp());
+ t0.setValueTimestamp(mongo::Timestamp(789, 321));
+ ASSERT(mongo::Timestamp(789, 321) == t0.getValueTimestamp());
t0.setValueString("foo bar baz");
ASSERT_EQUALS("foo bar baz", t0.getValueString());
- t0.setValueTimestamp(mongo::OpTime(9876, 5432));
- ASSERT(mongo::OpTime(9876, 5432) == t0.getValueTimestamp());
+ t0.setValueTimestamp(mongo::Timestamp(9876, 5432));
+ ASSERT(mongo::Timestamp(9876, 5432) == t0.getValueTimestamp());
}
TEST(TimestampType, appendElement) {
mmb::Document doc;
mmb::Element t0 = doc.makeElementObject("e0");
- t0.appendTimestamp("a timestamp field", mongo::OpTime(1352151971, 471));
+ t0.appendTimestamp("a timestamp field", mongo::Timestamp(1352151971, 471));
mmb::Element it =
mmb::findFirstChildNamed(t0, "a timestamp field");
ASSERT_TRUE(it.ok());
- ASSERT(mongo::OpTime(1352151971, 471) == it.getValueTimestamp());
+ ASSERT(mongo::Timestamp(1352151971, 471) == it.getValueTimestamp());
}
TEST(SafeNumType, createElement) {
@@ -2264,11 +2264,11 @@ namespace {
TEST(TypeSupport, EncodingEquivalenceTimestamp) {
mongo::BSONObjBuilder builder;
const char name[] = "thing";
- const mongo::OpTime value1 = mongo::OpTime(mongo::jsTime());
+ const mongo::Timestamp value1 = mongo::Timestamp(mongo::jsTime());
builder.append(name, value1);
mongo::BSONObj source = builder.done();
const mongo::BSONElement thing = source.firstElement();
- ASSERT_TRUE(thing.type() == mongo::Timestamp);
+ ASSERT_TRUE(thing.type() == mongo::bsonTimestamp);
mmb::Document doc;
@@ -2276,7 +2276,7 @@ namespace {
ASSERT_OK(doc.root().appendTimestamp(name, value1));
mmb::Element a = doc.root().rightChild();
ASSERT_TRUE(a.ok());
- ASSERT_EQUALS(a.getType(), mongo::Timestamp);
+ ASSERT_EQUALS(a.getType(), mongo::bsonTimestamp);
ASSERT_TRUE(a.hasValue());
ASSERT_TRUE(value1 == mmb::ConstElement(a).getValueTimestamp());
@@ -2284,7 +2284,7 @@ namespace {
ASSERT_OK(doc.root().appendElement(thing));
mmb::Element b = doc.root().rightChild();
ASSERT_TRUE(b.ok());
- ASSERT_EQUALS(b.getType(), mongo::Timestamp);
+ ASSERT_EQUALS(b.getType(), mongo::bsonTimestamp);
ASSERT_TRUE(b.hasValue());
// Construct via setValue call.
@@ -2292,7 +2292,7 @@ namespace {
mmb::Element c = doc.root().rightChild();
ASSERT_TRUE(c.ok());
c.setValueTimestamp(value1);
- ASSERT_EQUALS(c.getType(), mongo::Timestamp);
+ ASSERT_EQUALS(c.getType(), mongo::bsonTimestamp);
ASSERT_TRUE(c.hasValue());
// Ensure identity:
@@ -2788,7 +2788,7 @@ namespace {
}
TEST(DocumentInPlace, TimestampLifecycle) {
- mongo::BSONObj obj(BSON("x" << mongo::OpTime(mongo::Date_t(1000))));
+ mongo::BSONObj obj(BSON("x" << mongo::Timestamp(mongo::Date_t(1000))));
mmb::Document doc(obj, mmb::Document::kInPlaceEnabled);
mmb::Element x = doc.root().leftChild();
@@ -2796,13 +2796,13 @@ namespace {
mmb::DamageVector damages;
const char* source = NULL;
- x.setValueTimestamp(mongo::OpTime(mongo::Date_t(20000)));
+ x.setValueTimestamp(mongo::Timestamp(mongo::Date_t(20000)));
ASSERT_TRUE(doc.getInPlaceUpdates(&damages, &source));
ASSERT_EQUALS(1U, damages.size());
apply(&obj, damages, source);
ASSERT_TRUE(x.hasValue());
- ASSERT_TRUE(x.isType(mongo::Timestamp));
- ASSERT_TRUE(mongo::OpTime(mongo::Date_t(20000)) == x.getValueTimestamp());
+ ASSERT_TRUE(x.isType(mongo::bsonTimestamp));
+ ASSERT_TRUE(mongo::Timestamp(mongo::Date_t(20000)) == x.getValueTimestamp());
// TODO: When in-place updates for leaf elements is implemented, add tests here.
}
diff --git a/src/mongo/bson/optime.cpp b/src/mongo/bson/timestamp.cpp
index ff044533a65..cfd43fe8fe2 100644
--- a/src/mongo/bson/optime.cpp
+++ b/src/mongo/bson/timestamp.cpp
@@ -26,27 +26,49 @@
*/
#include "mongo/bson/bsontypes.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
+#include <ctime>
#include <iostream>
#include <limits>
-#include <ctime>
+#include <sstream>
#include "mongo/platform/cstdint.h"
+#include "mongo/util/time_support.h"
namespace mongo {
- OpTime OpTime::max() {
+ Timestamp Timestamp::max() {
unsigned int t = static_cast<unsigned int>(std::numeric_limits<int32_t>::max());
unsigned int i = std::numeric_limits<uint32_t>::max();
- return OpTime(t, i);
+ return Timestamp(t, i);
}
- void OpTime::append(BufBuilder& builder, const StringData& fieldName) const {
+ void Timestamp::append(BufBuilder& builder, const StringData& fieldName) const {
// No endian conversions needed, since we store in-memory representation
// in little endian format, regardless of target endian.
- builder.appendNum( static_cast<char>(Timestamp) );
+ builder.appendNum( static_cast<char>(bsonTimestamp) );
builder.appendStr( fieldName );
- builder.appendNum( asDate() );
+ builder.appendNum( asULL() );
}
+
+ std::string Timestamp::toStringLong() const {
+ std::stringstream ss;
+ ss << time_t_to_String_short(secs) << ' ';
+ ss << std::hex << secs << ':' << i;
+ return ss.str();
+ }
+
+ std::string Timestamp::toStringPretty() const {
+ std::stringstream ss;
+ ss << time_t_to_String_short(secs) << ':' << std::hex << i;
+ return ss.str();
+ }
+
+ std::string Timestamp::toString() const {
+ std::stringstream ss;
+ ss << std::hex << secs << ':' << i;
+ return ss.str();
+ }
+
}
diff --git a/src/mongo/bson/optime.h b/src/mongo/bson/timestamp.h
index bcd6ae3e5a8..b223b5deb50 100644
--- a/src/mongo/bson/optime.h
+++ b/src/mongo/bson/timestamp.h
@@ -27,24 +27,16 @@
#pragma once
-#include <boost/thread/condition.hpp>
-#include <sstream>
-
+#include "mongo/base/data_view.h"
#include "mongo/bson/util/builder.h"
#include "mongo/util/assert_util.h"
-#include "mongo/util/concurrency/mutex.h"
-#include "mongo/util/time_support.h"
namespace mongo {
- struct ClockSkewException : public DBException {
- ClockSkewException() : DBException( "clock skew exception" , 20001 ) {}
- };
-
- /* Operation sequence #. A combination of current second plus an ordinal value.
+ /* Timestamp: A combination of current second plus an ordinal value.
*/
#pragma pack(4)
- class OpTime {
+ class Timestamp {
unsigned i; // ordinal comes first so we can do a single 64 bit compare on little endian
unsigned secs;
public:
@@ -55,30 +47,30 @@ namespace mongo {
return i;
}
- OpTime(Date_t date) {
+ Timestamp(Date_t date) {
reinterpret_cast<unsigned long long&>(*this) = date.millis;
dassert( (int)secs >= 0 );
}
- OpTime(unsigned a, unsigned b) {
+ Timestamp(unsigned a, unsigned b) {
secs = a;
i = b;
dassert( (int)secs >= 0 );
}
- OpTime( const OpTime& other ) {
+ Timestamp( const Timestamp& other ) {
secs = other.secs;
i = other.i;
dassert( (int)secs >= 0 );
}
- OpTime() {
+ Timestamp() {
secs = 0;
i = 0;
}
- // Maximum OpTime value.
- static OpTime max();
+ // Maximum Timestamp value.
+ static Timestamp max();
- unsigned long long asDate() const {
+ unsigned long long asULL() const {
return reinterpret_cast<const unsigned long long*>(&i)[0];
}
long long asLL() const {
@@ -87,48 +79,35 @@ namespace mongo {
bool isNull() const { return secs == 0; }
- std::string toStringLong() const {
- std::stringstream ss;
- ss << time_t_to_String_short(secs) << ' ';
- ss << std::hex << secs << ':' << i;
- return ss.str();
- }
+ std::string toStringLong() const;
- std::string toStringPretty() const {
- std::stringstream ss;
- ss << time_t_to_String_short(secs) << ':' << std::hex << i;
- return ss.str();
- }
+ std::string toStringPretty() const;
- std::string toString() const {
- std::stringstream ss;
- ss << std::hex << secs << ':' << i;
- return ss.str();
- }
+ std::string toString() const;
- bool operator==(const OpTime& r) const {
+ bool operator==(const Timestamp& r) const {
return i == r.i && secs == r.secs;
}
- bool operator!=(const OpTime& r) const {
+ bool operator!=(const Timestamp& r) const {
return !(*this == r);
}
- bool operator<(const OpTime& r) const {
+ bool operator<(const Timestamp& r) const {
if ( secs != r.secs )
return secs < r.secs;
return i < r.i;
}
- bool operator<=(const OpTime& r) const {
+ bool operator<=(const Timestamp& r) const {
return *this < r || *this == r;
}
- bool operator>(const OpTime& r) const {
+ bool operator>(const Timestamp& r) const {
return !(*this <= r);
}
- bool operator>=(const OpTime& r) const {
+ bool operator>=(const Timestamp& r) const {
return !(*this < r);
}
- // Append the BSON representation of this OpTime to the given BufBuilder with the given
- // name. This lives here because OpTime manages its own serialization format.
+ // Append the BSON representation of this Timestamp to the given BufBuilder with the given
+ // name. This lives here because Timestamp manages its own serialization format.
void append(BufBuilder& builder, const StringData& fieldName) const;
};
diff --git a/src/mongo/bson/util/bson_extract.cpp b/src/mongo/bson/util/bson_extract.cpp
index 5247c1fea39..ef8f5110568 100644
--- a/src/mongo/bson/util/bson_extract.cpp
+++ b/src/mongo/bson/util/bson_extract.cpp
@@ -106,14 +106,14 @@ namespace mongo {
return Status::OK();
}
- Status bsonExtractOpTimeField(const BSONObj& object,
+ Status bsonExtractTimestampField(const BSONObj& object,
StringData fieldName,
- OpTime* out) {
+ Timestamp* out) {
BSONElement element;
- Status status = bsonExtractTypedField(object, fieldName, Timestamp, &element);
+ Status status = bsonExtractTypedField(object, fieldName, bsonTimestamp, &element);
if (!status.isOK())
return status;
- *out = element._opTime();
+ *out = element.timestamp();
return Status::OK();
}
diff --git a/src/mongo/bson/util/bson_extract.h b/src/mongo/bson/util/bson_extract.h
index 7d4217a66bf..4558e18b22d 100644
--- a/src/mongo/bson/util/bson_extract.h
+++ b/src/mongo/bson/util/bson_extract.h
@@ -39,7 +39,7 @@ namespace mongo {
class BSONObj;
class BSONElement;
class OID;
- class OpTime;
+ class Timestamp;
/**
* Finds an element named "fieldName" in "object".
@@ -103,16 +103,16 @@ namespace mongo {
std::string* out);
/**
- * Finds an OpTime-typed element named "fieldName" in "object" and stores its value in "out".
+ * Finds an Timestamp-typed element named "fieldName" in "object" and stores its value in "out".
*
- * Returns Status::OK() and sets *out to the found element's OpTime value on success. Returns
+ * Returns Status::OK() and sets *out to the found element's Timestamp value on success. Returns
* ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch
- * if the type of the matching element is not OpTime. For return values other than
+ * if the type of the matching element is not Timestamp. For return values other than
* Status::OK(), the resulting value of "*out" is undefined.
*/
- Status bsonExtractOpTimeField(const BSONObj& object,
- StringData fieldName,
- OpTime* out);
+ Status bsonExtractTimestampField(const BSONObj& object,
+ StringData fieldName,
+ Timestamp* out);
/**
* Finds an OID-typed element named "fieldName" in "object" and stores its value in "out".
diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h
index 3385e255cf3..534a03871cf 100644
--- a/src/mongo/client/connpool.h
+++ b/src/mongo/client/connpool.h
@@ -36,6 +36,7 @@
#include "mongo/platform/atomic_word.h"
#include "mongo/platform/cstdint.h"
#include "mongo/util/background.h"
+#include "mongo/util/concurrency/mutex.h"
namespace mongo {
diff --git a/src/mongo/client/dbclient_rs_test.cpp b/src/mongo/client/dbclient_rs_test.cpp
index 030ebaaac26..40b25441f42 100644
--- a/src/mongo/client/dbclient_rs_test.cpp
+++ b/src/mongo/client/dbclient_rs_test.cpp
@@ -31,22 +31,22 @@
* the DBClientReplicaSet talks to, so the tests only covers the client side logic.
*/
-#include "mongo/bson/bson_field.h"
+#include <boost/scoped_ptr.hpp>
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
#include "mongo/client/connpool.h"
-#include "mongo/client/dbclientinterface.h"
#include "mongo/client/dbclient_rs.h"
+#include "mongo/client/dbclientinterface.h"
#include "mongo/client/replica_set_monitor.h"
+#include "mongo/db/jsobj.h"
#include "mongo/dbtests/mock/mock_conn_registry.h"
#include "mongo/dbtests/mock/mock_replica_set.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
-#include <boost/scoped_ptr.hpp>
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
namespace {
using boost::scoped_ptr;
using std::auto_ptr;
diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h
index e2d6bafe0d8..d53166107ae 100644
--- a/src/mongo/client/dbclientinterface.h
+++ b/src/mongo/client/dbclientinterface.h
@@ -32,11 +32,11 @@
#pragma once
+#include <boost/thread/lock_guard.hpp>
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
#include "mongo/base/string_data.h"
-#include "mongo/bson/bson_field.h"
#include "mongo/config.h"
#include "mongo/db/jsobj.h"
#include "mongo/logger/log_severity.h"
@@ -350,7 +350,7 @@ namespace mongo {
std::string _string;
std::string _setName;
- static mutex _connectHookMutex;
+ static boost::mutex _connectHookMutex;
static ConnectionHook* _connectHook;
};
diff --git a/src/mongo/client/replica_set_monitor.cpp b/src/mongo/client/replica_set_monitor.cpp
index f3d25a97cb6..7f52c9114ae 100644
--- a/src/mongo/client/replica_set_monitor.cpp
+++ b/src/mongo/client/replica_set_monitor.cpp
@@ -34,6 +34,7 @@
#include <algorithm>
#include <boost/make_shared.hpp>
#include <boost/thread.hpp>
+#include <boost/thread/condition.hpp>
#include <limits>
#include "mongo/db/server_options.h"
diff --git a/src/mongo/client/replica_set_monitor_internal.h b/src/mongo/client/replica_set_monitor_internal.h
index d69f90afc1f..6d5f54bf3b1 100644
--- a/src/mongo/client/replica_set_monitor_internal.h
+++ b/src/mongo/client/replica_set_monitor_internal.h
@@ -33,10 +33,11 @@
#pragma once
+#include <boost/thread/condition.hpp>
#include <deque>
+#include <set>
#include <string>
#include <vector>
-#include <set>
#include "mongo/base/disallow_copying.h"
#include "mongo/client/dbclient_rs.h" // for TagSet and ReadPreferenceSettings
diff --git a/src/mongo/client/syncclusterconnection.h b/src/mongo/client/syncclusterconnection.h
index 1f8d336318d..5be9aec74a1 100644
--- a/src/mongo/client/syncclusterconnection.h
+++ b/src/mongo/client/syncclusterconnection.h
@@ -35,6 +35,7 @@
#include "mongo/bson/bsonelement.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/client/dbclientinterface.h"
+#include "mongo/util/concurrency/mutex.h"
namespace mongo {
diff --git a/src/mongo/db/auth/privilege_parser.h b/src/mongo/db/auth/privilege_parser.h
index 66349199492..aec390e3973 100644
--- a/src/mongo/db/auth/privilege_parser.h
+++ b/src/mongo/db/auth/privilege_parser.h
@@ -32,7 +32,6 @@
#include <vector>
#include "mongo/base/string_data.h"
-#include "mongo/bson/bson_field.h"
#include "mongo/db/jsobj.h"
#include "mongo/s/bson_serializable.h"
diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h
index 554fb0e7076..86d8bc0b7bb 100644
--- a/src/mongo/db/clientcursor.h
+++ b/src/mongo/db/clientcursor.h
@@ -136,9 +136,9 @@ namespace mongo {
//
void updateSlaveLocation(OperationContext* txn);
- void slaveReadTill( const OpTime& t ) { _slaveReadTill = t; }
+ void slaveReadTill( const Timestamp& t ) { _slaveReadTill = t; }
/** Just for testing. */
- OpTime getSlaveReadTill() const { return _slaveReadTill; }
+ Timestamp getSlaveReadTill() const { return _slaveReadTill; }
//
// Query-specific functionality that may be adapted for the PlanExecutor.
@@ -250,7 +250,7 @@ namespace mongo {
bool _isNoTimeout;
// TODO: document better.
- OpTime _slaveReadTill;
+ Timestamp _slaveReadTill;
// How long has the cursor been idle?
int _idleAgeMillis;
diff --git a/src/mongo/db/commands/fsync.cpp b/src/mongo/db/commands/fsync.cpp
index 8a2329c7f95..ac63457aa15 100644
--- a/src/mongo/db/commands/fsync.cpp
+++ b/src/mongo/db/commands/fsync.cpp
@@ -30,6 +30,7 @@
#include "mongo/db/commands/fsync.h"
+#include <boost/thread/condition.hpp>
#include <iostream>
#include <sstream>
#include <string>
diff --git a/src/mongo/db/commands/get_last_error.cpp b/src/mongo/db/commands/get_last_error.cpp
index 2a376a369a4..065fc484d58 100644
--- a/src/mongo/db/commands/get_last_error.cpp
+++ b/src/mongo/db/commands/get_last_error.cpp
@@ -130,7 +130,7 @@ namespace mongo {
Client& c = *txn->getClient();
if (repl::getGlobalReplicationCoordinator()->getReplicationMode() ==
repl::ReplicationCoordinator::modeReplSet) {
- const OpTime lastOp = repl::ReplClientInfo::forClient(c).getLastOp();
+ const Timestamp lastOp = repl::ReplClientInfo::forClient(c).getLastOp();
if (!lastOp.isNull()) {
result.append("lastOp", lastOp);
}
@@ -139,8 +139,8 @@ namespace mongo {
// for sharding; also useful in general for debugging
result.appendNumber( "connectionId" , c.getConnectionId() );
- OpTime lastOpTime;
- BSONField<OpTime> wOpTimeField("wOpTime");
+ Timestamp lastOpTime;
+ BSONField<Timestamp> wOpTimeField("wOpTime");
FieldParser::FieldState extracted = FieldParser::extract(cmdObj, wOpTimeField,
&lastOpTime, &errmsg);
if (!extracted) {
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index 6fa03e9909a..297dd866f7d 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -1397,9 +1397,9 @@ namespace mongo {
};
namespace {
- void appendGLEHelperData(BSONObjBuilder& bob, const OpTime& opTime, const OID& oid) {
+ void appendGLEHelperData(BSONObjBuilder& bob, const Timestamp& opTime, const OID& oid) {
BSONObjBuilder subobj(bob.subobjStart(kGLEStatsFieldName));
- subobj.appendTimestamp(kGLEStatsLastOpTimeFieldName, opTime.asDate());
+ subobj.append(kGLEStatsLastOpTimeFieldName, opTime);
subobj.appendOID(kGLEStatsElectionIdFieldName, const_cast<OID*>(&oid));
subobj.done();
}
diff --git a/src/mongo/db/field_parser.cpp b/src/mongo/db/field_parser.cpp
index a53714afadb..1dbca72c2c7 100644
--- a/src/mongo/db/field_parser.cpp
+++ b/src/mongo/db/field_parser.cpp
@@ -162,16 +162,16 @@ namespace mongo {
}
FieldParser::FieldState FieldParser::extract( BSONObj doc,
- const BSONField<OpTime>& field,
- OpTime* out,
+ const BSONField<Timestamp>& field,
+ Timestamp* out,
string* errMsg ) {
return extract( doc[field.name()], field, out, errMsg );
}
FieldParser::FieldState FieldParser::extract( BSONElement elem,
- const BSONField<OpTime>& field,
- OpTime* out,
+ const BSONField<Timestamp>& field,
+ Timestamp* out,
string* errMsg )
{
if (elem.eoo()) {
@@ -184,8 +184,8 @@ namespace mongo {
}
}
- if (elem.type() == Timestamp) {
- *out = elem._opTime();
+ if (elem.type() == bsonTimestamp) {
+ *out = elem.timestamp();
return FIELD_SET;
}
diff --git a/src/mongo/db/field_parser.h b/src/mongo/db/field_parser.h
index 92a3df37e39..2b8da3eaa0a 100644
--- a/src/mongo/db/field_parser.h
+++ b/src/mongo/db/field_parser.h
@@ -30,7 +30,6 @@
#include <string>
-#include "mongo/bson/bson_field.h"
#include "mongo/db/jsobj.h"
#include "mongo/s/bson_serializable.h"
#include "mongo/util/time_support.h"
@@ -107,13 +106,13 @@ namespace mongo {
std::string* errMsg = NULL );
static FieldState extract( BSONObj doc,
- const BSONField<OpTime>& field,
- OpTime* out,
+ const BSONField<Timestamp>& field,
+ Timestamp* out,
std::string* errMsg = NULL );
static FieldState extract( BSONElement elem,
- const BSONField<OpTime>& field,
- OpTime* out,
+ const BSONField<Timestamp>& field,
+ Timestamp* out,
std::string* errMsg = NULL );
static FieldState extract( BSONObj doc,
diff --git a/src/mongo/db/field_parser_test.cpp b/src/mongo/db/field_parser_test.cpp
index 9e3f974c915..902b6548e64 100644
--- a/src/mongo/db/field_parser_test.cpp
+++ b/src/mongo/db/field_parser_test.cpp
@@ -30,7 +30,6 @@
#include <vector>
#include <map>
-#include "mongo/bson/bson_field.h"
#include "mongo/db/field_parser.h"
#include "mongo/db/jsobj.h"
#include "mongo/unittest/unittest.h"
diff --git a/src/mongo/db/global_optime.cpp b/src/mongo/db/global_timestamp.cpp
index 664838a179c..f6cf646ba7e 100644
--- a/src/mongo/db/global_optime.cpp
+++ b/src/mongo/db/global_timestamp.cpp
@@ -28,15 +28,17 @@
#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault
-#include "mongo/db/global_optime.h"
+#include <boost/thread.hpp>
+
+#include "mongo/db/global_timestamp.h"
#include "mongo/util/concurrency/mutex.h"
#include "mongo/util/log.h"
namespace {
- mongo::mutex globalOptimeMutex;
- mongo::OpTime globalOpTime(0, 0);
+ mongo::mutex globalTimestampMutex;
+ mongo::Timestamp globalTimestamp(0, 0);
- bool skewed(const mongo::OpTime& val) {
+ bool skewed(const mongo::Timestamp& val) {
if (val.getInc() & 0x80000000) {
mongo::warning() << "clock skew detected prev: " << val.getSecs()
<< " now: " << (unsigned) time(0) << std::endl;
@@ -48,33 +50,33 @@ namespace {
}
namespace mongo {
- void setGlobalOptime(const OpTime& newTime) {
- boost::lock_guard<boost::mutex> lk(globalOptimeMutex);
- globalOpTime = newTime;
+ void setGlobalTimestamp(const Timestamp& newTime) {
+ boost::lock_guard<boost::mutex> lk(globalTimestampMutex);
+ globalTimestamp = newTime;
}
- OpTime getLastSetOptime() {
- boost::lock_guard<boost::mutex> lk(globalOptimeMutex);
- return globalOpTime;
+ Timestamp getLastSetTimestamp() {
+ boost::lock_guard<boost::mutex> lk(globalTimestampMutex);
+ return globalTimestamp;
}
- OpTime getNextGlobalOptime() {
- boost::lock_guard<boost::mutex> lk(globalOptimeMutex);
+ Timestamp getNextGlobalTimestamp() {
+ boost::lock_guard<boost::mutex> lk(globalTimestampMutex);
const unsigned now = (unsigned) time(0);
- const unsigned globalSecs = globalOpTime.getSecs();
+ const unsigned globalSecs = globalTimestamp.getSecs();
if ( globalSecs == now ) {
- globalOpTime = OpTime(globalSecs, globalOpTime.getInc() + 1);
+ globalTimestamp = Timestamp(globalSecs, globalTimestamp.getInc() + 1);
}
else if ( now < globalSecs ) {
- globalOpTime = OpTime(globalSecs, globalOpTime.getInc() + 1);
+ globalTimestamp = Timestamp(globalSecs, globalTimestamp.getInc() + 1);
// separate function to keep out of the hot code path
- fassert(17449, !skewed(globalOpTime));
+ fassert(17449, !skewed(globalTimestamp));
}
else {
- globalOpTime = OpTime(now, 1);
+ globalTimestamp = Timestamp(now, 1);
}
- return globalOpTime;
+ return globalTimestamp;
}
}
diff --git a/src/mongo/db/global_optime.h b/src/mongo/db/global_timestamp.h
index acb6e2d0ae6..d39a5364fd5 100644
--- a/src/mongo/db/global_optime.h
+++ b/src/mongo/db/global_timestamp.h
@@ -28,18 +28,18 @@
#pragma once
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
namespace mongo {
- void setGlobalOptime(const OpTime& newTime);
+ void setGlobalTimestamp(const Timestamp& newTime);
/**
- * Returns the value of the global OpTime generated last time or set.
+ * Returns the value of the global Timestamp generated last time or set.
*/
- OpTime getLastSetOptime();
+ Timestamp getLastSetTimestamp();
/**
- * Generates a new and unique OpTime.
+ * Generates a new and unique Timestamp.
*/
- OpTime getNextGlobalOptime();
+ Timestamp getNextGlobalTimestamp();
}
diff --git a/src/mongo/db/hasher_test.cpp b/src/mongo/db/hasher_test.cpp
index 1d52e8815b0..02351127c48 100644
--- a/src/mongo/db/hasher_test.cpp
+++ b/src/mongo/db/hasher_test.cpp
@@ -345,7 +345,7 @@ namespace {
BSONObj o = BSON( "check" << Date_t( 0x5566778811223344LL ) );
ASSERT_EQUALS( hashIt( o ), 4476222765095560467LL );
- o = builder1.append( "check", OpTime(0x55667788LL, 0x11223344LL) ).obj();
+ o = builder1.append( "check", Timestamp(0x55667788LL, 0x11223344LL) ).obj();
ASSERT_EQUALS( hashIt( o ), 4873046866288452390LL );
o = BSON( "check" << Date_t( 0 ) );
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 1c49b54c3a1..0595cf83ede 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -59,7 +59,7 @@
#include "mongo/db/exec/delete.h"
#include "mongo/db/exec/update.h"
#include "mongo/db/service_context.h"
-#include "mongo/db/global_optime.h"
+#include "mongo/db/global_timestamp.h"
#include "mongo/db/instance.h"
#include "mongo/db/introspect.h"
#include "mongo/db/json.h"
@@ -828,7 +828,7 @@ namespace {
int pass = 0;
bool exhaust = false;
QueryResult::View msgdata = 0;
- OpTime last;
+ Timestamp last;
while( 1 ) {
bool isCursorAuthorized = false;
try {
@@ -846,10 +846,10 @@ namespace {
}
if (pass == 0) {
- last = getLastSetOptime();
+ last = getLastSetTimestamp();
}
else {
- repl::waitUpToOneSecondForOptimeChange(last);
+ repl::waitUpToOneSecondForTimestampChange(last);
}
}
diff --git a/src/mongo/db/jsobj.h b/src/mongo/db/jsobj.h
index 83bb1d80879..6a4e962b683 100644
--- a/src/mongo/db/jsobj.h
+++ b/src/mongo/db/jsobj.h
@@ -43,7 +43,7 @@
#include "mongo/platform/basic.h"
#include "mongo/bson/util/builder.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/bson/bsontypes.h"
#include "mongo/bson/oid.h"
#include "mongo/bson/bsonelement.h"
@@ -52,5 +52,4 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/bson/ordering.h"
#include "mongo/base/string_data.h"
-#include "mongo/bson/bson_db.h"
diff --git a/src/mongo/db/json.cpp b/src/mongo/db/json.cpp
index 6369ddfe50a..8fca4e77190 100644
--- a/src/mongo/db/json.cpp
+++ b/src/mongo/db/json.cpp
@@ -555,7 +555,7 @@ namespace mongo {
if (!readToken(RBRACE)) {
return parseError("Expecting '}'");
}
- builder.append(fieldName, OpTime(seconds, count));
+ builder.append(fieldName, Timestamp(seconds, count));
return Status::OK();
}
@@ -815,7 +815,7 @@ namespace mongo {
if (!readToken(RPAREN)) {
return parseError("Expecting ')'");
}
- builder.append(fieldName, OpTime(seconds, count));
+ builder.append(fieldName, Timestamp(seconds, count));
return Status::OK();
}
diff --git a/src/mongo/db/lasterror.h b/src/mongo/db/lasterror.h
index 60cd9c1eae2..778a1653bb3 100644
--- a/src/mongo/db/lasterror.h
+++ b/src/mongo/db/lasterror.h
@@ -43,6 +43,7 @@ namespace mongo {
static const char kUpsertedFieldName[] = "upserted";
static const char kGLEStatsFieldName[] = "$gleStats";
static const char kGLEStatsLastOpTimeFieldName[] = "lastOpTime";
+ static const char kGLEStatsLastOpTimeTermFieldName[] = "lastOpTimeTerm";
static const char kGLEStatsElectionIdFieldName[] = "electionId";
struct LastError {
diff --git a/src/mongo/db/ops/SConscript b/src/mongo/db/ops/SConscript
index f16faacf6e1..5c0018803a5 100644
--- a/src/mongo/db/ops/SConscript
+++ b/src/mongo/db/ops/SConscript
@@ -69,7 +69,7 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/expressions',
- '$BUILD_DIR/mongo/global_optime',
+ '$BUILD_DIR/mongo/global_timestamp',
'update_common',
],
)
diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp
index f410962b5b3..715895830da 100644
--- a/src/mongo/db/ops/insert.cpp
+++ b/src/mongo/db/ops/insert.cpp
@@ -29,7 +29,7 @@
*/
#include "mongo/db/ops/insert.h"
-#include "mongo/db/global_optime.h"
+#include "mongo/db/global_timestamp.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
@@ -53,7 +53,7 @@ namespace mongo {
while ( i.more() ) {
BSONElement e = i.next();
- if ( e.type() == Timestamp && e.timestampValue() == 0 ) {
+ if ( e.type() == bsonTimestamp && e.timestampValue() == 0 ) {
// we replace Timestamp(0,0) at the top level with a correct value
// in the fast pass, we just mark that we want to swap
hasTimestampToFix = true;
@@ -122,8 +122,8 @@ namespace mongo {
if ( hadId && e.fieldNameStringData() == "_id" ) {
// no-op
}
- else if ( e.type() == Timestamp && e.timestampValue() == 0 ) {
- b.append( e.fieldName(), getNextGlobalOptime() );
+ else if ( e.type() == bsonTimestamp && e.timestampValue() == 0 ) {
+ b.append( e.fieldName(), getNextGlobalTimestamp() );
}
else {
b.append( e );
diff --git a/src/mongo/db/ops/modifier_current_date.cpp b/src/mongo/db/ops/modifier_current_date.cpp
index aa683a5404f..f38cc4e4441 100644
--- a/src/mongo/db/ops/modifier_current_date.cpp
+++ b/src/mongo/db/ops/modifier_current_date.cpp
@@ -30,7 +30,7 @@
#include "mongo/base/error_codes.h"
#include "mongo/bson/mutable/document.h"
-#include "mongo/db/global_optime.h"
+#include "mongo/db/global_timestamp.h"
#include "mongo/db/ops/field_checker.h"
#include "mongo/db/ops/log_builder.h"
#include "mongo/db/ops/path_support.h"
@@ -210,7 +210,7 @@ namespace mongo {
elemToSet = _typeIsDate ?
doc.makeElementDate(lastPart, Date_t()) :
- doc.makeElementTimestamp(lastPart, OpTime());
+ doc.makeElementTimestamp(lastPart, Timestamp());
if (!elemToSet.ok()) {
return Status(ErrorCodes::InternalError, "can't create new element");
@@ -246,7 +246,7 @@ namespace mongo {
return s;
}
else {
- Status s = elemToSet.setValueTimestamp(getNextGlobalOptime());
+ Status s = elemToSet.setValueTimestamp(getNextGlobalTimestamp());
if (!s.isOK())
return s;
}
diff --git a/src/mongo/db/ops/modifier_current_date_test.cpp b/src/mongo/db/ops/modifier_current_date_test.cpp
index 512c857bc1b..51eb4a79659 100644
--- a/src/mongo/db/ops/modifier_current_date_test.cpp
+++ b/src/mongo/db/ops/modifier_current_date_test.cpp
@@ -43,7 +43,7 @@ namespace {
using mongo::LogBuilder;
using mongo::ModifierCurrentDate;
using mongo::ModifierInterface;
- using mongo::OpTime;
+ using mongo::Timestamp;
using mongo::Status;
using mongo::StringData;
using mongo::fromjson;
@@ -220,7 +220,7 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_EQUALS("a", execInfo.fieldRef[0]->dottedField());
- mongo::OpTime ts;
+ mongo::Timestamp ts;
BSONObj olderDateObj = BSON("a" << ts);
ASSERT_OK(mod.apply());
ASSERT_FALSE(doc.isInPlaceModeEnabled());
@@ -305,7 +305,7 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_EQUALS("a", execInfo.fieldRef[0]->dottedField());
- mongo::OpTime ts;
+ mongo::Timestamp ts;
BSONObj olderDateObj = BSON("a" << ts);
ASSERT_OK(mod.apply());
ASSERT_TRUE(doc.isInPlaceModeEnabled()); //Same Size as Date
@@ -327,7 +327,7 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_EQUALS("a.b", execInfo.fieldRef[0]->dottedField());
- mongo::OpTime ts;
+ mongo::Timestamp ts;
BSONObj olderDateObj = BSON("a" << BSON( "b" << ts));
ASSERT_OK(mod.apply());
ASSERT_TRUE(doc.isInPlaceModeEnabled()); //Same Size as Date
@@ -349,7 +349,7 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_EQUALS("a.b", execInfo.fieldRef[0]->dottedField());
- mongo::OpTime ts;
+ mongo::Timestamp ts;
BSONObj olderDateObj = BSON("a" << BSON( "b" << ts));
ASSERT_OK(mod.apply());
ASSERT_FALSE(doc.isInPlaceModeEnabled());
diff --git a/src/mongo/db/ops/modifier_object_replace.cpp b/src/mongo/db/ops/modifier_object_replace.cpp
index dc714b52105..5ebbb4bd342 100644
--- a/src/mongo/db/ops/modifier_object_replace.cpp
+++ b/src/mongo/db/ops/modifier_object_replace.cpp
@@ -30,7 +30,7 @@
#include "mongo/base/error_codes.h"
#include "mongo/bson/mutable/document.h"
-#include "mongo/db/global_optime.h"
+#include "mongo/db/global_timestamp.h"
#include "mongo/db/ops/log_builder.h"
#include "mongo/util/mongoutils/str.h"
@@ -47,14 +47,15 @@ namespace mongo {
BSONElement e = i.next();
// Skip _id field -- we do not replace it
- if (e.type() == Timestamp && e.fieldNameStringData() != idFieldName) {
- // performance note, this locks a mutex:
+ if (e.type() == bsonTimestamp && e.fieldNameStringData() != idFieldName) {
+ // TODO(emilkie): This is not endian-safe.
unsigned long long &timestamp =
*(reinterpret_cast<unsigned long long*>(
const_cast<char *>(e.value())));
if (timestamp == 0) {
- OpTime ts(getNextGlobalOptime());
- timestamp = ts.asDate();
+ // performance note, this locks a mutex:
+ Timestamp ts(getNextGlobalTimestamp());
+ timestamp = ts.asULL();
}
}
}
diff --git a/src/mongo/db/ops/modifier_object_replace_test.cpp b/src/mongo/db/ops/modifier_object_replace_test.cpp
index 77946d11e05..3a5de50fead 100644
--- a/src/mongo/db/ops/modifier_object_replace_test.cpp
+++ b/src/mongo/db/ops/modifier_object_replace_test.cpp
@@ -34,7 +34,7 @@
#include "mongo/bson/mutable/algorithm.h"
#include "mongo/bson/mutable/document.h"
#include "mongo/bson/mutable/mutable_bson_test_utils.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
#include "mongo/db/ops/log_builder.h"
diff --git a/src/mongo/db/pipeline/document_value_test.cpp b/src/mongo/db/pipeline/document_value_test.cpp
index 28e63419242..0deb17f7341 100644
--- a/src/mongo/db/pipeline/document_value_test.cpp
+++ b/src/mongo/db/pipeline/document_value_test.cpp
@@ -375,7 +375,7 @@ namespace DocumentTests {
append("codeWScope", BSONCodeWScope("asdf", BSONObj()));
append("codeWScopeWScope", BSONCodeWScope("asdf", BSON("one" << 1)));
append("int", 1);
- append("timestamp", OpTime());
+ append("timestamp", Timestamp());
append("long", 1LL);
append("very long", 1LL << 40);
append("maxkey", MAXKEY);
@@ -533,12 +533,12 @@ namespace DocumentTests {
};
/** Timestamp type. */
- class Timestamp {
+ class JSTimestamp {
public:
void run() {
- Value value = Value( OpTime( 777 ) );
- ASSERT( OpTime( 777 ) == value.getTimestamp() );
- ASSERT_EQUALS( mongo::Timestamp, value.getType() );
+ Value value = Value( Timestamp( 777 ) );
+ ASSERT( Timestamp( 777 ) == value.getTimestamp() );
+ ASSERT_EQUALS( mongo::bsonTimestamp, value.getType() );
assertRoundTrips( value );
}
};
@@ -1024,7 +1024,7 @@ namespace DocumentTests {
*/
class TimestampToDate : public ToDateBase {
Value value() {
- return Value( OpTime( 777, 666 ) );
+ return Value( Timestamp( 777, 666 ) );
}
long long expected() { return 777 * 1000; }
};
@@ -1076,9 +1076,9 @@ namespace DocumentTests {
/** Coerce timestamp to string. */
class TimestampToString : public ToStringBase {
Value value() {
- return Value( OpTime( 1, 2 ) );
+ return Value( Timestamp( 1, 2 ) );
}
- string expected() { return OpTime( 1, 2 ).toStringPretty(); }
+ string expected() { return Timestamp( 1, 2 ).toStringPretty(); }
};
/** Coerce date to string. */
@@ -1111,8 +1111,8 @@ namespace DocumentTests {
class TimestampToTimestamp {
public:
void run() {
- Value value = Value( OpTime( 1010 ) );
- ASSERT( OpTime( 1010 ) == value.coerceToTimestamp() );
+ Value value = Value( Timestamp( 1010 ) );
+ ASSERT( Timestamp( 1010 ) == value.coerceToTimestamp() );
}
};
@@ -1272,8 +1272,8 @@ namespace DocumentTests {
assertComparison( -1, fromjson( "{'':/a/}" ), fromjson( "{'':/aa/}" ) );
// Timestamp.
- assertComparison( 0, OpTime( 1234 ), OpTime( 1234 ) );
- assertComparison( -1, OpTime( 4 ), OpTime( 1234 ) );
+ assertComparison( 0, Timestamp( 1234 ), Timestamp( 1234 ) );
+ assertComparison( -1, Timestamp( 4 ), Timestamp( 1234 ) );
// Cross-type comparisons. Listed in order of canonical types.
assertComparison(-1, Value(mongo::MINKEY), Value());
@@ -1291,8 +1291,8 @@ namespace DocumentTests {
assertComparison(-1, Value(BSONBinData("", 0, MD5Type)), Value(mongo::OID()));
assertComparison(-1, Value(mongo::OID()), Value(false));
assertComparison(-1, Value(false), Value(Date_t(0)));
- assertComparison(-1, Value(Date_t(0)), Value(OpTime()));
- assertComparison(-1, Value(OpTime()), Value(BSONRegEx("")));
+ assertComparison(-1, Value(Date_t(0)), Value(Timestamp()));
+ assertComparison(-1, Value(Timestamp()), Value(BSONRegEx("")));
assertComparison(-1, Value(BSONRegEx("")), Value(BSONDBRef("", mongo::OID())));
assertComparison(-1, Value(BSONDBRef("", mongo::OID())), Value(BSONCode("")));
assertComparison(-1, Value(BSONCode("")), Value(BSONCodeWScope("", BSONObj())));
@@ -1303,11 +1303,11 @@ namespace DocumentTests {
void assertComparison( int expectedResult, const T& a, const U& b ) {
assertComparison( expectedResult, BSON( "" << a ), BSON( "" << b ) );
}
- void assertComparison( int expectedResult, const OpTime& a, const OpTime& b ) {
+ void assertComparison( int expectedResult, const Timestamp& a, const Timestamp& b ) {
BSONObjBuilder first;
- first.appendTimestamp( "", a.asDate() );
+ first.append( "", a );
BSONObjBuilder second;
- second.appendTimestamp( "", b.asDate() );
+ second.append( "", b );
assertComparison( expectedResult, first.obj(), second.obj() );
}
int sign(int cmp) {
@@ -1433,7 +1433,7 @@ namespace DocumentTests {
add<Value::String>();
add<Value::StringWithNull>();
add<Value::Date>();
- add<Value::Timestamp>();
+ add<Value::JSTimestamp>();
add<Value::EmptyDocument>();
add<Value::EmptyArray>();
add<Value::Array>();
diff --git a/src/mongo/db/pipeline/value.cpp b/src/mongo/db/pipeline/value.cpp
index f96e8c0aeca..8ef22166e84 100644
--- a/src/mongo/db/pipeline/value.cpp
+++ b/src/mongo/db/pipeline/value.cpp
@@ -56,7 +56,7 @@ namespace mongo {
case MaxKey:
case jstOID:
case Date:
- case Timestamp:
+ case bsonTimestamp:
case EOO:
case jstNULL:
case Undefined:
@@ -199,8 +199,8 @@ namespace mongo {
_storage.intValue = elem.numberInt();
break;
- case Timestamp:
- _storage.timestampValue = elem._opTime().asDate();
+ case bsonTimestamp:
+ _storage.timestampValue = elem.timestamp().asULL();
break;
case NumberLong:
@@ -289,7 +289,7 @@ namespace mongo {
case String: return builder << val.getStringData();
case Bool: return builder << val.getBool();
case Date: return builder << Date_t(val.getDate());
- case Timestamp: return builder << val.getTimestamp();
+ case bsonTimestamp: return builder << val.getTimestamp();
case Object: return builder << val.getDocument();
case Symbol: return builder << BSONSymbol(val.getStringData());
case Code: return builder << BSONCode(val.getStringData());
@@ -347,7 +347,7 @@ namespace mongo {
case Date:
case RegEx:
case Symbol:
- case Timestamp:
+ case bsonTimestamp:
return true;
case EOO:
@@ -425,7 +425,7 @@ namespace mongo {
case Date:
return getDate();
- case Timestamp:
+ case bsonTimestamp:
return getTimestamp().getSecs() * 1000LL;
default:
@@ -502,7 +502,7 @@ namespace mongo {
case String:
return getStringData().toString();
- case Timestamp:
+ case bsonTimestamp:
return getTimestamp().toStringPretty();
case Date:
@@ -521,9 +521,9 @@ namespace mongo {
} // switch(getType())
}
- OpTime Value::coerceToTimestamp() const {
+ Timestamp Value::coerceToTimestamp() const {
switch(getType()) {
- case Timestamp:
+ case bsonTimestamp:
return getTimestamp();
default:
@@ -578,7 +578,7 @@ namespace mongo {
case Bool:
return rL.getBool() - rR.getBool();
- case Timestamp: // unsigned
+ case bsonTimestamp: // unsigned
return cmp(rL._storage.timestampValue, rR._storage.timestampValue);
case Date: // signed
@@ -705,7 +705,7 @@ namespace mongo {
boost::hash_combine(seed, getBool());
break;
- case Timestamp:
+ case bsonTimestamp:
case Date:
BOOST_STATIC_ASSERT(sizeof(_storage.dateValue) == sizeof(_storage.timestampValue));
boost::hash_combine(seed, _storage.dateValue);
@@ -864,7 +864,7 @@ namespace mongo {
case Bool:
case Date:
case NumberInt:
- case Timestamp:
+ case bsonTimestamp:
case NumberLong:
case jstNULL:
case Undefined:
@@ -897,7 +897,7 @@ namespace mongo {
case jstNULL: return out << "null";
case Undefined: return out << "undefined";
case Date: return out << tmToISODateString(val.coerceToTm());
- case Timestamp: return out << val.getTimestamp().toString();
+ case bsonTimestamp: return out << val.getTimestamp().toString();
case Object: return out << val.getDocument().toString();
case Array: {
out << "[";
@@ -948,7 +948,7 @@ namespace mongo {
case NumberDouble: buf.appendNum(_storage.doubleValue); break;
case Bool: buf.appendChar(_storage.boolValue); break;
case Date: buf.appendNum(_storage.dateValue); break;
- case Timestamp: buf.appendStruct(getTimestamp()); break;
+ case bsonTimestamp: buf.appendStruct(getTimestamp()); break;
// types that are like strings
case String:
@@ -1019,7 +1019,7 @@ namespace mongo {
case NumberDouble: return Value(buf.read<double>());
case Bool: return Value(bool(buf.read<char>()));
case Date: return Value(Date_t(buf.read<long long>()));
- case Timestamp: return Value(buf.read<OpTime>());
+ case bsonTimestamp: return Value(buf.read<Timestamp>());
// types that are like strings
case String:
diff --git a/src/mongo/db/pipeline/value.h b/src/mongo/db/pipeline/value.h
index dc10ea3246e..4e30c30564d 100644
--- a/src/mongo/db/pipeline/value.h
+++ b/src/mongo/db/pipeline/value.h
@@ -72,7 +72,7 @@ namespace mongo {
explicit Value(int value) : _storage(NumberInt, value) {}
explicit Value(long long value) : _storage(NumberLong, value) {}
explicit Value(double value) : _storage(NumberDouble, value) {}
- explicit Value(const OpTime& value) : _storage(Timestamp, value) {}
+ explicit Value(const Timestamp& value) : _storage(bsonTimestamp, value) {}
explicit Value(const OID& value) : _storage(jstOID, value) {}
explicit Value(StringData value) : _storage(String, value) {}
explicit Value(const std::string& value) : _storage(String, StringData(value)) {}
@@ -150,7 +150,7 @@ namespace mongo {
OID getOid() const;
bool getBool() const;
long long getDate() const; // in milliseconds
- OpTime getTimestamp() const;
+ Timestamp getTimestamp() const;
const char* getRegex() const;
const char* getRegexFlags() const;
std::string getSymbol() const;
@@ -189,7 +189,7 @@ namespace mongo {
int coerceToInt() const;
long long coerceToLong() const;
double coerceToDouble() const;
- OpTime coerceToTimestamp() const;
+ Timestamp coerceToTimestamp() const;
long long coerceToDate() const;
time_t coerceToTimeT() const;
tm coerceToTm() const; // broken-out time struct (see man gmtime)
@@ -326,8 +326,8 @@ namespace mongo {
return _storage.dateValue;
}
- inline OpTime Value::getTimestamp() const {
- verify(getType() == Timestamp);
+ inline Timestamp Value::getTimestamp() const {
+ verify(getType() == bsonTimestamp);
return Date_t(_storage.timestampValue);
}
diff --git a/src/mongo/db/pipeline/value_internal.h b/src/mongo/db/pipeline/value_internal.h
index 910728019ce..834c2e7d1d6 100644
--- a/src/mongo/db/pipeline/value_internal.h
+++ b/src/mongo/db/pipeline/value_internal.h
@@ -37,7 +37,7 @@
#include "mongo/bson/oid.h"
#include "mongo/util/debug_util.h"
#include "mongo/util/intrusive_counter.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
namespace mongo {
@@ -81,7 +81,7 @@ namespace mongo {
ValueStorage(BSONType t, int i) { zero(); type = t; intValue = i; }
ValueStorage(BSONType t, long long l) { zero(); type = t; longValue = l; }
ValueStorage(BSONType t, double d) { zero(); type = t; doubleValue = d; }
- ValueStorage(BSONType t, OpTime r) { zero(); type = t; timestampValue = r.asDate(); }
+ ValueStorage(BSONType t, Timestamp r) { zero(); type = t; timestampValue = r.asULL(); }
ValueStorage(BSONType t, bool b) { zero(); type = t; boolValue = b; }
ValueStorage(BSONType t, const Document& d) { zero(); type = t; putDocument(d); }
ValueStorage(BSONType t, const RCVector* a) { zero(); type = t; putVector(a); }
diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp
index fb6218fc800..a6a13db1fc8 100644
--- a/src/mongo/db/query/find.cpp
+++ b/src/mongo/db/query/find.cpp
@@ -377,7 +377,7 @@ namespace mongo {
}
// If we're replaying the oplog, we save the last time that we read.
- OpTime slaveReadTill;
+ Timestamp slaveReadTill;
// What number result are we starting at? Used to fill out the reply.
startingResult = cc->pos();
@@ -401,8 +401,8 @@ namespace mongo {
// Possibly note slave's position in the oplog.
if (queryOptions & QueryOption_OplogReplay) {
BSONElement e = obj["ts"];
- if (Date == e.type() || Timestamp == e.type()) {
- slaveReadTill = e._opTime();
+ if (Date == e.type() || bsonTimestamp == e.type()) {
+ slaveReadTill = e.timestamp();
}
}
@@ -615,7 +615,7 @@ namespace mongo {
int numResults = 0;
// If we're replaying the oplog, we save the last time that we read.
- OpTime slaveReadTill;
+ Timestamp slaveReadTill;
BSONObj obj;
PlanExecutor::ExecState state;
@@ -634,8 +634,8 @@ namespace mongo {
// Possibly note slave's position in the oplog.
if (pq.isOplogReplay()) {
BSONElement e = obj["ts"];
- if (Date == e.type() || Timestamp == e.type()) {
- slaveReadTill = e._opTime();
+ if (Date == e.type() || bsonTimestamp == e.type()) {
+ slaveReadTill = e.timestamp();
}
}
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index 6e3af1c474b..202be486a68 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -556,8 +556,8 @@ namespace {
// See if the RecordStore supports the oplogStartHack
const BSONElement tsElem = extractOplogTsOptime(tsExpr);
- if (tsElem.type() == Timestamp) {
- StatusWith<RecordId> goal = oploghack::keyForOptime(tsElem._opTime());
+ if (tsElem.type() == bsonTimestamp) {
+ StatusWith<RecordId> goal = oploghack::keyForOptime(tsElem.timestamp());
if (goal.isOK()) {
startLoc = collection->getRecordStore()->oplogStartHack(txn, goal.getValue());
}
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index e8d797785de..725740ec022 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -90,7 +90,7 @@ env.Library('repl_coordinator_impl',
'$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/db/index/index_descriptor',
'$BUILD_DIR/mongo/fail_point',
- '$BUILD_DIR/mongo/global_optime',
+ '$BUILD_DIR/mongo/global_timestamp',
'$BUILD_DIR/mongo/server_options_core',
'$BUILD_DIR/mongo/service_context',
'$BUILD_DIR/mongo/util/net/command_status',
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp
index ad2833df368..7cdd1d42a2a 100644
--- a/src/mongo/db/repl/bgsync.cpp
+++ b/src/mongo/db/repl/bgsync.cpp
@@ -228,7 +228,7 @@ namespace {
// find a target to sync from the last optime fetched
- OpTime lastOpTimeFetched;
+ Timestamp lastOpTimeFetched;
{
boost::unique_lock<boost::mutex> lock(_mutex);
lastOpTimeFetched = _lastOpTimeFetched;
@@ -354,7 +354,7 @@ namespace {
{
boost::unique_lock<boost::mutex> lock(_mutex);
_lastFetchedHash = o["h"].numberLong();
- _lastOpTimeFetched = o["ts"]._opTime();
+ _lastOpTimeFetched = o["ts"].timestamp();
LOG(3) << "lastOpTimeFetched: " << _lastOpTimeFetched.toStringPretty();
}
}
@@ -402,7 +402,7 @@ namespace {
sleepsecs(2);
return true;
}
- OpTime theirTS = theirLastOp["ts"]._opTime();
+ Timestamp theirTS = theirLastOp["ts"].timestamp();
if (theirTS < _lastOpTimeFetched) {
log() << "we are ahead of the sync source, will try to roll back";
syncRollback(txn, _replCoord->getMyLastOptime(), &r, _replCoord);
@@ -420,7 +420,7 @@ namespace {
}
BSONObj o = r.nextSafe();
- OpTime ts = o["ts"]._opTime();
+ Timestamp ts = o["ts"].timestamp();
long long hash = o["h"].numberLong();
if( ts != _lastOpTimeFetched || hash != _lastFetchedHash ) {
log() << "our last op time fetched: " << _lastOpTimeFetched.toStringPretty();
@@ -447,7 +447,7 @@ namespace {
_pause = true;
_syncSourceHost = HostAndPort();
- _lastOpTimeFetched = OpTime(0,0);
+ _lastOpTimeFetched = Timestamp(0,0);
_lastFetchedHash = 0;
_appliedBufferCondition.notify_all();
_pausedCondition.notify_all();
diff --git a/src/mongo/db/repl/bgsync.h b/src/mongo/db/repl/bgsync.h
index 8a36e572abe..7537e0e8606 100644
--- a/src/mongo/db/repl/bgsync.h
+++ b/src/mongo/db/repl/bgsync.h
@@ -131,7 +131,7 @@ namespace repl {
// _mutex protects all of the class variables except _syncSourceReader and _buffer
mutable boost::mutex _mutex;
- OpTime _lastOpTimeFetched;
+ Timestamp _lastOpTimeFetched;
// lastAppliedHash is used to generate a new hash for the following op, when primary.
long long _lastAppliedHash;
diff --git a/src/mongo/db/repl/freshness_checker.cpp b/src/mongo/db/repl/freshness_checker.cpp
index 3f533e28f6e..ebe3d59b67b 100644
--- a/src/mongo/db/repl/freshness_checker.cpp
+++ b/src/mongo/db/repl/freshness_checker.cpp
@@ -33,7 +33,7 @@
#include "mongo/db/repl/freshness_checker.h"
#include "mongo/base/status.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/repl/member_heartbeat_data.h"
#include "mongo/db/repl/replica_set_config.h"
#include "mongo/db/repl/replication_executor.h"
@@ -47,7 +47,7 @@ namespace mongo {
namespace repl {
FreshnessChecker::Algorithm::Algorithm(
- OpTime lastOpTimeApplied,
+ Timestamp lastOpTimeApplied,
const ReplicaSetConfig& rsConfig,
int selfIndex,
const std::vector<HostAndPort>& targets) :
@@ -88,7 +88,7 @@ namespace repl {
BSONObjBuilder freshCmdBuilder;
freshCmdBuilder.append("replSetFresh", 1);
freshCmdBuilder.append("set", _rsConfig.getReplSetName());
- freshCmdBuilder.append("opTime", Date_t(_lastOpTimeApplied.asDate()));
+ freshCmdBuilder.append("opTime", Date_t(_lastOpTimeApplied.asULL()));
freshCmdBuilder.append("who", selfConfig.getHostAndPort().toString());
freshCmdBuilder.appendIntOrLL("cfgver", _rsConfig.getConfigVersion());
freshCmdBuilder.append("id", selfConfig.getId());
@@ -169,7 +169,7 @@ namespace repl {
_abortReason = FresherNodeFound;
return;
}
- OpTime remoteTime(res["opTime"].date());
+ Timestamp remoteTime(res["opTime"].date());
if (remoteTime == _lastOpTimeApplied) {
_abortReason = FreshnessTie;
}
@@ -216,7 +216,7 @@ namespace repl {
StatusWith<ReplicationExecutor::EventHandle> FreshnessChecker::start(
ReplicationExecutor* executor,
- const OpTime& lastOpTimeApplied,
+ const Timestamp& lastOpTimeApplied,
const ReplicaSetConfig& currentConfig,
int selfIndex,
const std::vector<HostAndPort>& targets,
diff --git a/src/mongo/db/repl/freshness_checker.h b/src/mongo/db/repl/freshness_checker.h
index 71f82cb86d3..3570ee8b051 100644
--- a/src/mongo/db/repl/freshness_checker.h
+++ b/src/mongo/db/repl/freshness_checker.h
@@ -32,7 +32,7 @@
#include <vector>
#include "mongo/base/disallow_copying.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/repl/replica_set_config.h"
#include "mongo/db/repl/replication_executor.h"
#include "mongo/db/repl/scatter_gather_algorithm.h"
@@ -59,7 +59,7 @@ namespace repl {
class Algorithm : public ScatterGatherAlgorithm {
public:
- Algorithm(OpTime lastOpTimeApplied,
+ Algorithm(Timestamp lastOpTimeApplied,
const ReplicaSetConfig& rsConfig,
int selfIndex,
const std::vector<HostAndPort>& targets);
@@ -84,8 +84,8 @@ namespace repl {
// Number of failed voter responses so far.
int _failedVoterResponses;
- // Last OpTime applied by the caller; used in the Fresh command
- const OpTime _lastOpTimeApplied;
+ // Last Timestamp applied by the caller; used in the Fresh command
+ const Timestamp _lastOpTimeApplied;
// Config to use for this check
const ReplicaSetConfig _rsConfig;
@@ -124,7 +124,7 @@ namespace repl {
**/
StatusWith<ReplicationExecutor::EventHandle> start(
ReplicationExecutor* executor,
- const OpTime& lastOpTimeApplied,
+ const Timestamp& lastOpTimeApplied,
const ReplicaSetConfig& currentConfig,
int selfIndex,
const std::vector<HostAndPort>& targets,
diff --git a/src/mongo/db/repl/freshness_checker_test.cpp b/src/mongo/db/repl/freshness_checker_test.cpp
index 362b4746606..2a7480e8d56 100644
--- a/src/mongo/db/repl/freshness_checker_test.cpp
+++ b/src/mongo/db/repl/freshness_checker_test.cpp
@@ -59,7 +59,7 @@ namespace {
class FreshnessCheckerTest : public mongo::unittest::Test {
protected:
- void startTest(const OpTime& lastOpTimeApplied,
+ void startTest(const Timestamp& lastOpTimeApplied,
const ReplicaSetConfig& currentConfig,
int selfIndex,
const std::vector<HostAndPort>& hosts);
@@ -80,7 +80,7 @@ namespace {
private:
void freshnessCheckerRunner(const ReplicationExecutor::CallbackData& data,
- const OpTime& lastOpTimeApplied,
+ const Timestamp& lastOpTimeApplied,
const ReplicaSetConfig& currentConfig,
int selfIndex,
const std::vector<HostAndPort>& hosts);
@@ -120,12 +120,12 @@ namespace {
}
const BSONObj makeFreshRequest(const ReplicaSetConfig& rsConfig,
- OpTime lastOpTimeApplied,
+ Timestamp lastOpTimeApplied,
int selfIndex) {
const MemberConfig& myConfig = rsConfig.getMemberAt(selfIndex);
return BSON("replSetFresh" << 1 <<
"set" << rsConfig.getReplSetName() <<
- "opTime" << Date_t(lastOpTimeApplied.asDate()) <<
+ "opTime" << Date_t(lastOpTimeApplied.asULL()) <<
"who" << myConfig.getHostAndPort().toString() <<
"cfgver" << rsConfig.getConfigVersion() <<
"id" << myConfig.getId());
@@ -135,7 +135,7 @@ namespace {
// for correct concurrency operation.
void FreshnessCheckerTest::freshnessCheckerRunner(
const ReplicationExecutor::CallbackData& data,
- const OpTime& lastOpTimeApplied,
+ const Timestamp& lastOpTimeApplied,
const ReplicaSetConfig& currentConfig,
int selfIndex,
const std::vector<HostAndPort>& hosts) {
@@ -149,7 +149,7 @@ namespace {
_checkerDoneEvent = assertGet(evh);
}
- void FreshnessCheckerTest::startTest(const OpTime& lastOpTimeApplied,
+ void FreshnessCheckerTest::startTest(const Timestamp& lastOpTimeApplied,
const ReplicaSetConfig& currentConfig,
int selfIndex,
const std::vector<HostAndPort>& hosts) {
@@ -176,9 +176,9 @@ namespace {
std::vector<HostAndPort> hosts;
hosts.push_back(config.getMemberAt(1).getHostAndPort());
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(0,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(0,0), 0);
- startTest(OpTime(0, 0), config, 0, hosts);
+ startTest(Timestamp(0, 0), config, 0, hosts);
const Date_t startDate = _net->now();
_net->enterNetwork();
for (size_t i = 0; i < hosts.size(); ++i) {
@@ -195,7 +195,7 @@ namespace {
"set" << "rs0" <<
"who" << "h1" <<
"cfgver" << 1 <<
- "opTime" << Date_t(OpTime(0,0).asDate())),
+ "opTime" << Date_t(Timestamp(0,0).asULL())),
Milliseconds(8))));
}
_net->runUntil(startDate + 10);
@@ -218,7 +218,7 @@ namespace {
hosts.push_back(config.getMemberAt(1).getHostAndPort());
startTest(
- OpTime(0, 0),
+ Timestamp(0, 0),
config,
0,
hosts);
@@ -244,9 +244,9 @@ namespace {
std::vector<HostAndPort> hosts;
hosts.push_back(config.getMemberAt(1).getHostAndPort());
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(10,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(10,0), 0);
- startTest(OpTime(10, 0), config, 0, hosts);
+ startTest(Timestamp(10, 0), config, 0, hosts);
const Date_t startDate = _net->now();
_net->enterNetwork();
for (size_t i = 0; i < hosts.size(); ++i) {
@@ -264,7 +264,7 @@ namespace {
"who" << "h1" <<
"cfgver" << 1 <<
"fresher" << true <<
- "opTime" << Date_t(OpTime(0,0).asDate())),
+ "opTime" << Date_t(Timestamp(0,0).asULL())),
Milliseconds(8))));
}
_net->runUntil(startDate + 10);
@@ -290,9 +290,9 @@ namespace {
std::vector<HostAndPort> hosts;
hosts.push_back(config.getMemberAt(1).getHostAndPort());
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(0,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(0,0), 0);
- startTest(OpTime(0, 0), config, 0, hosts);
+ startTest(Timestamp(0, 0), config, 0, hosts);
const Date_t startDate = _net->now();
_net->enterNetwork();
for (size_t i = 0; i < hosts.size(); ++i) {
@@ -309,7 +309,7 @@ namespace {
"set" << "rs0" <<
"who" << "h1" <<
"cfgver" << 1 <<
- "opTime" << Date_t(OpTime(10,0).asDate())),
+ "opTime" << Date_t(Timestamp(10,0).asULL())),
Milliseconds(8))));
}
_net->runUntil(startDate + 10);
@@ -334,9 +334,9 @@ namespace {
std::vector<HostAndPort> hosts;
hosts.push_back(config.getMemberAt(1).getHostAndPort());
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(10,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(10,0), 0);
- startTest(OpTime(10, 0), config, 0, hosts);
+ startTest(Timestamp(10, 0), config, 0, hosts);
const Date_t startDate = _net->now();
_net->enterNetwork();
for (size_t i = 0; i < hosts.size(); ++i) {
@@ -381,9 +381,9 @@ namespace {
std::vector<HostAndPort> hosts;
hosts.push_back(config.getMemberAt(1).getHostAndPort());
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(10,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(10,0), 0);
- startTest(OpTime(10, 0), config, 0, hosts);
+ startTest(Timestamp(10, 0), config, 0, hosts);
const Date_t startDate = _net->now();
_net->enterNetwork();
for (size_t i = 0; i < hosts.size(); ++i) {
@@ -402,7 +402,7 @@ namespace {
"cfgver" << 1 <<
"veto" << true <<
"errmsg" << "I'd rather you didn't" <<
- "opTime" << Date_t(OpTime(0,0).asDate())),
+ "opTime" << Date_t(Timestamp(0,0).asULL())),
Milliseconds(8))));
}
_net->runUntil(startDate + 10);
@@ -443,9 +443,9 @@ namespace {
hosts.push_back(mem->getHostAndPort());
}
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(10,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(10,0), 0);
- startTest(OpTime(10, 0), config, 0, hosts);
+ startTest(Timestamp(10, 0), config, 0, hosts);
const Date_t startDate = _net->now();
unordered_set<HostAndPort> seen;
_net->enterNetwork();
@@ -462,7 +462,7 @@ namespace {
"set" << "rs0" <<
"who" << target.toString() <<
"cfgver" << 1 <<
- "opTime" << Date_t(OpTime(0,0).asDate());
+ "opTime" << Date_t(Timestamp(0,0).asULL());
if (target.host() == "h1") {
responseBuilder << "fresher" << true;
}
@@ -505,9 +505,9 @@ namespace {
hosts.push_back(mem->getHostAndPort());
}
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(10,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(10,0), 0);
- startTest(OpTime(10, 0), config, 0, hosts);
+ startTest(Timestamp(10, 0), config, 0, hosts);
const Date_t startDate = _net->now();
unordered_set<HostAndPort> seen;
_net->enterNetwork();
@@ -526,7 +526,7 @@ namespace {
"set" << "rs0" <<
"who" << target.toString() <<
"cfgver" << 1 <<
- "opTime" << Date_t(OpTime(20,0).asDate());
+ "opTime" << Date_t(Timestamp(20,0).asULL());
_net->scheduleResponse(
noi,
startDate + 20,
@@ -541,7 +541,7 @@ namespace {
"set" << "rs0" <<
"who" << target.toString() <<
"cfgver" << 1 <<
- "opTime" << Date_t(OpTime(10,0).asDate());
+ "opTime" << Date_t(Timestamp(10,0).asULL());
_net->scheduleResponse(
noi,
startDate + 10,
@@ -581,9 +581,9 @@ namespace {
hosts.push_back(mem->getHostAndPort());
}
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(10,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(10,0), 0);
- startTest(OpTime(10, 0), config, 0, hosts);
+ startTest(Timestamp(10, 0), config, 0, hosts);
const Date_t startDate = _net->now();
unordered_set<HostAndPort> seen;
_net->enterNetwork();
@@ -604,7 +604,7 @@ namespace {
responseBuilder << "opTime" << 3;
}
else {
- responseBuilder << "opTime" << Date_t(OpTime(0,0).asDate());
+ responseBuilder << "opTime" << Date_t(Timestamp(0,0).asULL());
}
_net->scheduleResponse(
noi,
@@ -643,9 +643,9 @@ namespace {
hosts.push_back(mem->getHostAndPort());
}
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(10,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(10,0), 0);
- startTest(OpTime(10, 0), config, 0, hosts);
+ startTest(Timestamp(10, 0), config, 0, hosts);
const Date_t startDate = _net->now();
unordered_set<HostAndPort> seen;
_net->enterNetwork();
@@ -662,7 +662,7 @@ namespace {
"set" << "rs0" <<
"who" << target.toString() <<
"cfgver" << 1 <<
- "opTime" << Date_t(OpTime(0,0).asDate());
+ "opTime" << Date_t(Timestamp(0,0).asULL());
if (target.host() == "h1") {
responseBuilder << "veto" << true << "errmsg" << "I'd rather you didn't";
}
@@ -706,9 +706,9 @@ namespace {
hosts.push_back(mem->getHostAndPort());
}
- const BSONObj freshRequest = makeFreshRequest(config, OpTime(10,0), 0);
+ const BSONObj freshRequest = makeFreshRequest(config, Timestamp(10,0), 0);
- startTest(OpTime(10, 0), config, 0, hosts);
+ startTest(Timestamp(10, 0), config, 0, hosts);
const Date_t startDate = _net->now();
unordered_set<HostAndPort> seen;
_net->enterNetwork();
@@ -729,7 +729,7 @@ namespace {
"cfgver" << 1 <<
"veto" << true <<
"errmsg" << "I'd rather you didn't" <<
- "opTime" << Date_t(OpTime(10,0).asDate());
+ "opTime" << Date_t(Timestamp(10,0).asULL());
_net->scheduleResponse(
noi,
startDate + 20,
@@ -744,7 +744,7 @@ namespace {
"set" << "rs0" <<
"who" << target.toString() <<
"cfgver" << 1 <<
- "opTime" << Date_t(OpTime(10,0).asDate());
+ "opTime" << Date_t(Timestamp(10,0).asULL());
_net->scheduleResponse(
noi,
startDate + 10,
@@ -785,10 +785,10 @@ namespace {
hosts.push_back(mem->getHostAndPort());
}
- const OpTime lastOpTimeApplied(10,0);
+ const Timestamp lastOpTimeApplied(10,0);
const BSONObj freshRequest = makeFreshRequest(config, lastOpTimeApplied, 0);
- startTest(OpTime(10, 0), config, 0, hosts);
+ startTest(Timestamp(10, 0), config, 0, hosts);
const Date_t startDate = _net->now();
unordered_set<HostAndPort> seen;
_net->enterNetwork();
@@ -812,7 +812,7 @@ namespace {
"set" << "rs0" <<
"who" << target.toString() <<
"cfgver" << 1 <<
- "opTime" << Date_t(OpTime(0,0).asDate());
+ "opTime" << Date_t(Timestamp(0,0).asULL());
_net->scheduleResponse(
noi,
startDate + 10,
@@ -832,7 +832,7 @@ namespace {
public:
virtual void setUp() {
int selfConfigIndex = 0;
- OpTime lastOpTimeApplied(100, 0);
+ Timestamp lastOpTimeApplied(100, 0);
ReplicaSetConfig config;
config.initialize(BSON("_id" << "rs0" <<
@@ -876,14 +876,14 @@ namespace {
ResponseStatus lessFresh() {
BSONObjBuilder bb;
bb.append("ok", 1.0);
- bb.appendDate("opTime", OpTime(10, 0).asDate());
+ bb.appendDate("opTime", Timestamp(10, 0).asULL());
return ResponseStatus(NetworkInterfaceMock::Response(bb.obj(), Milliseconds(10)));
}
ResponseStatus moreFreshViaOpTime() {
BSONObjBuilder bb;
bb.append("ok", 1.0);
- bb.appendDate("opTime", OpTime(110, 0).asDate());
+ bb.appendDate("opTime", Timestamp(110, 0).asULL());
return ResponseStatus(NetworkInterfaceMock::Response(bb.obj(), Milliseconds(10)));
}
@@ -905,7 +905,7 @@ namespace {
ResponseStatus tiedForFreshness() {
BSONObjBuilder bb;
bb.append("ok", 1.0);
- bb.appendDate("opTime", OpTime(100, 0).asDate());
+ bb.appendDate("opTime", Timestamp(100, 0).asULL());
return ResponseStatus(NetworkInterfaceMock::Response(bb.obj(), Milliseconds(10)));
}
diff --git a/src/mongo/db/repl/initial_sync.cpp b/src/mongo/db/repl/initial_sync.cpp
index 494094862ba..2af2810db29 100644
--- a/src/mongo/db/repl/initial_sync.cpp
+++ b/src/mongo/db/repl/initial_sync.cpp
@@ -48,7 +48,7 @@ namespace repl {
/* initial oplog application, during initial sync, after cloning.
*/
- void InitialSync::oplogApplication(OperationContext* txn, const OpTime& endOpTime) {
+ void InitialSync::oplogApplication(OperationContext* txn, const Timestamp& endOpTime) {
if (replSetForceInitialSyncFailure > 0) {
log() << "test code invoked, forced InitialSync failure: "
<< replSetForceInitialSyncFailure;
diff --git a/src/mongo/db/repl/initial_sync.h b/src/mongo/db/repl/initial_sync.h
index 69e99524b3e..593cefa3acf 100644
--- a/src/mongo/db/repl/initial_sync.h
+++ b/src/mongo/db/repl/initial_sync.h
@@ -46,7 +46,7 @@ namespace repl {
/**
* applies up to endOpTime, fetching missing documents as needed.
*/
- void oplogApplication(OperationContext* txn, const OpTime& endOpTime);
+ void oplogApplication(OperationContext* txn, const Timestamp& endOpTime);
};
// Used for ReplSetTest testing.
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index b0ab3cb5037..2165b91da3d 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -119,8 +119,9 @@ namespace repl {
uassert( 10119 , "only source='main' allowed for now with replication", sourceName() == "main" );
BSONElement e = o.getField("syncedTo");
if ( !e.eoo() ) {
- uassert( 10120 , "bad sources 'syncedTo' field value", e.type() == Date || e.type() == Timestamp );
- OpTime tmp( e.date() );
+ uassert(10120, "bad sources 'syncedTo' field value",
+ e.type() == Date || e.type() == bsonTimestamp);
+ Timestamp tmp( e.date() );
syncedTo = tmp;
}
@@ -156,7 +157,7 @@ namespace repl {
if ( !only.empty() )
b.append("only", only);
if ( !syncedTo.isNull() )
- b.appendTimestamp("syncedTo", syncedTo.asDate());
+ b.append("syncedTo", syncedTo);
BSONObjBuilder dbsNextPassBuilder;
int n = 0;
@@ -453,7 +454,7 @@ namespace repl {
}
}
}
- syncedTo = OpTime();
+ syncedTo = Timestamp();
addDbNextPass.clear();
save(txn);
}
@@ -512,13 +513,13 @@ namespace repl {
static DatabaseIgnorer ___databaseIgnorer;
- void DatabaseIgnorer::doIgnoreUntilAfter( const string &db, const OpTime &futureOplogTime ) {
+ void DatabaseIgnorer::doIgnoreUntilAfter( const string &db, const Timestamp &futureOplogTime ) {
if ( futureOplogTime > _ignores[ db ] ) {
_ignores[ db ] = futureOplogTime;
}
}
- bool DatabaseIgnorer::ignoreAt( const string &db, const OpTime &currentOplogTime ) {
+ bool DatabaseIgnorer::ignoreAt( const string &db, const Timestamp &currentOplogTime ) {
if ( _ignores[ db ].isNull() ) {
return false;
}
@@ -541,7 +542,7 @@ namespace repl {
return true;
}
BSONElement ts = op.getField( "ts" );
- if ( ( ts.type() == Date || ts.type() == Timestamp ) && ___databaseIgnorer.ignoreAt( db, ts.date() ) ) {
+ if ( ( ts.type() == Date || ts.type() == bsonTimestamp ) && ___databaseIgnorer.ignoreAt( db, ts.date() ) ) {
// Database is ignored due to a previous indication that it is
// missing from master after optime "ts".
return false;
@@ -551,7 +552,7 @@ namespace repl {
return true;
}
- OpTime lastTime;
+ Timestamp lastTime;
bool dbOk = false;
{
// This is always a GlobalWrite lock (so no ns/db used from the context)
@@ -564,9 +565,10 @@ namespace repl {
BSONObj last = oplogReader.findOne( this->ns().c_str(), Query().sort( BSON( "$natural" << -1 ) ) );
if ( !last.isEmpty() ) {
- BSONElement ts = last.getField( "ts" );
- massert( 14032, "Invalid 'ts' in remote log", ts.type() == Date || ts.type() == Timestamp );
- lastTime = OpTime( ts.date() );
+ BSONElement ts = last.getField( "ts" );
+ massert(14032, "Invalid 'ts' in remote log",
+ ts.type() == Date || ts.type() == bsonTimestamp);
+ lastTime = Timestamp( ts.date() );
}
BSONObj info;
@@ -782,8 +784,9 @@ namespace repl {
BSONObj last = oplogReader.findOne( _ns.c_str(), Query( b.done() ).sort( BSON( "$natural" << -1 ) ) );
if ( !last.isEmpty() ) {
BSONElement ts = last.getField( "ts" );
- massert( 10386 , "non Date ts found: " + last.toString(), ts.type() == Date || ts.type() == Timestamp );
- syncedTo = OpTime( ts.date() );
+ massert(10386, "non Date ts found: " + last.toString(),
+ ts.type() == Date || ts.type() == bsonTimestamp);
+ syncedTo = Timestamp( ts.date() );
}
}
@@ -878,7 +881,7 @@ namespace repl {
}
BSONObjBuilder gte;
- gte.appendTimestamp("$gte", syncedTo.asDate());
+ gte.append("$gte", syncedTo);
BSONObjBuilder query;
query.append("ts", gte.done());
if ( !only.empty() ) {
@@ -931,11 +934,11 @@ namespace repl {
return okResultCode;
}
- OpTime nextOpTime;
+ Timestamp nextOpTime;
{
BSONObj op = oplogReader.next();
BSONElement ts = op.getField("ts");
- if ( ts.type() != Date && ts.type() != Timestamp ) {
+ if ( ts.type() != Date && ts.type() != bsonTimestamp ) {
string err = op.getStringField("$err");
if ( !err.empty() ) {
// 13051 is "tailable cursor requested on non capped collection"
@@ -954,7 +957,7 @@ namespace repl {
}
}
- nextOpTime = OpTime( ts.date() );
+ nextOpTime = Timestamp( ts.date() );
LOG(2) << "first op time received: " << nextOpTime.toString() << '\n';
if ( initial ) {
LOG(1) << "initial run\n";
@@ -967,7 +970,7 @@ namespace repl {
verify(false);
}
oplogReader.putBack( op ); // op will be processed in the loop below
- nextOpTime = OpTime(); // will reread the op below
+ nextOpTime = Timestamp(); // will reread the op below
}
else if ( nextOpTime != syncedTo ) { // didn't get what we queried for - error
log()
@@ -1033,15 +1036,15 @@ namespace repl {
while( 1 ) {
BSONElement ts = op.getField("ts");
- if( !( ts.type() == Date || ts.type() == Timestamp ) ) {
+ if( !( ts.type() == Date || ts.type() == bsonTimestamp ) ) {
log() << "sync error: problem querying remote oplog record" << endl;
log() << "op: " << op.toString() << endl;
log() << "halting replication" << endl;
replInfo = replAllDead = "sync error: no ts found querying remote oplog record";
throw SyncException();
}
- OpTime last = nextOpTime;
- nextOpTime = OpTime( ts.date() );
+ Timestamp last = nextOpTime;
+ nextOpTime = Timestamp( ts.date() );
if ( !( last < nextOpTime ) ) {
log() << "sync error: last applied optime at slave >= nextOpTime from master" << endl;
log() << " last: " << last.toStringLong() << endl;
diff --git a/src/mongo/db/repl/master_slave.h b/src/mongo/db/repl/master_slave.h
index 117e26d08a1..4a05efd48b9 100644
--- a/src/mongo/db/repl/master_slave.h
+++ b/src/mongo/db/repl/master_slave.h
@@ -135,7 +135,7 @@ namespace repl {
std::string only; // only a certain db. note that in the sources collection, this may not be changed once you start replicating.
/* the last time point we have already synced up to (in the remote/master's oplog). */
- OpTime syncedTo;
+ Timestamp syncedTo;
int nClonedThisPass;
@@ -176,19 +176,19 @@ namespace repl {
/**
* Helper class used to set and query an ignore state for a named database.
- * The ignore state will expire after a specified OpTime.
+ * The ignore state will expire after a specified Timestamp.
*/
class DatabaseIgnorer {
public:
/** Indicate that operations for 'db' should be ignored until after 'futureOplogTime' */
- void doIgnoreUntilAfter( const std::string &db, const OpTime &futureOplogTime );
+ void doIgnoreUntilAfter( const std::string &db, const Timestamp &futureOplogTime );
/**
* Query ignore state of 'db'; if 'currentOplogTime' is after the ignore
* limit, the ignore state will be cleared.
*/
- bool ignoreAt( const std::string &db, const OpTime &currentOplogTime );
+ bool ignoreAt( const std::string &db, const Timestamp &currentOplogTime );
private:
- std::map< std::string, OpTime > _ignores;
+ std::map< std::string, Timestamp > _ignores;
};
} // namespace repl
diff --git a/src/mongo/db/repl/member_heartbeat_data.cpp b/src/mongo/db/repl/member_heartbeat_data.cpp
index 8ca22c40649..5ae8f1fbffc 100644
--- a/src/mongo/db/repl/member_heartbeat_data.cpp
+++ b/src/mongo/db/repl/member_heartbeat_data.cpp
@@ -47,8 +47,8 @@ namespace repl {
_authIssue(false) {
_lastResponse.setState(MemberState::RS_UNKNOWN);
- _lastResponse.setElectionTime(OpTime());
- _lastResponse.setOpTime(OpTime());
+ _lastResponse.setElectionTime(Timestamp());
+ _lastResponse.setOpTime(Timestamp());
}
void MemberHeartbeatData::setUpValues(Date_t now,
@@ -88,8 +88,8 @@ namespace repl {
_lastResponse = ReplSetHeartbeatResponse();
_lastResponse.setState(MemberState::RS_DOWN);
- _lastResponse.setElectionTime(OpTime());
- _lastResponse.setOpTime(OpTime());
+ _lastResponse.setElectionTime(Timestamp());
+ _lastResponse.setOpTime(Timestamp());
_lastResponse.setHbMsg(heartbeatMessage);
_lastResponse.setSyncingTo("");
}
@@ -102,8 +102,8 @@ namespace repl {
_lastResponse = ReplSetHeartbeatResponse();
_lastResponse.setState(MemberState::RS_UNKNOWN);
- _lastResponse.setElectionTime(OpTime());
- _lastResponse.setOpTime(OpTime());
+ _lastResponse.setElectionTime(Timestamp());
+ _lastResponse.setOpTime(Timestamp());
_lastResponse.setHbMsg("");
_lastResponse.setSyncingTo("");
}
diff --git a/src/mongo/db/repl/member_heartbeat_data.h b/src/mongo/db/repl/member_heartbeat_data.h
index 624c572d33f..b54c3e539d8 100644
--- a/src/mongo/db/repl/member_heartbeat_data.h
+++ b/src/mongo/db/repl/member_heartbeat_data.h
@@ -28,7 +28,7 @@
#pragma once
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/repl/member_state.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
#include "mongo/util/time_support.h"
@@ -54,11 +54,11 @@ namespace repl {
}
const std::string& getLastHeartbeatMsg() const { return _lastResponse.getHbMsg(); }
const std::string& getSyncSource() const { return _lastResponse.getSyncingTo(); }
- OpTime getOpTime() const { return _lastResponse.getOpTime(); }
+ Timestamp getOpTime() const { return _lastResponse.getOpTime(); }
int getConfigVersion() const { return _lastResponse.getVersion(); }
bool hasAuthIssue() const { return _authIssue; }
- OpTime getElectionTime() const { return _lastResponse.getElectionTime(); }
+ Timestamp getElectionTime() const { return _lastResponse.getElectionTime(); }
// Returns true if the last heartbeat data explicilty stated that the node
// is not electable.
diff --git a/src/mongo/db/repl/minvalid.cpp b/src/mongo/db/repl/minvalid.cpp
index 5553747147a..c648dcd5fa7 100644
--- a/src/mongo/db/repl/minvalid.cpp
+++ b/src/mongo/db/repl/minvalid.cpp
@@ -32,7 +32,7 @@
#include "mongo/db/repl/minvalid.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/jsobj.h"
@@ -63,7 +63,7 @@ namespace {
Helpers::putSingleton(txn, minvalidNS, BSON("$set" << initialSyncFlag));
}
- void setMinValid(OperationContext* ctx, OpTime ts) {
+ void setMinValid(OperationContext* ctx, Timestamp ts) {
ScopedTransaction transaction(ctx, MODE_IX);
Lock::DBLock dblk(ctx->lockState(), "local", MODE_X);
Helpers::putSingleton(ctx, minvalidNS, BSON("$set" << BSON("ts" << ts)));
@@ -84,16 +84,16 @@ namespace {
return false;
}
- OpTime getMinValid(OperationContext* txn) {
+ Timestamp getMinValid(OperationContext* txn) {
ScopedTransaction transaction(txn, MODE_IS);
Lock::DBLock dblk(txn->lockState(), "local", MODE_IS);
Lock::CollectionLock lk(txn->lockState(), minvalidNS, MODE_IS);
BSONObj mv;
bool found = Helpers::getSingleton(txn, minvalidNS, mv);
if (found) {
- return mv["ts"]._opTime();
+ return mv["ts"].timestamp();
}
- return OpTime();
+ return Timestamp();
}
}
diff --git a/src/mongo/db/repl/minvalid.h b/src/mongo/db/repl/minvalid.h
index 7bbe7c39c69..853c96b6c27 100644
--- a/src/mongo/db/repl/minvalid.h
+++ b/src/mongo/db/repl/minvalid.h
@@ -31,7 +31,7 @@
namespace mongo {
class BSONObj;
class OperationContext;
- class OpTime;
+ class Timestamp;
namespace repl {
@@ -57,11 +57,11 @@ namespace repl {
bool getInitialSyncFlag();
/**
- * The minValid optime value is the earliest (minimum) OpTime that must be applied in order to
+ * The minValid value is the earliest (minimum) Timestamp that must be applied in order to
* consider the dataset consistent. Do not allow client reads if our last applied operation is
* before the minValid time.
*/
- void setMinValid(OperationContext* ctx, OpTime ts);
- OpTime getMinValid(OperationContext* txn);
+ void setMinValid(OperationContext* ctx, Timestamp ts);
+ Timestamp getMinValid(OperationContext* txn);
}
}
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index ae387139c9a..7c90e58c8a5 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -52,7 +52,7 @@
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/service_context.h"
-#include "mongo/db/global_optime.h"
+#include "mongo/db/global_timestamp.h"
#include "mongo/db/index_builder.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/op_observer.h"
@@ -91,7 +91,7 @@ namespace {
Database* _localDB = nullptr;
Collection* _localOplogCollection = nullptr;
- // Synchronizes the section where a new OpTime is generated and when it actually
+ // Synchronizes the section where a new Timestamp is generated and when it actually
// appears in the oplog.
mongo::mutex newOpMutex;
boost::condition newOptimeNotifier;
@@ -115,13 +115,13 @@ namespace {
* function registers the new optime with the storage system and the replication coordinator,
* and provides no facility to revert those registrations on rollback.
*/
- std::pair<OpTime, long long> getNextOpTime(OperationContext* txn,
+ std::pair<Timestamp, long long> getNextOpTime(OperationContext* txn,
Collection* oplog,
const char* ns,
ReplicationCoordinator* replCoord,
const char* opstr) {
boost::lock_guard<boost::mutex> lk(newOpMutex);
- OpTime ts = getNextGlobalOptime();
+ Timestamp ts = getNextGlobalTimestamp();
newOptimeNotifier.notify_all();
fassert(28560, oplog->getRecordStore()->oplogDiskLocRegister(txn, ts));
@@ -151,7 +151,7 @@ namespace {
}
replCoord->setMyLastOptime(ts);
- return std::pair<OpTime,long long>(ts, hashNew);
+ return std::pair<Timestamp,long long>(ts, hashNew);
}
/**
@@ -259,7 +259,7 @@ namespace {
_localOplogCollection);
}
- std::pair<OpTime, long long> slot = getNextOpTime(txn,
+ std::pair<Timestamp, long long> slot = getNextOpTime(txn,
_localOplogCollection,
ns,
replCoord,
@@ -270,7 +270,7 @@ namespace {
*/
BSONObjBuilder b(256);
- b.appendTimestamp("ts", slot.first.asDate());
+ b.append("ts", slot.first);
b.append("h", slot.second);
b.append("v", OPLOG_VERSION);
b.append("op", opstr);
@@ -296,9 +296,9 @@ namespace {
ReplClientInfo::forClient(txn->getClient()).setLastOp( slot.first );
}
- OpTime writeOpsToOplog(OperationContext* txn, const std::deque<BSONObj>& ops) {
+ Timestamp writeOpsToOplog(OperationContext* txn, const std::deque<BSONObj>& ops) {
ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator();
- OpTime lastOptime = replCoord->getMyLastOptime();
+ Timestamp lastOptime = replCoord->getMyLastOptime();
invariant(!ops.empty());
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
@@ -323,7 +323,7 @@ namespace {
it != ops.end();
++it) {
const BSONObj& op = *it;
- const OpTime ts = op["ts"]._opTime();
+ const Timestamp ts = op["ts"].timestamp();
checkOplogInsert(_localOplogCollection->insertDocument(txn, op, false));
@@ -669,19 +669,19 @@ namespace {
return Status::OK();
}
- void waitUpToOneSecondForOptimeChange(const OpTime& referenceTime) {
+ void waitUpToOneSecondForTimestampChange(const Timestamp& referenceTime) {
boost::unique_lock<boost::mutex> lk(newOpMutex);
- while (referenceTime == getLastSetOptime()) {
+ while (referenceTime == getLastSetTimestamp()) {
if (!newOptimeNotifier.timed_wait(lk,
boost::posix_time::seconds(1)))
return;
}
}
- void setNewOptime(const OpTime& newTime) {
+ void setNewOptime(const Timestamp& newTime) {
boost::lock_guard<boost::mutex> lk(newOpMutex);
- setGlobalOptime(newTime);
+ setGlobalTimestamp(newTime);
newOptimeNotifier.notify_all();
}
diff --git a/src/mongo/db/repl/oplog.h b/src/mongo/db/repl/oplog.h
index 49e9175f0d9..f587ae074df 100644
--- a/src/mongo/db/repl/oplog.h
+++ b/src/mongo/db/repl/oplog.h
@@ -43,7 +43,7 @@ namespace mongo {
class Database;
class NamespaceString;
class OperationContext;
- class OpTime;
+ class Timestamp;
class RecordId;
namespace repl {
@@ -58,7 +58,7 @@ namespace repl {
// used internally by replication secondaries after they have applied ops. Updates the global
// optime.
// Returns the optime for the last op inserted.
- OpTime writeOpsToOplog(OperationContext* txn,
+ Timestamp writeOpsToOplog(OperationContext* txn,
const std::deque<BSONObj>& ops);
extern std::string rsOplogName;
@@ -104,9 +104,9 @@ namespace repl {
bool convertUpdateToUpsert = false);
/**
- * Waits one second for the OpTime from the oplog to change.
+ * Waits one second for the Timestamp from the oplog to change.
*/
- void waitUpToOneSecondForOptimeChange(const OpTime& referenceTime);
+ void waitUpToOneSecondForTimestampChange(const Timestamp& referenceTime);
/**
* Initializes the global OpTime with the value from the timestamp of the last oplog entry.
@@ -116,7 +116,7 @@ namespace repl {
/**
* Sets the global OpTime to be 'newTime'.
*/
- void setNewOptime(const OpTime& newTime);
+ void setNewOptime(const Timestamp& newTime);
/**
* Detects the current replication mode and sets the "_oplogCollectionName" accordingly.
diff --git a/src/mongo/db/repl/oplogreader.cpp b/src/mongo/db/repl/oplogreader.cpp
index 9746d975fda..0301cbb0311 100644
--- a/src/mongo/db/repl/oplogreader.cpp
+++ b/src/mongo/db/repl/oplogreader.cpp
@@ -130,9 +130,9 @@ namespace repl {
cursor.reset( _conn->query( ns, query, 0, 0, fields, _tailingQueryOptions ).release() );
}
- void OplogReader::tailingQueryGTE(const char *ns, OpTime optime, const BSONObj* fields ) {
+ void OplogReader::tailingQueryGTE(const char *ns, Timestamp optime, const BSONObj* fields ) {
BSONObjBuilder gte;
- gte.appendTimestamp("$gte", optime.asDate());
+ gte.append("$gte", optime);
BSONObjBuilder query;
query.append("ts", gte.done());
tailingQuery(ns, query.done(), fields);
@@ -143,10 +143,10 @@ namespace repl {
}
void OplogReader::connectToSyncSource(OperationContext* txn,
- OpTime lastOpTimeFetched,
+ Timestamp lastOpTimeFetched,
ReplicationCoordinator* replCoord) {
- const OpTime sentinel(Milliseconds(curTimeMillis64()).total_seconds(), 0);
- OpTime oldestOpTimeSeen = sentinel;
+ const Timestamp sentinel(Milliseconds(curTimeMillis64()).total_seconds(), 0);
+ Timestamp oldestOpTimeSeen = sentinel;
invariant(conn() == NULL);
@@ -190,7 +190,7 @@ namespace repl {
// fetched op. Otherwise, we have fallen off the back of that source's oplog.
BSONObj remoteOldestOp(findOne(rsOplogName.c_str(), Query()));
BSONElement tsElem(remoteOldestOp["ts"]);
- if (tsElem.type() != Timestamp) {
+ if (tsElem.type() != bsonTimestamp) {
// This member's got a bad op in its oplog.
warning() << "oplog invalid format on node " << candidate.toString();
resetConnection();
@@ -198,7 +198,7 @@ namespace repl {
Date_t(curTimeMillis64() + 600*1000));
continue;
}
- OpTime remoteOldOpTime = tsElem._opTime();
+ Timestamp remoteOldOpTime = tsElem.timestamp();
if (lastOpTimeFetched < remoteOldOpTime) {
// We're too stale to use this sync source.
diff --git a/src/mongo/db/repl/oplogreader.h b/src/mongo/db/repl/oplogreader.h
index d8639ee8530..bf089450535 100644
--- a/src/mongo/db/repl/oplogreader.h
+++ b/src/mongo/db/repl/oplogreader.h
@@ -99,10 +99,10 @@ namespace repl {
void tailingQuery(const char *ns, const BSONObj& query, const BSONObj* fields=0);
- void tailingQueryGTE(const char *ns, OpTime t, const BSONObj* fields=0);
+ void tailingQueryGTE(const char *ns, Timestamp t, const BSONObj* fields=0);
/* Do a tailing query, but only send the ts field back. */
- void ghostQueryGTE(const char *ns, OpTime t) {
+ void ghostQueryGTE(const char *ns, Timestamp t) {
const BSONObj fields = BSON("ts" << 1 << "_id" << 0);
return tailingQueryGTE(ns, t, &fields);
}
@@ -146,7 +146,7 @@ namespace repl {
* This function may throw DB exceptions.
*/
void connectToSyncSource(OperationContext* txn,
- OpTime lastOpTimeFetched,
+ Timestamp lastOpTimeFetched,
ReplicationCoordinator* replCoord);
};
diff --git a/src/mongo/db/repl/optime.h b/src/mongo/db/repl/optime.h
new file mode 100644
index 00000000000..4ceee222475
--- /dev/null
+++ b/src/mongo/db/repl/optime.h
@@ -0,0 +1,83 @@
+/**
+* Copyright (C) 2015 MongoDB Inc.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License, version 3,
+* as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* As a special exception, the copyright holders give permission to link the
+* code of portions of this program with the OpenSSL library under certain
+* conditions as described in each individual source file and distribute
+* linked combinations including the program with the OpenSSL library. You
+* must comply with the GNU Affero General Public License in all respects for
+* all of the code used other than as permitted herein. If you modify file(s)
+* with this exception, you may extend this exception to your version of the
+* file(s), but you are not obligated to do so. If you do not wish to do so,
+* delete this exception statement from your version. If you delete this
+* exception statement from all source files in the program, then also delete
+* it in the license file.
+*/
+
+#pragma once
+
+#include <tuple>
+#include <utility>
+
+#include "mongo/bson/timestamp.h"
+
+namespace mongo {
+namespace repl {
+
+ class OpTime {
+ public:
+ OpTime() = default;
+ OpTime(Timestamp ts, long long term) : _timestamp(std::move(ts)), _term(term) {}
+
+ Timestamp getTimestamp() const {
+ return _timestamp;
+ }
+
+ long long getTerm() const {
+ return _term;
+ }
+
+ private:
+ Timestamp _timestamp;
+ long long _term = -1;
+ };
+
+ inline bool operator==(const OpTime& lhs, const OpTime& rhs) {
+ return std::tie(lhs.opTime, lhs.term) == std::tie(rhs.opTime, rhs.term);
+ }
+
+ inline bool operator<(const OpTime& lhs, const OpTime& rhs) {
+ // Compare term first, then the opTimes.
+ return std::tie(lhs.term, lhs.opTime) < std::tie(rhs.term, rhs.opTime);
+ }
+
+ inline bool operator!=(const OpTime& lhs, const OpTime& rhs) {
+ return !(lhs == rhs);
+ }
+
+ inline bool operator<=(const OpTime& lhs, const OpTime& rhs) {
+ return lhs < rhs || lhs == rhs;
+ }
+
+ inline bool operator>(const OpTime& lhs, const OpTime& rhs) {
+ return !(lhs <= rhs);
+ }
+
+ inline bool operator>=(const OpTime& lhs, const OpTime& rhs) {
+ return !(lhs < rhs);
+ }
+
+} // namespace repl
+} // namespace mongo
diff --git a/src/mongo/db/repl/repl_client_info.h b/src/mongo/db/repl/repl_client_info.h
index 3aa0c73b66f..d7a748f8641 100644
--- a/src/mongo/db/repl/repl_client_info.h
+++ b/src/mongo/db/repl/repl_client_info.h
@@ -29,7 +29,7 @@
#pragma once
#include "mongo/bson/oid.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/client.h"
namespace mongo {
@@ -43,15 +43,15 @@ namespace repl {
public:
static const Client::Decoration<ReplClientInfo> forClient;
- void setLastOp(OpTime op) { _lastOp = op; }
- OpTime getLastOp() const { return _lastOp; }
+ void setLastOp(Timestamp op) { _lastOp = op; }
+ Timestamp getLastOp() const { return _lastOp; }
// Only used for master/slave
void setRemoteID(OID rid) { _remoteId = rid; }
OID getRemoteID() const { return _remoteId; }
private:
- OpTime _lastOp = OpTime();
+ Timestamp _lastOp = Timestamp();
OID _remoteId = OID();
};
diff --git a/src/mongo/db/repl/repl_set_heartbeat_response.cpp b/src/mongo/db/repl/repl_set_heartbeat_response.cpp
index 4e968ef0175..8dac175ddf9 100644
--- a/src/mongo/db/repl/repl_set_heartbeat_response.cpp
+++ b/src/mongo/db/repl/repl_set_heartbeat_response.cpp
@@ -90,13 +90,13 @@ namespace {
builder->append(kOkFieldName, 1.0);
if (_opTimeSet) {
- builder->appendDate(kOpTimeFieldName, _opTime.asDate());
+ builder->appendDate(kOpTimeFieldName, _opTime.asULL());
}
if (_timeSet) {
*builder << kTimeFieldName << _time.total_seconds();
}
if (_electionTimeSet) {
- builder->appendDate(kElectionTimeFieldName, _electionTime.asDate());
+ builder->appendDate(kElectionTimeFieldName, _electionTime.asULL());
}
if (_configSet) {
*builder << kConfigFieldName << _config.toBSON();
@@ -178,13 +178,13 @@ namespace {
if (electionTimeElement.eoo()) {
_electionTimeSet = false;
}
- else if (electionTimeElement.type() == Timestamp) {
+ else if (electionTimeElement.type() == bsonTimestamp) {
_electionTimeSet = true;
- _electionTime = electionTimeElement._opTime();
+ _electionTime = electionTimeElement.timestamp();
}
else if (electionTimeElement.type() == Date) {
_electionTimeSet = true;
- _electionTime = OpTime(electionTimeElement.date());
+ _electionTime = Timestamp(electionTimeElement.date());
}
else {
return Status(ErrorCodes::TypeMismatch, str::stream() << "Expected \"" <<
@@ -212,13 +212,13 @@ namespace {
if (opTimeElement.eoo()) {
_opTimeSet = false;
}
- else if (opTimeElement.type() == Timestamp) {
+ else if (opTimeElement.type() == bsonTimestamp) {
_opTimeSet = true;
- _opTime = opTimeElement._opTime();
+ _opTime = opTimeElement.timestamp();
}
else if (opTimeElement.type() == Date) {
_opTimeSet = true;
- _opTime = OpTime(opTimeElement.date());
+ _opTime = Timestamp(opTimeElement.date());
}
else {
return Status(ErrorCodes::TypeMismatch, str::stream() << "Expected \"" <<
@@ -329,7 +329,7 @@ namespace {
return _state;
}
- OpTime ReplSetHeartbeatResponse::getElectionTime() const {
+ Timestamp ReplSetHeartbeatResponse::getElectionTime() const {
invariant(_electionTimeSet);
return _electionTime;
}
@@ -344,7 +344,7 @@ namespace {
return _time;
}
- OpTime ReplSetHeartbeatResponse::getOpTime() const {
+ Timestamp ReplSetHeartbeatResponse::getOpTime() const {
invariant(_opTimeSet);
return _opTime;
}
diff --git a/src/mongo/db/repl/repl_set_heartbeat_response.h b/src/mongo/db/repl/repl_set_heartbeat_response.h
index a5629fbc3bf..94692d7f27c 100644
--- a/src/mongo/db/repl/repl_set_heartbeat_response.h
+++ b/src/mongo/db/repl/repl_set_heartbeat_response.h
@@ -78,14 +78,14 @@ namespace repl {
bool hasState() const { return _stateSet; }
MemberState getState() const;
bool hasElectionTime() const { return _electionTimeSet; }
- OpTime getElectionTime() const;
+ Timestamp getElectionTime() const;
bool hasIsElectable() const { return _electableSet; }
bool isElectable() const;
const std::string& getHbMsg() const { return _hbmsg; }
bool hasTime() const { return _timeSet; }
Seconds getTime() const;
bool hasOpTime() const { return _opTimeSet; }
- OpTime getOpTime() const;
+ Timestamp getOpTime() const;
const std::string& getSyncingTo() const { return _syncingTo; }
int getVersion() const { return _version; }
bool hasConfig() const { return _configSet; }
@@ -122,9 +122,9 @@ namespace repl {
void setState(MemberState state) { _stateSet = true; _state = state; }
/**
- * Sets the optional "electionTime" field to the given OpTime.
+ * Sets the optional "electionTime" field to the given Timestamp.
*/
- void setElectionTime(OpTime time) { _electionTimeSet = true; _electionTime = time; }
+ void setElectionTime(Timestamp time) { _electionTimeSet = true; _electionTime = time; }
/**
* Sets _electable to "electable" and sets _electableSet to true to indicate
@@ -147,7 +147,7 @@ namespace repl {
* Sets _opTime to "time" and sets _opTimeSet to true to indicate that the value
* of _opTime has been modified.
*/
- void setOpTime(OpTime time) { _opTimeSet = true; _opTime = time; }
+ void setOpTime(Timestamp time) { _opTimeSet = true; _opTime = time; }
/**
* Sets _syncingTo to "syncingTo".
@@ -166,13 +166,13 @@ namespace repl {
private:
bool _electionTimeSet;
- OpTime _electionTime;
+ Timestamp _electionTime;
bool _timeSet;
Seconds _time; // Seconds since UNIX epoch.
bool _opTimeSet;
- OpTime _opTime;
+ Timestamp _opTime;
bool _electableSet;
bool _electable;
diff --git a/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp b/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
index 71003ab4fec..05e634fbc03 100644
--- a/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
+++ b/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
@@ -124,7 +124,7 @@ namespace {
ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON().toString());
// set electionTime
- hbResponse.setElectionTime(OpTime(10,0));
+ hbResponse.setElectionTime(Timestamp(10,0));
++fieldsSet;
ASSERT_EQUALS(false, hbResponse.hasState());
ASSERT_EQUALS(true, hbResponse.hasElectionTime());
@@ -139,14 +139,14 @@ namespace {
ASSERT_EQUALS("", hbResponse.getHbMsg());
ASSERT_EQUALS("", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
hbResponseObj = hbResponse.toBSON();
ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields());
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj);
ASSERT_EQUALS(Status::OK(), initializeResult);
@@ -168,16 +168,16 @@ namespace {
ASSERT_EQUALS("", hbResponse.getHbMsg());
ASSERT_EQUALS("", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
hbResponseObj = hbResponse.toBSON();
ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields());
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponseObj["opTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponseObj["opTime"].timestamp());
initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj);
ASSERT_EQUALS(Status::OK(), initializeResult);
@@ -199,8 +199,8 @@ namespace {
ASSERT_EQUALS("", hbResponse.getHbMsg());
ASSERT_EQUALS("", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
ASSERT_EQUALS(10, hbResponse.getTime().total_seconds());
hbResponseObj = hbResponse.toBSON();
@@ -208,8 +208,8 @@ namespace {
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponseObj["opTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponseObj["opTime"].timestamp());
ASSERT_EQUALS(10, hbResponseObj["time"].numberLong());
initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj);
@@ -232,8 +232,8 @@ namespace {
ASSERT_EQUALS("", hbResponse.getHbMsg());
ASSERT_EQUALS("", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
ASSERT_EQUALS(10, hbResponse.getTime().total_seconds());
ASSERT_EQUALS(true, hbResponse.isElectable());
@@ -242,8 +242,8 @@ namespace {
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponseObj["opTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponseObj["opTime"].timestamp());
ASSERT_EQUALS(10, hbResponseObj["time"].numberLong());
ASSERT_EQUALS(true, hbResponseObj["e"].trueValue());
@@ -268,8 +268,8 @@ namespace {
ASSERT_EQUALS("", hbResponse.getHbMsg());
ASSERT_EQUALS("", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
ASSERT_EQUALS(10, hbResponse.getTime().total_seconds());
ASSERT_EQUALS(true, hbResponse.isElectable());
ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString());
@@ -279,8 +279,8 @@ namespace {
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponseObj["opTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponseObj["opTime"].timestamp());
ASSERT_EQUALS(10, hbResponseObj["time"].numberLong());
ASSERT_EQUALS(true, hbResponseObj["e"].trueValue());
ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString());
@@ -307,8 +307,8 @@ namespace {
ASSERT_EQUALS("", hbResponse.getHbMsg());
ASSERT_EQUALS("", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
ASSERT_EQUALS(10, hbResponse.getTime().total_seconds());
ASSERT_EQUALS(true, hbResponse.isElectable());
ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString());
@@ -318,8 +318,8 @@ namespace {
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponseObj["opTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponseObj["opTime"].timestamp());
ASSERT_EQUALS(10, hbResponseObj["time"].numberLong());
ASSERT_EQUALS(true, hbResponseObj["e"].trueValue());
ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString());
@@ -347,8 +347,8 @@ namespace {
ASSERT_EQUALS("", hbResponse.getHbMsg());
ASSERT_EQUALS("", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
ASSERT_EQUALS(10, hbResponse.getTime().total_seconds());
ASSERT_EQUALS(true, hbResponse.isElectable());
ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString());
@@ -358,8 +358,8 @@ namespace {
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponseObj["opTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponseObj["opTime"].timestamp());
ASSERT_EQUALS(10, hbResponseObj["time"].numberLong());
ASSERT_EQUALS(true, hbResponseObj["e"].trueValue());
ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString());
@@ -389,8 +389,8 @@ namespace {
ASSERT_EQUALS("", hbResponse.getHbMsg());
ASSERT_EQUALS("", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
ASSERT_EQUALS(10, hbResponse.getTime().total_seconds());
ASSERT_EQUALS(true, hbResponse.isElectable());
ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString());
@@ -400,8 +400,8 @@ namespace {
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponseObj["opTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponseObj["opTime"].timestamp());
ASSERT_EQUALS(10, hbResponseObj["time"].numberLong());
ASSERT_EQUALS(true, hbResponseObj["e"].trueValue());
ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString());
@@ -432,8 +432,8 @@ namespace {
ASSERT_EQUALS("", hbResponse.getHbMsg());
ASSERT_EQUALS("syncTarget", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
ASSERT_EQUALS(10, hbResponse.getTime().total_seconds());
ASSERT_EQUALS(true, hbResponse.isElectable());
ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString());
@@ -443,8 +443,8 @@ namespace {
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponseObj["opTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponseObj["opTime"].timestamp());
ASSERT_EQUALS(10, hbResponseObj["time"].numberLong());
ASSERT_EQUALS(true, hbResponseObj["e"].trueValue());
ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString());
@@ -475,8 +475,8 @@ namespace {
ASSERT_EQUALS("lub dub", hbResponse.getHbMsg());
ASSERT_EQUALS("syncTarget", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
ASSERT_EQUALS(10, hbResponse.getTime().total_seconds());
ASSERT_EQUALS(true, hbResponse.isElectable());
ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString());
@@ -486,8 +486,8 @@ namespace {
ASSERT_EQUALS("rs0", hbResponseObj["set"].String());
ASSERT_EQUALS("lub dub", hbResponseObj["hbmsg"].String());
ASSERT_EQUALS(1, hbResponseObj["v"].Number());
- ASSERT_EQUALS(OpTime(10,0), hbResponseObj["electionTime"]._opTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponseObj["opTime"]._opTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponseObj["electionTime"].timestamp());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponseObj["opTime"].timestamp());
ASSERT_EQUALS(10, hbResponseObj["time"].numberLong());
ASSERT_EQUALS(true, hbResponseObj["e"].trueValue());
ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString());
@@ -518,8 +518,8 @@ namespace {
ASSERT_EQUALS("lub dub", hbResponse.getHbMsg());
ASSERT_EQUALS("syncTarget", hbResponse.getSyncingTo());
ASSERT_EQUALS(1, hbResponse.getVersion());
- ASSERT_EQUALS(OpTime(10,0), hbResponse.getElectionTime());
- ASSERT_EQUALS(OpTime(0,10), hbResponse.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), hbResponse.getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,10), hbResponse.getOpTime());
ASSERT_EQUALS(10, hbResponse.getTime().total_seconds());
ASSERT_EQUALS(true, hbResponse.isElectable());
ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString());
@@ -724,7 +724,7 @@ namespace {
ReplSetHeartbeatResponse hbResp;
std::string msg = "still initializing";
Status result = hbResp.initialize(BSON("ok" << 1.0 <<
- "opTime" << OpTime()));
+ "opTime" << Timestamp()));
ASSERT_EQUALS(ErrorCodes::NoSuchKey, result.code());
ASSERT_TRUE(stringContains(result.reason(), "\"v\""))
<< result.reason() << " doesn't contain 'v' field required error msg";
diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h
index 06e541ac06e..934ccedb531 100644
--- a/src/mongo/db/repl/replication_coordinator.h
+++ b/src/mongo/db/repl/replication_coordinator.h
@@ -44,7 +44,7 @@ namespace mongo {
class IndexDescriptor;
class NamespaceString;
class OperationContext;
- class OpTime;
+ class Timestamp;
struct WriteConcernOptions;
namespace repl {
@@ -172,7 +172,7 @@ namespace repl {
* ErrorCodes::Interrupted if the operation was killed with killop()
*/
virtual StatusAndDuration awaitReplication(const OperationContext* txn,
- const OpTime& ts,
+ const Timestamp& ts,
const WriteConcernOptions& writeConcern) = 0;
/**
@@ -246,7 +246,7 @@ namespace repl {
* Updates our internal tracking of the last OpTime applied for the given slave
* identified by "rid". Only valid to call in master/slave mode
*/
- virtual Status setLastOptimeForSlave(const OID& rid, const OpTime& ts) = 0;
+ virtual Status setLastOptimeForSlave(const OID& rid, const Timestamp& ts) = 0;
/**
* Updates our internal tracking of the last OpTime applied to this node.
@@ -256,7 +256,7 @@ namespace repl {
* that after calls to resetLastOpTimeFromOplog(), the minimum acceptable value for "ts" is
* reset based on the contents of the oplog, and may go backwards due to rollback.
*/
- virtual void setMyLastOptime(const OpTime& ts) = 0;
+ virtual void setMyLastOptime(const Timestamp& ts) = 0;
/**
* Same as above, but used during places we need to zero our last optime.
@@ -271,7 +271,7 @@ namespace repl {
/**
* Returns the last optime recorded by setMyLastOptime.
*/
- virtual OpTime getMyLastOptime() const = 0;
+ virtual Timestamp getMyLastOptime() const = 0;
/**
* Retrieves and returns the current election id, which is a unique id that is local to
@@ -443,7 +443,7 @@ namespace repl {
HostAndPort who; // host and port of the member that sent the replSetFresh command
unsigned id; // replSet id of the member that sent the replSetFresh command
int cfgver; // replSet config version that the member who sent the command thinks it has
- OpTime opTime; // last optime seen by the member who sent the replSetFresh command
+ Timestamp opTime; // last optime seen by the member who sent the replSetFresh command
};
/*
@@ -503,7 +503,7 @@ namespace repl {
/**
* Returns a vector of members that have applied the operation with OpTime 'op'.
*/
- virtual std::vector<HostAndPort> getHostsWrittenTo(const OpTime& op) = 0;
+ virtual std::vector<HostAndPort> getHostsWrittenTo(const Timestamp& op) = 0;
/**
* Returns a vector of the members other than ourself in the replica set, as specified in
@@ -554,7 +554,7 @@ namespace repl {
* Committed means a majority of the voting nodes of the config are known to have the
* operation in their oplogs. This implies such ops will never be rolled back.
*/
- virtual OpTime getLastCommittedOpTime() const = 0;
+ virtual Timestamp getLastCommittedOpTime() const = 0;
protected:
diff --git a/src/mongo/db/repl/replication_coordinator_external_state.h b/src/mongo/db/repl/replication_coordinator_external_state.h
index 7734d119040..07fa9ed921a 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state.h
+++ b/src/mongo/db/repl/replication_coordinator_external_state.h
@@ -31,7 +31,7 @@
#include <boost/scoped_ptr.hpp>
#include "mongo/base/disallow_copying.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/util/time_support.h"
namespace mongo {
@@ -114,13 +114,13 @@ namespace repl {
/**
* Sets the global opTime to be 'newTime'.
*/
- virtual void setGlobalOpTime(const OpTime& newTime) = 0;
+ virtual void setGlobalTimestamp(const Timestamp& newTime) = 0;
/**
* Gets the last optime of an operation performed on this host, from stable
* storage.
*/
- virtual StatusWith<OpTime> loadLastOpTime(OperationContext* txn) = 0;
+ virtual StatusWith<Timestamp> loadLastOpTime(OperationContext* txn) = 0;
/**
* Returns the HostAndPort of the remote client connected to us that initiated the operation
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index 824aac77634..6a83bba6d50 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -186,38 +186,38 @@ namespace {
}
}
- void ReplicationCoordinatorExternalStateImpl::setGlobalOpTime(const OpTime& newTime) {
+ void ReplicationCoordinatorExternalStateImpl::setGlobalTimestamp(const Timestamp& newTime) {
setNewOptime(newTime);
}
- StatusWith<OpTime> ReplicationCoordinatorExternalStateImpl::loadLastOpTime(
+ StatusWith<Timestamp> ReplicationCoordinatorExternalStateImpl::loadLastOpTime(
OperationContext* txn) {
try {
BSONObj oplogEntry;
if (!Helpers::getLast(txn, rsOplogName.c_str(), oplogEntry)) {
- return StatusWith<OpTime>(
+ return StatusWith<Timestamp>(
ErrorCodes::NoMatchingDocument,
str::stream() << "Did not find any entries in " << rsOplogName);
}
BSONElement tsElement = oplogEntry[tsFieldName];
if (tsElement.eoo()) {
- return StatusWith<OpTime>(
+ return StatusWith<Timestamp>(
ErrorCodes::NoSuchKey,
str::stream() << "Most recent entry in " << rsOplogName << " missing \"" <<
tsFieldName << "\" field");
}
- if (tsElement.type() != Timestamp) {
- return StatusWith<OpTime>(
+ if (tsElement.type() != bsonTimestamp) {
+ return StatusWith<Timestamp>(
ErrorCodes::TypeMismatch,
str::stream() << "Expected type of \"" << tsFieldName <<
"\" in most recent " << rsOplogName <<
" entry to have type Timestamp, but found " << typeName(tsElement.type()));
}
- return StatusWith<OpTime>(tsElement._opTime());
+ return StatusWith<Timestamp>(tsElement.timestamp());
}
catch (const DBException& ex) {
- return StatusWith<OpTime>(ex.toStatus());
+ return StatusWith<Timestamp>(ex.toStatus());
}
}
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.h b/src/mongo/db/repl/replication_coordinator_external_state_impl.h
index 3d1c7bef733..482b143f629 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.h
@@ -54,8 +54,8 @@ namespace repl {
virtual bool isSelf(const HostAndPort& host);
virtual StatusWith<BSONObj> loadLocalConfigDocument(OperationContext* txn);
virtual Status storeLocalConfigDocument(OperationContext* txn, const BSONObj& config);
- virtual void setGlobalOpTime(const OpTime& newTime);
- virtual StatusWith<OpTime> loadLastOpTime(OperationContext* txn);
+ virtual void setGlobalTimestamp(const Timestamp& newTime);
+ virtual StatusWith<Timestamp> loadLastOpTime(OperationContext* txn);
virtual HostAndPort getClientHostAndPort(const OperationContext* txn);
virtual void closeConnections();
virtual void killAllUserOperations(OperationContext* txn);
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_mock.cpp b/src/mongo/db/repl/replication_coordinator_external_state_mock.cpp
index e308bc2588e..bd4e194c5fc 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_mock.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_mock.cpp
@@ -108,16 +108,16 @@ namespace repl {
_localRsConfigDocument = localConfigDocument;
}
- void ReplicationCoordinatorExternalStateMock::setGlobalOpTime(const OpTime& newTime) {
+ void ReplicationCoordinatorExternalStateMock::setGlobalTimestamp(const Timestamp& newTime) {
}
- StatusWith<OpTime> ReplicationCoordinatorExternalStateMock::loadLastOpTime(
+ StatusWith<Timestamp> ReplicationCoordinatorExternalStateMock::loadLastOpTime(
OperationContext* txn) {
return _lastOpTime;
}
void ReplicationCoordinatorExternalStateMock::setLastOpTime(
- const StatusWith<OpTime>& lastApplied) {
+ const StatusWith<Timestamp>& lastApplied) {
_lastOpTime = lastApplied;
}
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_mock.h b/src/mongo/db/repl/replication_coordinator_external_state_mock.h
index 2f86ebc4d77..8f4366b7e17 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_mock.h
+++ b/src/mongo/db/repl/replication_coordinator_external_state_mock.h
@@ -28,12 +28,14 @@
#pragma once
+#include <boost/thread.hpp>
+#include <boost/thread/condition.hpp>
#include <vector>
#include "mongo/base/disallow_copying.h"
#include "mongo/base/status_with.h"
#include "mongo/bson/oid.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/repl/replication_coordinator_external_state.h"
#include "mongo/util/net/hostandport.h"
@@ -58,8 +60,8 @@ namespace repl {
virtual HostAndPort getClientHostAndPort(const OperationContext* txn);
virtual StatusWith<BSONObj> loadLocalConfigDocument(OperationContext* txn);
virtual Status storeLocalConfigDocument(OperationContext* txn, const BSONObj& config);
- virtual void setGlobalOpTime(const OpTime& newTime);
- virtual StatusWith<OpTime> loadLastOpTime(OperationContext* txn);
+ virtual void setGlobalTimestamp(const Timestamp& newTime);
+ virtual StatusWith<Timestamp> loadLastOpTime(OperationContext* txn);
virtual void closeConnections();
virtual void killAllUserOperations(OperationContext* txn);
virtual void clearShardingState();
@@ -86,7 +88,7 @@ namespace repl {
/**
* Sets the return value for subsequent calls to loadLastOpTimeApplied.
*/
- void setLastOpTime(const StatusWith<OpTime>& lastApplied);
+ void setLastOpTime(const StatusWith<Timestamp>& lastApplied);
/**
* Sets the return value for subsequent calls to storeLocalConfigDocument().
@@ -102,7 +104,7 @@ namespace repl {
private:
StatusWith<BSONObj> _localRsConfigDocument;
- StatusWith<OpTime> _lastOpTime;
+ StatusWith<Timestamp> _lastOpTime;
std::vector<HostAndPort> _selfHosts;
bool _canAcquireGlobalSharedLock;
Status _storeLocalConfigDocumentStatus;
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 3ee5b1227ea..4f9e9514509 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -37,7 +37,7 @@
#include "mongo/base/status.h"
#include "mongo/db/concurrency/d_concurrency.h"
-#include "mongo/db/global_optime.h"
+#include "mongo/db/global_timestamp.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/repl/check_quorum_for_config_change.h"
@@ -109,7 +109,7 @@ namespace {
*/
WaiterInfo(std::vector<WaiterInfo*>* _list,
unsigned int _opID,
- const OpTime* _opTime,
+ const Timestamp* _opTime,
const WriteConcernOptions* _writeConcern,
boost::condition_variable* _condVar) : list(_list),
master(true),
@@ -127,7 +127,7 @@ namespace {
std::vector<WaiterInfo*>* list;
bool master; // Set to false to indicate that stepDown was called while waiting
const unsigned int opID;
- const OpTime* opTime;
+ const Timestamp* opTime;
const WriteConcernOptions* writeConcern;
boost::condition_variable* condVar;
};
@@ -213,7 +213,7 @@ namespace {
fassertFailedNoTrace(28545);
}
- StatusWith<OpTime> lastOpTimeStatus = _externalState->loadLastOpTime(txn);
+ StatusWith<Timestamp> lastOpTimeStatus = _externalState->loadLastOpTime(txn);
// Use a callback here, because _finishLoadLocalConfig calls isself() which requires
// that the server's networking layer be up and running and accepting connections, which
@@ -230,7 +230,7 @@ namespace {
void ReplicationCoordinatorImpl::_finishLoadLocalConfig(
const ReplicationExecutor::CallbackData& cbData,
const ReplicaSetConfig& localConfig,
- const StatusWith<OpTime>& lastOpTimeStatus) {
+ const StatusWith<Timestamp>& lastOpTimeStatus) {
if (!cbData.status.isOK()) {
LOG(1) << "Loading local replica set configuration failed due to " << cbData.status;
return;
@@ -266,7 +266,7 @@ namespace {
// Do not check optime, if this node is an arbiter.
bool isArbiter = myIndex.getValue() != -1 &&
localConfig.getMemberAt(myIndex.getValue()).isArbiter();
- OpTime lastOpTime(0, 0);
+ Timestamp lastOpTime(0, 0);
if (!isArbiter) {
if (!lastOpTimeStatus.isOK()) {
warning() << "Failed to load timestamp of most recently applied operation; " <<
@@ -282,7 +282,7 @@ namespace {
const PostMemberStateUpdateAction action =
_setCurrentRSConfig_inlock(localConfig, myIndex.getValue());
_setMyLastOptime_inlock(&lk, lastOpTime, false);
- _externalState->setGlobalOpTime(lastOpTime);
+ _externalState->setGlobalTimestamp(lastOpTime);
if (lk.owns_lock()) {
lk.unlock();
}
@@ -575,7 +575,7 @@ namespace {
}
void ReplicationCoordinatorImpl::_updateSlaveInfoOptime_inlock(SlaveInfo* slaveInfo,
- OpTime ts) {
+ Timestamp ts) {
slaveInfo->opTime = ts;
@@ -646,7 +646,7 @@ namespace {
}
Status ReplicationCoordinatorImpl::setLastOptimeForSlave(const OID& rid,
- const OpTime& ts) {
+ const Timestamp& ts) {
boost::unique_lock<boost::mutex> lock(_mutex);
massert(28576,
"Received an old style replication progress update, which is only used for Master/"
@@ -682,18 +682,18 @@ namespace {
_replExecutor.wait(cbh.getValue());
}
- void ReplicationCoordinatorImpl::setMyLastOptime(const OpTime& ts) {
+ void ReplicationCoordinatorImpl::setMyLastOptime(const Timestamp& ts) {
boost::unique_lock<boost::mutex> lock(_mutex);
_setMyLastOptime_inlock(&lock, ts, false);
}
void ReplicationCoordinatorImpl::resetMyLastOptime() {
boost::unique_lock<boost::mutex> lock(_mutex);
- _setMyLastOptime_inlock(&lock, OpTime(), true);
+ _setMyLastOptime_inlock(&lock, Timestamp(), true);
}
void ReplicationCoordinatorImpl::_setMyLastOptime_inlock(
- boost::unique_lock<boost::mutex>* lock, const OpTime& ts, bool isRollbackAllowed) {
+ boost::unique_lock<boost::mutex>* lock, const Timestamp& ts, bool isRollbackAllowed) {
invariant(lock->owns_lock());
SlaveInfo* mySlaveInfo = &_slaveInfo[_getMyIndexInSlaveInfo_inlock()];
invariant(isRollbackAllowed || mySlaveInfo->opTime <= ts);
@@ -709,18 +709,18 @@ namespace {
_externalState->forwardSlaveProgress(); // Must do this outside _mutex
}
- OpTime ReplicationCoordinatorImpl::getMyLastOptime() const {
+ Timestamp ReplicationCoordinatorImpl::getMyLastOptime() const {
boost::lock_guard<boost::mutex> lock(_mutex);
return _getMyLastOptime_inlock();
}
- OpTime ReplicationCoordinatorImpl::_getMyLastOptime_inlock() const {
+ Timestamp ReplicationCoordinatorImpl::_getMyLastOptime_inlock() const {
return _slaveInfo[_getMyIndexInSlaveInfo_inlock()].opTime;
}
Status ReplicationCoordinatorImpl::setLastOptime_forTest(long long cfgVer,
long long memberId,
- const OpTime& ts) {
+ const Timestamp& ts) {
boost::lock_guard<boost::mutex> lock(_mutex);
invariant(_getReplicationMode_inlock() == modeReplSet);
@@ -824,7 +824,7 @@ namespace {
}
bool ReplicationCoordinatorImpl::_doneWaitingForReplication_inlock(
- const OpTime& opTime, const WriteConcernOptions& writeConcern) {
+ const Timestamp& opTime, const WriteConcernOptions& writeConcern) {
Status status = _checkIfWriteConcernCanBeSatisfied_inlock(writeConcern);
if (!status.isOK()) {
return true;
@@ -850,7 +850,7 @@ namespace {
}
}
- bool ReplicationCoordinatorImpl::_haveNumNodesReachedOpTime_inlock(const OpTime& opTime,
+ bool ReplicationCoordinatorImpl::_haveNumNodesReachedOpTime_inlock(const Timestamp& opTime,
int numNodes) {
if (_getMyLastOptime_inlock() < opTime) {
// Secondaries that are for some reason ahead of us should not allow us to
@@ -861,7 +861,7 @@ namespace {
for (SlaveInfoVector::iterator it = _slaveInfo.begin();
it != _slaveInfo.end(); ++it) {
- const OpTime& slaveTime = it->opTime;
+ const Timestamp& slaveTime = it->opTime;
if (slaveTime >= opTime) {
--numNodes;
}
@@ -874,13 +874,13 @@ namespace {
}
bool ReplicationCoordinatorImpl::_haveTaggedNodesReachedOpTime_inlock(
- const OpTime& opTime, const ReplicaSetTagPattern& tagPattern) {
+ const Timestamp& opTime, const ReplicaSetTagPattern& tagPattern) {
ReplicaSetTagMatch matcher(tagPattern);
for (SlaveInfoVector::iterator it = _slaveInfo.begin();
it != _slaveInfo.end(); ++it) {
- const OpTime& slaveTime = it->opTime;
+ const Timestamp& slaveTime = it->opTime;
if (slaveTime >= opTime) {
// This node has reached the desired optime, now we need to check if it is a part
// of the tagPattern.
@@ -899,7 +899,7 @@ namespace {
ReplicationCoordinator::StatusAndDuration ReplicationCoordinatorImpl::awaitReplication(
const OperationContext* txn,
- const OpTime& opTime,
+ const Timestamp& opTime,
const WriteConcernOptions& writeConcern) {
Timer timer;
boost::unique_lock<boost::mutex> lock(_mutex);
@@ -924,7 +924,7 @@ namespace {
const Timer* timer,
boost::unique_lock<boost::mutex>* lock,
const OperationContext* txn,
- const OpTime& opTime,
+ const Timestamp& opTime,
const WriteConcernOptions& writeConcern) {
const Mode replMode = _getReplicationMode_inlock();
@@ -1951,7 +1951,7 @@ namespace {
case kActionWinElection: {
boost::unique_lock<boost::mutex> lk(_mutex);
_electionId = OID::gen();
- _topCoord->processWinElection(_electionId, getNextGlobalOptime());
+ _topCoord->processWinElection(_electionId, getNextGlobalTimestamp());
_isWaitingForDrainToComplete = true;
const PostMemberStateUpdateAction nextAction =
_updateMemberStateFromTopologyCoordinator_inlock();
@@ -2049,7 +2049,7 @@ namespace {
invariant(_settings.usingReplSets());
_cancelHeartbeats();
_setConfigState_inlock(kConfigSteady);
- OpTime myOptime = _getMyLastOptime_inlock(); // Must get this before changing our config.
+ Timestamp myOptime = _getMyLastOptime_inlock(); // Must get this before changing our config.
_topCoord->updateConfig(
newConfig,
myIndex,
@@ -2146,7 +2146,7 @@ namespace {
return self.shouldBuildIndexes();
}
- std::vector<HostAndPort> ReplicationCoordinatorImpl::getHostsWrittenTo(const OpTime& op) {
+ std::vector<HostAndPort> ReplicationCoordinatorImpl::getHostsWrittenTo(const Timestamp& op) {
std::vector<HostAndPort> hosts;
boost::lock_guard<boost::mutex> lk(_mutex);
for (size_t i = 0; i < _slaveInfo.size(); ++i) {
@@ -2305,8 +2305,8 @@ namespace {
}
void ReplicationCoordinatorImpl::resetLastOpTimeFromOplog(OperationContext* txn) {
- StatusWith<OpTime> lastOpTimeStatus = _externalState->loadLastOpTime(txn);
- OpTime lastOpTime(0, 0);
+ StatusWith<Timestamp> lastOpTimeStatus = _externalState->loadLastOpTime(txn);
+ Timestamp lastOpTime(0, 0);
if (!lastOpTimeStatus.isOK()) {
warning() << "Failed to load timestamp of most recently applied operation; " <<
lastOpTimeStatus.getStatus();
@@ -2316,7 +2316,7 @@ namespace {
}
boost::unique_lock<boost::mutex> lk(_mutex);
_setMyLastOptime_inlock(&lk, lastOpTime, true);
- _externalState->setGlobalOpTime(lastOpTime);
+ _externalState->setGlobalTimestamp(lastOpTime);
}
void ReplicationCoordinatorImpl::_shouldChangeSyncSource(
@@ -2355,7 +2355,7 @@ namespace {
invariant(tagPattern.isOK());
ReplicaSetTagMatch matcher{tagPattern.getValue()};
- std::vector<OpTime> votingNodesOpTimes;
+ std::vector<Timestamp> votingNodesOpTimes;
for (const auto& sI : _slaveInfo) {
auto memberConfig = _rsConfig.findMemberByID(sI.memberId);
@@ -2375,7 +2375,7 @@ namespace {
_lastCommittedOpTime = votingNodesOpTimes[(votingNodesOpTimes.size() - 1) / 2];
}
- OpTime ReplicationCoordinatorImpl::getLastCommittedOpTime() const {
+ Timestamp ReplicationCoordinatorImpl::getLastCommittedOpTime() const {
boost::unique_lock<boost::mutex> lk(_mutex);
return _lastCommittedOpTime;
}
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h
index a66043ac23e..970d6c877f1 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_impl.h
@@ -35,7 +35,7 @@
#include <vector>
#include "mongo/base/status.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/service_context.h"
#include "mongo/db/repl/member_state.h"
#include "mongo/db/repl/replica_set_config.h"
@@ -110,7 +110,7 @@ namespace repl {
virtual ReplicationCoordinator::StatusAndDuration awaitReplication(
const OperationContext* txn,
- const OpTime& ts,
+ const Timestamp& ts,
const WriteConcernOptions& writeConcern);
virtual ReplicationCoordinator::StatusAndDuration awaitReplicationOfLastOpForClient(
@@ -135,15 +135,15 @@ namespace repl {
virtual bool shouldIgnoreUniqueIndex(const IndexDescriptor* idx);
- virtual Status setLastOptimeForSlave(const OID& rid, const OpTime& ts);
+ virtual Status setLastOptimeForSlave(const OID& rid, const Timestamp& ts);
- virtual void setMyLastOptime(const OpTime& ts);
+ virtual void setMyLastOptime(const Timestamp& ts);
virtual void resetMyLastOptime();
virtual void setMyHeartbeatMessage(const std::string& msg);
- virtual OpTime getMyLastOptime() const;
+ virtual Timestamp getMyLastOptime() const;
virtual OID getElectionId();
@@ -208,7 +208,7 @@ namespace repl {
virtual bool buildsIndexes();
- virtual std::vector<HostAndPort> getHostsWrittenTo(const OpTime& op);
+ virtual std::vector<HostAndPort> getHostsWrittenTo(const Timestamp& op);
virtual std::vector<HostAndPort> getOtherNodesInReplSet() const;
@@ -226,7 +226,7 @@ namespace repl {
virtual bool shouldChangeSyncSource(const HostAndPort& currentSource);
- virtual OpTime getLastCommittedOpTime() const;
+ virtual Timestamp getLastCommittedOpTime() const;
// ================== Test support API ===================
@@ -245,7 +245,7 @@ namespace repl {
/**
* Simple wrapper around _setLastOptime_inlock to make it easier to test.
*/
- Status setLastOptime_forTest(long long cfgVer, long long memberId, const OpTime& ts);
+ Status setLastOptime_forTest(long long cfgVer, long long memberId, const Timestamp& ts);
private:
@@ -296,7 +296,7 @@ namespace repl {
// Struct that holds information about nodes in this replication group, mainly used for
// tracking replication progress for write concern satisfaction.
struct SlaveInfo {
- OpTime opTime; // Our last known OpTime that this slave has replicated to.
+ Timestamp opTime; // Our last known OpTime that this slave has replicated to.
HostAndPort hostAndPort; // Client address of the slave.
int memberId; // Id of the node in the replica set config, or -1 if we're not a replSet.
OID rid; // RID of the node.
@@ -331,7 +331,7 @@ namespace repl {
* and wakes up any threads waiting for replication that now have their write concern
* satisfied.
*/
- void _updateSlaveInfoOptime_inlock(SlaveInfo* slaveInfo, OpTime ts);
+ void _updateSlaveInfoOptime_inlock(SlaveInfo* slaveInfo, Timestamp ts);
/**
* Returns the index into _slaveInfo where data corresponding to ourself is stored.
@@ -430,25 +430,25 @@ namespace repl {
const Timer* timer,
boost::unique_lock<boost::mutex>* lock,
const OperationContext* txn,
- const OpTime& ts,
+ const Timestamp& ts,
const WriteConcernOptions& writeConcern);
/*
* Returns true if the given writeConcern is satisfied up to "optime" or is unsatisfiable.
*/
- bool _doneWaitingForReplication_inlock(const OpTime& opTime,
+ bool _doneWaitingForReplication_inlock(const Timestamp& opTime,
const WriteConcernOptions& writeConcern);
/**
* Helper for _doneWaitingForReplication_inlock that takes an integer write concern.
*/
- bool _haveNumNodesReachedOpTime_inlock(const OpTime& opTime, int numNodes);
+ bool _haveNumNodesReachedOpTime_inlock(const Timestamp& opTime, int numNodes);
/**
* Helper for _doneWaitingForReplication_inlock that takes a tag pattern representing a
* named write concern mode.
*/
- bool _haveTaggedNodesReachedOpTime_inlock(const OpTime& opTime,
+ bool _haveTaggedNodesReachedOpTime_inlock(const Timestamp& opTime,
const ReplicaSetTagPattern& tagPattern);
Status _checkIfWriteConcernCanBeSatisfied_inlock(
@@ -479,7 +479,7 @@ namespace repl {
int _getMyId_inlock() const;
- OpTime _getMyLastOptime_inlock() const;
+ Timestamp _getMyLastOptime_inlock() const;
/**
@@ -514,7 +514,7 @@ namespace repl {
* "isRollbackAllowed" is true.
*/
void _setMyLastOptime_inlock(boost::unique_lock<boost::mutex>* lock,
- const OpTime& ts,
+ const Timestamp& ts,
bool isRollbackAllowed);
/**
@@ -541,7 +541,7 @@ namespace repl {
*
* Updates the optime associated with the member at "memberIndex" in our config.
*/
- void _updateOpTimeFromHeartbeat_inlock(int memberIndex, OpTime optime);
+ void _updateOpTimeFromHeartbeat_inlock(int memberIndex, Timestamp optime);
/**
* Starts a heartbeat for each member in the current config. Called within the executor
@@ -591,7 +591,7 @@ namespace repl {
*/
void _finishLoadLocalConfig(const ReplicationExecutor::CallbackData& cbData,
const ReplicaSetConfig& localConfig,
- const StatusWith<OpTime>& lastOpTimeStatus);
+ const StatusWith<Timestamp>& lastOpTimeStatus);
/**
* Callback that finishes the work of processReplSetInitiate() inside the replication
@@ -888,7 +888,7 @@ namespace repl {
AtomicUInt32 _canServeNonLocalReads; // (S)
// OpTime of the latest committed operation. Matches the concurrency level of _slaveInfo.
- OpTime _lastCommittedOpTime; // (M)
+ Timestamp _lastCommittedOpTime; // (M)
};
} // namespace repl
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect.cpp
index 57d150b8e48..dffe1e3793f 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect.cpp
@@ -120,9 +120,9 @@ namespace {
invariant(_rsConfig.getMemberAt(_selfIndex).isElectable());
- OpTime lastOpTimeApplied(_getMyLastOptime_inlock());
+ Timestamp lastOpTimeApplied(_getMyLastOptime_inlock());
- if (lastOpTimeApplied == OpTime()) {
+ if (lastOpTimeApplied == Timestamp()) {
log() << "not trying to elect self, "
"do not yet have a complete set of data from any point in time";
return;
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
index b7674970363..5ea30666316 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect_test.cpp
@@ -99,7 +99,7 @@ namespace {
net->scheduleResponse(noi, net->now(), makeResponseStatus(
BSON("ok" << 1 <<
"fresher" << false <<
- "opTime" << Date_t(OpTime(0, 0).asDate()) <<
+ "opTime" << Date_t(Timestamp(0, 0).asULL()) <<
"veto" << false)));
}
else {
@@ -149,7 +149,7 @@ namespace {
ASSERT(getReplCoord()->getMemberState().secondary()) <<
getReplCoord()->getMemberState().toString();
- getReplCoord()->setMyLastOptime(OpTime(10,0));
+ getReplCoord()->setMyLastOptime(Timestamp(10,0));
NetworkInterfaceMock* net = getNet();
net->enterNetwork();
@@ -210,7 +210,7 @@ namespace {
));
assertStartSuccess(configObj, HostAndPort("node1", 12345));
OperationContextNoop txn;
- getReplCoord()->setMyLastOptime(OpTime (100, 1));
+ getReplCoord()->setMyLastOptime(Timestamp (100, 1));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
startCapturingLogMessages();
simulateSuccessfulElection();
@@ -231,7 +231,7 @@ namespace {
ReplicaSetConfig config = assertMakeRSConfig(configObj);
OperationContextNoop txn;
- OpTime time1(100, 1);
+ Timestamp time1(100, 1);
getReplCoord()->setMyLastOptime(time1);
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -278,7 +278,7 @@ namespace {
ReplicaSetConfig config = assertMakeRSConfig(configObj);
OperationContextNoop txn;
- OpTime time1(100, 1);
+ Timestamp time1(100, 1);
getReplCoord()->setMyLastOptime(time1);
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
@@ -326,7 +326,7 @@ namespace {
BSON("_id" << 5 << "host" << "node5:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100,0));
+ getReplCoord()->setMyLastOptime(Timestamp(100,0));
// set hbreconfig to hang while in progress
getExternalState()->setStoreLocalConfigDocumentToHang(true);
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
index 9ec647d8dee..ab278b5c7b7 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
@@ -126,7 +126,7 @@ namespace {
const bool isUnauthorized = (responseStatus.code() == ErrorCodes::Unauthorized) ||
(responseStatus.code() == ErrorCodes::AuthenticationFailed);
const Date_t now = _replExecutor.now();
- const OpTime lastApplied = getMyLastOptime(); // Locks and unlocks _mutex.
+ const Timestamp lastApplied = getMyLastOptime(); // Locks and unlocks _mutex.
Milliseconds networkTime(0);
StatusWith<ReplSetHeartbeatResponse> hbStatusResponse(hbResponse);
@@ -177,7 +177,7 @@ namespace {
}
void ReplicationCoordinatorImpl::_updateOpTimeFromHeartbeat_inlock(int targetIndex,
- OpTime optime) {
+ Timestamp optime) {
invariant(_selfIndex >= 0);
invariant(targetIndex >= 0);
diff --git a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
index 7b1b8f8ff20..f29a830bb6f 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
@@ -92,7 +92,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
BSONObjBuilder result;
@@ -123,7 +123,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
BSONObjBuilder result;
@@ -151,7 +151,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
BSONObjBuilder result;
@@ -207,7 +207,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
Status status(ErrorCodes::InternalError, "Not Set");
@@ -243,7 +243,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
Status status(ErrorCodes::InternalError, "Not Set");
@@ -281,7 +281,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
Status status(ErrorCodes::InternalError, "Not Set");
@@ -316,7 +316,7 @@ namespace {
init();
start(HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
// initiate
Status status(ErrorCodes::InternalError, "Not Set");
@@ -354,7 +354,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345"))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
Status status(ErrorCodes::InternalError, "Not Set");
@@ -391,7 +391,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100,0));
+ getReplCoord()->setMyLastOptime(Timestamp(100,0));
simulateSuccessfulElection();
ASSERT_TRUE(getReplCoord()->getMemberState().primary());
@@ -443,7 +443,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100,0));
+ getReplCoord()->setMyLastOptime(Timestamp(100,0));
simulateSuccessfulElection();
ASSERT_TRUE(getReplCoord()->getMemberState().primary());
@@ -502,7 +502,7 @@ namespace {
BSON("_id" << 2 << "host" << "node2:12345") )),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
// fail before forced
BSONObjBuilder result;
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index 550ef262f62..d7fcffc6ed6 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -406,7 +406,7 @@ namespace {
TEST_F(ReplCoordTest, AwaitReplicationNoReplEnabled) {
init("");
OperationContextNoop txn;
- OpTime time(100, 1);
+ Timestamp time(100, 1);
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoWaiting;
@@ -424,7 +424,7 @@ namespace {
settings.master = true;
init(settings);
OperationContextNoop txn;
- OpTime time(100, 1);
+ Timestamp time(100, 1);
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoWaiting;
@@ -449,7 +449,7 @@ namespace {
HostAndPort("node1", 12345));
OperationContextNoop txn;
- OpTime time(100, 1);
+ Timestamp time(100, 1);
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoWaiting;
@@ -462,7 +462,7 @@ namespace {
ASSERT_EQUALS(ErrorCodes::NotMaster, statusAndDur.status);
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
statusAndDur = getReplCoord()->awaitReplication(&txn, time, writeConcern);
@@ -480,11 +480,11 @@ namespace {
BSON("host" << "node4:12345" << "_id" << 3))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
- OpTime time1(100, 1);
- OpTime time2(100, 2);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoWaiting;
@@ -555,11 +555,11 @@ namespace {
"multiDCAndRack" << BSON("dc" << 2 << "rack" << 3)))),
HostAndPort("node0"));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
- OpTime time1(100, 1);
- OpTime time2(100, 2);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
// Test invalid write concern
WriteConcernOptions invalidWriteConcern;
@@ -643,7 +643,7 @@ namespace {
_result(ReplicationCoordinator::StatusAndDuration(
Status::OK(), ReplicationCoordinator::Milliseconds(0))) {}
- void setOpTime(const OpTime& ot) {
+ void setOpTime(const Timestamp& ot) {
_optime = ot;
}
@@ -681,7 +681,7 @@ namespace {
ReplicationCoordinatorImpl* _replCoord;
bool _finished;
- OpTime _optime;
+ Timestamp _optime;
WriteConcernOptions _writeConcern;
ReplicationCoordinator::StatusAndDuration _result;
boost::scoped_ptr<boost::thread> _thread;
@@ -697,13 +697,13 @@ namespace {
BSON("host" << "node3:12345" << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
- OpTime time1(100, 1);
- OpTime time2(100, 2);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoTimeout;
@@ -748,13 +748,13 @@ namespace {
BSON("host" << "node3:12345" << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
- OpTime time1(100, 1);
- OpTime time2(100, 2);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
WriteConcernOptions writeConcern;
writeConcern.wTimeout = 50;
@@ -781,13 +781,13 @@ namespace {
BSON("host" << "node3:12345" << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
- OpTime time1(100, 1);
- OpTime time2(100, 2);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoTimeout;
@@ -817,13 +817,13 @@ namespace {
BSON("host" << "node3:12345" << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
- OpTime time1(100, 1);
- OpTime time2(100, 2);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoTimeout;
@@ -893,13 +893,13 @@ namespace {
BSON("_id" << 2 << "host" << "node3"))),
HostAndPort("node1"));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
ReplicationAwaiter awaiter(getReplCoord(), &txn);
- OpTime time1(100, 1);
- OpTime time2(100, 2);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
WriteConcernOptions writeConcern;
writeConcern.wTimeout = WriteConcernOptions::kNoTimeout;
@@ -947,7 +947,7 @@ namespace {
TEST_F(StepDownTest, StepDownNotPrimary) {
OperationContextReplMock txn;
- OpTime optime1(100, 1);
+ Timestamp optime1(100, 1);
// All nodes are caught up
getReplCoord()->setMyLastOptime(optime1);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 1, optime1));
@@ -960,7 +960,7 @@ namespace {
TEST_F(StepDownTest, StepDownTimeoutAcquiringGlobalLock) {
OperationContextReplMock txn;
- OpTime optime1(100, 1);
+ Timestamp optime1(100, 1);
// All nodes are caught up
getReplCoord()->setMyLastOptime(optime1);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 1, optime1));
@@ -978,7 +978,7 @@ namespace {
TEST_F(StepDownTest, StepDownNoWaiting) {
OperationContextReplMock txn;
- OpTime optime1(100, 1);
+ Timestamp optime1(100, 1);
// All nodes are caught up
getReplCoord()->setMyLastOptime(optime1);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 1, optime1));
@@ -1114,8 +1114,8 @@ namespace {
TEST_F(StepDownTest, StepDownNotCaughtUp) {
OperationContextReplMock txn;
- OpTime optime1(100, 1);
- OpTime optime2(100, 2);
+ Timestamp optime1(100, 1);
+ Timestamp optime2(100, 2);
// No secondary is caught up
getReplCoord()->setMyLastOptime(optime2);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 1, optime1));
@@ -1156,8 +1156,8 @@ namespace {
TEST_F(StepDownTest, StepDownCatchUp) {
OperationContextReplMock txn;
- OpTime optime1(100, 1);
- OpTime optime2(100, 2);
+ Timestamp optime1(100, 1);
+ Timestamp optime2(100, 2);
// No secondary is caught up
getReplCoord()->setMyLastOptime(optime2);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 1, optime1));
@@ -1204,8 +1204,8 @@ namespace {
TEST_F(StepDownTest, InterruptStepDown) {
OperationContextNoopWithInterrupt txn;
- OpTime optime1(100, 1);
- OpTime optime2(100, 2);
+ Timestamp optime1(100, 1);
+ Timestamp optime2(100, 2);
// No secondary is caught up
getReplCoord()->setMyLastOptime(optime2);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 1, optime1));
@@ -1278,9 +1278,9 @@ namespace {
BSON("_id" << 1 << "host" << "test2:1234") <<
BSON("_id" << 2 << "host" << "test3:1234"))),
HostAndPort("test1", 1234));
- OpTime optime1(100, 1);
- OpTime optime2(100, 2);
- OpTime optime3(2, 1);
+ Timestamp optime1(100, 1);
+ Timestamp optime2(100, 2);
+ Timestamp optime3(2, 1);
getReplCoord()->setMyLastOptime(optime1);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 1, optime2));
ASSERT_OK(getReplCoord()->setLastOptime_forTest(1, 2, optime3));
@@ -1299,12 +1299,12 @@ namespace {
long long memberId = entry["memberId"].Number();
memberIds.insert(memberId);
if (memberId == 0) {
- ASSERT_EQUALS(optime1, entry["optime"]._opTime());
+ ASSERT_EQUALS(optime1, entry["optime"].timestamp());
} else if (memberId == 1) {
- ASSERT_EQUALS(optime2, entry["optime"]._opTime());
+ ASSERT_EQUALS(optime2, entry["optime"].timestamp());
} else {
ASSERT_EQUALS(2, memberId);
- ASSERT_EQUALS(optime3, entry["optime"]._opTime());
+ ASSERT_EQUALS(optime3, entry["optime"].timestamp());
}
}
ASSERT_EQUALS(3U, memberIds.size()); // Make sure we saw all 3 nodes
@@ -1321,7 +1321,7 @@ namespace {
HostAndPort("test2", 1234));
OperationContextNoop txn;
getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY);
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
// Can't unset maintenance mode if it was never set to begin with.
Status status = getReplCoord()->setMaintenanceMode(false);
@@ -1404,8 +1404,8 @@ namespace {
HostAndPort("node1", 12345));
OperationContextNoop txn;
- OpTime time1(100, 1);
- OpTime time2(100, 2);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
getReplCoord()->setMyLastOptime(time2);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(2, 1, time1));
@@ -1434,8 +1434,8 @@ namespace {
OperationContextNoop txn;
OID client = OID::gen();
- OpTime time1(100, 1);
- OpTime time2(100, 2);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
getExternalState()->setClientHostAndPort(clientHost);
HandshakeArgs handshake;
@@ -1579,12 +1579,12 @@ namespace {
BSON("host" << "node3:12345" << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 0));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 0));
simulateSuccessfulElection();
- OpTime time1(100, 1);
- OpTime time2(100, 2);
- OpTime staleTime(10, 0);
+ Timestamp time1(100, 1);
+ Timestamp time2(100, 2);
+ Timestamp staleTime(10, 0);
getReplCoord()->setMyLastOptime(time1);
WriteConcernOptions writeConcern;
@@ -1678,10 +1678,10 @@ namespace {
BSON("host" << "node3:12345" << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 2));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 2));
simulateSuccessfulElection();
- OpTime time(100, 2);
+ Timestamp time(100, 2);
// 3 nodes waiting for time
WriteConcernOptions writeConcern;
@@ -1748,10 +1748,10 @@ namespace {
BSON("host" << "node3:12345" << "_id" << 2))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 2));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 2));
simulateSuccessfulElection();
- OpTime time(100, 2);
+ Timestamp time(100, 2);
// 3 nodes waiting for time
WriteConcernOptions writeConcern;
@@ -1805,10 +1805,10 @@ namespace {
BSON("host" << "node5:12345" << "_id" << 4))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- getReplCoord()->setMyLastOptime(OpTime(100, 1));
+ getReplCoord()->setMyLastOptime(Timestamp(100, 1));
simulateSuccessfulElection();
- OpTime time(100, 2);
+ Timestamp time(100, 2);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(2, 1, time));
ASSERT_OK(getReplCoord()->setLastOptime_forTest(2, 2, time));
@@ -1878,7 +1878,7 @@ namespace {
"arbiterOnly" << true))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- OpTime time(100, 0);
+ Timestamp time(100, 0);
getReplCoord()->setMyLastOptime(time);
simulateSuccessfulElection();
@@ -1919,8 +1919,8 @@ namespace {
"arbiterOnly" << true))),
HostAndPort("node1", 12345));
ASSERT(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- OpTime zero(0, 0);
- OpTime time(100, 0);
+ Timestamp zero(0, 0);
+ Timestamp time(100, 0);
getReplCoord()->setMyLastOptime(time);
simulateSuccessfulElection();
@@ -1935,7 +1935,7 @@ namespace {
// Set a new, later OpTime.
- OpTime newTime = OpTime(100, 1);
+ Timestamp newTime = Timestamp(100, 1);
getReplCoord()->setMyLastOptime(newTime);
ASSERT_OK(getReplCoord()->setLastOptime_forTest(2, 3, newTime));
ASSERT_EQUALS(time, getReplCoord()->getLastCommittedOpTime());
diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp
index e0efd70392e..99bda38afc0 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.cpp
+++ b/src/mongo/db/repl/replication_coordinator_mock.cpp
@@ -81,7 +81,7 @@ namespace repl {
ReplicationCoordinator::StatusAndDuration ReplicationCoordinatorMock::awaitReplication(
const OperationContext* txn,
- const OpTime& ts,
+ const Timestamp& ts,
const WriteConcernOptions& writeConcern) {
// TODO
return StatusAndDuration(Status::OK(), Milliseconds(0));
@@ -123,7 +123,7 @@ namespace repl {
return false;
}
- Status ReplicationCoordinatorMock::setLastOptimeForSlave(const OID& rid, const OpTime& ts) {
+ Status ReplicationCoordinatorMock::setLastOptimeForSlave(const OID& rid, const Timestamp& ts) {
return Status::OK();
}
@@ -131,13 +131,13 @@ namespace repl {
// TODO
}
- void ReplicationCoordinatorMock::setMyLastOptime(const OpTime& ts) {}
+ void ReplicationCoordinatorMock::setMyLastOptime(const Timestamp& ts) {}
void ReplicationCoordinatorMock::resetMyLastOptime() {}
- OpTime ReplicationCoordinatorMock::getMyLastOptime() const {
+ Timestamp ReplicationCoordinatorMock::getMyLastOptime() const {
// TODO
- return OpTime();
+ return Timestamp();
}
@@ -256,7 +256,7 @@ namespace repl {
return true;
}
- std::vector<HostAndPort> ReplicationCoordinatorMock::getHostsWrittenTo(const OpTime& op) {
+ std::vector<HostAndPort> ReplicationCoordinatorMock::getHostsWrittenTo(const Timestamp& op) {
return std::vector<HostAndPort>();
}
@@ -295,8 +295,8 @@ namespace repl {
invariant(false);
}
- OpTime ReplicationCoordinatorMock::getLastCommittedOpTime() const {
- return OpTime();
+ Timestamp ReplicationCoordinatorMock::getLastCommittedOpTime() const {
+ return Timestamp();
}
} // namespace repl
diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h
index d0a40f1414c..2ec2b344c34 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.h
+++ b/src/mongo/db/repl/replication_coordinator_mock.h
@@ -66,7 +66,7 @@ namespace repl {
virtual ReplicationCoordinator::StatusAndDuration awaitReplication(
const OperationContext* txn,
- const OpTime& ts,
+ const Timestamp& ts,
const WriteConcernOptions& writeConcern);
virtual ReplicationCoordinator::StatusAndDuration awaitReplicationOfLastOpForClient(
@@ -91,15 +91,15 @@ namespace repl {
virtual bool shouldIgnoreUniqueIndex(const IndexDescriptor* idx);
- virtual Status setLastOptimeForSlave(const OID& rid, const OpTime& ts);
+ virtual Status setLastOptimeForSlave(const OID& rid, const Timestamp& ts);
- virtual void setMyLastOptime(const OpTime& ts);
+ virtual void setMyLastOptime(const Timestamp& ts);
virtual void resetMyLastOptime();
virtual void setMyHeartbeatMessage(const std::string& msg);
- virtual OpTime getMyLastOptime() const;
+ virtual Timestamp getMyLastOptime() const;
virtual OID getElectionId();
@@ -164,7 +164,7 @@ namespace repl {
virtual bool buildsIndexes();
- virtual std::vector<HostAndPort> getHostsWrittenTo(const OpTime& op);
+ virtual std::vector<HostAndPort> getHostsWrittenTo(const Timestamp& op);
virtual std::vector<HostAndPort> getOtherNodesInReplSet() const;
@@ -180,7 +180,7 @@ namespace repl {
virtual bool shouldChangeSyncSource(const HostAndPort& currentSource);
- virtual OpTime getLastCommittedOpTime() const;
+ virtual Timestamp getLastCommittedOpTime() const;
private:
const ReplSettings _settings;
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index 2479c5d4724..808bffe819c 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -191,7 +191,7 @@ namespace {
net->scheduleResponse(noi, net->now(), makeResponseStatus(
BSON("ok" << 1 <<
"fresher" << false <<
- "opTime" << Date_t(OpTime(0, 0).asDate()) <<
+ "opTime" << Date_t(Timestamp(0, 0).asULL()) <<
"veto" << false)));
}
else if (request.cmdObj.firstElement().fieldNameStringData() == "replSetElect") {
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 8d064089244..dfba98f56aa 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -186,7 +186,7 @@ namespace repl {
uassert(17347,
"Problem reading earliest entry from oplog",
Helpers::getSingleton(txn, oplogNS.c_str(), o));
- result.append("earliestOptime", o["ts"]._opTime());
+ result.append("earliestOptime", o["ts"].timestamp());
return result.obj();
}
} oplogInfoServerStatus;
diff --git a/src/mongo/db/repl/replset_commands.cpp b/src/mongo/db/repl/replset_commands.cpp
index a86ee0e1379..8f090862013 100644
--- a/src/mongo/db/repl/replset_commands.cpp
+++ b/src/mongo/db/repl/replset_commands.cpp
@@ -729,7 +729,7 @@ namespace {
"numeric type, but found " << typeName(cfgverElement.type()),
cfgverElement.isNumber());
parsedArgs.cfgver = cfgverElement.safeNumberLong();
- parsedArgs.opTime = OpTime(cmdObj["opTime"].Date());
+ parsedArgs.opTime = Timestamp(cmdObj["opTime"].Date());
status = getGlobalReplicationCoordinator()->processReplSetFresh(parsedArgs, &result);
return appendCommandStatus(result, status);
diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp
index 6fdf3e72190..1380ae190c9 100644
--- a/src/mongo/db/repl/rs_initialsync.cpp
+++ b/src/mongo/db/repl/rs_initialsync.cpp
@@ -32,7 +32,7 @@
#include "mongo/db/repl/rs_initialsync.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/bson/util/bson_extract.h"
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_manager_global.h"
@@ -207,7 +207,7 @@ namespace {
bool _initialSyncApplyOplog( OperationContext* ctx,
repl::SyncTail& syncer,
OplogReader* r) {
- const OpTime startOpTime = getGlobalReplicationCoordinator()->getMyLastOptime();
+ const Timestamp startOpTime = getGlobalReplicationCoordinator()->getMyLastOptime();
BSONObj lastOp;
try {
// It may have been a long time since we last used this connection to
@@ -234,7 +234,7 @@ namespace {
return false;
}
- OpTime stopOpTime = lastOp["ts"]._opTime();
+ Timestamp stopOpTime = lastOp["ts"].timestamp();
// If we already have what we need then return.
if (stopOpTime == startOpTime)
@@ -333,7 +333,7 @@ namespace {
truncateAndResetOplog(&txn, replCoord, bgsync);
OplogReader r;
- OpTime now(Milliseconds(curTimeMillis64()).total_seconds(), 0);
+ Timestamp now(Milliseconds(curTimeMillis64()).total_seconds(), 0);
while (r.getHost().empty()) {
// We must prime the sync source selector so that it considers all candidates regardless
@@ -391,7 +391,7 @@ namespace {
std::deque<BSONObj> ops;
ops.push_back(lastOp);
- OpTime lastOptime = writeOpsToOplog(&txn, ops);
+ Timestamp lastOptime = writeOpsToOplog(&txn, ops);
ReplClientInfo::forClient(txn.getClient()).setLastOp(lastOptime);
replCoord->setMyLastOptime(lastOptime);
setNewOptime(lastOptime);
@@ -443,7 +443,7 @@ namespace {
{
ScopedTransaction scopedXact(&txn, MODE_IX);
AutoGetDb autodb(&txn, "local", MODE_X);
- OpTime lastOpTimeWritten(getGlobalReplicationCoordinator()->getMyLastOptime());
+ Timestamp lastOpTimeWritten(getGlobalReplicationCoordinator()->getMyLastOptime());
log() << "set minValid=" << lastOpTimeWritten;
// Initial sync is now complete. Flag this by setting minValid to the last thing
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 22870e6de7e..0d1f4f79929 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -146,7 +146,7 @@ namespace {
set<string> collectionsToResync;
- OpTime commonPoint;
+ Timestamp commonPoint;
RecordId commonPointOurDiskloc;
int rbid; // remote server's current rollback sequence #
@@ -286,9 +286,9 @@ namespace {
if (oplogCursor.get() == NULL || !oplogCursor->more())
throw RSFatalException("remote oplog empty or unreadable");
- OpTime ourTime = ourObj["ts"]._opTime();
+ Timestamp ourTime = ourObj["ts"].timestamp();
BSONObj theirObj = oplogCursor->nextSafe();
- OpTime theirTime = theirObj["ts"]._opTime();
+ Timestamp theirTime = theirObj["ts"].timestamp();
long long diff = static_cast<long long>(ourTime.getSecs())
- static_cast<long long>(theirTime.getSecs());
@@ -328,7 +328,7 @@ namespace {
throw RSFatalException("RS100 reached beginning of remote oplog [2]");
}
theirObj = oplogCursor->nextSafe();
- theirTime = theirObj["ts"]._opTime();
+ theirTime = theirObj["ts"].timestamp();
if (PlanExecutor::ADVANCED != exec->getNext(&ourObj, &ourLoc)) {
severe() << "rollback error RS101 reached beginning of local oplog";
@@ -337,7 +337,7 @@ namespace {
log() << " ourTime: " << ourTime.toStringLong();
throw RSFatalException("RS101 reached beginning of local oplog [1]");
}
- ourTime = ourObj["ts"]._opTime();
+ ourTime = ourObj["ts"].timestamp();
}
else if (theirTime > ourTime) {
if (!oplogCursor->more()) {
@@ -349,7 +349,7 @@ namespace {
throw RSFatalException("RS100 reached beginning of remote oplog [1]");
}
theirObj = oplogCursor->nextSafe();
- theirTime = theirObj["ts"]._opTime();
+ theirTime = theirObj["ts"].timestamp();
}
else {
// theirTime < ourTime
@@ -361,7 +361,7 @@ namespace {
log() << " ourTime: " << ourTime.toStringLong();
throw RSFatalException("RS101 reached beginning of local oplog [2]");
}
- ourTime = ourObj["ts"]._opTime();
+ ourTime = ourObj["ts"].timestamp();
}
}
}
@@ -449,7 +449,7 @@ namespace {
// we have items we are writing that aren't from a point-in-time. thus best not to come
// online until we get to that point in freshness.
- OpTime minValid = newMinValid["ts"]._opTime();
+ Timestamp minValid = newMinValid["ts"].timestamp();
log() << "minvalid=" << minValid.toStringLong();
setMinValid(txn, minValid);
@@ -499,7 +499,7 @@ namespace {
err = "can't get minvalid from sync source";
}
else {
- OpTime minValid = newMinValid["ts"]._opTime();
+ Timestamp minValid = newMinValid["ts"].timestamp();
log() << "minvalid=" << minValid.toStringLong();
setMinValid(txn, minValid);
}
@@ -807,13 +807,13 @@ namespace {
} // namespace
void syncRollback(OperationContext* txn,
- OpTime lastOpTimeApplied,
+ Timestamp lastOpTimeApplied,
OplogReader* oplogreader,
ReplicationCoordinator* replCoord) {
// check that we are at minvalid, otherwise we cannot rollback as we may be in an
// inconsistent state
{
- OpTime minvalid = getMinValid(txn);
+ Timestamp minvalid = getMinValid(txn);
if( minvalid > lastOpTimeApplied ) {
severe() << "need to rollback, but in inconsistent state" << endl;
log() << "minvalid: " << minvalid.toString() << " our last optime: "
diff --git a/src/mongo/db/repl/rs_rollback.h b/src/mongo/db/repl/rs_rollback.h
index 8c5644f816a..55f1b887d92 100644
--- a/src/mongo/db/repl/rs_rollback.h
+++ b/src/mongo/db/repl/rs_rollback.h
@@ -30,7 +30,7 @@
namespace mongo {
class OperationContext;
- class OpTime;
+ class Timestamp;
namespace repl {
class OplogReader;
@@ -59,7 +59,7 @@ namespace repl {
*/
void syncRollback(OperationContext* txn,
- OpTime lastOpTimeWritten,
+ Timestamp lastOpTimeWritten,
OplogReader* oplogreader,
ReplicationCoordinator* replCoord);
diff --git a/src/mongo/db/repl/sync_source_feedback.h b/src/mongo/db/repl/sync_source_feedback.h
index 0e3fccccfac..054f6d6b183 100644
--- a/src/mongo/db/repl/sync_source_feedback.h
+++ b/src/mongo/db/repl/sync_source_feedback.h
@@ -31,7 +31,7 @@
#include <boost/scoped_ptr.hpp>
#include <boost/thread/mutex.hpp>
-#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/condition.hpp>
#include "mongo/client/constants.h"
#include "mongo/client/dbclientcursor.h"
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 7b6349a1738..40f70579704 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -266,7 +266,7 @@ namespace repl {
}
// Doles out all the work to the writer pool threads and waits for them to complete
- OpTime SyncTail::multiApply(OperationContext* txn, std::deque<BSONObj>& ops) {
+ Timestamp SyncTail::multiApply(OperationContext* txn, std::deque<BSONObj>& ops) {
if (getGlobalServiceContext()->getGlobalStorageEngine()->isMmapV1()) {
// Use a ThreadPool to prefetch all the operations in a batch.
@@ -297,13 +297,13 @@ namespace repl {
applyOps(writerVectors);
if (inShutdown()) {
- return OpTime();
+ return Timestamp();
}
if (mustAwaitCommit) {
txn->recoveryUnit()->goingToAwaitCommit();
}
- OpTime lastOpTime = writeOpsToOplog(txn, ops);
+ Timestamp lastOpTime = writeOpsToOplog(txn, ops);
// Wait for journal before setting last op time if any op in batch had j:true
if (mustAwaitCommit) {
txn->recoveryUnit()->awaitCommit();
@@ -359,12 +359,12 @@ namespace repl {
(*writerVectors)[hash % writerVectors->size()].push_back(*it);
}
}
- void SyncTail::oplogApplication(OperationContext* txn, const OpTime& endOpTime) {
+ void SyncTail::oplogApplication(OperationContext* txn, const Timestamp& endOpTime) {
_applyOplogUntil(txn, endOpTime);
}
/* applies oplog from "now" until endOpTime using the applier threads for initial sync*/
- void SyncTail::_applyOplogUntil(OperationContext* txn, const OpTime& endOpTime) {
+ void SyncTail::_applyOplogUntil(OperationContext* txn, const Timestamp& endOpTime) {
unsigned long long bytesApplied = 0;
unsigned long long entriesApplied = 0;
while (true) {
@@ -376,7 +376,7 @@ namespace repl {
// Check if we reached the end
const BSONObj currentOp = ops.back();
- const OpTime currentOpTime = currentOp["ts"]._opTime();
+ const Timestamp currentOpTime = currentOp["ts"].timestamp();
// When we reach the end return this batch
if (currentOpTime == endOpTime) {
@@ -406,7 +406,7 @@ namespace repl {
bytesApplied += ops.getSize();
entriesApplied += ops.getDeque().size();
- const OpTime lastOpTime = multiApply(txn, ops.getDeque());
+ const Timestamp lastOpTime = multiApply(txn, ops.getDeque());
if (inShutdown()) {
return;
@@ -442,7 +442,7 @@ namespace {
return;
}
- OpTime minvalid = getMinValid(txn);
+ Timestamp minvalid = getMinValid(txn);
if (minvalid > replCoord->getMyLastOptime()) {
return;
}
@@ -495,7 +495,7 @@ namespace {
const int slaveDelaySecs = replCoord->getSlaveDelaySecs().total_seconds();
if (!ops.empty() && slaveDelaySecs > 0) {
const BSONObj& lastOp = ops.getDeque().back();
- const unsigned int opTimestampSecs = lastOp["ts"]._opTime().getSecs();
+ const unsigned int opTimestampSecs = lastOp["ts"].timestamp().getSecs();
// Stop the batch as the lastOp is too new to be applied. If we continue
// on, we can get ops that are way ahead of the delay and this will
@@ -527,7 +527,7 @@ namespace {
// Set minValid to the last op to be applied in this next batch.
// This will cause this node to go into RECOVERING state
// if we should crash and restart before updating the oplog
- OpTime minValid = lastOp["ts"]._opTime();
+ Timestamp minValid = lastOp["ts"].timestamp();
setMinValid(&txn, minValid);
multiApply(&txn, ops.getDeque());
}
@@ -617,7 +617,7 @@ namespace {
// ignore slaveDelay if the box is still initializing. once
// it becomes secondary we can worry about it.
if( slaveDelaySecs > 0 && replCoord->getMemberState().secondary() ) {
- const OpTime ts = lastOp["ts"]._opTime();
+ const Timestamp ts = lastOp["ts"].timestamp();
long long a = ts.getSecs();
long long b = time(0);
long long lag = b - a;
diff --git a/src/mongo/db/repl/sync_tail.h b/src/mongo/db/repl/sync_tail.h
index 5932634362e..68e5f546845 100644
--- a/src/mongo/db/repl/sync_tail.h
+++ b/src/mongo/db/repl/sync_tail.h
@@ -57,7 +57,7 @@ namespace repl {
/**
* Runs _applyOplogUntil(stopOpTime)
*/
- virtual void oplogApplication(OperationContext* txn, const OpTime& stopOpTime);
+ virtual void oplogApplication(OperationContext* txn, const Timestamp& stopOpTime);
void oplogApplication();
bool peek(BSONObj* obj);
@@ -101,14 +101,14 @@ namespace repl {
// Prefetch and write a deque of operations, using the supplied function.
// Initial Sync and Sync Tail each use a different function.
// Returns the last OpTime applied.
- OpTime multiApply(OperationContext* txn, std::deque<BSONObj>& ops);
+ Timestamp multiApply(OperationContext* txn, std::deque<BSONObj>& ops);
/**
* Applies oplog entries until reaching "endOpTime".
*
* NOTE:Will not transition or check states
*/
- void _applyOplogUntil(OperationContext* txn, const OpTime& endOpTime);
+ void _applyOplogUntil(OperationContext* txn, const Timestamp& endOpTime);
private:
BackgroundSyncInterface* _networkQueue;
diff --git a/src/mongo/db/repl/topology_coordinator.h b/src/mongo/db/repl/topology_coordinator.h
index 1da4aa09642..fe8edd37333 100644
--- a/src/mongo/db/repl/topology_coordinator.h
+++ b/src/mongo/db/repl/topology_coordinator.h
@@ -41,7 +41,7 @@
namespace mongo {
class OperationContext;
- class OpTime;
+ class Timestamp;
namespace repl {
@@ -117,7 +117,7 @@ namespace repl {
/**
* Chooses and sets a new sync source, based on our current knowledge of the world.
*/
- virtual HostAndPort chooseNewSyncSource(Date_t now, const OpTime& lastOpApplied) = 0;
+ virtual HostAndPort chooseNewSyncSource(Date_t now, const Timestamp& lastOpApplied) = 0;
/**
* Suppresses selecting "host" as sync source until "until".
@@ -185,21 +185,21 @@ namespace repl {
// produces a reply to a replSetSyncFrom command
virtual void prepareSyncFromResponse(const ReplicationExecutor::CallbackData& data,
const HostAndPort& target,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
BSONObjBuilder* response,
Status* result) = 0;
// produce a reply to a replSetFresh command
virtual void prepareFreshResponse(const ReplicationCoordinator::ReplSetFreshArgs& args,
Date_t now,
- OpTime lastOpApplied,
+ Timestamp lastOpApplied,
BSONObjBuilder* response,
Status* result) = 0;
// produce a reply to a received electCmd
virtual void prepareElectResponse(const ReplicationCoordinator::ReplSetElectArgs& args,
Date_t now,
- OpTime lastOpApplied,
+ Timestamp lastOpApplied,
BSONObjBuilder* response,
Status* result) = 0;
@@ -207,14 +207,14 @@ namespace repl {
virtual Status prepareHeartbeatResponse(Date_t now,
const ReplSetHeartbeatArgs& args,
const std::string& ourSetName,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
ReplSetHeartbeatResponse* response) = 0;
// produce a reply to a status request
virtual void prepareStatusResponse(const ReplicationExecutor::CallbackData& data,
Date_t now,
unsigned uptime,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
BSONObjBuilder* response,
Status* result) = 0;
@@ -246,7 +246,7 @@ namespace repl {
virtual void updateConfig(const ReplicaSetConfig& newConfig,
int selfIndex,
Date_t now,
- OpTime lastOpApplied) = 0;
+ Timestamp lastOpApplied) = 0;
/**
* Prepares a heartbeat request appropriate for sending to "target", assuming the
@@ -296,7 +296,7 @@ namespace repl {
Milliseconds networkRoundTripTime,
const HostAndPort& target,
const StatusWith<ReplSetHeartbeatResponse>& hbResponse,
- OpTime myLastOpApplied) = 0;
+ Timestamp myLastOpApplied) = 0;
/**
* If getRole() == Role::candidate and this node has not voted too recently, updates the
@@ -312,7 +312,7 @@ namespace repl {
* Exactly one of either processWinElection or processLoseElection must be called if
* processHeartbeatResponse returns StartElection, to exit candidate mode.
*/
- virtual void processWinElection(OID electionId, OpTime electionOpTime) = 0;
+ virtual void processWinElection(OID electionId, Timestamp electionOpTime) = 0;
/**
* Performs state updates associated with losing an election.
@@ -332,7 +332,7 @@ namespace repl {
*
* Returns whether or not the step down succeeded.
*/
- virtual bool stepDown(Date_t until, bool force, OpTime lastOpApplied) = 0;
+ virtual bool stepDown(Date_t until, bool force, Timestamp lastOpApplied) = 0;
/**
* Sometimes a request to step down comes in (like via a heartbeat), but we don't have the
@@ -348,7 +348,7 @@ namespace repl {
* Considers whether or not this node should stand for election, and returns true
* if the node has transitioned to candidate role as a result of the call.
*/
- virtual bool checkShouldStandForElection(Date_t now, const OpTime& lastOpApplied) = 0;
+ virtual bool checkShouldStandForElection(Date_t now, const Timestamp& lastOpApplied) = 0;
/**
* Set the outgoing heartbeat message from self
diff --git a/src/mongo/db/repl/topology_coordinator_impl.cpp b/src/mongo/db/repl/topology_coordinator_impl.cpp
index 7e964ef0d8b..1d019eec216 100644
--- a/src/mongo/db/repl/topology_coordinator_impl.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl.cpp
@@ -149,7 +149,7 @@ namespace {
}
HostAndPort TopologyCoordinatorImpl::chooseNewSyncSource(Date_t now,
- const OpTime& lastOpApplied) {
+ const Timestamp& lastOpApplied) {
// If we are primary, then we aren't syncing from anyone (else).
if (_iAmPrimary()) {
return HostAndPort();
@@ -211,23 +211,23 @@ namespace {
// Find primary's oplog time. Reject sync candidates that are more than
// maxSyncSourceLagSecs seconds behind.
- OpTime primaryOpTime;
+ Timestamp primaryOpTime;
if (_currentPrimaryIndex != -1) {
primaryOpTime = _hbdata[_currentPrimaryIndex].getOpTime();
}
else {
// choose a time that will exclude no candidates, since we don't see a primary
- primaryOpTime = OpTime(_maxSyncSourceLagSecs.total_seconds(), 0);
+ primaryOpTime = Timestamp(_maxSyncSourceLagSecs.total_seconds(), 0);
}
if (primaryOpTime.getSecs() <
static_cast<unsigned int>(_maxSyncSourceLagSecs.total_seconds())) {
// erh - I think this means there was just a new election
// and we don't yet know the new primary's optime
- primaryOpTime = OpTime(_maxSyncSourceLagSecs.total_seconds(), 0);
+ primaryOpTime = Timestamp(_maxSyncSourceLagSecs.total_seconds(), 0);
}
- OpTime oldestSyncOpTime(primaryOpTime.getSecs() - _maxSyncSourceLagSecs.total_seconds(), 0);
+ Timestamp oldestSyncOpTime(primaryOpTime.getSecs() - _maxSyncSourceLagSecs.total_seconds(), 0);
int closestIndex = -1;
@@ -348,7 +348,7 @@ namespace {
void TopologyCoordinatorImpl::prepareSyncFromResponse(
const ReplicationExecutor::CallbackData& data,
const HostAndPort& target,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
BSONObjBuilder* response,
Status* result) {
if (data.status == ErrorCodes::CallbackCanceled) {
@@ -442,7 +442,7 @@ namespace {
void TopologyCoordinatorImpl::prepareFreshResponse(
const ReplicationCoordinator::ReplSetFreshArgs& args,
const Date_t now,
- const OpTime lastOpApplied,
+ const Timestamp lastOpApplied,
BSONObjBuilder* response,
Status* result) {
@@ -478,7 +478,7 @@ namespace {
else if (args.opTime < _latestKnownOpTime(lastOpApplied)) {
weAreFresher = true;
}
- response->appendDate("opTime", lastOpApplied.asDate());
+ response->appendDate("opTime", lastOpApplied.asULL());
response->append("fresher", weAreFresher);
std::string errmsg;
@@ -493,7 +493,7 @@ namespace {
bool TopologyCoordinatorImpl::_shouldVetoMember(
const ReplicationCoordinator::ReplSetFreshArgs& args,
const Date_t& now,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
std::string* errmsg) const {
if (_rsConfig.getConfigVersion() < args.cfgver) {
@@ -564,7 +564,7 @@ namespace {
void TopologyCoordinatorImpl::prepareElectResponse(
const ReplicationCoordinator::ReplSetElectArgs& args,
const Date_t now,
- const OpTime lastOpApplied,
+ const Timestamp lastOpApplied,
BSONObjBuilder* response,
Status* result) {
@@ -648,7 +648,7 @@ namespace {
Date_t now,
const ReplSetHeartbeatArgs& args,
const std::string& ourSetName,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
ReplSetHeartbeatResponse* response) {
if (args.getProtocolVersion() != 1) {
@@ -802,7 +802,7 @@ namespace {
Milliseconds networkRoundTripTime,
const HostAndPort& target,
const StatusWith<ReplSetHeartbeatResponse>& hbResponse,
- OpTime myLastOpApplied) {
+ Timestamp myLastOpApplied) {
const MemberState originalState = getMemberState();
PingStats& hbStats = _pings[target];
@@ -928,7 +928,7 @@ namespace {
int updatedConfigIndex,
const MemberState& originalState,
Date_t now,
- const OpTime& lastOpApplied) {
+ const Timestamp& lastOpApplied) {
// This method has two interrelated responsibilities, performed in two phases.
//
@@ -970,13 +970,13 @@ namespace {
_rsConfig.getMemberAt(_currentPrimaryIndex);
const MemberConfig& highestPriorityMember =
_rsConfig.getMemberAt(highestPriorityIndex);
- const OpTime highestPriorityMemberOptime = highestPriorityIndex == _selfIndex ?
+ const Timestamp highestPriorityMemberOptime = highestPriorityIndex == _selfIndex ?
lastOpApplied : _hbdata[highestPriorityIndex].getOpTime();
if ((highestPriorityMember.getPriority() > currentPrimaryMember.getPriority()) &&
_isOpTimeCloseEnoughToLatestToElect(highestPriorityMemberOptime,
lastOpApplied)) {
- const OpTime latestOpTime = _latestKnownOpTime(lastOpApplied);
+ const Timestamp latestOpTime = _latestKnownOpTime(lastOpApplied);
if (_iAmPrimary()) {
if (_stepDownPending) {
@@ -1050,7 +1050,7 @@ namespace {
// If we are also primary, this is a problem. Determine who should step down.
if (_iAmPrimary()) {
- OpTime remoteElectionTime = _hbdata[remotePrimaryIndex].getElectionTime();
+ Timestamp remoteElectionTime = _hbdata[remotePrimaryIndex].getElectionTime();
log() << "another primary seen with election time "
<< remoteElectionTime << " my election time is " << _electionTime;
@@ -1122,7 +1122,7 @@ namespace {
}
bool TopologyCoordinatorImpl::checkShouldStandForElection(
- Date_t now, const OpTime& lastOpApplied) {
+ Date_t now, const Timestamp& lastOpApplied) {
if (_currentPrimaryIndex != -1) {
return false;
}
@@ -1170,8 +1170,8 @@ namespace {
}
bool TopologyCoordinatorImpl::_isOpTimeCloseEnoughToLatestToElect(
- const OpTime& otherOpTime, const OpTime& ourLastOpApplied) const {
- const OpTime latestKnownOpTime = _latestKnownOpTime(ourLastOpApplied);
+ const Timestamp& otherOpTime, const Timestamp& ourLastOpApplied) const {
+ const Timestamp latestKnownOpTime = _latestKnownOpTime(ourLastOpApplied);
// Use addition instead of subtraction to avoid overflow.
return otherOpTime.getSecs() + 10 >= (latestKnownOpTime.getSecs());
}
@@ -1184,8 +1184,8 @@ namespace {
return false;
}
- OpTime TopologyCoordinatorImpl::_latestKnownOpTime(OpTime ourLastOpApplied) const {
- OpTime latest = ourLastOpApplied;
+ Timestamp TopologyCoordinatorImpl::_latestKnownOpTime(Timestamp ourLastOpApplied) const {
+ Timestamp latest = ourLastOpApplied;
for (std::vector<MemberHeartbeatData>::const_iterator it = _hbdata.begin();
it != _hbdata.end();
@@ -1198,7 +1198,7 @@ namespace {
continue;
}
- OpTime optime = it->getOpTime();
+ Timestamp optime = it->getOpTime();
if (optime > latest) {
latest = optime;
@@ -1221,7 +1221,7 @@ namespace {
}
int TopologyCoordinatorImpl::_getHighestPriorityElectableIndex(
- Date_t now, OpTime lastOpApplied) const {
+ Date_t now, Timestamp lastOpApplied) const {
int maxIndex = -1;
for (int currentIndex = 0; currentIndex < _rsConfig.getNumMembers(); currentIndex++) {
UnelectableReasonMask reason = currentIndex == _selfIndex ?
@@ -1236,7 +1236,7 @@ namespace {
}
void TopologyCoordinatorImpl::changeMemberState_forTest(const MemberState& newMemberState,
- OpTime electionTime) {
+ Timestamp electionTime) {
invariant(_selfIndex != -1);
if (newMemberState == getMemberState())
return;
@@ -1262,7 +1262,7 @@ namespace {
ReplicaSetConfig(),
-1,
Date_t(),
- OpTime());
+ Timestamp());
break;
default:
severe() << "Cannot switch to state " << newMemberState;
@@ -1287,7 +1287,7 @@ namespace {
if (primaryIndex != -1) {
ReplSetHeartbeatResponse hbResponse;
hbResponse.setState(MemberState::RS_PRIMARY);
- hbResponse.setElectionTime(OpTime());
+ hbResponse.setElectionTime(Timestamp());
hbResponse.setOpTime(_hbdata[primaryIndex].getOpTime());
hbResponse.setSyncingTo("");
hbResponse.setHbMsg("");
@@ -1311,7 +1311,7 @@ namespace {
const ReplicationExecutor::CallbackData& data,
Date_t now,
unsigned selfUptime,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
BSONObjBuilder* response,
Status* result) {
if (data.status == ErrorCodes::CallbackCanceled) {
@@ -1577,7 +1577,7 @@ namespace {
}
}
- OpTime TopologyCoordinatorImpl::getElectionTime() const {
+ Timestamp TopologyCoordinatorImpl::getElectionTime() const {
return _electionTime;
}
@@ -1631,7 +1631,7 @@ namespace {
void TopologyCoordinatorImpl::updateConfig(const ReplicaSetConfig& newConfig,
int selfIndex,
Date_t now,
- OpTime lastOpApplied) {
+ Timestamp lastOpApplied) {
invariant(_role != Role::candidate);
invariant(selfIndex < newConfig.getNumMembers());
@@ -1689,7 +1689,7 @@ namespace {
TopologyCoordinatorImpl::UnelectableReasonMask TopologyCoordinatorImpl::_getUnelectableReason(
int index,
- const OpTime& lastOpApplied) const {
+ const Timestamp& lastOpApplied) const {
invariant(index != _selfIndex);
const MemberConfig& memberConfig = _rsConfig.getMemberAt(index);
const MemberHeartbeatData& hbData = _hbdata[index];
@@ -1715,7 +1715,7 @@ namespace {
TopologyCoordinatorImpl::UnelectableReasonMask TopologyCoordinatorImpl::_getMyUnelectableReason(
const Date_t now,
- const OpTime lastApplied) const {
+ const Timestamp lastApplied) const {
UnelectableReasonMask result = None;
if (lastApplied.isNull()) {
@@ -1838,7 +1838,7 @@ namespace {
return _pings[host].getMillis();
}
- void TopologyCoordinatorImpl::_setElectionTime(const OpTime& newElectionTime) {
+ void TopologyCoordinatorImpl::_setElectionTime(const Timestamp& newElectionTime) {
_electionTime = newElectionTime;
}
@@ -1913,7 +1913,7 @@ namespace {
void TopologyCoordinatorImpl::processWinElection(
OID electionId,
- OpTime electionOpTime) {
+ Timestamp electionOpTime) {
invariant(_role == Role::candidate);
_electionTime = electionOpTime;
_electionId = electionId;
@@ -1926,7 +1926,7 @@ namespace {
void TopologyCoordinatorImpl::processLoseElection() {
invariant(_role == Role::candidate);
const HostAndPort syncSourceAddress = getSyncSourceAddress();
- _electionTime = OpTime(0, 0);
+ _electionTime = Timestamp(0, 0);
_electionId = OID();
_role = Role::follower;
@@ -1937,7 +1937,7 @@ namespace {
}
}
- bool TopologyCoordinatorImpl::stepDown(Date_t until, bool force, OpTime lastOpApplied) {
+ bool TopologyCoordinatorImpl::stepDown(Date_t until, bool force, Timestamp lastOpApplied) {
bool canStepDown = force;
for (int i = 0; !canStepDown && i < _rsConfig.getNumMembers(); ++i) {
if (i == _selfIndex) {
@@ -2051,7 +2051,7 @@ namespace {
}
invariant(currentMemberIndex != _selfIndex);
- OpTime currentOpTime = _hbdata[currentMemberIndex].getOpTime();
+ Timestamp currentOpTime = _hbdata[currentMemberIndex].getOpTime();
if (currentOpTime.isNull()) {
// Haven't received a heartbeat from the sync source yet, so can't tell if we should
// change.
diff --git a/src/mongo/db/repl/topology_coordinator_impl.h b/src/mongo/db/repl/topology_coordinator_impl.h
index 3e9c9a48c18..e8d0d42a46a 100644
--- a/src/mongo/db/repl/topology_coordinator_impl.h
+++ b/src/mongo/db/repl/topology_coordinator_impl.h
@@ -31,7 +31,7 @@
#include <string>
#include <vector>
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/repl/member_heartbeat_data.h"
#include "mongo/db/repl/member_state.h"
#include "mongo/db/repl/replica_set_config.h"
@@ -127,7 +127,7 @@ namespace repl {
virtual int getMaintenanceCount() const;
virtual void setForceSyncSourceIndex(int index);
virtual HostAndPort chooseNewSyncSource(Date_t now,
- const OpTime& lastOpApplied);
+ const Timestamp& lastOpApplied);
virtual void blacklistSyncSource(const HostAndPort& host, Date_t until);
virtual void unblacklistSyncSource(const HostAndPort& host, Date_t now);
virtual void clearSyncSourceBlacklist();
@@ -138,28 +138,28 @@ namespace repl {
virtual void adjustMaintenanceCountBy(int inc);
virtual void prepareSyncFromResponse(const ReplicationExecutor::CallbackData& data,
const HostAndPort& target,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
BSONObjBuilder* response,
Status* result);
virtual void prepareFreshResponse(const ReplicationCoordinator::ReplSetFreshArgs& args,
Date_t now,
- OpTime lastOpApplied,
+ Timestamp lastOpApplied,
BSONObjBuilder* response,
Status* result);
virtual void prepareElectResponse(const ReplicationCoordinator::ReplSetElectArgs& args,
Date_t now,
- OpTime lastOpApplied,
+ Timestamp lastOpApplied,
BSONObjBuilder* response,
Status* result);
virtual Status prepareHeartbeatResponse(Date_t now,
const ReplSetHeartbeatArgs& args,
const std::string& ourSetName,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
ReplSetHeartbeatResponse* response);
virtual void prepareStatusResponse(const ReplicationExecutor::CallbackData& data,
Date_t now,
unsigned uptime,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
BSONObjBuilder* response,
Status* result);
virtual void fillIsMasterForReplSet(IsMasterResponse* response);
@@ -167,7 +167,7 @@ namespace repl {
virtual void updateConfig(const ReplicaSetConfig& newConfig,
int selfIndex,
Date_t now,
- OpTime lastOpApplied);
+ Timestamp lastOpApplied);
virtual std::pair<ReplSetHeartbeatArgs, Milliseconds> prepareHeartbeatRequest(
Date_t now,
const std::string& ourSetName,
@@ -177,13 +177,13 @@ namespace repl {
Milliseconds networkRoundTripTime,
const HostAndPort& target,
const StatusWith<ReplSetHeartbeatResponse>& hbResponse,
- OpTime myLastOpApplied);
+ Timestamp myLastOpApplied);
virtual bool voteForMyself(Date_t now);
- virtual void processWinElection(OID electionId, OpTime electionOpTime);
+ virtual void processWinElection(OID electionId, Timestamp electionOpTime);
virtual void processLoseElection();
- virtual bool checkShouldStandForElection(Date_t now, const OpTime& lastOpApplied);
+ virtual bool checkShouldStandForElection(Date_t now, const Timestamp& lastOpApplied);
virtual void setMyHeartbeatMessage(const Date_t now, const std::string& message);
- virtual bool stepDown(Date_t until, bool force, OpTime lastOpApplied);
+ virtual bool stepDown(Date_t until, bool force, Timestamp lastOpApplied);
virtual bool stepDownIfPending();
virtual Date_t getStepDownTime() const;
@@ -195,10 +195,10 @@ namespace repl {
// Changes _memberState to newMemberState. Only for testing.
void changeMemberState_forTest(const MemberState& newMemberState,
- OpTime electionTime = OpTime(0,0));
+ Timestamp electionTime = Timestamp(0,0));
// Sets "_electionTime" to "newElectionTime". Only for testing.
- void _setElectionTime(const OpTime& newElectionTime);
+ void _setElectionTime(const Timestamp& newElectionTime);
// Sets _currentPrimaryIndex to the given index. Should only be used in unit tests!
// TODO(spencer): Remove this once we can easily call for an election in unit tests to
@@ -206,7 +206,7 @@ namespace repl {
void _setCurrentPrimaryForTest(int primaryIndex);
// Returns _electionTime. Only used in unittests.
- OpTime getElectionTime() const;
+ Timestamp getElectionTime() const;
// Returns _electionId. Only used in unittests.
OID getElectionId() const;
@@ -242,7 +242,7 @@ namespace repl {
// If we veto, the errmsg will be filled in with a reason
bool _shouldVetoMember(const ReplicationCoordinator::ReplSetFreshArgs& args,
const Date_t& now,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
std::string* errmsg) const;
// Returns the index of the member with the matching id, or -1 if none match.
@@ -253,18 +253,18 @@ namespace repl {
// Is otherOpTime close enough (within 10 seconds) to the latest known optime to qualify
// for an election
- bool _isOpTimeCloseEnoughToLatestToElect(const OpTime& otherOpTime,
- const OpTime& ourLastOpApplied) const;
+ bool _isOpTimeCloseEnoughToLatestToElect(const Timestamp& otherOpTime,
+ const Timestamp& ourLastOpApplied) const;
// Returns reason why "self" member is unelectable
UnelectableReasonMask _getMyUnelectableReason(
const Date_t now,
- const OpTime lastOpApplied) const;
+ const Timestamp lastOpApplied) const;
// Returns reason why memberIndex is unelectable
UnelectableReasonMask _getUnelectableReason(
int memberIndex,
- const OpTime& lastOpApplied) const;
+ const Timestamp& lastOpApplied) const;
// Returns the nice text of why the node is unelectable
std::string _getUnelectableReasonString(UnelectableReasonMask ur) const;
@@ -273,10 +273,10 @@ namespace repl {
bool _iAmPrimary() const;
// Scans through all members that are 'up' and return the latest known optime.
- OpTime _latestKnownOpTime(OpTime ourLastOpApplied) const;
+ Timestamp _latestKnownOpTime(Timestamp ourLastOpApplied) const;
// Scans the electable set and returns the highest priority member index
- int _getHighestPriorityElectableIndex(Date_t now, OpTime lastOpApplied) const;
+ int _getHighestPriorityElectableIndex(Date_t now, Timestamp lastOpApplied) const;
// Returns true if "one" member is higher priority than "two" member
bool _isMemberHigherPriority(int memberOneIndex, int memberTwoIndex) const;
@@ -294,7 +294,7 @@ namespace repl {
int updatedConfigIndex,
const MemberState& originalState,
Date_t now,
- const OpTime& lastOpApplied);
+ const Timestamp& lastOpApplied);
/**
* Updates _hbdata based on the newConfig, ensuring that every member in the newConfig
@@ -325,7 +325,7 @@ namespace repl {
// result of an election.
OID _electionId;
// The time at which the current PRIMARY was elected.
- OpTime _electionTime;
+ Timestamp _electionTime;
// the index of the member we currently believe is primary, if one exists, otherwise -1
int _currentPrimaryIndex;
diff --git a/src/mongo/db/repl/topology_coordinator_impl_test.cpp b/src/mongo/db/repl/topology_coordinator_impl_test.cpp
index 2ec2cd2b89c..ce99ca62ee9 100644
--- a/src/mongo/db/repl/topology_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl_test.cpp
@@ -83,7 +83,7 @@ namespace {
needle));
}
- void makeSelfPrimary(const OpTime& electionOpTime = OpTime(0,0)) {
+ void makeSelfPrimary(const Timestamp& electionOpTime = Timestamp(0,0)) {
getTopoCoord().changeMemberState_forTest(MemberState::RS_PRIMARY, electionOpTime);
getTopoCoord()._setCurrentPrimaryForTest(_selfIndex);
}
@@ -100,7 +100,7 @@ namespace {
void updateConfig(BSONObj cfg,
int selfIndex,
Date_t now = Date_t(-1),
- OpTime lastOp = OpTime()) {
+ Timestamp lastOp = Timestamp()) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(cfg));
ASSERT_OK(config.validate());
@@ -121,9 +121,9 @@ namespace {
const HostAndPort& member,
const std::string& setName,
MemberState memberState,
- OpTime electionTime,
- OpTime lastOpTimeSender,
- OpTime lastOpTimeReceiver) {
+ Timestamp electionTime,
+ Timestamp lastOpTimeSender,
+ Timestamp lastOpTimeReceiver) {
return _receiveHeartbeatHelper(Status::OK(),
member,
setName,
@@ -137,14 +137,14 @@ namespace {
HeartbeatResponseAction receiveDownHeartbeat(
const HostAndPort& member,
const std::string& setName,
- OpTime lastOpTimeReceiver,
+ Timestamp lastOpTimeReceiver,
ErrorCodes::Error errcode = ErrorCodes::HostUnreachable) {
return _receiveHeartbeatHelper(Status(errcode, ""),
member,
setName,
MemberState::RS_UNKNOWN,
- OpTime(),
- OpTime(),
+ Timestamp(),
+ Timestamp(),
lastOpTimeReceiver,
Milliseconds(0));
}
@@ -152,15 +152,15 @@ namespace {
HeartbeatResponseAction heartbeatFromMember(const HostAndPort& member,
const std::string& setName,
MemberState memberState,
- OpTime lastOpTimeSender,
+ Timestamp lastOpTimeSender,
Milliseconds roundTripTime = Milliseconds(0)) {
return _receiveHeartbeatHelper(Status::OK(),
member,
setName,
memberState,
- OpTime(),
+ Timestamp(),
lastOpTimeSender,
- OpTime(),
+ Timestamp(),
roundTripTime);
}
@@ -170,9 +170,9 @@ namespace {
const HostAndPort& member,
const std::string& setName,
MemberState memberState,
- OpTime electionTime,
- OpTime lastOpTimeSender,
- OpTime lastOpTimeReceiver,
+ Timestamp electionTime,
+ Timestamp lastOpTimeSender,
+ Timestamp lastOpTimeReceiver,
Milliseconds roundTripTime) {
StatusWith<ReplSetHeartbeatResponse> hbResponse =
StatusWith<ReplSetHeartbeatResponse>(responseStatus);
@@ -204,7 +204,7 @@ namespace {
TEST_F(TopoCoordTest, ChooseSyncSourceBasic) {
// if we do not have an index in the config, we should get an empty syncsource
- HostAndPort newSyncSource = getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ HostAndPort newSyncSource = getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_TRUE(newSyncSource.empty());
updateConfig(BSON("_id" << "rs0" <<
@@ -217,49 +217,49 @@ namespace {
setSelfMemberState(MemberState::RS_SECONDARY);
// member h2 is the furthest ahead
- heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, OpTime(1,0));
- heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, OpTime(0,0));
+ heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, Timestamp(1,0));
+ heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, Timestamp(0,0));
// We start with no sync source
ASSERT(getTopoCoord().getSyncSourceAddress().empty());
// Fail due to insufficient number of pings
- newSyncSource = getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ newSyncSource = getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(getTopoCoord().getSyncSourceAddress(), newSyncSource);
ASSERT(getTopoCoord().getSyncSourceAddress().empty());
// Record 2nd round of pings to allow choosing a new sync source; all members equidistant
- heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, OpTime(1,0));
- heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, OpTime(0,0));
+ heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, Timestamp(1,0));
+ heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, Timestamp(0,0));
// Should choose h2, since it is furthest ahead
- newSyncSource = getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ newSyncSource = getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(getTopoCoord().getSyncSourceAddress(), newSyncSource);
ASSERT_EQUALS(HostAndPort("h2"), getTopoCoord().getSyncSourceAddress());
// h3 becomes further ahead, so it should be chosen
- heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, OpTime(2,0));
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, Timestamp(2,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h3"), getTopoCoord().getSyncSourceAddress());
// h3 becomes an invalid candidate for sync source; should choose h2 again
- heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_RECOVERING, OpTime(2,0));
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_RECOVERING, Timestamp(2,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h2"), getTopoCoord().getSyncSourceAddress());
// h3 back in SECONDARY and ahead
- heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, OpTime(2,0));
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, Timestamp(2,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h3"), getTopoCoord().getSyncSourceAddress());
// h3 goes down
- receiveDownHeartbeat(HostAndPort("h3"), "rs0", OpTime());
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ receiveDownHeartbeat(HostAndPort("h3"), "rs0", Timestamp());
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h2"), getTopoCoord().getSyncSourceAddress());
// h3 back up and ahead
- heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, OpTime(2,0));
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, Timestamp(2,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h3"), getTopoCoord().getSyncSourceAddress());
}
@@ -282,43 +282,43 @@ namespace {
0);
setSelfMemberState(MemberState::RS_SECONDARY);
- OpTime lastOpTimeWeApplied = OpTime(100,0);
+ Timestamp lastOpTimeWeApplied = Timestamp(100,0);
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(700));
+ Timestamp(501, 0), Milliseconds(700));
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(600));
+ Timestamp(501, 0), Milliseconds(600));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(500));
+ Timestamp(501, 0), Milliseconds(500));
heartbeatFromMember(HostAndPort("h4"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(400));
+ Timestamp(501, 0), Milliseconds(400));
heartbeatFromMember(HostAndPort("h5"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(300));
+ Timestamp(501, 0), Milliseconds(300));
// This node is lagged further than maxSyncSourceLagSeconds.
heartbeatFromMember(HostAndPort("h6"), "rs0", MemberState::RS_SECONDARY,
- OpTime(499, 0), Milliseconds(200));
+ Timestamp(499, 0), Milliseconds(200));
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
heartbeatFromMember(HostAndPort("hprimary"), "rs0", MemberState::RS_PRIMARY,
- OpTime(600, 0), Milliseconds(100));
+ Timestamp(600, 0), Milliseconds(100));
ASSERT_EQUALS(7, getCurrentPrimaryIndex());
// Record 2nd round of pings to allow choosing a new sync source
heartbeatFromMember(HostAndPort("h1"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(700));
+ Timestamp(501, 0), Milliseconds(700));
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(600));
+ Timestamp(501, 0), Milliseconds(600));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(500));
+ Timestamp(501, 0), Milliseconds(500));
heartbeatFromMember(HostAndPort("h4"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(400));
+ Timestamp(501, 0), Milliseconds(400));
heartbeatFromMember(HostAndPort("h5"), "rs0", MemberState::RS_SECONDARY,
- OpTime(501, 0), Milliseconds(300));
+ Timestamp(501, 0), Milliseconds(300));
heartbeatFromMember(HostAndPort("h6"), "rs0", MemberState::RS_SECONDARY,
- OpTime(499, 0), Milliseconds(200));
+ Timestamp(499, 0), Milliseconds(200));
heartbeatFromMember(HostAndPort("hprimary"), "rs0", MemberState::RS_PRIMARY,
- OpTime(600, 0), Milliseconds(100));
+ Timestamp(600, 0), Milliseconds(100));
// Should choose primary first; it's closest
getTopoCoord().chooseNewSyncSource(now()++, lastOpTimeWeApplied);
@@ -326,7 +326,7 @@ namespace {
// Primary goes far far away
heartbeatFromMember(HostAndPort("hprimary"), "rs0", MemberState::RS_PRIMARY,
- OpTime(600, 0), Milliseconds(100000000));
+ Timestamp(600, 0), Milliseconds(100000000));
// Should choose h4. (if an arbiter has an oplog, it's a valid sync source)
// h6 is not considered because it is outside the maxSyncLagSeconds window,
@@ -334,29 +334,29 @@ namespace {
ASSERT_EQUALS(HostAndPort("h4"), getTopoCoord().getSyncSourceAddress());
// h4 goes down; should choose h1
- receiveDownHeartbeat(HostAndPort("h4"), "rs0", OpTime());
+ receiveDownHeartbeat(HostAndPort("h4"), "rs0", Timestamp());
getTopoCoord().chooseNewSyncSource(now()++, lastOpTimeWeApplied);
ASSERT_EQUALS(HostAndPort("h1"), getTopoCoord().getSyncSourceAddress());
// Primary and h1 go down; should choose h6
- receiveDownHeartbeat(HostAndPort("h1"), "rs0", OpTime());
- receiveDownHeartbeat(HostAndPort("hprimary"), "rs0", OpTime());
+ receiveDownHeartbeat(HostAndPort("h1"), "rs0", Timestamp());
+ receiveDownHeartbeat(HostAndPort("hprimary"), "rs0", Timestamp());
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
getTopoCoord().chooseNewSyncSource(now()++, lastOpTimeWeApplied);
ASSERT_EQUALS(HostAndPort("h6"), getTopoCoord().getSyncSourceAddress());
// h6 goes down; should choose h5
- receiveDownHeartbeat(HostAndPort("h6"), "rs0", OpTime());
+ receiveDownHeartbeat(HostAndPort("h6"), "rs0", Timestamp());
getTopoCoord().chooseNewSyncSource(now()++, lastOpTimeWeApplied);
ASSERT_EQUALS(HostAndPort("h5"), getTopoCoord().getSyncSourceAddress());
// h5 goes down; should choose h3
- receiveDownHeartbeat(HostAndPort("h5"), "rs0", OpTime());
+ receiveDownHeartbeat(HostAndPort("h5"), "rs0", Timestamp());
getTopoCoord().chooseNewSyncSource(now()++, lastOpTimeWeApplied);
ASSERT_EQUALS(HostAndPort("h3"), getTopoCoord().getSyncSourceAddress());
// h3 goes down; no sync source candidates remain
- receiveDownHeartbeat(HostAndPort("h3"), "rs0", OpTime());
+ receiveDownHeartbeat(HostAndPort("h3"), "rs0", Timestamp());
getTopoCoord().chooseNewSyncSource(now()++, lastOpTimeWeApplied);
ASSERT(getTopoCoord().getSyncSourceAddress().empty());
}
@@ -375,27 +375,27 @@ namespace {
setSelfMemberState(MemberState::RS_SECONDARY);
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(100));
+ Timestamp(1, 0), Milliseconds(100));
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(100));
+ Timestamp(1, 0), Milliseconds(100));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(0, 0), Milliseconds(300));
+ Timestamp(0, 0), Milliseconds(300));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(0, 0), Milliseconds(300));
+ Timestamp(0, 0), Milliseconds(300));
// No primary situation: should choose no sync source.
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT(getTopoCoord().getSyncSourceAddress().empty());
// Add primary
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_PRIMARY,
- OpTime(0, 0), Milliseconds(300));
+ Timestamp(0, 0), Milliseconds(300));
ASSERT_EQUALS(2, getCurrentPrimaryIndex());
// h3 is primary and should be chosen as sync source, despite being further away than h2
// and the primary (h3) being behind our most recently applied optime
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(10,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(10,0));
ASSERT_EQUALS(HostAndPort("h3"), getTopoCoord().getSyncSourceAddress());
}
@@ -412,20 +412,20 @@ namespace {
setSelfMemberState(MemberState::RS_SECONDARY);
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(100));
+ Timestamp(1, 0), Milliseconds(100));
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(100));
+ Timestamp(1, 0), Milliseconds(100));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(0, 0), Milliseconds(300));
+ Timestamp(0, 0), Milliseconds(300));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(0, 0), Milliseconds(300));
+ Timestamp(0, 0), Milliseconds(300));
// No primary situation: should choose h2 sync source.
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h2"), getTopoCoord().getSyncSourceAddress());
// Become primary
- makeSelfPrimary(OpTime(3.0));
+ makeSelfPrimary(Timestamp(3.0));
ASSERT_EQUALS(0, getCurrentPrimaryIndex());
// Check sync source
@@ -445,27 +445,27 @@ namespace {
// two rounds of heartbeat pings from each member
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(300));
+ Timestamp(1, 0), Milliseconds(300));
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(300));
+ Timestamp(1, 0), Milliseconds(300));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
// force should overrule other defaults
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h3"), getTopoCoord().getSyncSourceAddress());
getTopoCoord().setForceSyncSourceIndex(1);
// force should cause shouldChangeSyncSource() to return true
// even if the currentSource is the force target
ASSERT_TRUE(getTopoCoord().shouldChangeSyncSource(HostAndPort("h2"), now()));
ASSERT_TRUE(getTopoCoord().shouldChangeSyncSource(HostAndPort("h3"), now()));
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h2"), getTopoCoord().getSyncSourceAddress());
// force should only work for one call to chooseNewSyncSource
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h3"), getTopoCoord().getSyncSourceAddress());
}
@@ -481,25 +481,25 @@ namespace {
setSelfMemberState(MemberState::RS_SECONDARY);
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(300));
+ Timestamp(1, 0), Milliseconds(300));
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(300));
+ Timestamp(1, 0), Milliseconds(300));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h3"), getTopoCoord().getSyncSourceAddress());
Date_t expireTime = 100;
getTopoCoord().blacklistSyncSource(HostAndPort("h3"), expireTime);
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
// Should choose second best choice now that h3 is blacklisted.
ASSERT_EQUALS(HostAndPort("h2"), getTopoCoord().getSyncSourceAddress());
// After time has passed, should go back to original sync source
- getTopoCoord().chooseNewSyncSource(expireTime, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(expireTime, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h3"), getTopoCoord().getSyncSourceAddress());
}
@@ -516,27 +516,27 @@ namespace {
setSelfMemberState(MemberState::RS_SECONDARY);
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_PRIMARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_PRIMARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
ASSERT_EQUALS(1, getCurrentPrimaryIndex());
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h2"), getTopoCoord().getSyncSourceAddress());
Date_t expireTime = 100;
getTopoCoord().blacklistSyncSource(HostAndPort("h2"), expireTime);
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
// Can't choose any sync source now.
ASSERT(getTopoCoord().getSyncSourceAddress().empty());
// After time has passed, should go back to the primary
- getTopoCoord().chooseNewSyncSource(expireTime, OpTime(0,0));
+ getTopoCoord().chooseNewSyncSource(expireTime, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h2"), getTopoCoord().getSyncSourceAddress());
}
@@ -553,38 +553,38 @@ namespace {
// Generate enough heartbeats to select a sync source below
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(300));
+ Timestamp(1, 0), Milliseconds(300));
heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(300));
+ Timestamp(1, 0), Milliseconds(300));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY,
- OpTime(2, 0), Milliseconds(100));
+ Timestamp(2, 0), Milliseconds(100));
ASSERT_EQUALS(HostAndPort("h3"),
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0)));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0)));
ASSERT_EQUALS(MemberState::RS_SECONDARY, getTopoCoord().getMemberState().s);
// Good state setup done
// Mark nodes down, ensure that we have no source and are secondary
- receiveDownHeartbeat(HostAndPort("h2"), "rs0", OpTime(), ErrorCodes::NetworkTimeout);
- receiveDownHeartbeat(HostAndPort("h3"), "rs0", OpTime(), ErrorCodes::NetworkTimeout);
- ASSERT_TRUE(getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0)).empty());
+ receiveDownHeartbeat(HostAndPort("h2"), "rs0", Timestamp(), ErrorCodes::NetworkTimeout);
+ receiveDownHeartbeat(HostAndPort("h3"), "rs0", Timestamp(), ErrorCodes::NetworkTimeout);
+ ASSERT_TRUE(getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0)).empty());
ASSERT_EQUALS(MemberState::RS_SECONDARY, getTopoCoord().getMemberState().s);
// Mark nodes down + unauth, ensure that we have no source and are secondary
- receiveDownHeartbeat(HostAndPort("h2"), "rs0", OpTime(), ErrorCodes::NetworkTimeout);
- receiveDownHeartbeat(HostAndPort("h3"), "rs0", OpTime(), ErrorCodes::Unauthorized);
- ASSERT_TRUE(getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0)).empty());
+ receiveDownHeartbeat(HostAndPort("h2"), "rs0", Timestamp(), ErrorCodes::NetworkTimeout);
+ receiveDownHeartbeat(HostAndPort("h3"), "rs0", Timestamp(), ErrorCodes::Unauthorized);
+ ASSERT_TRUE(getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0)).empty());
ASSERT_EQUALS(MemberState::RS_RECOVERING, getTopoCoord().getMemberState().s);
// Having an auth error but with another node up should bring us out of RECOVERING
HeartbeatResponseAction action = receiveUpHeartbeat(HostAndPort("h2"),
"rs0",
MemberState::RS_SECONDARY,
- OpTime(0, 0),
- OpTime(2, 0),
- OpTime(2, 0));
+ Timestamp(0, 0),
+ Timestamp(2, 0),
+ Timestamp(2, 0));
ASSERT_EQUALS(MemberState::RS_SECONDARY, getTopoCoord().getMemberState().s);
// Test that the heartbeat that brings us from RECOVERING to SECONDARY doesn't initiate
// an election (SERVER-17164)
@@ -600,12 +600,12 @@ namespace {
BSON("_id" << 30 << "host" << "h3"))),
-1);
ASSERT_NO_ACTION(heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY,
- OpTime(1, 0), Milliseconds(300)).getAction());
+ Timestamp(1, 0), Milliseconds(300)).getAction());
}
TEST_F(TopoCoordTest, PrepareSyncFromResponse) {
- OpTime staleOpTime(1, 1);
- OpTime ourOpTime(staleOpTime.getSecs() + 11, 1);
+ Timestamp staleOpTime(1, 1);
+ Timestamp ourOpTime(staleOpTime.getSecs() + 11, 1);
Status result = Status::OK();
BSONObjBuilder response;
@@ -689,7 +689,7 @@ namespace {
result.reason());
// Try to sync from a member that is down
- receiveDownHeartbeat(HostAndPort("h4"), "rs0", OpTime());
+ receiveDownHeartbeat(HostAndPort("h4"), "rs0", Timestamp());
BSONObjBuilder response7;
getTopoCoord().prepareSyncFromResponse(
@@ -731,12 +731,12 @@ namespace {
BSONObj response10Obj = response10.obj();
ASSERT_FALSE(response10Obj.hasField("warning"));
ASSERT_EQUALS(HostAndPort("h6").toString(), response10Obj["prevSyncTarget"].String());
- receiveDownHeartbeat(HostAndPort("h6"), "rs0", OpTime());
- HostAndPort syncSource = getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ receiveDownHeartbeat(HostAndPort("h6"), "rs0", Timestamp());
+ HostAndPort syncSource = getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h6"), syncSource);
// Try to sync from a member that is unauth'd
- receiveDownHeartbeat(HostAndPort("h5"), "rs0", OpTime(), ErrorCodes::Unauthorized);
+ receiveDownHeartbeat(HostAndPort("h5"), "rs0", Timestamp(), ErrorCodes::Unauthorized);
BSONObjBuilder response11;
getTopoCoord().prepareSyncFromResponse(
@@ -753,7 +753,7 @@ namespace {
getTopoCoord().prepareSyncFromResponse(
cbData(), HostAndPort("h6"), ourOpTime, &response12, &result);
ASSERT_OK(result);
- syncSource = getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ syncSource = getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
ASSERT_EQUALS(HostAndPort("h6"), syncSource);
}
@@ -771,8 +771,8 @@ namespace {
Date_t heartbeatTime = 5000;
Seconds uptimeSecs(10);
Date_t curTime = heartbeatTime + uptimeSecs.total_milliseconds();
- OpTime electionTime(1, 2);
- OpTime oplogProgress(3, 4);
+ Timestamp electionTime(1, 2);
+ Timestamp oplogProgress(3, 4);
std::string setName = "mySet";
updateConfig(BSON("_id" << setName <<
@@ -793,7 +793,7 @@ namespace {
Milliseconds(0),
member,
hbResponse,
- OpTime(0,0));
+ Timestamp(0,0));
member = HostAndPort("test1:1234");
ReplSetHeartbeatResponse hb;
@@ -810,7 +810,7 @@ namespace {
Milliseconds(4000),
member,
hbResponse,
- OpTime(0,0));
+ Timestamp(0,0));
makeSelfPrimary();
// Now node 0 is down, node 1 is up, and for node 2 we have no heartbeat data yet.
@@ -841,9 +841,9 @@ namespace {
ASSERT_EQUALS(MemberState::RS_DOWN, member0Status["state"].numberInt());
ASSERT_EQUALS("(not reachable/healthy)", member0Status["stateStr"].str());
ASSERT_EQUALS(0, member0Status["uptime"].numberInt());
- ASSERT_EQUALS(OpTime(), OpTime(member0Status["optime"].timestampValue()));
+ ASSERT_EQUALS(Timestamp(), Timestamp(member0Status["optime"].timestampValue()));
ASSERT_TRUE(member0Status.hasField("optimeDate"));
- ASSERT_EQUALS(Date_t(OpTime().getSecs() * 1000ULL),
+ ASSERT_EQUALS(Date_t(Timestamp().getSecs() * 1000ULL),
member0Status["optimeDate"].Date().millis);
ASSERT_EQUALS(heartbeatTime, member0Status["lastHeartbeat"].date());
ASSERT_EQUALS(Date_t(), member0Status["lastHeartbeatRecv"].date());
@@ -856,7 +856,7 @@ namespace {
ASSERT_EQUALS(MemberState(MemberState::RS_SECONDARY).toString(),
member1Status["stateStr"].String());
ASSERT_EQUALS(uptimeSecs.total_seconds(), member1Status["uptime"].numberInt());
- ASSERT_EQUALS(oplogProgress, OpTime(member1Status["optime"].timestampValue()));
+ ASSERT_EQUALS(oplogProgress, Timestamp(member1Status["optime"].timestampValue()));
ASSERT_TRUE(member1Status.hasField("optimeDate"));
ASSERT_EQUALS(Date_t(oplogProgress.getSecs() * 1000ULL),
member1Status["optimeDate"].Date().millis);
@@ -888,7 +888,7 @@ namespace {
ASSERT_EQUALS(MemberState(MemberState::RS_PRIMARY).toString(),
selfStatus["stateStr"].str());
ASSERT_EQUALS(uptimeSecs.total_seconds(), selfStatus["uptime"].numberInt());
- ASSERT_EQUALS(oplogProgress, OpTime(selfStatus["optime"].timestampValue()));
+ ASSERT_EQUALS(oplogProgress, Timestamp(selfStatus["optime"].timestampValue()));
ASSERT_TRUE(selfStatus.hasField("optimeDate"));
ASSERT_EQUALS(Date_t(oplogProgress.getSecs() * 1000ULL),
selfStatus["optimeDate"].Date().millis);
@@ -903,7 +903,7 @@ namespace {
Date_t heartbeatTime = 5000;
Seconds uptimeSecs(10);
Date_t curTime = heartbeatTime + uptimeSecs.total_milliseconds();
- OpTime oplogProgress(3, 4);
+ Timestamp oplogProgress(3, 4);
std::string setName = "mySet";
updateConfig(BSON("_id" << setName <<
@@ -928,9 +928,9 @@ namespace {
TEST_F(TopoCoordTest, PrepareFreshResponse) {
ReplicationCoordinator::ReplSetFreshArgs args;
- OpTime freshestOpTime(15, 10);
- OpTime ourOpTime(10, 10);
- OpTime staleOpTime(1, 1);
+ Timestamp freshestOpTime(15, 10);
+ Timestamp ourOpTime(10, 10);
+ Timestamp staleOpTime(1, 1);
Status internalErrorStatus(ErrorCodes::InternalError, "didn't set status");
// if we do not have an index in the config, we should get ErrorCodes::ReplicaSetNotFound
@@ -978,7 +978,7 @@ namespace {
ASSERT_OK(status1);
BSONObj response1 = responseBuilder1.obj();
ASSERT_EQUALS("config version stale", response1["info"].String());
- ASSERT_EQUALS(ourOpTime, OpTime(response1["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response1["opTime"].timestampValue()));
ASSERT_TRUE(response1["fresher"].Bool());
ASSERT_FALSE(response1["veto"].Bool());
ASSERT_FALSE(response1.hasField("errmsg"));
@@ -993,7 +993,7 @@ namespace {
getTopoCoord().prepareFreshResponse(args, Date_t(), ourOpTime, &responseBuilder2, &status2);
ASSERT_OK(status2);
BSONObj response2 = responseBuilder2.obj();
- ASSERT_EQUALS(ourOpTime, OpTime(response2["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response2["opTime"].timestampValue()));
ASSERT_FALSE(response2["fresher"].Bool());
ASSERT_TRUE(response2["veto"].Bool());
ASSERT_EQUALS("replSet couldn't find member with id 0", response2["errmsg"].String());
@@ -1011,7 +1011,7 @@ namespace {
ASSERT_OK(status3);
BSONObj response3 = responseBuilder3.obj();
ASSERT_FALSE(response3.hasField("info"));
- ASSERT_EQUALS(ourOpTime, OpTime(response3["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response3["opTime"].timestampValue()));
ASSERT_FALSE(response3["fresher"].Bool());
ASSERT_TRUE(response3["veto"].Bool());
ASSERT_EQUALS("I am already primary, h1:27017 can try again once I've stepped down",
@@ -1029,7 +1029,7 @@ namespace {
ASSERT_OK(status4);
BSONObj response4 = responseBuilder4.obj();
ASSERT_FALSE(response4.hasField("info"));
- ASSERT_EQUALS(ourOpTime, OpTime(response4["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response4["opTime"].timestampValue()));
ASSERT_FALSE(response4["fresher"].Bool());
ASSERT_TRUE(response4["veto"].Bool());
ASSERT_EQUALS(
@@ -1049,7 +1049,7 @@ namespace {
ASSERT_OK(status5);
BSONObj response5 = responseBuilder5.obj();
ASSERT_FALSE(response5.hasField("info"));
- ASSERT_EQUALS(ourOpTime, OpTime(response5["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response5["opTime"].timestampValue()));
ASSERT_FALSE(response5["fresher"].Bool());
ASSERT_TRUE(response5["veto"].Bool());
ASSERT(response5["errmsg"].String().find("h1:27017 has lower priority of 1 than") !=
@@ -1059,7 +1059,7 @@ namespace {
args.id = 40;
args.who = HostAndPort("h3");
- receiveDownHeartbeat(HostAndPort("h3"), "rs0", OpTime());
+ receiveDownHeartbeat(HostAndPort("h3"), "rs0", Timestamp());
BSONObjBuilder responseBuilder6;
Status status6 = internalErrorStatus;
@@ -1067,7 +1067,7 @@ namespace {
ASSERT_OK(status6);
BSONObj response6 = responseBuilder6.obj();
ASSERT_FALSE(response6.hasField("info"));
- ASSERT_EQUALS(ourOpTime, OpTime(response6["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response6["opTime"].timestampValue()));
ASSERT_FALSE(response6["fresher"].Bool());
ASSERT_TRUE(response6["veto"].Bool());
ASSERT_NE(std::string::npos, response6["errmsg"].String().find(
@@ -1085,7 +1085,7 @@ namespace {
ASSERT_OK(status7);
BSONObj response7 = responseBuilder7.obj();
ASSERT_FALSE(response7.hasField("info"));
- ASSERT_EQUALS(ourOpTime, OpTime(response7["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response7["opTime"].timestampValue()));
ASSERT_FALSE(response7["fresher"].Bool());
ASSERT_TRUE(response7["veto"].Bool());
ASSERT_NE(std::string::npos, response7["errmsg"].String().find(
@@ -1101,7 +1101,7 @@ namespace {
ASSERT_OK(status8);
BSONObj response8 = responseBuilder8.obj();
ASSERT_FALSE(response8.hasField("info"));
- ASSERT_EQUALS(ourOpTime, OpTime(response8["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response8["opTime"].timestampValue()));
ASSERT_FALSE(response8["fresher"].Bool());
ASSERT_TRUE(response8["veto"].Bool());
ASSERT_NE(std::string::npos, response8["errmsg"].String().find(
@@ -1117,7 +1117,7 @@ namespace {
ASSERT_OK(status9);
BSONObj response9 = responseBuilder9.obj();
ASSERT_FALSE(response9.hasField("info"));
- ASSERT_EQUALS(ourOpTime, OpTime(response9["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response9["opTime"].timestampValue()));
ASSERT_FALSE(response9["fresher"].Bool());
ASSERT_TRUE(response9["veto"].Bool());
ASSERT_NE(std::string::npos, response9["errmsg"].String().find(
@@ -1139,7 +1139,7 @@ namespace {
ASSERT_OK(status10);
BSONObj response10 = responseBuilder10.obj();
ASSERT_FALSE(response10.hasField("info"));
- ASSERT_EQUALS(ourOpTime, OpTime(response10["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response10["opTime"].timestampValue()));
ASSERT_TRUE(response10["fresher"].Bool());
ASSERT_TRUE(response10["veto"].Bool());
ASSERT_TRUE(response10.hasField("errmsg"));
@@ -1149,7 +1149,7 @@ namespace {
args.id = 40;
args.who = HostAndPort("h3");
- receiveDownHeartbeat(HostAndPort("h2"), "rs0", OpTime());
+ receiveDownHeartbeat(HostAndPort("h2"), "rs0", Timestamp());
heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, ourOpTime);
BSONObjBuilder responseBuilder11;
@@ -1159,7 +1159,7 @@ namespace {
ASSERT_OK(status11);
BSONObj response11 = responseBuilder11.obj();
ASSERT_FALSE(response11.hasField("info")) << response11.toString();
- ASSERT_EQUALS(ourOpTime, OpTime(response11["opTime"].timestampValue()));
+ ASSERT_EQUALS(ourOpTime, Timestamp(response11["opTime"].timestampValue()));
ASSERT_FALSE(response11["fresher"].Bool()) << response11.toString();
ASSERT_FALSE(response11["veto"].Bool()) << response11.toString();
ASSERT_FALSE(response11.hasField("errmsg")) << response11.toString();
@@ -1219,7 +1219,7 @@ namespace {
_target,
StatusWith<ReplSetHeartbeatResponse>(ErrorCodes::ExceededTimeLimit,
"Took too long"),
- OpTime(0, 0)); // We've never applied anything.
+ Timestamp(0, 0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::NoAction, action.getAction());
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
@@ -1261,7 +1261,7 @@ namespace {
Milliseconds(400), // Spent 0.4 of the 0.5 seconds in the network.
target(),
StatusWith<ReplSetHeartbeatResponse>(ErrorCodes::NodeNotFound, "Bad DNS?"),
- OpTime(0, 0)); // We've never applied anything.
+ Timestamp(0, 0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::NoAction, action.getAction());
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
// Because the first retry failed without timing out, we expect to retry immediately.
@@ -1295,7 +1295,7 @@ namespace {
};
TEST_F(HeartbeatResponseHighVerbosityTest, UpdateHeartbeatDataNodeBelivesWeAreDown) {
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
// request heartbeat
std::pair<ReplSetHeartbeatArgs, Milliseconds> request =
@@ -1321,7 +1321,7 @@ namespace {
}
TEST_F(HeartbeatResponseHighVerbosityTest, UpdateHeartbeatDataMemberNotInConfig) {
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
// request heartbeat
std::pair<ReplSetHeartbeatArgs, Milliseconds> request =
@@ -1346,7 +1346,7 @@ namespace {
}
TEST_F(HeartbeatResponseHighVerbosityTest, UpdateHeartbeatDataSameConfig) {
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
// request heartbeat
std::pair<ReplSetHeartbeatArgs, Milliseconds> request =
@@ -1385,7 +1385,7 @@ namespace {
}
TEST_F(HeartbeatResponseHighVerbosityTest, UpdateHeartbeatDataOldConfig) {
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
// request heartbeat
std::pair<ReplSetHeartbeatArgs, Milliseconds> request =
@@ -1438,7 +1438,7 @@ namespace {
Milliseconds(400), // Spent 0.4 of the 0.5 second in the network.
target(),
StatusWith<ReplSetHeartbeatResponse>(reconfigResponse),
- OpTime(0, 0)); // We've never applied anything.
+ Timestamp(0, 0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::Reconfig, action.getAction());
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(Date_t(firstRequestDate() + 6500), action.getNextHeartbeatStartDate());
@@ -1450,7 +1450,7 @@ namespace {
// make self primary
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
- makeSelfPrimary(OpTime(5,0));
+ makeSelfPrimary(Timestamp(5,0));
ASSERT_EQUALS(0, getCurrentPrimaryIndex());
ReplSetHeartbeatResponse electedMoreRecentlyResponse;
@@ -1458,7 +1458,7 @@ namespace {
electedMoreRecentlyResponse.setSetName("rs0");
electedMoreRecentlyResponse.setState(MemberState::RS_PRIMARY);
electedMoreRecentlyResponse.setElectable(true);
- electedMoreRecentlyResponse.setElectionTime(OpTime(3,0));
+ electedMoreRecentlyResponse.setElectionTime(Timestamp(3,0));
electedMoreRecentlyResponse.setVersion(5);
HeartbeatResponseAction action =
getTopoCoord().processHeartbeatResponse(
@@ -1466,7 +1466,7 @@ namespace {
Milliseconds(400), // Spent 0.4 of the 0.5 second in the network.
target(),
StatusWith<ReplSetHeartbeatResponse>(electedMoreRecentlyResponse),
- OpTime(0,0)); // We've never applied anything.
+ Timestamp(0,0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::StepDownRemotePrimary, action.getAction());
ASSERT_EQUALS(1, action.getPrimaryConfigIndex());
ASSERT_EQUALS(Date_t(firstRequestDate() + 6500), action.getNextHeartbeatStartDate());
@@ -1479,7 +1479,7 @@ namespace {
// acknowledge the other member so that we see a majority
HeartbeatResponseAction action = receiveDownHeartbeat(HostAndPort("host3"),
"rs0",
- OpTime(100, 0));
+ Timestamp(100, 0));
ASSERT_NO_ACTION(action.getAction());
// make us PRIMARY
@@ -1490,7 +1490,7 @@ namespace {
electedMoreRecentlyResponse.setSetName("rs0");
electedMoreRecentlyResponse.setState(MemberState::RS_PRIMARY);
electedMoreRecentlyResponse.setElectable(false);
- electedMoreRecentlyResponse.setElectionTime(OpTime(10,0));
+ electedMoreRecentlyResponse.setElectionTime(Timestamp(10,0));
electedMoreRecentlyResponse.setVersion(5);
action =
getTopoCoord().processHeartbeatResponse(
@@ -1498,7 +1498,7 @@ namespace {
Milliseconds(400), // Spent 0.4 of the 0.5 second in the network.
target(),
StatusWith<ReplSetHeartbeatResponse>(electedMoreRecentlyResponse),
- OpTime(0, 0)); // We've never applied anything.
+ Timestamp(0, 0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::StepDownSelf, action.getAction());
ASSERT_EQUALS(0, action.getPrimaryConfigIndex());
ASSERT_EQUALS(Date_t(firstRequestDate() + 6500), action.getNextHeartbeatStartDate());
@@ -1516,8 +1516,8 @@ namespace {
// action.
// acknowledge the other member so that we see a majority
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(300,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(300,0);
HeartbeatResponseAction action = receiveUpHeartbeat(HostAndPort("host3"),
"rs0",
MemberState::RS_SECONDARY,
@@ -1564,7 +1564,7 @@ namespace {
Milliseconds(100), // Spent 0.1 of the 0.3 seconds in the network.
target(),
StatusWith<ReplSetHeartbeatResponse>(ErrorCodes::NodeNotFound, "Bad DNS?"),
- OpTime(0, 0)); // We've never applied anything.
+ Timestamp(0, 0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::NoAction, action.getAction());
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
// Because this is the second retry, rather than retry again, we expect to wait for the
@@ -1578,7 +1578,7 @@ namespace {
// make self primary
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
- makeSelfPrimary(OpTime(5,0));
+ makeSelfPrimary(Timestamp(5,0));
ASSERT_EQUALS(0, getCurrentPrimaryIndex());
ReplSetHeartbeatResponse electedMoreRecentlyResponse;
@@ -1586,7 +1586,7 @@ namespace {
electedMoreRecentlyResponse.setSetName("rs0");
electedMoreRecentlyResponse.setState(MemberState::RS_PRIMARY);
electedMoreRecentlyResponse.setElectable(true);
- electedMoreRecentlyResponse.setElectionTime(OpTime(3,0));
+ electedMoreRecentlyResponse.setElectionTime(Timestamp(3,0));
electedMoreRecentlyResponse.setVersion(5);
HeartbeatResponseAction action =
getTopoCoord().processHeartbeatResponse(
@@ -1594,7 +1594,7 @@ namespace {
Milliseconds(400), // Spent 0.4 of the 0.5 second in the network.
target(),
StatusWith<ReplSetHeartbeatResponse>(electedMoreRecentlyResponse),
- OpTime(0,0)); // We've never applied anything.
+ Timestamp(0,0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::StepDownRemotePrimary, action.getAction());
ASSERT_EQUALS(1, action.getPrimaryConfigIndex());
ASSERT_EQUALS(Date_t(firstRequestDate() + 7000), action.getNextHeartbeatStartDate());
@@ -1607,7 +1607,7 @@ namespace {
// acknowledge the other member so that we see a majority
HeartbeatResponseAction action = receiveDownHeartbeat(HostAndPort("host3"),
"rs0",
- OpTime(100, 0));
+ Timestamp(100, 0));
ASSERT_NO_ACTION(action.getAction());
// make us PRIMARY
@@ -1618,7 +1618,7 @@ namespace {
electedMoreRecentlyResponse.setSetName("rs0");
electedMoreRecentlyResponse.setState(MemberState::RS_PRIMARY);
electedMoreRecentlyResponse.setElectable(false);
- electedMoreRecentlyResponse.setElectionTime(OpTime(10,0));
+ electedMoreRecentlyResponse.setElectionTime(Timestamp(10,0));
electedMoreRecentlyResponse.setVersion(5);
action =
getTopoCoord().processHeartbeatResponse(
@@ -1626,7 +1626,7 @@ namespace {
Milliseconds(400), // Spent 0.4 of the 0.5 second in the network.
target(),
StatusWith<ReplSetHeartbeatResponse>(electedMoreRecentlyResponse),
- OpTime(0, 0)); // We've never applied anything.
+ Timestamp(0, 0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::StepDownSelf, action.getAction());
ASSERT_EQUALS(0, action.getPrimaryConfigIndex());
ASSERT_EQUALS(Date_t(firstRequestDate() + 7000), action.getNextHeartbeatStartDate());
@@ -1644,8 +1644,8 @@ namespace {
// action.
// acknowledge the other member so that we see a majority
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(300,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(300,0);
HeartbeatResponseAction action = receiveUpHeartbeat(HostAndPort("host3"),
"rs0",
MemberState::RS_SECONDARY,
@@ -1698,7 +1698,7 @@ namespace {
target,
StatusWith<ReplSetHeartbeatResponse>(ErrorCodes::ExceededTimeLimit,
"Took too long"),
- OpTime(0, 0)); // We've never applied anything.
+ Timestamp(0, 0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::NoAction, action.getAction());
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
@@ -1716,7 +1716,7 @@ namespace {
target(),
StatusWith<ReplSetHeartbeatResponse>(ErrorCodes::ExceededTimeLimit,
"Took too long"),
- OpTime(0, 0)); // We've never applied anything.
+ Timestamp(0, 0)); // We've never applied anything.
ASSERT_EQUALS(HeartbeatResponseAction::NoAction, action.getAction());
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
@@ -1725,8 +1725,8 @@ namespace {
}
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataNewPrimary) {
- OpTime election = OpTime(5,0);
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp election = Timestamp(5,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -1741,9 +1741,9 @@ namespace {
}
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataTwoPrimariesNewOneOlder) {
- OpTime election = OpTime(5,0);
- OpTime election2 = OpTime(4,0);
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp election = Timestamp(5,0);
+ Timestamp election2 = Timestamp(4,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -1768,9 +1768,9 @@ namespace {
}
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataTwoPrimariesNewOneNewer) {
- OpTime election = OpTime(4,0);
- OpTime election2 = OpTime(5,0);
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp election = Timestamp(4,0);
+ Timestamp election2 = Timestamp(5,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -1796,10 +1796,10 @@ namespace {
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataTwoPrimariesIncludingMeNewOneOlder) {
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
- makeSelfPrimary(OpTime(5,0));
+ makeSelfPrimary(Timestamp(5,0));
- OpTime election = OpTime(4,0);
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp election = Timestamp(4,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
ASSERT_EQUALS(0, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -1828,9 +1828,9 @@ namespace {
0);
setSelfMemberState(MemberState::RS_SECONDARY);
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(13,0);
- OpTime slightlyLessFreshLastOpTimeApplied = OpTime(3,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(13,0);
+ Timestamp slightlyLessFreshLastOpTimeApplied = Timestamp(3,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -1864,7 +1864,7 @@ namespace {
BSON("_id" << 2 << "host" << "host3:27017" << "priority" << 3)) <<
"settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
- OpTime election = OpTime(1000,0);
+ Timestamp election = Timestamp(1000,0);
getTopoCoord().setFollowerMode(MemberState::RS_SECONDARY);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
@@ -1909,8 +1909,8 @@ namespace {
BSON("_id" << 2 << "host" << "host3:27017" << "priority" << 3)) <<
"settings" << BSON("heartbeatTimeoutSecs" << 5)),
0);
- OpTime election = OpTime(1000,0);
- OpTime staleTime = OpTime(0,0);
+ Timestamp election = Timestamp(1000,0);
+ Timestamp staleTime = Timestamp(0,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
makeSelfPrimary(election);
@@ -1938,8 +1938,8 @@ namespace {
0);
setSelfMemberState(MemberState::RS_SECONDARY);
- OpTime election = OpTime(1000,0);
- OpTime stale = OpTime(0,0);
+ Timestamp election = Timestamp(1000,0);
+ Timestamp stale = Timestamp(0,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -1961,10 +1961,10 @@ namespace {
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataTwoPrimariesIncludingMeNewOneNewer) {
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
- makeSelfPrimary(OpTime(2,0));
+ makeSelfPrimary(Timestamp(2,0));
- OpTime election = OpTime(4,0);
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp election = Timestamp(4,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
ASSERT_EQUALS(0, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -1987,8 +1987,8 @@ namespace {
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataPrimaryDownNoMajority) {
setSelfMemberState(MemberState::RS_SECONDARY);
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(300,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(300,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -2017,8 +2017,8 @@ namespace {
BSON("_id" << 2 << "host" << "host3:27017"))),
0);
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(300,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(300,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -2048,8 +2048,8 @@ namespace {
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataPrimaryDownMajorityButIAmStarting) {
setSelfMemberState(MemberState::RS_STARTUP);
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(300,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(300,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -2078,8 +2078,8 @@ namespace {
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataPrimaryDownMajorityButIAmRecovering) {
setSelfMemberState(MemberState::RS_RECOVERING);
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(300,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(300,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -2100,8 +2100,8 @@ namespace {
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataPrimaryDownMajorityButIHaveStepdownWait) {
setSelfMemberState(MemberState::RS_SECONDARY);
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(300,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(300,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -2141,8 +2141,8 @@ namespace {
BSON("_id" << 2 << "host" << "host3:27017"))),
0);
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(300,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(300,0);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host3"),
"rs0",
@@ -2171,8 +2171,8 @@ namespace {
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataPrimaryDownMajority) {
setSelfMemberState(MemberState::RS_SECONDARY);
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(399,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(399,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -2215,8 +2215,8 @@ namespace {
now() += 30000; // we need to be more than LastVote::leaseTime from the start of time or
// else some Date_t math goes horribly awry
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(130,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(130,0);
OID round = OID::gen();
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
@@ -2285,9 +2285,9 @@ namespace {
now() += 30000; // we need to be more than LastVote::leaseTime from the start of time or
// else some Date_t math goes horribly awry
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(100,0);
- OpTime fresherOpApplied = OpTime(200,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(100,0);
+ Timestamp fresherOpApplied = Timestamp(200,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -2313,7 +2313,7 @@ namespace {
ASSERT_EQUALS(HeartbeatResponseAction::StartElection, nextAction.getAction());
ASSERT_TRUE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
- OpTime originalElectionTime = getTopoCoord().getElectionTime();
+ Timestamp originalElectionTime = getTopoCoord().getElectionTime();
OID originalElectionId = getTopoCoord().getElectionId();
// prepare an incoming fresh command
ReplicationCoordinator::ReplSetFreshArgs freshArgs;
@@ -2329,7 +2329,7 @@ namespace {
freshArgs, now()++, lastOpTimeApplied, &freshResponseBuilder, &result);
BSONObj response = freshResponseBuilder.obj();
ASSERT_OK(result);
- ASSERT_EQUALS(lastOpTimeApplied, OpTime(response["opTime"].timestampValue()));
+ ASSERT_EQUALS(lastOpTimeApplied, Timestamp(response["opTime"].timestampValue()));
ASSERT_FALSE(response["fresher"].trueValue());
ASSERT_FALSE(response["veto"].trueValue());
ASSERT_TRUE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
@@ -2349,7 +2349,7 @@ namespace {
result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
getTopoCoord().prepareElectResponse(
- electArgs, now()++, OpTime(), &electResponseBuilder, &result);
+ electArgs, now()++, Timestamp(), &electResponseBuilder, &result);
stopCapturingLogMessages();
response = electResponseBuilder.obj();
ASSERT_OK(result);
@@ -2380,7 +2380,7 @@ namespace {
// now lose election and ensure _electionTime and _electionId are 0'd out
getTopoCoord().processLoseElection();
ASSERT_EQUALS(OID(), getTopoCoord().getElectionId());
- ASSERT_EQUALS(OpTime(0,0), getTopoCoord().getElectionTime());
+ ASSERT_EQUALS(Timestamp(0,0), getTopoCoord().getElectionTime());
ASSERT_TRUE(TopologyCoordinator::Role::follower == getTopoCoord().getRole());
ASSERT_EQUALS(2, getCurrentPrimaryIndex());
}
@@ -2403,9 +2403,9 @@ namespace {
now() += 30000; // we need to be more than LastVote::leaseTime from the start of time or
// else some Date_t math goes horribly awry
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(100,0);
- OpTime fresherLastOpTimeApplied = OpTime(200,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(100,0);
+ Timestamp fresherLastOpTimeApplied = Timestamp(200,0);
OID round = OID::gen();
OID remoteRound = OID::gen();
@@ -2447,7 +2447,7 @@ namespace {
freshArgs, now()++, lastOpTimeApplied, &freshResponseBuilder, &result);
BSONObj response = freshResponseBuilder.obj();
ASSERT_OK(result);
- ASSERT_EQUALS(lastOpTimeApplied, OpTime(response["opTime"].timestampValue()));
+ ASSERT_EQUALS(lastOpTimeApplied, Timestamp(response["opTime"].timestampValue()));
ASSERT_FALSE(response["fresher"].trueValue());
ASSERT_FALSE(response["veto"].trueValue());
ASSERT_TRUE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
@@ -2472,7 +2472,7 @@ namespace {
result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
getTopoCoord().prepareElectResponse(
- electArgs, now()++, OpTime(), &electResponseBuilder, &result);
+ electArgs, now()++, Timestamp(), &electResponseBuilder, &result);
stopCapturingLogMessages();
response = electResponseBuilder.obj();
ASSERT_OK(result);
@@ -2500,9 +2500,9 @@ namespace {
now() += 30000; // we need to be more than LastVote::leaseTime from the start of time or
// else some Date_t math goes horribly awry
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(100,0);
- OpTime fresherLastOpTimeApplied = OpTime(200,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(100,0);
+ Timestamp fresherLastOpTimeApplied = Timestamp(200,0);
OID round = OID::gen();
OID remoteRound = OID::gen();
@@ -2551,7 +2551,7 @@ namespace {
freshArgs, now()++, lastOpTimeApplied, &freshResponseBuilder, &result);
BSONObj response = freshResponseBuilder.obj();
ASSERT_OK(result);
- ASSERT_EQUALS(lastOpTimeApplied, OpTime(response["opTime"].timestampValue()));
+ ASSERT_EQUALS(lastOpTimeApplied, Timestamp(response["opTime"].timestampValue()));
ASSERT_FALSE(response["fresher"].trueValue());
ASSERT_TRUE(response["veto"].trueValue()) << response["errmsg"];
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
@@ -2568,7 +2568,7 @@ namespace {
result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
getTopoCoord().prepareElectResponse(
- electArgs, now()++, OpTime(), &electResponseBuilder, &result);
+ electArgs, now()++, Timestamp(), &electResponseBuilder, &result);
stopCapturingLogMessages();
response = electResponseBuilder.obj();
ASSERT_OK(result);
@@ -2594,8 +2594,8 @@ namespace {
setSelfMemberState(MemberState::RS_SECONDARY);
- OpTime election = OpTime(400,0);
- OpTime lastOpTimeApplied = OpTime(300,0);
+ Timestamp election = Timestamp(400,0);
+ Timestamp lastOpTimeApplied = Timestamp(300,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
@@ -2634,21 +2634,21 @@ namespace {
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataRelinquishPrimaryDueToNodeDisappearing) {
// become PRIMARY
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
- makeSelfPrimary(OpTime(2,0));
+ makeSelfPrimary(Timestamp(2,0));
ASSERT_EQUALS(0, getCurrentPrimaryIndex());
// become aware of other nodes
- heartbeatFromMember(HostAndPort("host2"), "rs0", MemberState::RS_SECONDARY, OpTime(1,0));
- heartbeatFromMember(HostAndPort("host2"), "rs0", MemberState::RS_SECONDARY, OpTime(1,0));
- heartbeatFromMember(HostAndPort("host3"), "rs0", MemberState::RS_SECONDARY, OpTime(0,0));
- heartbeatFromMember(HostAndPort("host3"), "rs0", MemberState::RS_SECONDARY, OpTime(0,0));
+ heartbeatFromMember(HostAndPort("host2"), "rs0", MemberState::RS_SECONDARY, Timestamp(1,0));
+ heartbeatFromMember(HostAndPort("host2"), "rs0", MemberState::RS_SECONDARY, Timestamp(1,0));
+ heartbeatFromMember(HostAndPort("host3"), "rs0", MemberState::RS_SECONDARY, Timestamp(0,0));
+ heartbeatFromMember(HostAndPort("host3"), "rs0", MemberState::RS_SECONDARY, Timestamp(0,0));
// lose that awareness and be sure we are going to stepdown
HeartbeatResponseAction nextAction = receiveDownHeartbeat(HostAndPort("host2"),
"rs0",
- OpTime(100, 0));
+ Timestamp(100, 0));
ASSERT_NO_ACTION(nextAction.getAction());
- nextAction = receiveDownHeartbeat(HostAndPort("host3"), "rs0", OpTime(100, 0));
+ nextAction = receiveDownHeartbeat(HostAndPort("host3"), "rs0", Timestamp(100, 0));
ASSERT_EQUALS(HeartbeatResponseAction::StepDownSelf, nextAction.getAction());
ASSERT_EQUALS(0, nextAction.getPrimaryConfigIndex());
// Doesn't actually do the stepdown until stepDownIfPending is called
@@ -2661,8 +2661,8 @@ namespace {
}
TEST_F(HeartbeatResponseTest, UpdateHeartbeatDataRemoteDoesNotExist) {
- OpTime election = OpTime(5,0);
- OpTime lastOpTimeApplied = OpTime(3,0);
+ Timestamp election = Timestamp(5,0);
+ Timestamp lastOpTimeApplied = Timestamp(3,0);
ASSERT_EQUALS(-1, getCurrentPrimaryIndex());
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host9"),
@@ -2717,7 +2717,7 @@ namespace {
BSONObjBuilder responseBuilder;
Status result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now += 60000, OpTime(), &responseBuilder, &result);
+ getTopoCoord().prepareElectResponse(args, now += 60000, Timestamp(), &responseBuilder, &result);
stopCapturingLogMessages();
BSONObj response = responseBuilder.obj();
ASSERT_OK(result);
@@ -2730,7 +2730,7 @@ namespace {
// Make sure nay votes, do not prevent subsequent yeas (the way a yea vote would)
args.set = "rs0";
BSONObjBuilder responseBuilder2;
- getTopoCoord().prepareElectResponse(args, now++, OpTime(), &responseBuilder2, &result);
+ getTopoCoord().prepareElectResponse(args, now++, Timestamp(), &responseBuilder2, &result);
BSONObj response2 = responseBuilder2.obj();
ASSERT_EQUALS(1, response2["vote"].Int());
ASSERT_EQUALS(round, response2["round"].OID());
@@ -2747,7 +2747,7 @@ namespace {
BSONObjBuilder responseBuilder;
Status result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now += 60000, OpTime(), &responseBuilder, &result);
+ getTopoCoord().prepareElectResponse(args, now += 60000, Timestamp(), &responseBuilder, &result);
stopCapturingLogMessages();
BSONObj response = responseBuilder.obj();
ASSERT_OK(result);
@@ -2759,7 +2759,7 @@ namespace {
// Make sure nay votes, do not prevent subsequent yeas (the way a yea vote would)
args.cfgver = 10;
BSONObjBuilder responseBuilder2;
- getTopoCoord().prepareElectResponse(args, now++, OpTime(), &responseBuilder2, &result);
+ getTopoCoord().prepareElectResponse(args, now++, Timestamp(), &responseBuilder2, &result);
BSONObj response2 = responseBuilder2.obj();
ASSERT_EQUALS(1, response2["vote"].Int());
ASSERT_EQUALS(round, response2["round"].OID());
@@ -2776,7 +2776,7 @@ namespace {
BSONObjBuilder responseBuilder;
Status result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now += 60000, OpTime(), &responseBuilder, &result);
+ getTopoCoord().prepareElectResponse(args, now += 60000, Timestamp(), &responseBuilder, &result);
stopCapturingLogMessages();
BSONObj response = responseBuilder.obj();
ASSERT_OK(result);
@@ -2788,7 +2788,7 @@ namespace {
// Make sure nay votes, do not prevent subsequent yeas (the way a yea vote would)
args.cfgver = 10;
BSONObjBuilder responseBuilder2;
- getTopoCoord().prepareElectResponse(args, now++, OpTime(), &responseBuilder2, &result);
+ getTopoCoord().prepareElectResponse(args, now++, Timestamp(), &responseBuilder2, &result);
BSONObj response2 = responseBuilder2.obj();
ASSERT_EQUALS(1, response2["vote"].Int());
ASSERT_EQUALS(round, response2["round"].OID());
@@ -2805,7 +2805,7 @@ namespace {
BSONObjBuilder responseBuilder;
Status result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now += 60000, OpTime(), &responseBuilder, &result);
+ getTopoCoord().prepareElectResponse(args, now += 60000, Timestamp(), &responseBuilder, &result);
stopCapturingLogMessages();
BSONObj response = responseBuilder.obj();
ASSERT_OK(result);
@@ -2816,7 +2816,7 @@ namespace {
// Make sure nay votes, do not prevent subsequent yeas (the way a yea vote would)
args.whoid = 1;
BSONObjBuilder responseBuilder2;
- getTopoCoord().prepareElectResponse(args, now++, OpTime(), &responseBuilder2, &result);
+ getTopoCoord().prepareElectResponse(args, now++, Timestamp(), &responseBuilder2, &result);
BSONObj response2 = responseBuilder2.obj();
ASSERT_EQUALS(1, response2["vote"].Int());
ASSERT_EQUALS(round, response2["round"].OID());
@@ -2835,7 +2835,7 @@ namespace {
BSONObjBuilder responseBuilder;
Status result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now += 60000, OpTime(), &responseBuilder, &result);
+ getTopoCoord().prepareElectResponse(args, now += 60000, Timestamp(), &responseBuilder, &result);
stopCapturingLogMessages();
BSONObj response = responseBuilder.obj();
ASSERT_OK(result);
@@ -2846,7 +2846,7 @@ namespace {
// Make sure nay votes, do not prevent subsequent yeas (the way a yea vote would)
getTopoCoord()._setCurrentPrimaryForTest(-1);
BSONObjBuilder responseBuilder2;
- getTopoCoord().prepareElectResponse(args, now++, OpTime(), &responseBuilder2, &result);
+ getTopoCoord().prepareElectResponse(args, now++, Timestamp(), &responseBuilder2, &result);
BSONObj response2 = responseBuilder2.obj();
ASSERT_EQUALS(1, response2["vote"].Int());
ASSERT_EQUALS(round, response2["round"].OID());
@@ -2864,7 +2864,7 @@ namespace {
BSONObjBuilder responseBuilder;
Status result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now += 60000, OpTime(), &responseBuilder, &result);
+ getTopoCoord().prepareElectResponse(args, now += 60000, Timestamp(), &responseBuilder, &result);
stopCapturingLogMessages();
BSONObj response = responseBuilder.obj();
ASSERT_OK(result);
@@ -2875,7 +2875,7 @@ namespace {
// Make sure nay votes, do not prevent subsequent yeas (the way a yea vote would)
getTopoCoord()._setCurrentPrimaryForTest(-1);
BSONObjBuilder responseBuilder2;
- getTopoCoord().prepareElectResponse(args, now++, OpTime(), &responseBuilder2, &result);
+ getTopoCoord().prepareElectResponse(args, now++, Timestamp(), &responseBuilder2, &result);
BSONObj response2 = responseBuilder2.obj();
ASSERT_EQUALS(1, response2["vote"].Int());
ASSERT_EQUALS(round, response2["round"].OID());
@@ -2894,7 +2894,7 @@ namespace {
BSONObjBuilder responseBuilder;
Status result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now += 60000, OpTime(), &responseBuilder, &result);
+ getTopoCoord().prepareElectResponse(args, now += 60000, Timestamp(), &responseBuilder, &result);
stopCapturingLogMessages();
BSONObj response = responseBuilder.obj();
ASSERT_OK(result);
@@ -2905,7 +2905,7 @@ namespace {
// Make sure nay votes, do not prevent subsequent yeas (the way a yea vote would)
args.whoid = 3;
BSONObjBuilder responseBuilder2;
- getTopoCoord().prepareElectResponse(args, now++, OpTime(), &responseBuilder2, &result);
+ getTopoCoord().prepareElectResponse(args, now++, Timestamp(), &responseBuilder2, &result);
BSONObj response2 = responseBuilder2.obj();
ASSERT_EQUALS(1, response2["vote"].Int());
ASSERT_EQUALS(round, response2["round"].OID());
@@ -2920,13 +2920,13 @@ namespace {
args.cfgver = 10;
args.whoid = 1;
- receiveDownHeartbeat(HostAndPort("h3"), "rs0", OpTime());
- receiveDownHeartbeat(HostAndPort("h2"), "rs0", OpTime());
+ receiveDownHeartbeat(HostAndPort("h3"), "rs0", Timestamp());
+ receiveDownHeartbeat(HostAndPort("h2"), "rs0", Timestamp());
BSONObjBuilder responseBuilder;
Status result = Status::OK();
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now += 60000, OpTime(), &responseBuilder, &result);
+ getTopoCoord().prepareElectResponse(args, now += 60000, Timestamp(), &responseBuilder, &result);
stopCapturingLogMessages();
BSONObj response = responseBuilder.obj();
ASSERT_EQUALS(1, response["vote"].Int());
@@ -2945,7 +2945,7 @@ namespace {
BSONObjBuilder responseBuilder1;
Status result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now += 60000, OpTime(), &responseBuilder1, &result);
+ getTopoCoord().prepareElectResponse(args, now += 60000, Timestamp(), &responseBuilder1, &result);
stopCapturingLogMessages();
BSONObj response1 = responseBuilder1.obj();
ASSERT_OK(result);
@@ -2958,7 +2958,7 @@ namespace {
BSONObjBuilder responseBuilder2;
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now, OpTime(), &responseBuilder2, &result);
+ getTopoCoord().prepareElectResponse(args, now, Timestamp(), &responseBuilder2, &result);
stopCapturingLogMessages();
BSONObj response2 = responseBuilder2.obj();
ASSERT_OK(result);
@@ -2972,7 +2972,7 @@ namespace {
BSONObjBuilder responseBuilder3;
startCapturingLogMessages();
- getTopoCoord().prepareElectResponse(args, now++, OpTime(), &responseBuilder3, &result);
+ getTopoCoord().prepareElectResponse(args, now++, Timestamp(), &responseBuilder3, &result);
stopCapturingLogMessages();
BSONObj response3 = responseBuilder3.obj();
ASSERT_OK(result);
@@ -2985,7 +2985,7 @@ namespace {
ReplicationCoordinator::ReplSetElectArgs args;
BSONObjBuilder response;
Status status = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
- getTopoCoord().prepareElectResponse(args, now(), OpTime(), &response, &status);
+ getTopoCoord().prepareElectResponse(args, now(), Timestamp(), &response, &status);
ASSERT_EQUALS(ErrorCodes::ReplicaSetNotFound, status);
ASSERT_EQUALS("Cannot participate in election because not initialized", status.reason());
}
@@ -3102,7 +3102,7 @@ namespace {
BSONObjBuilder response;
getTopoCoord().prepareSyncFromResponse(cbData(),
HostAndPort("host2:27017"),
- OpTime(0,0),
+ Timestamp(0,0),
&response,
&result);
ASSERT_EQUALS(ErrorCodes::ShutdownInProgress, result);
@@ -3116,7 +3116,7 @@ namespace {
getTopoCoord().prepareStatusResponse(cbData(),
Date_t(0),
0,
- OpTime(0,0),
+ Timestamp(0,0),
&response,
&result);
ASSERT_EQUALS(ErrorCodes::ShutdownInProgress, result);
@@ -3139,7 +3139,7 @@ namespace {
}
void prepareHeartbeatResponse(const ReplSetHeartbeatArgs& args,
- OpTime lastOpApplied,
+ Timestamp lastOpApplied,
ReplSetHeartbeatResponse* response,
Status* result) {
*result = getTopoCoord().prepareHeartbeatResponse(now()++,
@@ -3159,7 +3159,7 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
// prepare response and check the results
- prepareHeartbeatResponse(args, OpTime(0,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(0,0), &response, &result);
ASSERT_EQUALS(ErrorCodes::BadValue, result);
ASSERT_EQUALS("replset: incompatible replset protocol version: 3", result.reason());
ASSERT_EQUALS("", response.getHbMsg());
@@ -3173,7 +3173,7 @@ namespace {
args.setSenderId(10);
ReplSetHeartbeatResponse response;
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
- prepareHeartbeatResponse(args, OpTime(0,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(0,0), &response, &result);
ASSERT_EQUALS(ErrorCodes::BadValue, result);
ASSERT(result.reason().find("from member with the same member ID as our self")) <<
"Actual string was \"" << result.reason() << '"';
@@ -3189,7 +3189,7 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
startCapturingLogMessages();
- prepareHeartbeatResponse(args, OpTime(0,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(0,0), &response, &result);
stopCapturingLogMessages();
ASSERT_EQUALS(ErrorCodes::InconsistentReplicaSetNames, result);
ASSERT(result.reason().find("repl set names do not match")) << "Actual string was \"" <<
@@ -3211,12 +3211,12 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
// prepare response and check the results
- prepareHeartbeatResponse(args, OpTime(0,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(0,0), &response, &result);
ASSERT_OK(result);
ASSERT_FALSE(response.isElectable());
ASSERT_TRUE(response.isReplSet());
ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s);
- ASSERT_EQUALS(OpTime(0,0), response.getOpTime());
+ ASSERT_EQUALS(Timestamp(0,0), response.getOpTime());
ASSERT_EQUALS(Seconds(0).total_milliseconds(), response.getTime().total_milliseconds());
ASSERT_EQUALS("", response.getHbMsg());
ASSERT_EQUALS("rs0", response.getReplicaSetName());
@@ -3234,12 +3234,12 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
// prepare response and check the results
- prepareHeartbeatResponse(args, OpTime(0,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(0,0), &response, &result);
ASSERT_OK(result);
ASSERT_FALSE(response.isElectable());
ASSERT_TRUE(response.isReplSet());
ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s);
- ASSERT_EQUALS(OpTime(0,0), response.getOpTime());
+ ASSERT_EQUALS(Timestamp(0,0), response.getOpTime());
ASSERT_EQUALS(Seconds(0).total_milliseconds(), response.getTime().total_milliseconds());
ASSERT_EQUALS("", response.getHbMsg());
ASSERT_EQUALS("rs0", response.getReplicaSetName());
@@ -3257,13 +3257,13 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
// prepare response and check the results
- prepareHeartbeatResponse(args, OpTime(0,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(0,0), &response, &result);
ASSERT_OK(result);
ASSERT_TRUE(response.hasConfig());
ASSERT_FALSE(response.isElectable());
ASSERT_TRUE(response.isReplSet());
ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s);
- ASSERT_EQUALS(OpTime(0,0), response.getOpTime());
+ ASSERT_EQUALS(Timestamp(0,0), response.getOpTime());
ASSERT_EQUALS(Seconds(0).total_milliseconds(), response.getTime().total_milliseconds());
ASSERT_EQUALS("", response.getHbMsg());
ASSERT_EQUALS("rs0", response.getReplicaSetName());
@@ -3281,13 +3281,13 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
// prepare response and check the results
- prepareHeartbeatResponse(args, OpTime(0,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(0,0), &response, &result);
ASSERT_OK(result);
ASSERT_FALSE(response.hasConfig());
ASSERT_FALSE(response.isElectable());
ASSERT_TRUE(response.isReplSet());
ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s);
- ASSERT_EQUALS(OpTime(0,0), response.getOpTime());
+ ASSERT_EQUALS(Timestamp(0,0), response.getOpTime());
ASSERT_EQUALS(Seconds(0).total_milliseconds(), response.getTime().total_milliseconds());
ASSERT_EQUALS("", response.getHbMsg());
ASSERT_EQUALS("rs0", response.getReplicaSetName());
@@ -3305,12 +3305,12 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
// prepare response and check the results
- prepareHeartbeatResponse(args, OpTime(0,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(0,0), &response, &result);
ASSERT_OK(result);
ASSERT_FALSE(response.isElectable());
ASSERT_TRUE(response.isReplSet());
ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s);
- ASSERT_EQUALS(OpTime(0,0), response.getOpTime());
+ ASSERT_EQUALS(Timestamp(0,0), response.getOpTime());
ASSERT_EQUALS(Seconds(0).total_milliseconds(), response.getTime().total_milliseconds());
ASSERT_EQUALS("", response.getHbMsg());
ASSERT_EQUALS("rs0", response.getReplicaSetName());
@@ -3320,7 +3320,7 @@ namespace {
TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseSenderUp) {
// set up args and acknowledge sender
- heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, OpTime(0,0));
+ heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, Timestamp(0,0));
ReplSetHeartbeatArgs args;
args.setProtocolVersion(1);
args.setConfigVersion(1);
@@ -3330,13 +3330,13 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
// prepare response and check the results
- prepareHeartbeatResponse(args, OpTime(100,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(100,0), &response, &result);
ASSERT_OK(result);
// this change to true because we can now see a majority, unlike in the previous cases
ASSERT_TRUE(response.isElectable());
ASSERT_TRUE(response.isReplSet());
ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s);
- ASSERT_EQUALS(OpTime(100,0), response.getOpTime());
+ ASSERT_EQUALS(Timestamp(100,0), response.getOpTime());
ASSERT_EQUALS(Seconds(0).total_milliseconds(), response.getTime().total_milliseconds());
ASSERT_EQUALS("", response.getHbMsg());
ASSERT_EQUALS("rs0", response.getReplicaSetName());
@@ -3355,14 +3355,14 @@ namespace {
Status result = getTopoCoord().prepareHeartbeatResponse(now()++,
args,
"rs0",
- OpTime(0,0),
+ Timestamp(0,0),
&response);
ASSERT_OK(result);
// this change to true because we can now see a majority, unlike in the previous cases
ASSERT_FALSE(response.isElectable());
ASSERT_TRUE(response.isReplSet());
ASSERT_EQUALS(MemberState::RS_STARTUP, response.getState().s);
- ASSERT_EQUALS(OpTime(0,0), response.getOpTime());
+ ASSERT_EQUALS(Timestamp(0,0), response.getOpTime());
ASSERT_EQUALS(Seconds(0).total_milliseconds(), response.getTime().total_milliseconds());
ASSERT_EQUALS("", response.getHbMsg());
ASSERT_EQUALS("", response.getReplicaSetName());
@@ -3370,8 +3370,8 @@ namespace {
}
TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseAsPrimary) {
- makeSelfPrimary(OpTime(10,0));
- heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, OpTime(0,0));
+ makeSelfPrimary(Timestamp(10,0));
+ heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, Timestamp(0,0));
ReplSetHeartbeatArgs args;
args.setProtocolVersion(1);
@@ -3382,14 +3382,14 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
// prepare response and check the results
- prepareHeartbeatResponse(args, OpTime(11,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(11,0), &response, &result);
ASSERT_OK(result);
// electable because we are already primary
ASSERT_TRUE(response.isElectable());
ASSERT_TRUE(response.isReplSet());
ASSERT_EQUALS(MemberState::RS_PRIMARY, response.getState().s);
- ASSERT_EQUALS(OpTime(11,0), response.getOpTime());
- ASSERT_EQUALS(OpTime(10,0), response.getElectionTime());
+ ASSERT_EQUALS(Timestamp(11,0), response.getOpTime());
+ ASSERT_EQUALS(Timestamp(10,0), response.getElectionTime());
ASSERT_EQUALS(Seconds(0).total_milliseconds(), response.getTime().total_milliseconds());
ASSERT_EQUALS("", response.getHbMsg());
ASSERT_EQUALS("rs0", response.getReplicaSetName());
@@ -3398,11 +3398,11 @@ namespace {
TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseWithSyncSource) {
// get a sync source
- heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, OpTime(0,0));
- heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, OpTime(0,0));
- heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, OpTime(1,0));
- heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, OpTime(1,0));
- getTopoCoord().chooseNewSyncSource(now()++, OpTime(0,0));
+ heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, Timestamp(0,0));
+ heartbeatFromMember(HostAndPort("h3"), "rs0", MemberState::RS_SECONDARY, Timestamp(0,0));
+ heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, Timestamp(1,0));
+ heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, Timestamp(1,0));
+ getTopoCoord().chooseNewSyncSource(now()++, Timestamp(0,0));
// set up args
ReplSetHeartbeatArgs args;
@@ -3414,12 +3414,12 @@ namespace {
Status result(ErrorCodes::InternalError, "prepareHeartbeatResponse didn't set result");
// prepare response and check the results
- prepareHeartbeatResponse(args, OpTime(100,0), &response, &result);
+ prepareHeartbeatResponse(args, Timestamp(100,0), &response, &result);
ASSERT_OK(result);
ASSERT_TRUE(response.isElectable());
ASSERT_TRUE(response.isReplSet());
ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s);
- ASSERT_EQUALS(OpTime(100,0), response.getOpTime());
+ ASSERT_EQUALS(Timestamp(100,0), response.getOpTime());
ASSERT_EQUALS(Seconds(0).total_milliseconds(), response.getTime().total_milliseconds());
// changed to a syncing message because our sync source changed recently
ASSERT_EQUALS("syncing from: h2:27017", response.getHbMsg());
@@ -3453,7 +3453,7 @@ namespace {
"version" << 1 <<
"members" << BSON_ARRAY(
BSON("_id" << 1 << "host" << "hself" << "priority" << 0))));
- getTopoCoord().updateConfig(cfg, 0, now()++, OpTime());
+ getTopoCoord().updateConfig(cfg, 0, now()++, Timestamp());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
ASSERT_FALSE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
@@ -3480,7 +3480,7 @@ namespace {
"members" << BSON_ARRAY(
BSON("_id" << 1 << "host" << "hself" << "priority" << 0))));
- getTopoCoord().updateConfig(cfg, 0, now()++, OpTime());
+ getTopoCoord().updateConfig(cfg, 0, now()++, Timestamp());
ASSERT_EQUALS(MemberState::RS_STARTUP2, getTopoCoord().getMemberState().s);
// despite being the only node, we are unelectable, so we should not become a candidate
@@ -3556,7 +3556,7 @@ namespace {
ASSERT_TRUE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
// win election and primary
- getTopoCoord().processWinElection(OID::gen(), OpTime(0,0));
+ getTopoCoord().processWinElection(OID::gen(), Timestamp(0,0));
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
@@ -3586,7 +3586,7 @@ namespace {
ASSERT_TRUE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
// win election and primary
- getTopoCoord().processWinElection(OID::gen(), OpTime(0,0));
+ getTopoCoord().processWinElection(OID::gen(), Timestamp(0,0));
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
@@ -3617,7 +3617,7 @@ namespace {
ASSERT_TRUE(TopologyCoordinator::Role::candidate == getTopoCoord().getRole());
// win election and primary
- getTopoCoord().processWinElection(OID::gen(), OpTime(0,0));
+ getTopoCoord().processWinElection(OID::gen(), Timestamp(0,0));
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
@@ -3631,7 +3631,7 @@ namespace {
BSON("_id" << 2 << "host" << "host3:27017"))),
0,
Date_t(-1),
- OpTime(10,0));
+ Timestamp(10,0));
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
@@ -3646,7 +3646,7 @@ namespace {
"tags" << BSON("dc" << "NA" << "rack" << "rack1")))),
0,
Date_t(-1),
- OpTime(10,0));
+ Timestamp(10,0));
ASSERT_TRUE(TopologyCoordinator::Role::leader == getTopoCoord().getRole());
ASSERT_EQUALS(MemberState::RS_PRIMARY, getTopoCoord().getMemberState().s);
}
@@ -3676,8 +3676,8 @@ namespace {
}
TEST_F(HeartbeatResponseTest, ReconfigBetweenHeartbeatRequestAndRepsonse) {
- OpTime election = OpTime(14,0);
- OpTime lastOpTimeApplied = OpTime(13,0);
+ Timestamp election = Timestamp(14,0);
+ Timestamp lastOpTimeApplied = Timestamp(13,0);
// all three members up and secondaries
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -3727,8 +3727,8 @@ namespace {
}
TEST_F(HeartbeatResponseTest, ReconfigNodeRemovedBetweenHeartbeatRequestAndRepsonse) {
- OpTime election = OpTime(14,0);
- OpTime lastOpTimeApplied = OpTime(13,0);
+ Timestamp election = Timestamp(14,0);
+ Timestamp lastOpTimeApplied = Timestamp(13,0);
// all three members up and secondaries
setSelfMemberState(MemberState::RS_SECONDARY);
@@ -3793,10 +3793,10 @@ namespace {
TEST_F(HeartbeatResponseTest, ShouldChangeSyncSourceFresherHappierMemberExists) {
// In this test, the TopologyCoordinator should tell us to change sync sources away from
// "host2" and to "host3" since "host2" is more than maxSyncSourceLagSecs(30) behind "host3"
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(4,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(4,0);
// ahead by more than maxSyncSourceLagSecs (30)
- OpTime fresherLastOpTimeApplied = OpTime(3005,0);
+ Timestamp fresherLastOpTimeApplied = Timestamp(3005,0);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
"rs0",
@@ -3826,10 +3826,10 @@ namespace {
// "host2" and to "host3" despite "host2" being more than maxSyncSourceLagSecs(30) behind
// "host3", since "host3" is blacklisted
// Then, confirm that unblacklisting only works if time has passed the blacklist time.
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(400,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(400,0);
// ahead by more than maxSyncSourceLagSecs (30)
- OpTime fresherLastOpTimeApplied = OpTime(3005,0);
+ Timestamp fresherLastOpTimeApplied = Timestamp(3005,0);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
"rs0",
@@ -3867,10 +3867,10 @@ namespace {
// In this test, the TopologyCoordinator should not tell us to change sync sources away from
// "host2" and to "host3" despite "host2" being more than maxSyncSourceLagSecs(30) behind
// "host3", since "host3" is down
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(400,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(400,0);
// ahead by more than maxSyncSourceLagSecs (30)
- OpTime fresherLastOpTimeApplied = OpTime(3005,0);
+ Timestamp fresherLastOpTimeApplied = Timestamp(3005,0);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
"rs0",
@@ -3898,10 +3898,10 @@ namespace {
// In this test, the TopologyCoordinator should not tell us to change sync sources away from
// "host2" and to "host3" despite "host2" being more than maxSyncSourceLagSecs(30) behind
// "host3", since "host3" is in a non-readable mode (RS_ROLLBACK)
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(4,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(4,0);
// ahead by more than maxSyncSourceLagSecs (30)
- OpTime fresherLastOpTimeApplied = OpTime(3005,0);
+ Timestamp fresherLastOpTimeApplied = Timestamp(3005,0);
HeartbeatResponseAction nextAction = receiveUpHeartbeat(HostAndPort("host2"),
"rs0",
@@ -3927,10 +3927,10 @@ namespace {
// In this test, the TopologyCoordinator should not tell us to change sync sources away from
// "host2" and to "host3" despite "host2" being more than maxSyncSourceLagSecs(30) behind
// "host3", since "host3" does not build indexes
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(4,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(4,0);
// ahead by more than maxSyncSourceLagSecs (30)
- OpTime fresherLastOpTimeApplied = OpTime(3005,0);
+ Timestamp fresherLastOpTimeApplied = Timestamp(3005,0);
updateConfig(BSON("_id" << "rs0" <<
"version" << 6 <<
@@ -3963,10 +3963,10 @@ namespace {
// In this test, the TopologyCoordinator should tell us to change sync sources away from
// "host2" and to "host3" despite "host3" not building indexes because we do not build
// indexes either and "host2" is more than maxSyncSourceLagSecs(30) behind "host3"
- OpTime election = OpTime(0,0);
- OpTime lastOpTimeApplied = OpTime(4,0);
+ Timestamp election = Timestamp(0,0);
+ Timestamp lastOpTimeApplied = Timestamp(4,0);
// ahead by more than maxSyncSourceLagSecs (30)
- OpTime fresherLastOpTimeApplied = OpTime(3005,0);
+ Timestamp fresherLastOpTimeApplied = Timestamp(3005,0);
updateConfig(BSON("_id" << "rs0" <<
"version" << 7 <<
@@ -4009,8 +4009,8 @@ namespace {
0);
setSelfMemberState(MemberState::RS_SECONDARY);
- heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_PRIMARY, OpTime(1,0));
- ASSERT_FALSE(getTopoCoord().checkShouldStandForElection(now()++, OpTime(0,0)));
+ heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_PRIMARY, Timestamp(1,0));
+ ASSERT_FALSE(getTopoCoord().checkShouldStandForElection(now()++, Timestamp(0,0)));
}
TEST_F(TopoCoordTest, CheckShouldStandForElectionNotCloseEnoughToLastOptime) {
@@ -4023,8 +4023,8 @@ namespace {
0);
setSelfMemberState(MemberState::RS_SECONDARY);
- heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, OpTime(10000,0));
- ASSERT_FALSE(getTopoCoord().checkShouldStandForElection(now()++, OpTime(100,0)));
+ heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, Timestamp(10000,0));
+ ASSERT_FALSE(getTopoCoord().checkShouldStandForElection(now()++, Timestamp(100,0)));
}
TEST_F(TopoCoordTest, VoteForMyselfFailsWhileNotCandidate) {
@@ -4053,7 +4053,7 @@ namespace {
TEST_F(TopoCoordTest, UnelectableIfAbsentFromConfig) {
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
startCapturingLogMessages();
- ASSERT_FALSE(getTopoCoord().checkShouldStandForElection(now()++, OpTime(10,0)));
+ ASSERT_FALSE(getTopoCoord().checkShouldStandForElection(now()++, Timestamp(10,0)));
stopCapturingLogMessages();
ASSERT_EQUALS(1, countLogLinesContaining("not a member of a valid replica set config"));
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Log());
@@ -4068,7 +4068,7 @@ namespace {
BSON("_id" << 30 << "host" << "h3"))),
0);
setSelfMemberState(MemberState::RS_SECONDARY);
- heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, OpTime(100,0));
+ heartbeatFromMember(HostAndPort("h2"), "rs0", MemberState::RS_SECONDARY, Timestamp(100,0));
// vote for another node
OID remoteRound = OID::gen();
@@ -4083,7 +4083,7 @@ namespace {
BSONObjBuilder electResponseBuilder;
Status result = Status(ErrorCodes::InternalError, "status not set by prepareElectResponse");
getTopoCoord().prepareElectResponse(
- electArgs, now()++, OpTime(100,0), &electResponseBuilder, &result);
+ electArgs, now()++, Timestamp(100,0), &electResponseBuilder, &result);
BSONObj response = electResponseBuilder.obj();
ASSERT_OK(result);
std::cout << response;
@@ -4092,7 +4092,7 @@ namespace {
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(3));
startCapturingLogMessages();
- ASSERT_FALSE(getTopoCoord().checkShouldStandForElection(now()++, OpTime(10,0)));
+ ASSERT_FALSE(getTopoCoord().checkShouldStandForElection(now()++, Timestamp(10,0)));
stopCapturingLogMessages();
ASSERT_EQUALS(1, countLogLinesContaining("I recently voted for "));
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Log());
diff --git a/src/mongo/db/repl/update_position_args.cpp b/src/mongo/db/repl/update_position_args.cpp
index 78b08bfc483..39b0aa762f9 100644
--- a/src/mongo/db/repl/update_position_args.cpp
+++ b/src/mongo/db/repl/update_position_args.cpp
@@ -40,7 +40,7 @@ namespace repl {
UpdatePositionArgs::UpdateInfo::UpdateInfo(
- const OID& anRid, const OpTime& aTs, long long aCfgver, long long aMemberId)
+ const OID& anRid, const Timestamp& aTs, long long aCfgver, long long aMemberId)
: rid(anRid), ts(aTs), cfgver(aCfgver), memberId(aMemberId) {}
namespace {
@@ -93,8 +93,8 @@ namespace {
if (!status.isOK())
return status;
- OpTime ts;
- status = bsonExtractOpTimeField(entry, kOpTimeFieldName, &ts);
+ Timestamp ts;
+ status = bsonExtractTimestampField(entry, kOpTimeFieldName, &ts);
if (!status.isOK())
return status;
diff --git a/src/mongo/db/repl/update_position_args.h b/src/mongo/db/repl/update_position_args.h
index 9d9afebced2..e0fb6ebf805 100644
--- a/src/mongo/db/repl/update_position_args.h
+++ b/src/mongo/db/repl/update_position_args.h
@@ -44,10 +44,10 @@ namespace repl {
class UpdatePositionArgs {
public:
struct UpdateInfo {
- UpdateInfo(const OID& anRid, const OpTime& aTs, long long aCfgver, long long aMemberId);
+ UpdateInfo(const OID& anRid, const Timestamp& aTs, long long aCfgver, long long aMemberId);
OID rid;
- OpTime ts;
+ Timestamp ts;
long long cfgver;
long long memberId;
};
diff --git a/src/mongo/db/storage/index_entry_comparison.h b/src/mongo/db/storage/index_entry_comparison.h
index f12ea85c4f2..c1415c2fba2 100644
--- a/src/mongo/db/storage/index_entry_comparison.h
+++ b/src/mongo/db/storage/index_entry_comparison.h
@@ -30,9 +30,7 @@
#include <vector>
-#include "mongo/bson/bsonelement.h"
-#include "mongo/bson/bsonobj.h"
-#include "mongo/bson/ordering.h"
+#include "mongo/db/jsobj.h"
#include "mongo/db/record_id.h"
namespace mongo {
diff --git a/src/mongo/db/storage/key_string.cpp b/src/mongo/db/storage/key_string.cpp
index 13e7711a217..2b3391e1d42 100644
--- a/src/mongo/db/storage/key_string.cpp
+++ b/src/mongo/db/storage/key_string.cpp
@@ -143,7 +143,7 @@ namespace mongo {
case jstOID: return CType::kOID;
case Bool: return CType::kBool;
case Date: return CType::kDate;
- case Timestamp: return CType::kTimestamp;
+ case bsonTimestamp: return CType::kTimestamp;
case RegEx: return CType::kRegEx;
case DBRef: return CType::kDBRef;
@@ -363,7 +363,7 @@ namespace mongo {
_append(endian::nativeToBig(encoded), invert);
}
- void KeyString::_appendTimestamp(OpTime val, bool invert) {
+ void KeyString::_appendTimestamp(Timestamp val, bool invert) {
_append(CType::kTimestamp, invert);
_append(endian::nativeToBig(val.asLL()), invert);
}
@@ -558,7 +558,7 @@ namespace mongo {
break;
}
case NumberInt: _appendNumberInt(elem._numberInt(), invert); break;
- case Timestamp: _appendTimestamp(elem._opTime(), invert); break;
+ case bsonTimestamp: _appendTimestamp(elem.timestamp(), invert); break;
case NumberLong: _appendNumberLong(elem._numberLong(), invert); break;
default:
@@ -740,7 +740,7 @@ namespace mongo {
break;
case CType::kTimestamp:
- *stream << OpTime(endian::bigToNative(readType<uint64_t>(reader, inverted)));
+ *stream << Timestamp(endian::bigToNative(readType<uint64_t>(reader, inverted)));
break;
case CType::kOID:
diff --git a/src/mongo/db/storage/key_string.h b/src/mongo/db/storage/key_string.h
index 50b05141818..5bd9cf7c8a9 100644
--- a/src/mongo/db/storage/key_string.h
+++ b/src/mongo/db/storage/key_string.h
@@ -31,9 +31,8 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/bson/bsonmisc.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/bson/ordering.h"
-#include "mongo/bson/bson_db.h"
#include "mongo/db/record_id.h"
namespace mongo {
@@ -248,7 +247,7 @@ namespace mongo {
void _appendBool(bool val, bool invert);
void _appendDate(Date_t val, bool invert);
- void _appendTimestamp(OpTime val, bool invert);
+ void _appendTimestamp(Timestamp val, bool invert);
void _appendOID(OID val, bool invert);
void _appendString(StringData val, bool invert);
void _appendSymbol(StringData val, bool invert);
diff --git a/src/mongo/db/storage/key_string_test.cpp b/src/mongo/db/storage/key_string_test.cpp
index 5d122844aeb..267f1ba6501 100644
--- a/src/mongo/db/storage/key_string_test.cpp
+++ b/src/mongo/db/storage/key_string_test.cpp
@@ -150,7 +150,7 @@ TEST(KeyStringTest, AllTypesSimple) {
ROUNDTRIP(BSON("" << BSONCode("abc_code")));
ROUNDTRIP(BSON("" << BSONCodeWScope("def_code", BSON("x_scope" << "a"))));
ROUNDTRIP(BSON("" << 5));
- ROUNDTRIP(BSON("" << OpTime(123123, 123)));
+ ROUNDTRIP(BSON("" << Timestamp(123123, 123)));
ROUNDTRIP(BSON("" << 1235123123123LL));
}
@@ -310,12 +310,12 @@ TEST(KeyStringTest, RecordIdOrder2Double) {
ASSERT_LESS_THAN(a, c);
}
-TEST(KeyStringTest, OpTime) {
+TEST(KeyStringTest, Timestamp) {
- BSONObj a = BSON("" << OpTime(0, 0));
- BSONObj b = BSON("" << OpTime(1234, 1));
- BSONObj c = BSON("" << OpTime(1234, 2));
- BSONObj d = BSON("" << OpTime(1235, 1));
+ BSONObj a = BSON("" << Timestamp(0, 0));
+ BSONObj b = BSON("" << Timestamp(1234, 1));
+ BSONObj c = BSON("" << Timestamp(1234, 2));
+ BSONObj d = BSON("" << Timestamp(1235, 1));
{
ROUNDTRIP(a);
diff --git a/src/mongo/db/storage/mmap_v1/btree/key.cpp b/src/mongo/db/storage/mmap_v1/btree/key.cpp
index 0ee18f614ac..c49e944ceb3 100644
--- a/src/mongo/db/storage/mmap_v1/btree/key.cpp
+++ b/src/mongo/db/storage/mmap_v1/btree/key.cpp
@@ -65,7 +65,7 @@ namespace mongo {
return 0;
case Bool:
return *l.value() - *r.value();
- case Timestamp:
+ case bsonTimestamp:
case Date:
// unsigned dates for old version
if ( l.date() < r.date() )
diff --git a/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp b/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp
index 1a0d03d96a4..73583a77ef7 100644
--- a/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp
@@ -39,6 +39,7 @@
#include "mongo/platform/basic.h"
#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
#include "mongo/db/storage/mmap_v1/aligned_builder.h"
#include "mongo/db/storage/mmap_v1/durable_mapped_file.h"
diff --git a/src/mongo/db/storage/oplog_hack.cpp b/src/mongo/db/storage/oplog_hack.cpp
index 0bee74310f7..b25268e4271 100644
--- a/src/mongo/db/storage/oplog_hack.cpp
+++ b/src/mongo/db/storage/oplog_hack.cpp
@@ -34,7 +34,7 @@
#include <limits>
#include "mongo/bson/bson_validate.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/record_id.h"
#include "mongo/util/debug_util.h"
@@ -42,7 +42,7 @@
namespace mongo {
namespace oploghack {
- StatusWith<RecordId> keyForOptime(const OpTime& opTime) {
+ StatusWith<RecordId> keyForOptime(const Timestamp& opTime) {
// Make sure secs and inc wouldn't be negative if treated as signed. This ensures that they
// don't sort differently when put in a RecordId. It also avoids issues with Null/Invalid
// RecordIds
@@ -71,10 +71,10 @@ namespace oploghack {
const BSONElement elem = obj["ts"];
if (elem.eoo())
return StatusWith<RecordId>(ErrorCodes::BadValue, "no ts field");
- if (elem.type() != Timestamp)
+ if (elem.type() != bsonTimestamp)
return StatusWith<RecordId>(ErrorCodes::BadValue, "ts must be a Timestamp");
- return keyForOptime(elem._opTime());
+ return keyForOptime(elem.timestamp());
}
} // namespace oploghack
diff --git a/src/mongo/db/storage/oplog_hack.h b/src/mongo/db/storage/oplog_hack.h
index 20708c1db4c..92138959304 100644
--- a/src/mongo/db/storage/oplog_hack.h
+++ b/src/mongo/db/storage/oplog_hack.h
@@ -33,15 +33,15 @@
namespace mongo {
class RecordId;
- class OpTime;
+ class Timestamp;
namespace oploghack {
/**
- * Converts OpTime to a RecordId in an unspecified manor that is safe to use as the key to in a
- * RecordStore.
+ * Converts Timestamp to a RecordId in an unspecified manor that is safe to use as the key to
+ * in a RecordStore.
*/
- StatusWith<RecordId> keyForOptime(const OpTime& opTime);
+ StatusWith<RecordId> keyForOptime(const Timestamp& opTime);
/**
* data and len must be the arguments from RecordStore::insert() on an oplog collection.
diff --git a/src/mongo/db/storage/record_store.h b/src/mongo/db/storage/record_store.h
index 48e5aec5e06..f0a09eb67fd 100644
--- a/src/mongo/db/storage/record_store.h
+++ b/src/mongo/db/storage/record_store.h
@@ -343,7 +343,7 @@ namespace mongo {
* they are ordered.
*/
virtual Status oplogDiskLocRegister( OperationContext* txn,
- const OpTime& opTime ) {
+ const Timestamp& opTime ) {
return Status::OK();
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index ee440b67216..c53686fa623 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -863,7 +863,7 @@ namespace {
}
Status WiredTigerRecordStore::oplogDiskLocRegister( OperationContext* txn,
- const OpTime& opTime ) {
+ const Timestamp& opTime ) {
StatusWith<RecordId> loc = oploghack::keyForOptime( opTime );
if ( !loc.isOK() )
return loc.getStatus();
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
index 6defe3552fa..5447425ca9b 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
@@ -182,7 +182,7 @@ namespace mongo {
const RecordId& startingPosition) const;
virtual Status oplogDiskLocRegister( OperationContext* txn,
- const OpTime& opTime );
+ const Timestamp& opTime );
virtual void updateStatsAfterRepair(OperationContext* txn,
long long numRecords,
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
index b944e38329d..d8f8d6cc016 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
@@ -515,7 +515,7 @@ namespace {
StatusWith<RecordId> insertBSON(scoped_ptr<OperationContext>& opCtx,
scoped_ptr<RecordStore>& rs,
- const OpTime& opTime) {
+ const Timestamp& opTime) {
BSONObj obj = BSON( "ts" << opTime );
WriteUnitOfWork wuow(opCtx.get());
WiredTigerRecordStore* wrs = checked_cast<WiredTigerRecordStore*>(rs.get());
@@ -540,33 +540,33 @@ namespace {
scoped_ptr<OperationContext> opCtx(harnessHelper.newOperationContext());
// always illegal
- ASSERT_EQ(insertBSON(opCtx, rs, OpTime(2,-1)).getStatus(),
+ ASSERT_EQ(insertBSON(opCtx, rs, Timestamp(2,-1)).getStatus(),
ErrorCodes::BadValue);
{
- BSONObj obj = BSON("not_ts" << OpTime(2,1));
+ BSONObj obj = BSON("not_ts" << Timestamp(2,1));
ASSERT_EQ(rs->insertRecord(opCtx.get(), obj.objdata(), obj.objsize(),
false ).getStatus(),
ErrorCodes::BadValue);
- obj = BSON( "ts" << "not an OpTime" );
+ obj = BSON( "ts" << "not a Timestamp" );
ASSERT_EQ(rs->insertRecord(opCtx.get(), obj.objdata(), obj.objsize(),
false ).getStatus(),
ErrorCodes::BadValue);
}
// currently dasserts
- // ASSERT_EQ(insertBSON(opCtx, rs, BSON("ts" << OpTime(-2,1))).getStatus(),
+ // ASSERT_EQ(insertBSON(opCtx, rs, BSON("ts" << Timestamp(-2,1))).getStatus(),
// ErrorCodes::BadValue);
// success cases
- ASSERT_EQ(insertBSON(opCtx, rs, OpTime(1,1)).getValue(),
+ ASSERT_EQ(insertBSON(opCtx, rs, Timestamp(1,1)).getValue(),
RecordId(1,1));
- ASSERT_EQ(insertBSON(opCtx, rs, OpTime(1,2)).getValue(),
+ ASSERT_EQ(insertBSON(opCtx, rs, Timestamp(1,2)).getValue(),
RecordId(1,2));
- ASSERT_EQ(insertBSON(opCtx, rs, OpTime(2,2)).getValue(),
+ ASSERT_EQ(insertBSON(opCtx, rs, Timestamp(2,2)).getValue(),
RecordId(2,2));
}
@@ -628,7 +628,7 @@ namespace {
scoped_ptr<OperationContext> opCtx(harnessHelper.newOperationContext());
- BSONObj obj = BSON( "ts" << OpTime(2,-1) );
+ BSONObj obj = BSON( "ts" << Timestamp(2,-1) );
{
WriteUnitOfWork wuow( opCtx.get() );
ASSERT_OK(rs->insertRecord(opCtx.get(), obj.objdata(),
@@ -746,7 +746,7 @@ namespace {
RecordId _oplogOrderInsertOplog( OperationContext* txn,
scoped_ptr<RecordStore>& rs,
int inc ) {
- OpTime opTime = OpTime(5,inc);
+ Timestamp opTime = Timestamp(5,inc);
WiredTigerRecordStore* wrs = checked_cast<WiredTigerRecordStore*>(rs.get());
Status status = wrs->oplogDiskLocRegister( txn, opTime );
ASSERT_OK( status );
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
index 12c3380e760..7673bcddbac 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
@@ -31,6 +31,8 @@
#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage
+#include <boost/thread.hpp>
+
#include "mongo/db/storage/wiredtiger/wiredtiger_session_cache.h"
#include "mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h"
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp
index 8d61fb17712..5d0affb7305 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp
@@ -31,6 +31,7 @@
#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage
+#include <boost/thread.hpp>
#include <wiredtiger.h>
#include "mongo/bson/bsonobj.h"
diff --git a/src/mongo/db/write_concern.cpp b/src/mongo/db/write_concern.cpp
index 8b1b7334813..a16352b34fc 100644
--- a/src/mongo/db/write_concern.cpp
+++ b/src/mongo/db/write_concern.cpp
@@ -191,7 +191,7 @@ namespace mongo {
}
Status waitForWriteConcern( OperationContext* txn,
- const OpTime& replOpTime,
+ const Timestamp& replOpTime,
WriteConcernResult* result ) {
const WriteConcernOptions& writeConcern = txn->getWriteConcern();
diff --git a/src/mongo/db/write_concern.h b/src/mongo/db/write_concern.h
index c287d1ff8fd..0f375c9c069 100644
--- a/src/mongo/db/write_concern.h
+++ b/src/mongo/db/write_concern.h
@@ -94,7 +94,7 @@ namespace mongo {
* Returns UnknownReplWriteConcern if the wMode specified was not enforceable
*/
Status waitForWriteConcern( OperationContext* txn,
- const OpTime& replOpTime,
+ const Timestamp& replOpTime,
WriteConcernResult* result );
diff --git a/src/mongo/db/write_concern_options.cpp b/src/mongo/db/write_concern_options.cpp
index 5c0102ebc4a..50bf9cad040 100644
--- a/src/mongo/db/write_concern_options.cpp
+++ b/src/mongo/db/write_concern_options.cpp
@@ -27,9 +27,9 @@
#include "mongo/db/write_concern_options.h"
-#include "mongo/bson/bson_field.h"
#include "mongo/client/dbclientinterface.h"
#include "mongo/db/field_parser.h"
+#include "mongo/db/jsobj.h"
namespace mongo {
diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp
index b0790d2e6fc..8785cb312cb 100644
--- a/src/mongo/dbtests/documentsourcetests.cpp
+++ b/src/mongo/dbtests/documentsourcetests.cpp
@@ -32,6 +32,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/thread/condition.hpp>
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
diff --git a/src/mongo/dbtests/jsobjtests.cpp b/src/mongo/dbtests/jsobjtests.cpp
index ff99677170a..62a69fc6ded 100644
--- a/src/mongo/dbtests/jsobjtests.cpp
+++ b/src/mongo/dbtests/jsobjtests.cpp
@@ -1503,8 +1503,8 @@ namespace JsobjTests {
ASSERT_EQUALS(objTypeOf(1), NumberInt);
ASSERT_EQUALS(arrTypeOf(1), NumberInt);
- ASSERT_EQUALS(objTypeOf(OpTime()), Timestamp);
- ASSERT_EQUALS(arrTypeOf(OpTime()), Timestamp);
+ ASSERT_EQUALS(objTypeOf(Timestamp()), bsonTimestamp);
+ ASSERT_EQUALS(arrTypeOf(Timestamp()), bsonTimestamp);
ASSERT_EQUALS(objTypeOf(1LL), NumberLong);
ASSERT_EQUALS(arrTypeOf(1LL), NumberLong);
diff --git a/src/mongo/dbtests/jsontests.cpp b/src/mongo/dbtests/jsontests.cpp
index eadcec07af8..828e35c20e3 100644
--- a/src/mongo/dbtests/jsontests.cpp
+++ b/src/mongo/dbtests/jsontests.cpp
@@ -529,7 +529,7 @@ namespace JsonTests {
public:
void run() {
BSONObjBuilder b;
- b.append( "x" , OpTime(4, 10) );
+ b.append( "x" , Timestamp(4, 10) );
BSONObj o = b.obj();
ASSERT_EQUALS( "{ \"x\" : { \"$timestamp\" : { \"t\" : 4, \"i\" : 10 } } }",
o.jsonString( Strict ) );
@@ -1772,10 +1772,10 @@ namespace JsonTests {
}
};
- class Timestamp : public Base {
+ class JSTimestamp : public Base {
virtual BSONObj bson() const {
BSONObjBuilder b;
- b.append( "a", OpTime(20, 5) );
+ b.append( "a", Timestamp(20, 5) );
return b.obj();
}
virtual string json() const {
@@ -1792,7 +1792,7 @@ namespace JsonTests {
class TimestampZero : public Base {
virtual BSONObj bson() const {
BSONObjBuilder b;
- b.append( "a", OpTime() );
+ b.append( "a", Timestamp() );
return b.obj();
}
virtual string json() const {
@@ -1839,7 +1839,7 @@ namespace JsonTests {
class TimestampObject : public Base {
virtual BSONObj bson() const {
BSONObjBuilder b;
- b.append( "a", OpTime(20, 5) );
+ b.append( "a", Timestamp(20, 5) );
return b.obj();
}
virtual string json() const {
@@ -1880,7 +1880,7 @@ namespace JsonTests {
class TimestampObjectZero : public Base {
virtual BSONObj bson() const {
BSONObjBuilder b;
- b.append( "a", OpTime() );
+ b.append( "a", Timestamp() );
return b.obj();
}
virtual string json() const {
@@ -2836,7 +2836,7 @@ namespace JsonTests {
add< FromJsonTests::NumberIntNeg >();
add< FromJsonTests::NumberLongBad >();
add< FromJsonTests::NumberIntBad >();
- add< FromJsonTests::Timestamp >();
+ add< FromJsonTests::JSTimestamp >();
add< FromJsonTests::TimestampNoIncrement >();
add< FromJsonTests::TimestampZero >();
add< FromJsonTests::TimestampNoArgs >();
diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp
index 9389be5d4d0..a83e153185d 100644
--- a/src/mongo/dbtests/jstests.cpp
+++ b/src/mongo/dbtests/jstests.cpp
@@ -525,7 +525,7 @@ namespace JSTests {
b.appendTimestamp( "a" , 123456789 );
b.appendMinKey( "b" );
b.appendMaxKey( "c" );
- b.append( "d" , OpTime(1234, 9876) );
+ b.append( "d" , Timestamp(1234, 9876) );
{
@@ -539,10 +539,10 @@ namespace JSTests {
ASSERT( s->invoke( "y = { a : z.a , b : z.b , c : z.c , d: z.d }" , 0, 0 ) == 0 );
BSONObj out = s->getObject( "y" );
- ASSERT_EQUALS( Timestamp , out["a"].type() );
+ ASSERT_EQUALS( bsonTimestamp , out["a"].type() );
ASSERT_EQUALS( MinKey , out["b"].type() );
ASSERT_EQUALS( MaxKey , out["c"].type() );
- ASSERT_EQUALS( Timestamp , out["d"].type() );
+ ASSERT_EQUALS( bsonTimestamp , out["d"].type() );
ASSERT_EQUALS( 9876U , out["d"].timestampInc() );
ASSERT_EQUALS( 1234000U , out["d"].timestampTime() );
@@ -794,7 +794,7 @@ namespace JSTests {
BSONObj in;
{
BSONObjBuilder b;
- b.bb().appendNum( static_cast<char>(Timestamp) );
+ b.bb().appendNum( static_cast<char>(bsonTimestamp) );
b.bb().appendStr( "a" );
b.bb().appendNum( std::numeric_limits<unsigned long long>::max() );
@@ -1647,10 +1647,10 @@ namespace JSTests {
}
};
- class Timestamp : public TestRoundTrip {
+ class JSTimestamp : public TestRoundTrip {
virtual BSONObj bson() const {
BSONObjBuilder b;
- b.append( "a", OpTime(20, 5) );
+ b.append( "a", Timestamp(20, 5) );
return b.obj();
}
virtual string json() const {
@@ -1661,12 +1661,12 @@ namespace JSTests {
class TimestampMax : public TestRoundTrip {
virtual BSONObj bson() const {
BSONObjBuilder b;
- b.appendMaxForType( "a", mongo::Timestamp );
+ b.appendMaxForType( "a", mongo::bsonTimestamp );
BSONObj o = b.obj();
return o;
}
virtual string json() const {
- OpTime opTime = OpTime::max();
+ Timestamp opTime = Timestamp::max();
stringstream ss;
ss << "{ \"a\" : Timestamp( " << opTime.getSecs() << ", " << opTime.getInc()
<< " ) }";
@@ -2154,7 +2154,7 @@ namespace JSTests {
add< RoundTripTests::Date >();
add< RoundTripTests::DateNonzero >();
add< RoundTripTests::DateNegative >();
- add< RoundTripTests::Timestamp >();
+ add< RoundTripTests::JSTimestamp >();
add< RoundTripTests::TimestampMax >();
add< RoundTripTests::Regex >();
add< RoundTripTests::RegexWithQuotes >();
diff --git a/src/mongo/dbtests/mock/mock_remote_db_server.h b/src/mongo/dbtests/mock/mock_remote_db_server.h
index 61074e4c857..aded4542d31 100644
--- a/src/mongo/dbtests/mock/mock_remote_db_server.h
+++ b/src/mongo/dbtests/mock/mock_remote_db_server.h
@@ -31,9 +31,8 @@
#include <string>
#include <vector>
-#include "mongo/bson/bson_field.h"
-#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/client/dbclientinterface.h"
+#include "mongo/db/jsobj.h"
#include "mongo/platform/unordered_map.h"
#include "mongo/util/concurrency/spin_lock.h"
diff --git a/src/mongo/dbtests/pdfiletests.cpp b/src/mongo/dbtests/pdfiletests.cpp
index 28f777063ed..97eccd6cb25 100644
--- a/src/mongo/dbtests/pdfiletests.cpp
+++ b/src/mongo/dbtests/pdfiletests.cpp
@@ -106,9 +106,9 @@ namespace PdfileTests {
ASSERT( fixed.firstElement().number() == 1 );
BSONElement a = fixed["a"];
- ASSERT( o["a"].type() == Timestamp );
+ ASSERT( o["a"].type() == bsonTimestamp );
ASSERT( o["a"].timestampValue() == 0 );
- ASSERT( a.type() == Timestamp );
+ ASSERT( a.type() == bsonTimestamp );
ASSERT( a.timestampValue() > 0 );
}
};
@@ -131,15 +131,15 @@ namespace PdfileTests {
ASSERT( fixed.firstElement().number() == 1 );
BSONElement a = fixed["a"];
- ASSERT( o["a"].type() == Timestamp );
+ ASSERT( o["a"].type() == bsonTimestamp );
ASSERT( o["a"].timestampValue() == 0 );
- ASSERT( a.type() == Timestamp );
+ ASSERT( a.type() == bsonTimestamp );
ASSERT( a.timestampValue() > 0 );
BSONElement b = fixed["b"];
- ASSERT( o["b"].type() == Timestamp );
+ ASSERT( o["b"].type() == bsonTimestamp );
ASSERT( o["b"].timestampValue() == 0 );
- ASSERT( b.type() == Timestamp );
+ ASSERT( b.type() == bsonTimestamp );
ASSERT( b.timestampValue() > 0 );
}
};
diff --git a/src/mongo/dbtests/perftests.cpp b/src/mongo/dbtests/perftests.cpp
index 22a59967385..1da93f0e3d3 100644
--- a/src/mongo/dbtests/perftests.cpp
+++ b/src/mongo/dbtests/perftests.cpp
@@ -41,6 +41,7 @@
#include <boost/filesystem/operations.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/thread/condition.hpp>
#include <boost/version.hpp>
#include <iomanip>
#include <iostream>
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index eb5cf7402f9..5b9b84be5ba 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -40,7 +40,7 @@
#include "mongo/db/dbhelpers.h"
#include "mongo/db/service_context_d.h"
#include "mongo/db/service_context.h"
-#include "mongo/db/global_optime.h"
+#include "mongo/db/global_timestamp.h"
#include "mongo/db/json.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/operation_context_impl.h"
@@ -665,9 +665,9 @@ namespace QueryTests {
"capped" << true << "size" << 8192 ),
info );
- Date_t one = getNextGlobalOptime().asDate();
- Date_t two = getNextGlobalOptime().asDate();
- Date_t three = getNextGlobalOptime().asDate();
+ Date_t one = getNextGlobalTimestamp().asULL();
+ Date_t two = getNextGlobalTimestamp().asULL();
+ Date_t three = getNextGlobalTimestamp().asULL();
insert( ns, BSON( "ts" << one ) );
insert( ns, BSON( "ts" << two ) );
insert( ns, BSON( "ts" << three ) );
@@ -680,7 +680,7 @@ namespace QueryTests {
ClientCursorPin clientCursor( ctx.db()->getCollection( ns )->getCursorManager(),
cursorId );
- ASSERT_EQUALS( three.millis, clientCursor.c()->getSlaveReadTill().asDate() );
+ ASSERT_EQUALS( three.millis, clientCursor.c()->getSlaveReadTill().asULL() );
}
};
diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp
index 8b85906cf18..d768302d02d 100644
--- a/src/mongo/dbtests/repltests.cpp
+++ b/src/mongo/dbtests/repltests.cpp
@@ -1366,15 +1366,15 @@ namespace ReplTests {
public:
void run() {
DatabaseIgnorer d;
- ASSERT( !d.ignoreAt( "a", OpTime( 4, 0 ) ) );
- d.doIgnoreUntilAfter( "a", OpTime( 5, 0 ) );
- ASSERT( d.ignoreAt( "a", OpTime( 4, 0 ) ) );
- ASSERT( !d.ignoreAt( "b", OpTime( 4, 0 ) ) );
- ASSERT( d.ignoreAt( "a", OpTime( 4, 10 ) ) );
- ASSERT( d.ignoreAt( "a", OpTime( 5, 0 ) ) );
- ASSERT( !d.ignoreAt( "a", OpTime( 5, 1 ) ) );
+ ASSERT( !d.ignoreAt( "a", Timestamp( 4, 0 ) ) );
+ d.doIgnoreUntilAfter( "a", Timestamp( 5, 0 ) );
+ ASSERT( d.ignoreAt( "a", Timestamp( 4, 0 ) ) );
+ ASSERT( !d.ignoreAt( "b", Timestamp( 4, 0 ) ) );
+ ASSERT( d.ignoreAt( "a", Timestamp( 4, 10 ) ) );
+ ASSERT( d.ignoreAt( "a", Timestamp( 5, 0 ) ) );
+ ASSERT( !d.ignoreAt( "a", Timestamp( 5, 1 ) ) );
// Ignore state is expired.
- ASSERT( !d.ignoreAt( "a", OpTime( 4, 0 ) ) );
+ ASSERT( !d.ignoreAt( "a", Timestamp( 4, 0 ) ) );
}
};
@@ -1382,19 +1382,19 @@ namespace ReplTests {
public:
void run() {
DatabaseIgnorer d;
- d.doIgnoreUntilAfter( "a", OpTime( 5, 0 ) );
- d.doIgnoreUntilAfter( "a", OpTime( 6, 0 ) );
- ASSERT( d.ignoreAt( "a", OpTime( 5, 5 ) ) );
- ASSERT( d.ignoreAt( "a", OpTime( 6, 0 ) ) );
- ASSERT( !d.ignoreAt( "a", OpTime( 6, 1 ) ) );
-
- d.doIgnoreUntilAfter( "a", OpTime( 5, 0 ) );
- d.doIgnoreUntilAfter( "a", OpTime( 6, 0 ) );
- d.doIgnoreUntilAfter( "a", OpTime( 6, 0 ) );
- d.doIgnoreUntilAfter( "a", OpTime( 5, 0 ) );
- ASSERT( d.ignoreAt( "a", OpTime( 5, 5 ) ) );
- ASSERT( d.ignoreAt( "a", OpTime( 6, 0 ) ) );
- ASSERT( !d.ignoreAt( "a", OpTime( 6, 1 ) ) );
+ d.doIgnoreUntilAfter( "a", Timestamp( 5, 0 ) );
+ d.doIgnoreUntilAfter( "a", Timestamp( 6, 0 ) );
+ ASSERT( d.ignoreAt( "a", Timestamp( 5, 5 ) ) );
+ ASSERT( d.ignoreAt( "a", Timestamp( 6, 0 ) ) );
+ ASSERT( !d.ignoreAt( "a", Timestamp( 6, 1 ) ) );
+
+ d.doIgnoreUntilAfter( "a", Timestamp( 5, 0 ) );
+ d.doIgnoreUntilAfter( "a", Timestamp( 6, 0 ) );
+ d.doIgnoreUntilAfter( "a", Timestamp( 6, 0 ) );
+ d.doIgnoreUntilAfter( "a", Timestamp( 5, 0 ) );
+ ASSERT( d.ignoreAt( "a", Timestamp( 5, 5 ) ) );
+ ASSERT( d.ignoreAt( "a", Timestamp( 6, 0 ) ) );
+ ASSERT( !d.ignoreAt( "a", Timestamp( 6, 1 ) ) );
}
};
diff --git a/src/mongo/s/catalog/type_chunk.h b/src/mongo/s/catalog/type_chunk.h
index 3c03bc959e1..a53c256b6c0 100644
--- a/src/mongo/s/catalog/type_chunk.h
+++ b/src/mongo/s/catalog/type_chunk.h
@@ -31,7 +31,7 @@
#include <boost/optional.hpp>
#include <string>
-#include "mongo/bson/bson_field.h"
+#include "mongo/db/jsobj.h"
#include "mongo/s/chunk_version.h"
namespace mongo {
diff --git a/src/mongo/s/chunk_version.h b/src/mongo/s/chunk_version.h
index 720fd48de53..50f121b97ee 100644
--- a/src/mongo/s/chunk_version.h
+++ b/src/mongo/s/chunk_version.h
@@ -264,7 +264,7 @@ namespace mongo {
return ChunkVersion( 0, 0, el.OID() );
}
- if( type == Timestamp || type == Date ){
+ if( type == bsonTimestamp || type == Date ){
return fromDeprecatedLong( el._numberLong(), OID() );
}
diff --git a/src/mongo/s/client_info.cpp b/src/mongo/s/client_info.cpp
index adfefc5663e..bc7f0a91f15 100644
--- a/src/mongo/s/client_info.cpp
+++ b/src/mongo/s/client_info.cpp
@@ -34,6 +34,8 @@
#include "mongo/s/client_info.h"
+#include <boost/thread.hpp>
+
#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/service_context.h"
diff --git a/src/mongo/s/cluster_last_error_info.cpp b/src/mongo/s/cluster_last_error_info.cpp
index c2a1402c02e..8347bd50ec0 100644
--- a/src/mongo/s/cluster_last_error_info.cpp
+++ b/src/mongo/s/cluster_last_error_info.cpp
@@ -90,7 +90,7 @@ namespace mongo {
ConnectionString shardConn = ConnectionString::parse(hostString, errmsg);
BSONElement subobj = result[kGLEStatsFieldName];
- OpTime lastOpTime = subobj[kGLEStatsLastOpTimeFieldName]._opTime();
+ Timestamp lastOpTime = subobj[kGLEStatsLastOpTimeFieldName].timestamp();
OID electionId = subobj[kGLEStatsElectionIdFieldName].OID();
ClientInfo* clientInfo = ClientInfo::get();
LOG(4) << "saveGLEStats lastOpTime:" << lastOpTime
diff --git a/src/mongo/s/config.h b/src/mongo/s/config.h
index cf9c6d1bf3f..9a3128fc114 100644
--- a/src/mongo/s/config.h
+++ b/src/mongo/s/config.h
@@ -40,6 +40,7 @@
#include "mongo/client/dbclient_rs.h"
#include "mongo/s/shard.h"
#include "mongo/s/shard_key_pattern.h"
+#include "mongo/util/concurrency/mutex.h"
namespace mongo {
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp
index 4b7114592ae..7cb3e9c9968 100644
--- a/src/mongo/s/d_migrate.cpp
+++ b/src/mongo/s/d_migrate.cpp
@@ -2224,7 +2224,7 @@ namespace mongo {
// if running on a replicated system, we'll need to flush the docs we cloned to the secondaries
- OpTime lastOpApplied = repl::ReplClientInfo::forClient(txn->getClient()).getLastOp();
+ Timestamp lastOpApplied = repl::ReplClientInfo::forClient(txn->getClient()).getLastOp();
{
// 4. do bulk of mods
@@ -2395,8 +2395,8 @@ namespace mongo {
BSONObj max,
BSONObj shardKeyPattern,
const BSONObj& xfer,
- OpTime* lastOpApplied) {
- OpTime dummy;
+ Timestamp* lastOpApplied) {
+ Timestamp dummy;
if ( lastOpApplied == NULL ) {
lastOpApplied = &dummy;
}
@@ -2511,7 +2511,7 @@ namespace mongo {
* writeConcern (if not empty) have applied till the specified lastOp.
*/
bool opReplicatedEnough(const OperationContext* txn,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
const WriteConcernOptions& writeConcern) {
WriteConcernOptions majorityWriteConcern;
majorityWriteConcern.wTimeout = -1;
@@ -2538,10 +2538,10 @@ namespace mongo {
const std::string& ns,
BSONObj min,
BSONObj max,
- const OpTime& lastOpApplied,
+ const Timestamp& lastOpApplied,
const WriteConcernOptions& writeConcern) {
if (!opReplicatedEnough(txn, lastOpApplied, writeConcern)) {
- OpTime op( lastOpApplied );
+ Timestamp op( lastOpApplied );
OCCASIONALLY warning() << "migrate commit waiting for a majority of slaves for '"
<< ns << "' " << min << " -> " << max
<< " waiting for: " << op
diff --git a/src/mongo/s/type_database.h b/src/mongo/s/type_database.h
index 68cfa009ec8..cbecfd490f4 100644
--- a/src/mongo/s/type_database.h
+++ b/src/mongo/s/type_database.h
@@ -31,7 +31,7 @@
#include <boost/optional.hpp>
#include <string>
-#include "mongo/bson/bson_field.h"
+#include "mongo/db/jsobj.h"
namespace mongo {
diff --git a/src/mongo/s/type_shard.h b/src/mongo/s/type_shard.h
index 1b507fb3425..1e6e75da8ad 100644
--- a/src/mongo/s/type_shard.h
+++ b/src/mongo/s/type_shard.h
@@ -32,7 +32,7 @@
#include <string>
#include <vector>
-#include "mongo/bson/bson_field.h"
+#include "mongo/db/jsobj.h"
namespace mongo {
diff --git a/src/mongo/s/write_ops/batch_downconvert.cpp b/src/mongo/s/write_ops/batch_downconvert.cpp
index cc9736c4910..2a402748351 100644
--- a/src/mongo/s/write_ops/batch_downconvert.cpp
+++ b/src/mongo/s/write_ops/batch_downconvert.cpp
@@ -223,7 +223,7 @@ namespace mongo {
// Adds a wOpTime and a wElectionId field to a set of gle options
static BSONObj buildGLECmdWithOpTime( const BSONObj& gleOptions,
- const OpTime& opTime,
+ const Timestamp& opTime,
const OID& electionId ) {
BSONObjBuilder builder;
BSONObjIterator it( gleOptions );
@@ -241,7 +241,7 @@ namespace mongo {
builder.append( el );
}
- builder.appendTimestamp( "wOpTime", opTime.asDate() );
+ builder.append( "wOpTime", opTime );
builder.appendOID( "wElectionId", const_cast<OID*>(&electionId) );
return builder.obj();
}
@@ -261,7 +261,7 @@ namespace mongo {
const ConnectionString& shardEndpoint = it->first;
const HostOpTime hot = it->second;
- const OpTime& opTime = hot.opTime;
+ const Timestamp& opTime = hot.opTime;
const OID& electionId = hot.electionId;
LOG( 3 ) << "enforcing write concern " << options << " on " << shardEndpoint.toString()
diff --git a/src/mongo/s/write_ops/batch_downconvert.h b/src/mongo/s/write_ops/batch_downconvert.h
index b9ba45682ea..7cd8e95169d 100644
--- a/src/mongo/s/write_ops/batch_downconvert.h
+++ b/src/mongo/s/write_ops/batch_downconvert.h
@@ -33,7 +33,7 @@
#include "mongo/base/string_data.h"
#include "mongo/bson/bsonobj.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/s/write_ops/batch_write_exec.h"
#include "mongo/s/write_ops/batch_write_op.h"
#include "mongo/s/write_ops/batched_command_request.h"
diff --git a/src/mongo/s/write_ops/batch_write_exec.cpp b/src/mongo/s/write_ops/batch_write_exec.cpp
index 25ca80b7d4b..307c39321ee 100644
--- a/src/mongo/s/write_ops/batch_write_exec.cpp
+++ b/src/mongo/s/write_ops/batch_write_exec.cpp
@@ -291,7 +291,7 @@ namespace mongo {
// or delete any documents, which preserves old behavior but is conservative
_stats->noteWriteAt( shardHost,
response.isLastOpSet() ?
- response.getLastOp() : OpTime(),
+ response.getLastOp() : Timestamp(),
response.isElectionIdSet() ?
response.getElectionId() : OID());
}
@@ -386,7 +386,7 @@ namespace mongo {
}
void BatchWriteExecStats::noteWriteAt(const ConnectionString& host,
- OpTime opTime,
+ Timestamp opTime,
const OID& electionId) {
_writeOpTimes[host] = HostOpTime(opTime, electionId);
}
diff --git a/src/mongo/s/write_ops/batch_write_exec.h b/src/mongo/s/write_ops/batch_write_exec.h
index 195dbc374a2..90907a47443 100644
--- a/src/mongo/s/write_ops/batch_write_exec.h
+++ b/src/mongo/s/write_ops/batch_write_exec.h
@@ -34,7 +34,7 @@
#include <string>
#include "mongo/base/disallow_copying.h"
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/s/ns_targeter.h"
#include "mongo/s/shard_resolver.h"
#include "mongo/s/write_ops/batched_command_request.h"
@@ -97,9 +97,9 @@ namespace mongo {
};
struct HostOpTime {
- HostOpTime(OpTime ot, OID e) : opTime(ot), electionId(e) {};
+ HostOpTime(Timestamp ot, OID e) : opTime(ot), electionId(e) {};
HostOpTime() {};
- OpTime opTime;
+ Timestamp opTime;
OID electionId;
};
@@ -112,7 +112,7 @@ namespace mongo {
numRounds( 0 ), numTargetErrors( 0 ), numResolveErrors( 0 ), numStaleBatches( 0 ) {
}
- void noteWriteAt(const ConnectionString& host, OpTime opTime, const OID& electionId);
+ void noteWriteAt(const ConnectionString& host, Timestamp opTime, const OID& electionId);
const HostOpTimeMap& getWriteOpTimes() const;
diff --git a/src/mongo/s/write_ops/batched_command_response.cpp b/src/mongo/s/write_ops/batched_command_response.cpp
index a01dd16a77d..2af007c4602 100644
--- a/src/mongo/s/write_ops/batched_command_response.cpp
+++ b/src/mongo/s/write_ops/batched_command_response.cpp
@@ -45,7 +45,7 @@ namespace mongo {
const BSONField<long long> BatchedCommandResponse::nModified("nModified", 0);
const BSONField<std::vector<BatchedUpsertDetail*> >
BatchedCommandResponse::upsertDetails("upserted");
- const BSONField<OpTime> BatchedCommandResponse::lastOp("lastOp");
+ const BSONField<Timestamp> BatchedCommandResponse::lastOp("lastOp");
const BSONField<OID> BatchedCommandResponse::electionId("electionId");
const BSONField<std::vector<WriteErrorDetail*> >
BatchedCommandResponse::writeErrors("writeErrors");
@@ -223,7 +223,7 @@ namespace mongo {
_upsertDetails.reset();
}
- _lastOp = OpTime();
+ _lastOp = Timestamp();
_isLastOpSet = false;
_electionId = OID();
@@ -452,7 +452,7 @@ namespace mongo {
return _upsertDetails->at(pos);
}
- void BatchedCommandResponse::setLastOp(OpTime lastOp) {
+ void BatchedCommandResponse::setLastOp(Timestamp lastOp) {
_lastOp = lastOp;
_isLastOpSet = true;
}
@@ -465,7 +465,7 @@ namespace mongo {
return _isLastOpSet;
}
- OpTime BatchedCommandResponse::getLastOp() const {
+ Timestamp BatchedCommandResponse::getLastOp() const {
dassert(_isLastOpSet);
return _lastOp;
}
diff --git a/src/mongo/s/write_ops/batched_command_response.h b/src/mongo/s/write_ops/batched_command_response.h
index c7938b5954e..57fc0549330 100644
--- a/src/mongo/s/write_ops/batched_command_response.h
+++ b/src/mongo/s/write_ops/batched_command_response.h
@@ -59,7 +59,7 @@ namespace mongo {
static const BSONField<long long> n;
static const BSONField<long long> nModified;
static const BSONField<std::vector<BatchedUpsertDetail*> > upsertDetails;
- static const BSONField<OpTime> lastOp;
+ static const BSONField<Timestamp> lastOp;
static const BSONField<OID> electionId;
static const BSONField<std::vector<WriteErrorDetail*> > writeErrors;
static const BSONField<WCErrorDetail*> writeConcernError;
@@ -121,10 +121,10 @@ namespace mongo {
const std::vector<BatchedUpsertDetail*>& getUpsertDetails() const;
const BatchedUpsertDetail* getUpsertDetailsAt(std::size_t pos) const;
- void setLastOp(OpTime lastOp);
+ void setLastOp(Timestamp lastOp);
void unsetLastOp();
bool isLastOpSet() const;
- OpTime getLastOp() const;
+ Timestamp getLastOp() const;
void setElectionId(const OID& electionId);
void unsetElectionId();
@@ -181,7 +181,7 @@ namespace mongo {
// Normally, getLastError can use Client::_lastOp, but this is not valid for
// mongos which loses track of the session due to RCAR. Therefore, we must
// keep track of the lastOp manually ourselves.
- OpTime _lastOp;
+ Timestamp _lastOp;
bool _isLastOpSet;
// (O) In addition to keeping track of the above lastOp timestamp, we must also keep
diff --git a/src/mongo/s/write_ops/batched_delete_request_test.cpp b/src/mongo/s/write_ops/batched_delete_request_test.cpp
index 49eba66b61b..33aa331259a 100644
--- a/src/mongo/s/write_ops/batched_delete_request_test.cpp
+++ b/src/mongo/s/write_ops/batched_delete_request_test.cpp
@@ -43,7 +43,7 @@ namespace {
using mongo::BatchedRequestMetadata;
using mongo::BSONArrayBuilder;
using mongo::OID;
- using mongo::OpTime;
+ using mongo::Timestamp;
using std::string;
@@ -62,7 +62,7 @@ namespace {
// The BSON_ARRAY macro doesn't support Timestamps.
BSONArrayBuilder arrBuilder;
- arrBuilder.appendTimestamp(OpTime(1,1).asDate());
+ arrBuilder.append(Timestamp(1,1));
arrBuilder.append(OID::gen());
BSONArray shardVersionArray = arrBuilder.arr();
diff --git a/src/mongo/s/write_ops/batched_insert_request_test.cpp b/src/mongo/s/write_ops/batched_insert_request_test.cpp
index b326cfcfed9..ba553e254b4 100644
--- a/src/mongo/s/write_ops/batched_insert_request_test.cpp
+++ b/src/mongo/s/write_ops/batched_insert_request_test.cpp
@@ -47,7 +47,7 @@ namespace {
// The BSON_ARRAY macro doesn't support Timestamps.
BSONArrayBuilder arrBuilder;
- arrBuilder.appendTimestamp(OpTime(1,1).asDate());
+ arrBuilder.append(Timestamp(1,1));
arrBuilder.append(OID::gen());
BSONArray shardVersionArray = arrBuilder.arr();
diff --git a/src/mongo/s/write_ops/batched_request_metadata.h b/src/mongo/s/write_ops/batched_request_metadata.h
index e2dd99df0c1..029e915757e 100644
--- a/src/mongo/s/write_ops/batched_request_metadata.h
+++ b/src/mongo/s/write_ops/batched_request_metadata.h
@@ -31,8 +31,8 @@
#include <boost/scoped_ptr.hpp>
#include <string>
-#include "mongo/bson/bson_field.h"
#include "mongo/base/disallow_copying.h"
+#include "mongo/db/jsobj.h"
#include "mongo/s/bson_serializable.h"
#include "mongo/s/chunk_version.h"
diff --git a/src/mongo/s/write_ops/batched_request_metadata_test.cpp b/src/mongo/s/write_ops/batched_request_metadata_test.cpp
index 866e6a01d05..562497b5d27 100644
--- a/src/mongo/s/write_ops/batched_request_metadata_test.cpp
+++ b/src/mongo/s/write_ops/batched_request_metadata_test.cpp
@@ -27,13 +27,13 @@ namespace {
using mongo::BSONObj;
using mongo::BatchedRequestMetadata;
using mongo::OID;
- using mongo::OpTime;
+ using mongo::Timestamp;
using std::string;
TEST(RoundTrip, Normal) {
// The BSON_ARRAY macro doesn't support Timestamps.
BSONArrayBuilder arrBuilder;
- arrBuilder.appendTimestamp(OpTime(1,1).asDate());
+ arrBuilder.append(Timestamp(1,1));
arrBuilder.append(OID::gen());
BSONArray shardVersionArray = arrBuilder.arr();
diff --git a/src/mongo/s/write_ops/batched_update_request_test.cpp b/src/mongo/s/write_ops/batched_update_request_test.cpp
index acada54ddd9..c8e69b92b06 100644
--- a/src/mongo/s/write_ops/batched_update_request_test.cpp
+++ b/src/mongo/s/write_ops/batched_update_request_test.cpp
@@ -44,7 +44,7 @@ namespace {
using mongo::BSONArrayBuilder;
using mongo::BSONObj;
using mongo::OID;
- using mongo::OpTime;
+ using mongo::Timestamp;
TEST(RoundTrip, Normal) {
BSONArray updateArray =
@@ -65,7 +65,7 @@ namespace {
// The BSON_ARRAY macro doesn't support Timestamps.
BSONArrayBuilder arrBuilder;
- arrBuilder.appendTimestamp(OpTime(1,1).asDate());
+ arrBuilder.append(Timestamp(1,1));
arrBuilder.append(OID::gen());
BSONArray shardVersionArray = arrBuilder.arr();
diff --git a/src/mongo/scripting/engine_v8-3.25.cpp b/src/mongo/scripting/engine_v8-3.25.cpp
index 2e8142da771..cd8ff7aceeb 100644
--- a/src/mongo/scripting/engine_v8-3.25.cpp
+++ b/src/mongo/scripting/engine_v8-3.25.cpp
@@ -1541,7 +1541,7 @@ namespace mongo {
argv[1] = v8StringData(ss.str());
return BinDataFT()->GetFunction()->NewInstance(2, argv);
}
- case mongo::Timestamp: {
+ case mongo::bsonTimestamp: {
v8::TryCatch tryCatch;
argv[0] = v8::Number::New(_isolate, elem.timestampTime() / 1000);
@@ -1674,8 +1674,8 @@ namespace mongo {
} else if (BinDataFT()->HasInstance(value)) {
v8ToMongoBinData(b, elementName, obj);
} else if (TimestampFT()->HasInstance(value)) {
- OpTime ot (obj->Get(strLitToV8("t"))->Uint32Value(),
- obj->Get(strLitToV8("i"))->Uint32Value());
+ Timestamp ot (obj->Get(strLitToV8("t"))->Uint32Value(),
+ obj->Get(strLitToV8("i"))->Uint32Value());
b.append(elementName, ot);
} else if (MinKeyFT()->HasInstance(value)) {
b.appendMinKey(elementName);
diff --git a/src/mongo/scripting/engine_v8.cpp b/src/mongo/scripting/engine_v8.cpp
index 64386b0deaa..242e39be1a4 100644
--- a/src/mongo/scripting/engine_v8.cpp
+++ b/src/mongo/scripting/engine_v8.cpp
@@ -1469,7 +1469,7 @@ namespace mongo {
argv[1] = v8::String::New(ss.str().c_str());
return BinDataFT()->GetFunction()->NewInstance(2, argv);
}
- case mongo::Timestamp: {
+ case mongo::bsonTimestamp: {
v8::TryCatch tryCatch;
argv[0] = v8::Number::New(elem.timestampTime() / 1000);
@@ -1602,8 +1602,8 @@ namespace mongo {
} else if (BinDataFT()->HasInstance(value)) {
v8ToMongoBinData(b, elementName, obj);
} else if (TimestampFT()->HasInstance(value)) {
- OpTime ot (obj->Get(strLitToV8("t"))->Uint32Value(),
- obj->Get(strLitToV8("i"))->Uint32Value());
+ Timestamp ot (obj->Get(strLitToV8("t"))->Uint32Value(),
+ obj->Get(strLitToV8("i"))->Uint32Value());
b.append(elementName, ot);
} else if (MinKeyFT()->HasInstance(value)) {
b.appendMinKey(elementName);
diff --git a/src/mongo/scripting/v8_db.cpp b/src/mongo/scripting/v8_db.cpp
index f6babb8f3ab..8f962ec8195 100644
--- a/src/mongo/scripting/v8_db.cpp
+++ b/src/mongo/scripting/v8_db.cpp
@@ -846,7 +846,7 @@ namespace mongo {
return v8AssertionException("Timestamp increment must be a number");
}
int64_t t = args[0]->IntegerValue();
- int64_t largestVal = int64_t(OpTime::max().getSecs());
+ int64_t largestVal = int64_t(Timestamp::max().getSecs());
if( t > largestVal )
return v8AssertionException( str::stream()
<< "The first argument must be in seconds; "
diff --git a/src/mongo/shell/clientAndShell.cpp b/src/mongo/shell/clientAndShell.cpp
index 79d24d4842f..3242be39d7c 100644
--- a/src/mongo/shell/clientAndShell.cpp
+++ b/src/mongo/shell/clientAndShell.cpp
@@ -31,6 +31,8 @@
#include "mongo/platform/basic.h"
+#include <boost/thread.hpp>
+
#include "mongo/shell/shell_utils.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/shell/shell_utils.h b/src/mongo/shell/shell_utils.h
index bd8e8b033f5..040caa41653 100644
--- a/src/mongo/shell/shell_utils.h
+++ b/src/mongo/shell/shell_utils.h
@@ -32,6 +32,7 @@
#include <boost/thread/mutex.hpp>
#include "mongo/db/jsobj.h"
+#include "mongo/util/concurrency/mutex.h"
namespace mongo {
diff --git a/src/mongo/unittest/unittest_helpers.cpp b/src/mongo/unittest/unittest_helpers.cpp
index 9931a6a8d23..1205c04df80 100644
--- a/src/mongo/unittest/unittest_helpers.cpp
+++ b/src/mongo/unittest/unittest_helpers.cpp
@@ -32,12 +32,12 @@
#include <ostream>
-#include "mongo/bson/optime.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/util/time_support.h"
namespace mongo {
- std::ostream& operator<<(std::ostream &s, const OpTime &ot) {
+ std::ostream& operator<<(std::ostream &s, const Timestamp &ot) {
s << ot.toString();
return s;
}
diff --git a/src/mongo/unittest/unittest_helpers.h b/src/mongo/unittest/unittest_helpers.h
index 0bcf4adb84f..97ab7cc1efe 100644
--- a/src/mongo/unittest/unittest_helpers.h
+++ b/src/mongo/unittest/unittest_helpers.h
@@ -31,11 +31,11 @@
#include <ostream>
namespace mongo {
- class OpTime;
+ class Timestamp;
struct Date_t;
- // So that you can ASSERT_EQUALS two OpTimes
- std::ostream& operator<<(std::ostream& s, const OpTime& ot);
+ // So that you can ASSERT_EQUALS two Timestamps
+ std::ostream& operator<<(std::ostream& s, const Timestamp& ot);
// So that you can ASSERT_EQUALS two Date_ts
std::ostream& operator<<(std::ostream& s, const Date_t& t);
diff --git a/src/mongo/util/fail_point.cpp b/src/mongo/util/fail_point.cpp
index bbeb9cf00c9..ef3c2111b2b 100644
--- a/src/mongo/util/fail_point.cpp
+++ b/src/mongo/util/fail_point.cpp
@@ -31,6 +31,7 @@
#include "mongo/util/fail_point.h"
#include <boost/scoped_ptr.hpp>
+#include <boost/thread.hpp>
#include "mongo/platform/random.h"
#include "mongo/util/concurrency/threadlocal.h"
diff --git a/src/mongo/util/processinfo.h b/src/mongo/util/processinfo.h
index 18f6956d9b7..367d4c5f0e4 100644
--- a/src/mongo/util/processinfo.h
+++ b/src/mongo/util/processinfo.h
@@ -31,9 +31,10 @@
#include <string>
+#include "mongo/db/jsobj.h"
#include "mongo/platform/cstdint.h"
#include "mongo/platform/process_id.h"
-#include "mongo/db/jsobj.h"
+#include "mongo/util/concurrency/mutex.h"
namespace mongo {
diff --git a/src/mongo/util/safe_num.h b/src/mongo/util/safe_num.h
index 24cfe6d5a34..c498d89fcdf 100644
--- a/src/mongo/util/safe_num.h
+++ b/src/mongo/util/safe_num.h
@@ -30,8 +30,7 @@
#include <iosfwd>
#include <string>
-#include "mongo/bson/bsonelement.h"
-#include "mongo/bson/bsonobj.h"
+#include "mongo/db/jsobj.h"
namespace mongo {