summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-04-13 18:28:19 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-04-16 16:55:28 -0400
commit5ae0a2505ca14442ca6473b2d713be4e84958e6b (patch)
treec39ababf3c4c31502eadb3d26107c53594667017
parenta64b7af35ab0463276645e8d4637569c0ccdfd73 (diff)
downloadmongo-5ae0a2505ca14442ca6473b2d713be4e84958e6b.tar.gz
SERVER-17817 Remove ClientInfo class.
-rw-r--r--src/mongo/SConscript1
-rw-r--r--src/mongo/db/client.h3
-rw-r--r--src/mongo/s/chunk.cpp1
-rw-r--r--src/mongo/s/client/shard_connection_test.cpp6
-rw-r--r--src/mongo/s/client_info.cpp81
-rw-r--r--src/mongo/s/client_info.h65
-rw-r--r--src/mongo/s/cluster_last_error_info.cpp10
-rw-r--r--src/mongo/s/cluster_last_error_info.h5
-rw-r--r--src/mongo/s/commands/cluster_get_last_error_cmd.cpp7
-rw-r--r--src/mongo/s/commands/cluster_get_prev_error_cmd.cpp1
-rw-r--r--src/mongo/s/commands/cluster_index_filter_cmd.cpp1
-rw-r--r--src/mongo/s/commands/cluster_plan_cache_cmd.cpp1
-rw-r--r--src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_reset_error_cmd.cpp5
-rw-r--r--src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_write_cmd.cpp15
-rw-r--r--src/mongo/s/commands_public.cpp8
-rw-r--r--src/mongo/s/request.cpp4
-rw-r--r--src/mongo/s/request.h4
-rw-r--r--src/mongo/s/s_only.cpp30
-rw-r--r--src/mongo/s/server.cpp5
-rw-r--r--src/mongo/s/strategy.cpp1
22 files changed, 56 insertions, 206 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 29f9bbcc356..52e5799564d 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -891,7 +891,6 @@ env.Library('coreshard',
env.Library('mongoscore',
[
's/balance.cpp',
- 's/client_info.cpp',
's/cluster_last_error_info.cpp',
's/commands_public.cpp',
's/cursors.cpp',
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index 1b1dc51b251..b01656d3407 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -71,6 +71,9 @@ namespace mongo {
* call this when your thread starts.
*/
static void initThread(const char *desc, AbstractMessagingPort *mp = 0);
+ static void initThread(const char* desc,
+ ServiceContext* serviceContext,
+ AbstractMessagingPort* mp);
/**
* Inits a thread if that thread has not already been init'd, setting the thread name to
diff --git a/src/mongo/s/chunk.cpp b/src/mongo/s/chunk.cpp
index a4acdc70d51..4117303d2d7 100644
--- a/src/mongo/s/chunk.cpp
+++ b/src/mongo/s/chunk.cpp
@@ -48,7 +48,6 @@
#include "mongo/s/balancer_policy.h"
#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/s/chunk_manager.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/cluster_write.h"
#include "mongo/s/config_server_checker_service.h"
#include "mongo/s/cursors.h"
diff --git a/src/mongo/s/client/shard_connection_test.cpp b/src/mongo/s/client/shard_connection_test.cpp
index 72e4e0c862c..22274350170 100644
--- a/src/mongo/s/client/shard_connection_test.cpp
+++ b/src/mongo/s/client/shard_connection_test.cpp
@@ -30,13 +30,13 @@
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/authz_manager_external_state_mock.h"
+#include "mongo/db/client.h"
#include "mongo/db/service_context.h"
#include "mongo/db/service_context_noop.h"
#include "mongo/dbtests/mock/mock_conn_registry.h"
#include "mongo/dbtests/mock/mock_dbclient_connection.h"
#include "mongo/platform/cstdint.h"
#include "mongo/s/client/shard_connection.h"
-#include "mongo/s/client_info.h"
#include "mongo/stdx/memory.h"
#include "mongo/unittest/unittest.h"
@@ -74,8 +74,8 @@ namespace {
class ShardConnFixture: public mongo::unittest::Test {
public:
void setUp() {
- if (!ClientInfo::exists()) {
- ClientInfo::create(getGlobalServiceContext(), NULL);
+ if (!haveClient()) {
+ Client::initThread("ShardConnFixture", getGlobalServiceContext(), NULL);
}
_maxPoolSizePerHost = mongo::shardConnectionPool.getMaxPoolSize();
diff --git a/src/mongo/s/client_info.cpp b/src/mongo/s/client_info.cpp
deleted file mode 100644
index 98db7d326f2..00000000000
--- a/src/mongo/s/client_info.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-// @file s/client_info.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.
- */
-
-#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kSharding
-
-#include "mongo/platform/basic.h"
-
-#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"
-#include "mongo/util/assert_util.h"
-
-namespace mongo {
-
-namespace {
- boost::thread_specific_ptr<ClientInfo> tlInfo;
-} // namespace
-
- ClientInfo* ClientInfo::create(ServiceContext* serviceContext,
- AbstractMessagingPort* messagingPort) {
- ClientInfo * info = tlInfo.get();
- massert(16472, "A ClientInfo already exists for this thread", !info);
- info = new ClientInfo(serviceContext, messagingPort);
- AuthorizationSession::set(info,
- getGlobalAuthorizationManager()->makeAuthorizationSession());
- tlInfo.reset( info );
- return info;
- }
-
- ClientInfo* ClientInfo::get() {
- ClientInfo* info = tlInfo.get();
- //fassert(16483, info);
- if (!info) {
- return create(getGlobalServiceContext(), nullptr);
- }
- return info;
- }
-
- bool ClientInfo::exists() {
- return tlInfo.get();
- }
-
- ClientInfo::ClientInfo(ServiceContext* serviceContext, AbstractMessagingPort* messagingPort) :
- ClientBasic(serviceContext, messagingPort) {}
-
- ClientBasic* ClientBasic::getCurrent() {
- return ClientInfo::get();
- }
-
-} // namespace mongo
diff --git a/src/mongo/s/client_info.h b/src/mongo/s/client_info.h
deleted file mode 100644
index 0db7af3eafa..00000000000
--- a/src/mongo/s/client_info.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-#pragma once
-
-#include "mongo/db/client_basic.h"
-
-namespace mongo {
-
- class AbstractMessagingPort;
- class ServiceContext;
-
- /**
- * holds information about a client connected to a mongos
- * 1 per client socket
- * currently implemented with a thread local
- */
- class ClientInfo : public ClientBasic {
- public:
- /**
- * Returns whether or not a ClientInfo for this thread has already been bound to this
- * thread.
- */
- static bool exists();
-
- /**
- * Gets the ClientInfo object for this thread, creating one if necessary.
- */
- static ClientInfo * get();
-
- /**
- * Creates a ClientInfo and binds it to this thread.
- */
- static ClientInfo* create(ServiceContext* serviceContext,
- AbstractMessagingPort* messagingPort);
-
- private:
- ClientInfo(ServiceContext* serviceContext, AbstractMessagingPort* messagingPort);
- };
-
-} // namespace mongo
diff --git a/src/mongo/s/cluster_last_error_info.cpp b/src/mongo/s/cluster_last_error_info.cpp
index 8347bd50ec0..efa50d49101 100644
--- a/src/mongo/s/cluster_last_error_info.cpp
+++ b/src/mongo/s/cluster_last_error_info.cpp
@@ -34,10 +34,10 @@
#include <utility>
+#include "mongo/db/client.h"
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/stats/timer_stats.h"
-#include "mongo/s/client_info.h"
#include "mongo/util/log.h"
namespace mongo {
@@ -75,12 +75,8 @@ namespace mongo {
static ServerStatusMetricField<TimerStats> displayGleLatency("getLastError.wtime",
&gleWtimeStats);
- // Look for $gleStats in a command response, and fill in ClientInfo with the data,
- // if found.
- // This data will be used by subsequent GLE calls, to ensure we look for the correct
- // write on the correct PRIMARY.
void saveGLEStats(const BSONObj& result, const std::string& hostString) {
- if (!ClientInfo::exists()) {
+ if (!haveClient()) {
return;
}
if (result[kGLEStatsFieldName].type() != Object) {
@@ -92,7 +88,7 @@ namespace mongo {
BSONElement subobj = result[kGLEStatsFieldName];
Timestamp lastOpTime = subobj[kGLEStatsLastOpTimeFieldName].timestamp();
OID electionId = subobj[kGLEStatsElectionIdFieldName].OID();
- ClientInfo* clientInfo = ClientInfo::get();
+ auto& clientInfo = cc();
LOG(4) << "saveGLEStats lastOpTime:" << lastOpTime
<< " electionId:" << electionId;
diff --git a/src/mongo/s/cluster_last_error_info.h b/src/mongo/s/cluster_last_error_info.h
index e1a912bfee2..0a25b9732f8 100644
--- a/src/mongo/s/cluster_last_error_info.h
+++ b/src/mongo/s/cluster_last_error_info.h
@@ -104,8 +104,9 @@ namespace mongo {
};
/**
- * Looks for $gleStats in a command response, and fills in ClientInfo with the data,
- * if found.
+ * Looks for $gleStats in a command response, and fills in the ClusterLastErrorInfo for this
+ * thread's associated Client with the data, if found.
+ *
* This data will be used by subsequent GLE calls, to ensure we look for the correct
* write on the correct PRIMARY.
* result: the result from calling runCommand
diff --git a/src/mongo/s/commands/cluster_get_last_error_cmd.cpp b/src/mongo/s/commands/cluster_get_last_error_cmd.cpp
index db0f25f302f..5ef065d8e4e 100644
--- a/src/mongo/s/commands/cluster_get_last_error_cmd.cpp
+++ b/src/mongo/s/commands/cluster_get_last_error_cmd.cpp
@@ -30,10 +30,10 @@
#include <vector>
+#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/lasterror.h"
#include "mongo/s/client/dbclient_multi_command.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/cluster_last_error_info.h"
#include "mongo/s/dbclient_shard_resolver.h"
#include "mongo/s/write_ops/batch_downconvert.h"
@@ -100,8 +100,7 @@ namespace {
// For compatibility with 2.4 sharded GLE, we always enforce the write concern
// across all shards.
- const HostOpTimeMap hostOpTimes(
- ClusterLastErrorInfo::get(ClientInfo::get()).getPrevHostOpTimes());
+ const HostOpTimeMap hostOpTimes(ClusterLastErrorInfo::get(cc()).getPrevHostOpTimes());
HostOpTimeMap resolvedHostOpTimes;
Status status(Status::OK());
@@ -133,7 +132,7 @@ namespace {
}
// Don't forget about our last hosts, reset the client info
- ClusterLastErrorInfo::get(ClientInfo::get()).disableForCommand();
+ ClusterLastErrorInfo::get(cc()).disableForCommand();
// We're now done contacting all remote servers, just report results
diff --git a/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp b/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp
index 2e61db1683a..bc97b4dbb86 100644
--- a/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp
+++ b/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp
@@ -34,7 +34,6 @@
#include "mongo/db/commands.h"
#include "mongo/db/lasterror.h"
#include "mongo/s/client/shard_connection.h"
-#include "mongo/s/client_info.h"
namespace mongo {
namespace {
diff --git a/src/mongo/s/commands/cluster_index_filter_cmd.cpp b/src/mongo/s/commands/cluster_index_filter_cmd.cpp
index f39ca1bfd7b..9115583c2a3 100644
--- a/src/mongo/s/commands/cluster_index_filter_cmd.cpp
+++ b/src/mongo/s/commands/cluster_index_filter_cmd.cpp
@@ -31,7 +31,6 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/client_basic.h"
#include "mongo/db/commands.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/config.h"
#include "mongo/s/grid.h"
#include "mongo/s/stale_exception.h"
diff --git a/src/mongo/s/commands/cluster_plan_cache_cmd.cpp b/src/mongo/s/commands/cluster_plan_cache_cmd.cpp
index e6d1c75d5fe..718ab7dab3a 100644
--- a/src/mongo/s/commands/cluster_plan_cache_cmd.cpp
+++ b/src/mongo/s/commands/cluster_plan_cache_cmd.cpp
@@ -31,7 +31,6 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/client_basic.h"
#include "mongo/db/commands.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/config.h"
#include "mongo/s/grid.h"
#include "mongo/s/stale_exception.h"
diff --git a/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp b/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp
index 7d272c28619..81f34598115 100644
--- a/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp
+++ b/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp
@@ -28,9 +28,9 @@
#include "mongo/platform/basic.h"
+#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/lasterror.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/cluster_last_error_info.h"
namespace mongo {
@@ -74,7 +74,7 @@ namespace {
if (cmdObj["forShell"].trueValue()) {
lastError.disableForCommand();
- ClusterLastErrorInfo::get(ClientInfo::get()).disableForCommand();
+ ClusterLastErrorInfo::get(cc()).disableForCommand();
}
errmsg = "replSetGetStatus is not supported through mongos";
diff --git a/src/mongo/s/commands/cluster_reset_error_cmd.cpp b/src/mongo/s/commands/cluster_reset_error_cmd.cpp
index 9d8c697f678..9c5b7f271cc 100644
--- a/src/mongo/s/commands/cluster_reset_error_cmd.cpp
+++ b/src/mongo/s/commands/cluster_reset_error_cmd.cpp
@@ -31,10 +31,10 @@
#include <set>
#include <string>
+#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/lasterror.h"
#include "mongo/s/client/shard_connection.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/cluster_last_error_info.h"
namespace mongo {
@@ -72,9 +72,8 @@ namespace {
le->reset();
}
- ClientInfo* client = ClientInfo::get();
const std::set<std::string>* shards =
- ClusterLastErrorInfo::get(client).getPrevShardHosts();
+ ClusterLastErrorInfo::get(cc()).getPrevShardHosts();
for (std::set<std::string>::const_iterator i = shards->begin();
i != shards->end();
diff --git a/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp b/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp
index 2f9c3a618c5..565d60e6272 100644
--- a/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp
+++ b/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp
@@ -28,8 +28,8 @@
#include "mongo/platform/basic.h"
+#include "mongo/db/client.h"
#include "mongo/db/commands.h"
-#include "mongo/s/client_info.h"
#include "mongo/util/net/sock.h"
namespace mongo {
@@ -66,7 +66,7 @@ namespace {
BSONObjBuilder& result,
bool fromRepl) {
- result << "you" << ClientInfo::get()->getRemote().toString();
+ result << "you" << cc().getRemote().toString();
return true;
}
diff --git a/src/mongo/s/commands/cluster_write_cmd.cpp b/src/mongo/s/commands/cluster_write_cmd.cpp
index 2985debc4a7..42a63c1a4b7 100644
--- a/src/mongo/s/commands/cluster_write_cmd.cpp
+++ b/src/mongo/s/commands/cluster_write_cmd.cpp
@@ -29,19 +29,19 @@
#include "mongo/platform/basic.h"
#include "mongo/base/error_codes.h"
+#include "mongo/db/client.h"
#include "mongo/db/client_basic.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/write_commands/write_commands_common.h"
-#include "mongo/s/cluster_write.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/stats/counters.h"
-#include "mongo/s/client_info.h"
-#include "mongo/s/cluster_last_error_info.h"
+#include "mongo/db/stats/counters.h"
#include "mongo/s/cluster_explain.h"
+#include "mongo/s/cluster_last_error_info.h"
+#include "mongo/s/cluster_write.h"
+#include "mongo/s/write_ops/batch_upconvert.h"
#include "mongo/s/write_ops/batched_command_request.h"
#include "mongo/s/write_ops/batched_command_response.h"
-#include "mongo/s/write_ops/batch_upconvert.h"
-#include "mongo/db/stats/counters.h"
#include "mongo/util/timer.h"
namespace mongo {
@@ -212,9 +212,8 @@ namespace {
}
// Save the last opTimes written on each shard for this client, to allow GLE to work
- if (ClientInfo::exists() && writer.getStats().hasShardStats()) {
- ClientInfo* clientInfo = ClientInfo::get();
- ClusterLastErrorInfo::get(clientInfo).addHostOpTimes(
+ if (haveClient() && writer.getStats().hasShardStats()) {
+ ClusterLastErrorInfo::get(cc()).addHostOpTimes(
writer.getStats().getShardStats().getWriteOpTimes());
}
diff --git a/src/mongo/s/commands_public.cpp b/src/mongo/s/commands_public.cpp
index 8486b3cccf0..2da379e1f46 100644
--- a/src/mongo/s/commands_public.cpp
+++ b/src/mongo/s/commands_public.cpp
@@ -57,7 +57,6 @@
#include "mongo/s/catalog/catalog_cache.h"
#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/s/chunk_manager.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/cluster_explain.h"
#include "mongo/s/cluster_last_error_info.h"
#include "mongo/s/commands/cluster_commands_common.h"
@@ -993,9 +992,7 @@ namespace {
if (ok) {
// check whether split is necessary (using update object for size heuristic)
- ClientInfo *client = ClientInfo::get();
-
- if (client != NULL && ClusterLastErrorInfo::get(client).autoSplitOk()) {
+ if (haveClient() && ClusterLastErrorInfo::get(cc()).autoSplitOk()) {
chunk->splitIfShould(cmdObj.getObjectField("update").objsize());
}
}
@@ -2577,10 +2574,9 @@ namespace {
Command::unknownCommands.increment();
return;
}
- ClientInfo *client = ClientInfo::get();
OperationContext* noTxn = NULL; // mongos doesn't use transactions SERVER-13931
- execCommandClientBasic(noTxn, c, *client, queryOptions, ns, jsobj, anObjBuilder, false);
+ execCommandClientBasic(noTxn, c, cc(), queryOptions, ns, jsobj, anObjBuilder, false);
}
} // namespace mongo
diff --git a/src/mongo/s/request.cpp b/src/mongo/s/request.cpp
index a629478a366..8c8b40dc608 100644
--- a/src/mongo/s/request.cpp
+++ b/src/mongo/s/request.cpp
@@ -35,9 +35,9 @@
#include "mongo/s/request.h"
#include "mongo/db/auth/authorization_session.h"
+#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/stats/counters.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/cluster_last_error_info.h"
#include "mongo/s/cursors.h"
#include "mongo/s/grid.h"
@@ -51,7 +51,7 @@ namespace mongo {
using std::string;
Request::Request(Message& m, AbstractMessagingPort* p)
- : _clientInfo(ClientInfo::get()),
+ : _clientInfo(&cc()),
_m(m),
_d(m),
_p(p),
diff --git a/src/mongo/s/request.h b/src/mongo/s/request.h
index 53f80160c3e..4bdf7a816bb 100644
--- a/src/mongo/s/request.h
+++ b/src/mongo/s/request.h
@@ -35,7 +35,7 @@
namespace mongo {
- class ClientInfo;
+ class Client;
class Request {
MONGO_DISALLOW_COPYING(Request);
@@ -71,7 +71,7 @@ namespace mongo {
void init();
private:
- ClientInfo* const _clientInfo;
+ Client* const _clientInfo;
Message& _m;
DbMessage _d;
diff --git a/src/mongo/s/s_only.cpp b/src/mongo/s/s_only.cpp
index be5f6bdfc53..17c3d3be30f 100644
--- a/src/mongo/s/s_only.cpp
+++ b/src/mongo/s/s_only.cpp
@@ -37,7 +37,6 @@
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/service_context.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/cluster_last_error_info.h"
#include "mongo/util/concurrency/thread_name.h"
#include "mongo/util/log.h"
@@ -55,7 +54,7 @@ namespace mongo {
* in an operation to be read later by getLastError()
*/
void usingAShardConnection(const std::string& addr) {
- ClusterLastErrorInfo::get(ClientInfo::get()).addShardHost(addr);
+ ClusterLastErrorInfo::get(cc()).addShardHost(addr);
}
TSP_DEFINE(Client,currentClient)
@@ -70,10 +69,14 @@ namespace mongo {
void Client::shutdown() {}
void Client::initThread(const char *desc, AbstractMessagingPort *mp) {
- // mp is non-null only for client connections, and mongos uses ClientInfo for those
- massert(16478, "Client being used for incoming connection thread in mongos", mp == NULL);
+ initThread(desc, getGlobalServiceContext(), mp);
+ }
+
+ void Client::initThread(const char* desc,
+ ServiceContext* serviceContext,
+ AbstractMessagingPort *mp) {
- verify( currentClient.get() == 0 );
+ verify(currentClient.get() == 0);
string fullDesc = desc;
if ( str::equals( "conn" , desc ) && mp != NULL )
@@ -81,17 +84,24 @@ namespace mongo {
setThreadName( fullDesc.c_str() );
- Client *c = new Client( fullDesc, getGlobalServiceContext(), mp );
+ Client *c = new Client(fullDesc, serviceContext, mp);
currentClient.reset(c);
mongo::lastError.initThread();
AuthorizationSession::set(c, getGlobalAuthorizationManager()->makeAuthorizationSession());
}
+ ClientBasic* ClientBasic::getCurrent() {
+ return currentClient.get();
+ }
+
string Client::clientAddress(bool includePort) const {
- ClientInfo * ci = ClientInfo::get();
- if ( ci )
- return ci->getRemote().toString();
- return "";
+ if (!hasRemote()) {
+ return "";
+ }
+ if (includePort) {
+ return getRemote().toString();
+ }
+ return getRemote().host();
}
// Need a version that takes a Client to match the mongod interface so the web server can call
diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp
index 145746646ca..dc154bd4cf0 100644
--- a/src/mongo/s/server.cpp
+++ b/src/mongo/s/server.cpp
@@ -63,7 +63,6 @@
#include "mongo/s/catalog/legacy/config_upgrade.h"
#include "mongo/s/client/sharding_connection_hook.h"
#include "mongo/s/chunk_manager.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/config.h"
#include "mongo/s/config_server_checker_service.h"
#include "mongo/s/cursors.h"
@@ -139,8 +138,8 @@ namespace mongo {
public:
virtual ~ShardedMessageHandler() {}
- virtual void connected( AbstractMessagingPort* p ) {
- ClientInfo::create(getGlobalServiceContext(), p);
+ virtual void connected(AbstractMessagingPort* p) {
+ Client::initThread("conn", getGlobalServiceContext(), p);
}
virtual void process( Message& m , AbstractMessagingPort* p , LastError * le) {
diff --git a/src/mongo/s/strategy.cpp b/src/mongo/s/strategy.cpp
index f0d46b5fa44..c764795d055 100644
--- a/src/mongo/s/strategy.cpp
+++ b/src/mongo/s/strategy.cpp
@@ -52,7 +52,6 @@
#include "mongo/s/catalog/catalog_cache.h"
#include "mongo/s/chunk_manager_targeter.h"
#include "mongo/s/client/dbclient_multi_command.h"
-#include "mongo/s/client_info.h"
#include "mongo/s/cluster_write.h"
#include "mongo/s/chunk_manager.h"
#include "mongo/s/chunk_version.h"