Skip to content

Commit

Permalink
SERVER-19914 Remove connectionString() method on CatalogManager
Browse files Browse the repository at this point in the history
  • Loading branch information
stbrody committed Aug 13, 2015
1 parent 33ac3a1 commit adadd67
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 44 deletions.
5 changes: 3 additions & 2 deletions src/mongo/db/s/sharding_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ string ShardingState::getConfigServer(OperationContext* txn) {
stdx::lock_guard<stdx::mutex> lk(_mutex);
invariant(_enabled);

return grid.catalogManager(txn)->connectionString().toString();
return grid.shardRegistry()->getConfigServerConnectionString().toString();
}

string ShardingState::getShardName() {
Expand Down Expand Up @@ -752,7 +752,8 @@ void ShardingState::appendInfo(OperationContext* txn, BSONObjBuilder& builder) {
return;
}

builder.append("configServer", grid.catalogManager(txn)->connectionString().toString());
builder.append("configServer",
grid.shardRegistry()->getConfigServerConnectionString().toString());
builder.append("shardName", _shardName);

BSONObjBuilder versionB(builder.subobjStart("versions"));
Expand Down
6 changes: 0 additions & 6 deletions src/mongo/s/catalog/catalog_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ class CatalogManager {
public:
virtual ~CatalogManager() = default;

/**
* Retrieves the connection string for the catalog manager's backing server.
* TODO(spencer): Remove this method in favor of getting it from the ShardRegistry
*/
virtual ConnectionString connectionString() = 0;

/**
* Performs implementation-specific startup tasks. Must be run after the catalog manager
* has been installed into the global 'grid' object.
Expand Down
8 changes: 0 additions & 8 deletions src/mongo/s/catalog/catalog_manager_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,11 @@ namespace mongo {
using std::string;
using std::vector;

namespace {
ConnectionString kConfigHost(HostAndPort("dummy:1234"));
} // unnamed namespace

CatalogManagerMock::CatalogManagerMock() {
_mockDistLockMgr = stdx::make_unique<DistLockManagerMock>();
}
CatalogManagerMock::~CatalogManagerMock() = default;

ConnectionString CatalogManagerMock::connectionString() {
return kConfigHost;
}

Status CatalogManagerMock::startup() {
return Status::OK();
}
Expand Down
2 changes: 0 additions & 2 deletions src/mongo/s/catalog/catalog_manager_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class CatalogManagerMock : public CatalogManager {
CatalogManagerMock();
~CatalogManagerMock();

ConnectionString connectionString() override;

Status startup() override;

void shutDown() override;
Expand Down
6 changes: 1 addition & 5 deletions src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,6 @@ Status CatalogManagerLegacy::_startConfigServerChecker() {
return Status::OK();
}

ConnectionString CatalogManagerLegacy::connectionString() {
return _configServerConnectionString;
}

void CatalogManagerLegacy::shutDown() {
LOG(1) << "CatalogManagerLegacy::shutDown() called.";
{
Expand Down Expand Up @@ -607,7 +603,7 @@ Status CatalogManagerLegacy::dropCollection(OperationContext* txn, const Namespa

for (const auto& shardEntry : allShards) {
SetShardVersionRequest ssv = SetShardVersionRequest::makeForVersioningNoPersist(
connectionString(),
grid.shardRegistry()->getConfigServerConnectionString(),
shardEntry.getName(),
fassertStatusOK(28753, ConnectionString::parse(shardEntry.getHost())),
ns,
Expand Down
2 changes: 0 additions & 2 deletions src/mongo/s/catalog/legacy/catalog_manager_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class CatalogManagerLegacy final : public CatalogManager {

Status startup() override;

ConnectionString connectionString() override;

void shutDown() override;

Status shardCollection(OperationContext* txn,
Expand Down
8 changes: 6 additions & 2 deletions src/mongo/s/catalog/legacy/cluster_client_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/s/catalog/type_mongos.h"
#include "mongo/s/catalog/type_shard.h"
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/grid.h"
#include "mongo/util/log.h"
#include "mongo/util/stringutils.h"

Expand All @@ -58,7 +60,8 @@ Status checkClusterMongoVersions(CatalogManager* catalogManager, const string& m
//

try {
connPtr.reset(new ScopedDbConnection(catalogManager->connectionString(), 30));
connPtr.reset(
new ScopedDbConnection(grid.shardRegistry()->getConfigServerConnectionString(), 30));
ScopedDbConnection& conn = *connPtr;
unique_ptr<DBClientCursor> cursor(_safeCursor(conn->query(MongosType::ConfigNS, Query())));

Expand Down Expand Up @@ -148,7 +151,8 @@ Status checkClusterMongoVersions(CatalogManager* catalogManager, const string& m
}

// Add config servers to list of servers to check version against
vector<HostAndPort> configServers = catalogManager->connectionString().getServers();
vector<HostAndPort> configServers =
grid.shardRegistry()->getConfigServerConnectionString().getServers();
servers.insert(servers.end(), configServers.begin(), configServers.end());

//
Expand Down
7 changes: 5 additions & 2 deletions src/mongo/s/catalog/legacy/config_upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog/type_settings.h"
#include "mongo/s/catalog/type_shard.h"
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/grid.h"
#include "mongo/stdx/functional.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
Expand Down Expand Up @@ -330,7 +332,7 @@ Status getConfigVersion(CatalogManager* catalogManager, VersionType* versionInfo
try {
versionInfo->clear();

ScopedDbConnection conn(catalogManager->connectionString(), 30);
ScopedDbConnection conn(grid.shardRegistry()->getConfigServerConnectionString(), 30);

unique_ptr<DBClientCursor> cursor(_safeCursor(conn->query("config.version", BSONObj())));

Expand Down Expand Up @@ -425,7 +427,8 @@ bool checkAndUpgradeConfigVersion(CatalogManager* catalogManager,

// Contact the config servers to make sure all are online - otherwise we wait a long time
// for locks.
if (!_checkConfigServersAlive(catalogManager->connectionString(), errMsg)) {
if (!_checkConfigServersAlive(grid.shardRegistry()->getConfigServerConnectionString(),
errMsg)) {
if (isEmptyVersion) {
*errMsg = stream() << "all config servers must be reachable for initial"
<< " config database creation" << causedBy(errMsg);
Expand Down
6 changes: 1 addition & 5 deletions src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ Status CatalogManagerReplicaSet::startup() {
return Status::OK();
}

ConnectionString CatalogManagerReplicaSet::connectionString() {
return grid.shardRegistry()->getConfigServerConnectionString();
}

void CatalogManagerReplicaSet::shutDown() {
LOG(1) << "CatalogManagerReplicaSet::shutDown() called.";
{
Expand Down Expand Up @@ -524,7 +520,7 @@ Status CatalogManagerReplicaSet::dropCollection(OperationContext* txn, const Nam

for (const auto& shardEntry : allShards) {
SetShardVersionRequest ssv = SetShardVersionRequest::makeForVersioningNoPersist(
connectionString(),
grid.shardRegistry()->getConfigServerConnectionString(),
shardEntry.getName(),
fassertStatusOK(28781, ConnectionString::parse(shardEntry.getHost())),
ns,
Expand Down
2 changes: 0 additions & 2 deletions src/mongo/s/catalog/replset/catalog_manager_replica_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class CatalogManagerReplicaSet final : public CatalogManager {

Status startup() override;

ConnectionString connectionString() override;

void shutDown() override;

Status shardCollection(OperationContext* txn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void CatalogManagerReplSetTestFixture::setUp() {

auto configTargeter(stdx::make_unique<RemoteCommandTargeterMock>());
_configTargeter = configTargeter.get();
_targeterFactory->addTargeterToReturn(cm->connectionString(), std::move(configTargeter));
_targeterFactory->addTargeterToReturn(configCS, std::move(configTargeter));

auto shardRegistry(stdx::make_unique<ShardRegistry>(
std::move(targeterFactory), std::move(executor), _mockNetwork, configCS));
Expand Down Expand Up @@ -367,7 +367,7 @@ void CatalogManagerReplSetTestFixture::expectSetShardVersion(

ASSERT(!ssv.isInit());
ASSERT(ssv.isAuthoritative());
ASSERT_EQ(catalogManager()->connectionString().toString(),
ASSERT_EQ(grid.shardRegistry()->getConfigServerConnectionString().toString(),
ssv.getConfigServer().toString());
ASSERT_EQ(expectedShard.getHost(), ssv.getShardConnectionString().toString());
ASSERT_EQ(expectedNs.toString(), ssv.getNS().ns());
Expand Down
4 changes: 2 additions & 2 deletions src/mongo/s/chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ Status Chunk::multiSplit(OperationContext* txn, const vector<BSONObj>& m, BSONOb
cmd.append("max", getMax());
cmd.append("from", getShardId());
cmd.append("splitKeys", m);
cmd.append("configdb", grid.catalogManager(txn)->connectionString().toString());
cmd.append("configdb", grid.shardRegistry()->getConfigServerConnectionString().toString());
cmd.append("epoch", _manager->getVersion().epoch());
BSONObj cmdObj = cmd.obj();

Expand Down Expand Up @@ -497,7 +497,7 @@ bool Chunk::moveAndCommit(OperationContext* txn,
builder.append("min", _min);
builder.append("max", _max);
builder.append("maxChunkSizeBytes", chunkSize);
builder.append("configdb", grid.catalogManager(txn)->connectionString().toString());
builder.append("configdb", grid.shardRegistry()->getConfigServerConnectionString().toString());

// For legacy secondary throttle setting.
bool secondaryThrottle = true;
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/s/commands/cluster_merge_chunks_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class ClusterMergeChunksCommand : public Command {
remoteCmdObjB.append(cmdObj[ClusterMergeChunksCommand::nsField()]);
remoteCmdObjB.append(cmdObj[ClusterMergeChunksCommand::boundsField()]);
remoteCmdObjB.append(ClusterMergeChunksCommand::configField(),
grid.catalogManager(txn)->connectionString().toString());
grid.shardRegistry()->getConfigServerConnectionString().toString());
remoteCmdObjB.append(ClusterMergeChunksCommand::shardNameField(), firstChunk->getShardId());

BSONObj remoteResult;
Expand Down
4 changes: 3 additions & 1 deletion src/mongo/s/commands/cluster_netstat_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "mongo/db/commands.h"
#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/grid.h"

namespace mongo {
Expand Down Expand Up @@ -69,7 +70,8 @@ class NetStatCmd : public Command {
int options,
std::string& errmsg,
BSONObjBuilder& result) {
result.append("configserver", grid.catalogManager(txn)->connectionString().toString());
result.append("configserver",
grid.shardRegistry()->getConfigServerConnectionString().toString());
result.append("isdbgrid", 1);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/mongo/s/version_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ bool initShardVersionEmptyNS(OperationContext* txn, DBClientBase* conn_in) {

ok = setShardVersion(*conn,
"",
grid.catalogManager(txn)->connectionString().toString(),
grid.shardRegistry()->getConfigServerConnectionString().toString(),
ChunkVersion(),
NULL,
true,
Expand Down Expand Up @@ -373,7 +373,7 @@ bool checkShardVersion(OperationContext* txn,
BSONObj result;
if (setShardVersion(*conn,
ns,
grid.catalogManager(txn)->connectionString().toString(),
grid.shardRegistry()->getConfigServerConnectionString().toString(),
version,
manager.get(),
authoritative,
Expand Down

0 comments on commit adadd67

Please sign in to comment.