diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/client/SConscript | 25 | ||||
-rw-r--r-- | src/mongo/client/connection_string.cpp | 148 | ||||
-rw-r--r-- | src/mongo/client/connection_string.h | 93 | ||||
-rw-r--r-- | src/mongo/client/connection_string_test.cpp | 49 | ||||
-rw-r--r-- | src/mongo/s/client/multi_host_query_test.cpp | 57 | ||||
-rw-r--r-- | src/mongo/s/client/shard_test.cpp | 68 | ||||
-rw-r--r-- | src/mongo/util/net/SConscript | 1 |
7 files changed, 262 insertions, 179 deletions
diff --git a/src/mongo/client/SConscript b/src/mongo/client/SConscript index 15199f32ccd..86fd2e8973e 100644 --- a/src/mongo/client/SConscript +++ b/src/mongo/client/SConscript @@ -3,11 +3,26 @@ Import("env") # Contains only the core ConnectionString functionality, *not* the ability to call connect() -# and return a DBClientBase* back. For that you need to link against the 'clientdriver' library. -env.Library('connectionstring', - ["connection_string.cpp"], - LIBDEPS=[]) +# and return a DBClientBase* back. For that you need to link against the 'clientdriver' library. +env.Library( + target='connection_string', + source=[ + 'connection_string.cpp', + ], + LIBDEPS=[ + '$BUILD_DIR/mongo/util/net/hostandport', + ] +) +env.CppUnitTest( + target='connection_string_test', + source=[ + 'connection_string_test.cpp', + ], + LIBDEPS=[ + 'connection_string', + ] +) env.Library('clientdriver', [ "connection_string_connect.cpp", @@ -27,7 +42,7 @@ env.Library('clientdriver', [ "syncclusterconnection.cpp", "$BUILD_DIR/mongo/db/dbmessage.cpp" ], - LIBDEPS=['connectionstring', + LIBDEPS=['connection_string', '$BUILD_DIR/mongo/bson/util/bson_extract', '$BUILD_DIR/mongo/crypto/scramauth', '$BUILD_DIR/mongo/db/auth/authcommon', diff --git a/src/mongo/client/connection_string.cpp b/src/mongo/client/connection_string.cpp index d365a6fb50f..08c601b1e9f 100644 --- a/src/mongo/client/connection_string.cpp +++ b/src/mongo/client/connection_string.cpp @@ -1,4 +1,5 @@ -/* Copyright 2009 10gen Inc. +/** + * Copyright (C) 2009-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, @@ -16,13 +17,13 @@ * 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. + * 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. */ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork @@ -31,10 +32,55 @@ #include "mongo/client/connection_string.h" +#include "mongo/base/status_with.h" #include "mongo/util/mongoutils/str.h" namespace mongo { + ConnectionString::ConnectionString(const HostAndPort& server) : _type(MASTER) { + _servers.push_back(server); + _finishInit(); + } + + ConnectionString::ConnectionString(ConnectionType type, + const std::string& s, + const std::string& setName) { + _type = type; + _setName = setName; + _fillServers(s); + + switch (_type) { + case MASTER: + verify(_servers.size() == 1); + break; + case SET: + verify(_setName.size()); + verify(_servers.size() >= 1); // 1 is ok since we can derive + break; + default: + verify(_servers.size() > 0); + } + + _finishInit(); + } + + ConnectionString::ConnectionString(const std::string& s, ConnectionType favoredMultipleType) { + _fillServers(s); + + if (_type != INVALID) { + // set already + } + else if (_servers.size() == 1) { + _type = MASTER; + } + else { + _type = favoredMultipleType; + verify(_type == SET || _type == SYNC); + } + + _finishInit(); + } + void ConnectionString::_fillServers( std::string s ) { // @@ -64,31 +110,37 @@ namespace mongo { } void ConnectionString::_finishInit() { - // Needed here as well b/c the parsing logic isn't used in all constructors // TODO: Refactor so that the parsing logic *is* used in all constructors - if ( _type == MASTER && _servers.size() > 0 ){ - if( _servers[0].host().find( '$' ) == 0 ){ + if (_type == MASTER && _servers.size() > 0) { + if (_servers[0].host().find('$') == 0) { _type = CUSTOM; } } std::stringstream ss; - if ( _type == SET ) + + if (_type == SET) { ss << _setName << "/"; - for ( unsigned i=0; i<_servers.size(); i++ ) { - if ( i > 0 ) + } + + for (unsigned i = 0; i < _servers.size(); i++) { + if (i > 0) { ss << ","; + } + ss << _servers[i].toString(); } + _string = ss.str(); } - bool ConnectionString::sameLogicalEndpoint( const ConnectionString& other ) const { - if ( _type != other._type ) + bool ConnectionString::sameLogicalEndpoint(const ConnectionString& other) const { + if (_type != other._type) { return false; + } - switch ( _type ) { + switch (_type) { case INVALID: return true; case MASTER: @@ -97,44 +149,68 @@ namespace mongo { return _setName == other._setName; case SYNC: // The servers all have to be the same in each, but not in the same order. - if ( _servers.size() != other._servers.size() ) + if (_servers.size() != other._servers.size()) { return false; - for ( unsigned i = 0; i < _servers.size(); i++ ) { + } + + for (unsigned i = 0; i < _servers.size(); i++) { bool found = false; - for ( unsigned j = 0; j < other._servers.size(); j++ ) { - if ( _servers[i] == other._servers[j] ) { + for (unsigned j = 0; j < other._servers.size(); j++) { + if (_servers[i] == other._servers[j]) { found = true; break; } } - if ( ! found ) - return false; + + if (!found) return false; } + return true; case CUSTOM: return _string == other._string; } - verify( false ); + + MONGO_UNREACHABLE; + } + + ConnectionString ConnectionString::parse(const std::string& url, std::string& errmsg) { + auto status = parse(url); + if (status.isOK()) { + errmsg = ""; + return status.getValue(); + } + + errmsg = status.getStatus().toString(); + return ConnectionString(); } - ConnectionString ConnectionString::parse( const std::string& host , std::string& errmsg ) { + StatusWith<ConnectionString> ConnectionString::parse(const std::string& url) { + const std::string::size_type i = url.find('/'); - std::string::size_type i = host.find( '/' ); - if ( i != std::string::npos && i != 0) { - // replica set - return ConnectionString( SET , host.substr( i + 1 ) , host.substr( 0 , i ) ); + // Replica set + if (i != std::string::npos && i != 0) { + return ConnectionString(SET, url.substr(i + 1), url.substr(0, i)); } - int numCommas = str::count( host , ',' ); + const int numCommas = str::count(url, ','); - if( numCommas == 0 ) - return ConnectionString( HostAndPort( host ) ); + // Single host + if (numCommas == 0) { + HostAndPort singleHost; + Status status = singleHost.initialize(url); + if (!status.isOK()) { + return status; + } + + return ConnectionString(singleHost); + } - if ( numCommas == 2 ) - return ConnectionString( SYNC , host ); + // Sharding config server + if (numCommas == 2) { + return ConnectionString(SYNC, url, ""); + } - errmsg = (std::string)"invalid hostname [" + host + "]"; - return ConnectionString(); // INVALID + return Status(ErrorCodes::FailedToParse, str::stream() << "invalid url [" << url << "]"); } std::string ConnectionString::typeToString(ConnectionType type) { diff --git a/src/mongo/client/connection_string.h b/src/mongo/client/connection_string.h index fdd3c1c914a..86798668546 100644 --- a/src/mongo/client/connection_string.h +++ b/src/mongo/client/connection_string.h @@ -1,4 +1,5 @@ -/* Copyright 2009 10gen Inc. +/** + * Copyright (C) 2009-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, @@ -16,13 +17,13 @@ * 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. + * 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 @@ -38,6 +39,7 @@ namespace mongo { class DBClientBase; + template <typename T> class StatusWith; /** * ConnectionString handles parsing different ways to connect to mongo and determining method @@ -50,64 +52,23 @@ namespace mongo { * for some special things such as sharding config servers. * See syncclusterconnection.h for more info. * - * tyipcal use - * std::string errmsg, - * ConnectionString cs = ConnectionString::parse( url , errmsg ); - * if ( ! cs.isValid() ) throw "bad: " + errmsg; + * Typical use: + * + * ConnectionString cs(uassertStatusOK(ConnectionString::parse(url))); + * std::string errmsg; * DBClientBase * conn = cs.connect( errmsg ); */ class ConnectionString { public: enum ConnectionType { INVALID, MASTER, SET, SYNC, CUSTOM }; - ConnectionString() { - _type = INVALID; - } + ConnectionString() = default; - // Note: This should only be used for direct connections to a single server. For replica - // set and SyncClusterConnections, use ConnectionString::parse. - ConnectionString( const HostAndPort& server ) { - _type = MASTER; - _servers.push_back( server ); - _finishInit(); - } + explicit ConnectionString(const HostAndPort& server); - ConnectionString( ConnectionType type , const std::string& s , const std::string& setName = "" ) { - _type = type; - _setName = setName; - _fillServers( s ); - - switch ( _type ) { - case MASTER: - verify( _servers.size() == 1 ); - break; - case SET: - verify( _setName.size() ); - verify( _servers.size() >= 1 ); // 1 is ok since we can derive - break; - default: - verify( _servers.size() > 0 ); - } - - _finishInit(); - } + ConnectionString(ConnectionType type, const std::string& s, const std::string& setName); - ConnectionString( const std::string& s , ConnectionType favoredMultipleType ) { - _type = INVALID; - - _fillServers( s ); - if ( _type != INVALID ) { - // set already - } - else if ( _servers.size() == 1 ) { - _type = MASTER; - } - else { - _type = favoredMultipleType; - verify( _type == SET || _type == SYNC ); - } - _finishInit(); - } + ConnectionString(const std::string& s, ConnectionType favoredMultipleType); bool isValid() const { return _type != INVALID; } @@ -129,7 +90,8 @@ namespace mongo { DBClientBase* connect(std::string& errmsg, double socketTimeout = 0) const; - static ConnectionString parse( const std::string& url , std::string& errmsg ); + static ConnectionString parse(const std::string& url, std::string& errmsg); + static StatusWith<ConnectionString> parse(const std::string& url); static std::string typeToString( ConnectionType type ); @@ -164,24 +126,11 @@ namespace mongo { return _string < other._string; } - // - // FOR TESTING ONLY - useful to be able to directly mock a connection std::string without - // including the entire client library. - // - - static ConnectionString mock( const HostAndPort& server ) { - ConnectionString connStr; - connStr._servers.push_back( server ); - connStr._string = server.toString(); - return connStr; - } - private: - void _fillServers( std::string s ); void _finishInit(); - ConnectionType _type; + ConnectionType _type{INVALID}; std::vector<HostAndPort> _servers; std::string _string; std::string _setName; diff --git a/src/mongo/client/connection_string_test.cpp b/src/mongo/client/connection_string_test.cpp new file mode 100644 index 00000000000..c1cb8c95683 --- /dev/null +++ b/src/mongo/client/connection_string_test.cpp @@ -0,0 +1,49 @@ +/** + * 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. + */ + +#include "mongo/platform/basic.h" + +#include "mongo/client/connection_string.h" + +#include "mongo/unittest/unittest.h" + +namespace { + + using namespace mongo; + + TEST(ConnectionString, EqualitySync) { + ConnectionString cs(ConnectionString::SYNC, "a,b,c", ""); + + ASSERT(cs.sameLogicalEndpoint(ConnectionString(ConnectionString::SYNC, "a,b,c", ""))); + ASSERT(cs.sameLogicalEndpoint(ConnectionString(ConnectionString::SYNC, "c,b,a", ""))); + ASSERT(cs.sameLogicalEndpoint(ConnectionString(ConnectionString::SYNC, "c,a,b", ""))); + + ASSERT(!cs.sameLogicalEndpoint(ConnectionString(ConnectionString::SYNC, "d,a,b", ""))); + } + +} // namespace diff --git a/src/mongo/s/client/multi_host_query_test.cpp b/src/mongo/s/client/multi_host_query_test.cpp index 230825eba30..3a684d30597 100644 --- a/src/mongo/s/client/multi_host_query_test.cpp +++ b/src/mongo/s/client/multi_host_query_test.cpp @@ -26,9 +26,12 @@ * it in the license file. */ +#include "mongo/platform/basic.h" + #include <boost/scoped_ptr.hpp> #include <boost/shared_ptr.hpp> +#include "mongo/base/status_with.h" #include "mongo/s/client/multi_host_query.h" #include "mongo/unittest/unittest.h" #include "mongo/util/concurrency/synchronization.h" @@ -176,8 +179,8 @@ namespace { // This means a single thread pool with a single thread would hang. cbCheckA.blockUntil(&cbCheckB); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); threadPool.schedule(hostA, cbCheckA.getHostCallback(hostA)); cbCheckA.waitForCallback(); @@ -233,7 +236,7 @@ namespace { void addMockTimestepAt(int timeMillis) { // Add a mock query to a host we aren't using at the provided time - ConnectionString host = ConnectionString::mock(HostAndPort("$timestepHost:1000")); + ConnectionString host = uassertStatusOK(ConnectionString::parse("$timestepHost:1000")); newMockHostResultAt(host, timeMillis, Status::OK(), NULL); // The query won't be scheduled by the multi op, so we need to do so ourselves @@ -423,7 +426,7 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString host = ConnectionString::mock(HostAndPort("$host:1000")); + ConnectionString host = uassertStatusOK(ConnectionString::parse("$host:1000")); vector<ConnectionString> hosts; hosts.push_back(host); @@ -445,7 +448,7 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString host = ConnectionString::mock(HostAndPort("$host:1000")); + ConnectionString host = uassertStatusOK(ConnectionString::parse("$host:1000")); vector<ConnectionString> hosts; hosts.push_back(host); @@ -469,7 +472,7 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString host = ConnectionString::mock(HostAndPort("$host:1000")); + ConnectionString host = uassertStatusOK(ConnectionString::parse("$host:1000")); vector<ConnectionString> hosts; hosts.push_back(host); @@ -490,8 +493,8 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); vector<ConnectionString> hosts; hosts.push_back(hostA); hosts.push_back(hostB); @@ -516,8 +519,8 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); vector<ConnectionString> hosts; hosts.push_back(hostA); hosts.push_back(hostB); @@ -543,8 +546,8 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); vector<ConnectionString> hosts; hosts.push_back(hostA); hosts.push_back(hostB); @@ -570,8 +573,8 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); vector<ConnectionString> hosts; hosts.push_back(hostA); hosts.push_back(hostB); @@ -601,8 +604,8 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); vector<ConnectionString> hosts; hosts.push_back(hostA); hosts.push_back(hostB); @@ -631,9 +634,9 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); - ConnectionString hostC = ConnectionString::mock(HostAndPort("$hostC:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); + ConnectionString hostC = uassertStatusOK(ConnectionString::parse("$hostC:1000")); vector<ConnectionString> hosts; hosts.push_back(hostA); hosts.push_back(hostB); @@ -665,9 +668,9 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); - ConnectionString hostC = ConnectionString::mock(HostAndPort("$hostC:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); + ConnectionString hostC = uassertStatusOK(ConnectionString::parse("$hostC:1000")); vector<ConnectionString> hosts; hosts.push_back(hostA); hosts.push_back(hostB); @@ -698,9 +701,9 @@ namespace { HostThreadPools threadPool(1, true); MockSystemEnv mockSystem(&threadPool); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); - ConnectionString hostC = ConnectionString::mock(HostAndPort("$hostC:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); + ConnectionString hostC = uassertStatusOK(ConnectionString::parse("$hostC:1000")); vector<ConnectionString> hosts; hosts.push_back(hostA); hosts.push_back(hostB); @@ -734,8 +737,8 @@ namespace { scoped_ptr<HostThreadPools> threadPool(new HostThreadPools(1, false)); MockSystemEnv mockSystem(threadPool.get()); - ConnectionString hostA = ConnectionString::mock(HostAndPort("$hostA:1000")); - ConnectionString hostB = ConnectionString::mock(HostAndPort("$hostB:1000")); + ConnectionString hostA = uassertStatusOK(ConnectionString::parse("$hostA:1000")); + ConnectionString hostB = uassertStatusOK(ConnectionString::parse("$hostB:1000")); vector<ConnectionString> hosts; hosts.push_back(hostA); hosts.push_back(hostB); diff --git a/src/mongo/s/client/shard_test.cpp b/src/mongo/s/client/shard_test.cpp index 00f9aeab2ee..0c57d6450da 100644 --- a/src/mongo/s/client/shard_test.cpp +++ b/src/mongo/s/client/shard_test.cpp @@ -1,37 +1,37 @@ -// shard_test.cpp - /** -* Copyright (C) 2008 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. -*/ + * Copyright (C) 2008-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. + */ #include "mongo/s/client/shard.h" #include "mongo/unittest/unittest.h" -namespace mongo { +namespace { + + using namespace mongo; TEST( Shard, EqualityRs ) { Shard a("foo", "bar/a,b", 0, false); @@ -53,12 +53,4 @@ namespace mongo { Shard("foa", "b.foo.com:123", 0, false)); } - TEST( Shard, EqualitySync ) { - ConnectionString cs( ConnectionString::SYNC, "a,b,c" ); - ASSERT( cs.sameLogicalEndpoint( ConnectionString( ConnectionString::SYNC, "a,b,c" ) ) ); - ASSERT( cs.sameLogicalEndpoint( ConnectionString( ConnectionString::SYNC, "c,b,a" ) ) ); - ASSERT( cs.sameLogicalEndpoint( ConnectionString( ConnectionString::SYNC, "c,a,b" ) ) ); - - ASSERT( ! cs.sameLogicalEndpoint( ConnectionString( ConnectionString::SYNC, "d,a,b" ) ) ); - } -} +} // namespace diff --git a/src/mongo/util/net/SConscript b/src/mongo/util/net/SConscript index e2ee996ea45..a7aff8c2776 100644 --- a/src/mongo/util/net/SConscript +++ b/src/mongo/util/net/SConscript @@ -9,7 +9,6 @@ env.Library( ], LIBDEPS=[ '$BUILD_DIR/mongo/util/foundation', - '$BUILD_DIR/mongo/db/server_options_core', ], ) |