summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2013-02-27 07:25:51 -0500
committerEric Milkie <milkie@10gen.com>2013-03-11 11:15:02 -0400
commita8c05c5fd10f1aa9a57b7edbe0589d4a0b17f5b0 (patch)
tree3ef0484dbb81d3b8d228298c788e98694b667cd4 /src/mongo
parentcac2effa776649208b8428f6c8c9692d45148fd2 (diff)
downloadmongo-a8c05c5fd10f1aa9a57b7edbe0589d4a0b17f5b0.tar.gz
SERVER-7772 move all of optime into optime.cpp/.h
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/SConscript2
-rw-r--r--src/mongo/bson/bson_db.h2
-rw-r--r--src/mongo/db/common.cpp20
-rw-r--r--src/mongo/db/instance.cpp35
-rw-r--r--src/mongo/db/jsobj.cpp2
-rw-r--r--src/mongo/db/jsobj.h2
-rw-r--r--src/mongo/db/oplog.h4
-rw-r--r--src/mongo/db/pipeline/value_internal.h2
-rw-r--r--src/mongo/db/repl.h2
-rw-r--r--src/mongo/db/repl/optime.cpp9
-rw-r--r--src/mongo/db/repl/optime.h20
-rw-r--r--src/mongo/db/repl/rs.h2
-rw-r--r--src/mongo/db/repl/rs_initialsync.cpp2
-rw-r--r--src/mongo/util/util.cpp3
14 files changed, 30 insertions, 77 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 87e99e7b7b1..bcd702d06d6 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -276,7 +276,6 @@ env.StaticLibrary("coredb", [
'$BUILD_DIR/mongo/foundation'])
coreServerFiles = [ "db/client_basic.cpp",
- "db/common.cpp",
"util/net/miniwebserver.cpp",
"db/indexkey.cpp",
"db/stats/counters.cpp",
@@ -381,6 +380,7 @@ serverOnlyFiles = [ "db/curop.cpp",
"db/repl/master_slave.cpp",
"db/repl/finding_start_cursor.cpp",
"db/repl/sync.cpp",
+ "db/repl/optime.cpp",
"db/oplog.cpp",
"db/prefetch.cpp",
"db/repl_block.cpp",
diff --git a/src/mongo/bson/bson_db.h b/src/mongo/bson/bson_db.h
index c421816e50a..6b8eccb142c 100644
--- a/src/mongo/bson/bson_db.h
+++ b/src/mongo/bson/bson_db.h
@@ -26,7 +26,7 @@
#pragma once
-#include "../util/optime.h"
+#include "mongo/db/repl/optime.h"
#include "../util/time_support.h"
namespace mongo {
diff --git a/src/mongo/db/common.cpp b/src/mongo/db/common.cpp
index 970b8386fde..2eb21edbde0 100644
--- a/src/mongo/db/common.cpp
+++ b/src/mongo/db/common.cpp
@@ -24,23 +24,3 @@
/**
* this just has globals
*/
-namespace mongo {
-
- NOINLINE_DECL OpTime OpTime::skewed() {
- bool toLog = false;
- ONCE toLog = true;
- RARELY toLog = true;
- last.i++;
- if ( last.i & 0x80000000 )
- toLog = true;
- if ( toLog ) {
- log() << "clock skew detected prev: " << last.secs << " now: " << (unsigned) time(0) << endl;
- }
- if ( last.i & 0x80000000 ) {
- log() << "error large clock skew detected, shutting down" << endl;
- throw ClockSkewException();
- }
- return last;
- }
-
-}
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 2daee09b14d..cfff2b270c3 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -90,33 +90,6 @@ namespace mongo {
MONGO_FP_DECLARE(rsStopGetMore);
- /*static*/ OpTime OpTime::_now() {
- OpTime result;
- unsigned t = (unsigned) time(0);
- if ( last.secs == t ) {
- last.i++;
- result = last;
- }
- else if ( t < last.secs ) {
- result = skewed(); // separate function to keep out of the hot code path
- }
- else {
- last = OpTime(t, 1);
- result = last;
- }
- notifier.notify_all();
- return last;
- }
- OpTime OpTime::now(const mongo::mutex::scoped_lock&) {
- return _now();
- }
- OpTime OpTime::getLast(const mongo::mutex::scoped_lock&) {
- return last;
- }
- boost::condition OpTime::notifier;
- mongo::mutex OpTime::m("optime");
-
- // OpTime::now() uses mutex, thus it is in this file not in the cpp files used by drivers and such
void BSONElementManipulator::initTimestamp() {
massert( 10332 , "Expected CurrentTime type", _element.type() == Timestamp );
unsigned long long &timestamp = *( reinterpret_cast< unsigned long long* >( value() ) );
@@ -636,14 +609,6 @@ namespace mongo {
QueryResult* emptyMoreResult(long long);
- void OpTime::waitForDifferent(unsigned millis){
- mutex::scoped_lock lk(m);
- while (*this == last) {
- if (!notifier.timed_wait(lk.boost(), boost::posix_time::milliseconds(millis)))
- return; // timed out
- }
- }
-
bool receivedGetMore(DbResponse& dbresponse, Message& m, CurOp& curop ) {
bool ok = true;
diff --git a/src/mongo/db/jsobj.cpp b/src/mongo/db/jsobj.cpp
index 67967ba91d5..04abe4750cc 100644
--- a/src/mongo/db/jsobj.cpp
+++ b/src/mongo/db/jsobj.cpp
@@ -36,7 +36,7 @@
#include "mongo/util/embedded_builder.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/optime.h"
+#include "mongo/db/repl/optime.h"
#include "mongo/util/startup_test.h"
#include "mongo/util/stringutils.h"
diff --git a/src/mongo/db/jsobj.h b/src/mongo/db/jsobj.h
index b108caaf314..c504084e6b6 100644
--- a/src/mongo/db/jsobj.h
+++ b/src/mongo/db/jsobj.h
@@ -30,7 +30,7 @@
#include "mongo/pch.h"
#include "../bson/util/builder.h"
-#include "../util/optime.h"
+#include "mongo/db/repl/optime.h"
#include "../bson/bsontypes.h"
#include "../bson/oid.h"
#include "../bson/bsonelement.h"
diff --git a/src/mongo/db/oplog.h b/src/mongo/db/oplog.h
index 8eeebdf4a2c..21cfc64e0f2 100644
--- a/src/mongo/db/oplog.h
+++ b/src/mongo/db/oplog.h
@@ -27,7 +27,7 @@
#include "db.h"
#include "dbhelpers.h"
#include "clientcursor.h"
-#include "../util/optime.h"
+#include "mongo/db/repl/optime.h"
#include "../util/timer.h"
namespace mongo {
@@ -43,6 +43,8 @@ namespace mongo {
void _logOpObjRS(const BSONObj& op);
+ const char rsoplog[] = "local.oplog.rs";
+
/** Write operation to the log (local.oplog.$main)
@param opstr
diff --git a/src/mongo/db/pipeline/value_internal.h b/src/mongo/db/pipeline/value_internal.h
index e3481951f9e..48eb8ee36e3 100644
--- a/src/mongo/db/pipeline/value_internal.h
+++ b/src/mongo/db/pipeline/value_internal.h
@@ -22,7 +22,7 @@
#include "bson/bsonmisc.h"
#include "bson/oid.h"
#include "util/intrusive_counter.h"
-#include "util/optime.h"
+#include "mongo/db/repl/optime.h"
namespace mongo {
diff --git a/src/mongo/db/repl.h b/src/mongo/db/repl.h
index 2b85a8f376c..652ef8eab10 100644
--- a/src/mongo/db/repl.h
+++ b/src/mongo/db/repl.h
@@ -30,7 +30,7 @@
#include "pdfile.h"
#include "db.h"
#include "dbhelpers.h"
-#include "../util/optime.h"
+#include "mongo/db/repl/optime.h"
#include "oplog.h"
#include "../util/concurrency/thread_pool.h"
#include "oplogreader.h"
diff --git a/src/mongo/db/repl/optime.cpp b/src/mongo/db/repl/optime.cpp
index 5f3f4055252..0f31d6c07b4 100644
--- a/src/mongo/db/repl/optime.cpp
+++ b/src/mongo/db/repl/optime.cpp
@@ -24,6 +24,10 @@
namespace mongo {
+ OpTime OpTime::last(0, 0);
+ boost::condition OpTime::notifier;
+ mongo::mutex OpTime::m("optime");
+
NOINLINE_DECL OpTime OpTime::skewed() {
bool toLog = false;
ONCE toLog = true;
@@ -32,10 +36,11 @@ namespace mongo {
if ( last.i & 0x80000000 )
toLog = true;
if ( toLog ) {
- log() << "clock skew detected prev: " << last.secs << " now: " << (unsigned) time(0) << endl;
+ log() << "clock skew detected prev: " << last.secs << " now: " << (unsigned) time(0)
+ << std::endl;
}
if ( last.i & 0x80000000 ) {
- log() << "error large clock skew detected, shutting down" << endl;
+ log() << "error large clock skew detected, shutting down" << std::endl;
throw ClockSkewException();
}
return last;
diff --git a/src/mongo/db/repl/optime.h b/src/mongo/db/repl/optime.h
index 740e7cfeb37..71dbf1a631e 100644
--- a/src/mongo/db/repl/optime.h
+++ b/src/mongo/db/repl/optime.h
@@ -1,5 +1,3 @@
-// optime.h - OpTime class
-
/* Copyright 2009 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +16,12 @@
#pragma once
#include <boost/thread/condition.hpp>
+#include <iostream>
+#include <sstream>
+
+#include "mongo/bson/util/misc.h" // time_t_to_String
+#include "mongo/util/assert_util.h"
+#include "mongo/util/concurrency/mutex.h"
namespace mongo {
@@ -109,21 +113,21 @@ namespace mongo {
string toStringLong() const {
char buf[64];
time_t_to_String(secs, buf);
- stringstream ss;
+ std::stringstream ss;
ss << time_t_to_String_short(secs) << ' ';
- ss << hex << secs << ':' << i;
+ ss << std::hex << secs << ':' << i;
return ss.str();
}
string toStringPretty() const {
- stringstream ss;
- ss << time_t_to_String_short(secs) << ':' << hex << i;
+ std::stringstream ss;
+ ss << time_t_to_String_short(secs) << ':' << std::hex << i;
return ss.str();
}
string toString() const {
- stringstream ss;
- ss << hex << secs << ':' << i;
+ std::stringstream ss;
+ ss << std::hex << secs << ':' << i;
return ss.str();
}
diff --git a/src/mongo/db/repl/rs.h b/src/mongo/db/repl/rs.h
index cd353752e82..03efd8de88b 100644
--- a/src/mongo/db/repl/rs.h
+++ b/src/mongo/db/repl/rs.h
@@ -25,7 +25,7 @@
#include "mongo/db/repl/rs_config.h"
#include "mongo/db/repl/rs_exception.h"
#include "mongo/db/repl/rs_member.h"
-#include "mongo/db/repl/rs_optime.h"
+#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/rs_sync.h"
#include "mongo/util/concurrency/list.h"
#include "mongo/util/concurrency/msg.h"
diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp
index 94954a0f914..2cebdddc737 100644
--- a/src/mongo/db/repl/rs_initialsync.cpp
+++ b/src/mongo/db/repl/rs_initialsync.cpp
@@ -24,7 +24,7 @@
#include "mongo/db/oplogreader.h"
#include "mongo/db/repl.h"
#include "mongo/db/repl/bgsync.h"
-#include "mongo/db/repl/rs_optime.h"
+#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/rs_sync.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/util/util.cpp b/src/mongo/util/util.cpp
index fcbb4eaaf2a..61e4d7e61b9 100644
--- a/src/mongo/util/util.cpp
+++ b/src/mongo/util/util.cpp
@@ -20,7 +20,6 @@
#include "mongo/util/stacktrace.h"
#include "mongo/util/startup_test.h"
#include "file_allocator.h"
-#include "optime.h"
#include "time_support.h"
#include "mongoutils/str.h"
#include "timer.h"
@@ -131,8 +130,6 @@ namespace mongo {
}
} utilTest;
- OpTime OpTime::last(0, 0);
-
ostream& operator<<( ostream &s, const ThreadSafeString &o ) {
s << o.toString();
return s;