summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-12-27 13:11:00 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-12-28 21:46:54 -0500
commit10e3ce2d905ca3afc1e5949da2daa3353740171a (patch)
tree0f532002ff244bac41b652daf6c2c1e783a3a25e /src/mongo/db
parent800f84351f3f4f07aadf84b08be68f6be44fcfca (diff)
downloadmongo-10e3ce2d905ca3afc1e5949da2daa3353740171a.tar.gz
SERVER-28992 Get rid of unused code from the write commands tests
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/range_arithmetic.h6
-rw-r--r--src/mongo/db/range_arithmetic_test.cpp1
-rw-r--r--src/mongo/db/s/balancer/balancer.cpp2
-rw-r--r--src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp12
-rw-r--r--src/mongo/db/s/balancer/migration_manager.cpp7
-rw-r--r--src/mongo/db/s/chunk_splitter.cpp2
-rw-r--r--src/mongo/db/s/collection_metadata.h5
-rw-r--r--src/mongo/db/s/collection_sharding_state.cpp4
-rw-r--r--src/mongo/db/s/get_shard_version_command.cpp2
-rw-r--r--src/mongo/db/s/merge_chunks_command.cpp4
-rw-r--r--src/mongo/db/s/metadata_manager_test.cpp3
-rw-r--r--src/mongo/db/transaction_reaper.cpp2
12 files changed, 19 insertions, 31 deletions
diff --git a/src/mongo/db/range_arithmetic.h b/src/mongo/db/range_arithmetic.h
index 91e35d8bd6f..bafcfeb44e1 100644
--- a/src/mongo/db/range_arithmetic.h
+++ b/src/mongo/db/range_arithmetic.h
@@ -28,12 +28,8 @@
#pragma once
-#include <map>
-#include <string>
-
+#include "mongo/bson/bsonobj.h"
#include "mongo/bson/simple_bsonobj_comparator.h"
-#include "mongo/db/jsobj.h"
-#include "mongo/s/chunk_version.h"
namespace mongo {
diff --git a/src/mongo/db/range_arithmetic_test.cpp b/src/mongo/db/range_arithmetic_test.cpp
index f4d5f3fb14f..7ee3e7450c8 100644
--- a/src/mongo/db/range_arithmetic_test.cpp
+++ b/src/mongo/db/range_arithmetic_test.cpp
@@ -28,6 +28,7 @@
#include "mongo/platform/basic.h"
+#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/range_arithmetic.h"
#include "mongo/unittest/unittest.h"
diff --git a/src/mongo/db/s/balancer/balancer.cpp b/src/mongo/db/s/balancer/balancer.cpp
index 036cb89cb75..99fed7b8737 100644
--- a/src/mongo/db/s/balancer/balancer.cpp
+++ b/src/mongo/db/s/balancer/balancer.cpp
@@ -623,7 +623,7 @@ void Balancer::_splitOrMarkJumbo(OperationContext* opCtx,
Grid::get(opCtx)->catalogCache()->getShardedCollectionRoutingInfoWithRefresh(opCtx, nss));
const auto cm = routingInfo.cm().get();
- auto chunk = cm->findIntersectingChunkWithSimpleCollation(minKey);
+ const auto chunk = cm->findIntersectingChunkWithSimpleCollation(minKey);
try {
const auto splitPoints = uassertStatusOK(shardutil::selectChunkSplitPoints(
diff --git a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp
index 2bf7db8dc9a..1ebe571a210 100644
--- a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp
+++ b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp
@@ -385,8 +385,7 @@ StatusWith<SplitInfoVector> BalancerChunkSelectionPolicyImpl::_getSplitCandidate
for (const auto& tagRangeEntry : distribution.tagRanges()) {
const auto& tagRange = tagRangeEntry.second;
- shared_ptr<Chunk> chunkAtZoneMin =
- cm->findIntersectingChunkWithSimpleCollation(tagRange.min);
+ const auto chunkAtZoneMin = cm->findIntersectingChunkWithSimpleCollation(tagRange.min);
invariant(chunkAtZoneMin->getMax().woCompare(tagRange.min) > 0);
if (chunkAtZoneMin->getMin().woCompare(tagRange.min)) {
@@ -397,8 +396,7 @@ StatusWith<SplitInfoVector> BalancerChunkSelectionPolicyImpl::_getSplitCandidate
if (!tagRange.max.woCompare(shardKeyPattern.globalMax()))
continue;
- shared_ptr<Chunk> chunkAtZoneMax =
- cm->findIntersectingChunkWithSimpleCollation(tagRange.max);
+ const auto chunkAtZoneMax = cm->findIntersectingChunkWithSimpleCollation(tagRange.max);
// We need to check that both the chunk's minKey does not match the zone's max and also that
// the max is not equal, which would only happen in the case of the zone ending in MaxKey.
@@ -436,8 +434,7 @@ StatusWith<MigrateInfoVector> BalancerChunkSelectionPolicyImpl::_getMigrateCandi
for (const auto& tagRangeEntry : distribution.tagRanges()) {
const auto& tagRange = tagRangeEntry.second;
- shared_ptr<Chunk> chunkAtZoneMin =
- cm->findIntersectingChunkWithSimpleCollation(tagRange.min);
+ const auto chunkAtZoneMin = cm->findIntersectingChunkWithSimpleCollation(tagRange.min);
if (chunkAtZoneMin->getMin().woCompare(tagRange.min)) {
return {ErrorCodes::IllegalOperation,
@@ -455,8 +452,7 @@ StatusWith<MigrateInfoVector> BalancerChunkSelectionPolicyImpl::_getMigrateCandi
if (!tagRange.max.woCompare(shardKeyPattern.globalMax()))
continue;
- shared_ptr<Chunk> chunkAtZoneMax =
- cm->findIntersectingChunkWithSimpleCollation(tagRange.max);
+ const auto chunkAtZoneMax = cm->findIntersectingChunkWithSimpleCollation(tagRange.max);
// We need to check that both the chunk's minKey does not match the zone's max and also that
// the max is not equal, which would only happen in the case of the zone ending in MaxKey.
diff --git a/src/mongo/db/s/balancer/migration_manager.cpp b/src/mongo/db/s/balancer/migration_manager.cpp
index cd2d1baa30e..91af176fa8b 100644
--- a/src/mongo/db/s/balancer/migration_manager.cpp
+++ b/src/mongo/db/s/balancer/migration_manager.cpp
@@ -190,8 +190,8 @@ Status MigrationManager::executeManualMigration(
auto& routingInfo = routingInfoStatus.getValue();
- auto chunk = routingInfo.cm()->findIntersectingChunkWithSimpleCollation(migrateInfo.minKey);
- invariant(chunk);
+ const auto chunk =
+ routingInfo.cm()->findIntersectingChunkWithSimpleCollation(migrateInfo.minKey);
Status commandStatus = _processRemoteCommandResponse(
remoteCommandResponse, &statusWithScopedMigrationRequest.getValue());
@@ -336,9 +336,8 @@ void MigrationManager::finishRecovery(OperationContext* opCtx,
auto waitForDelete = migrationType.getWaitForDelete();
migrateInfos.pop_front();
- auto chunk =
+ const auto chunk =
routingInfo.cm()->findIntersectingChunkWithSimpleCollation(migrationInfo.minKey);
- invariant(chunk);
if (chunk->getShardId() != migrationInfo.from) {
// Chunk is no longer on the source shard specified by this migration. Erase the
diff --git a/src/mongo/db/s/chunk_splitter.cpp b/src/mongo/db/s/chunk_splitter.cpp
index 8384048dd18..8c4e0a859e8 100644
--- a/src/mongo/db/s/chunk_splitter.cpp
+++ b/src/mongo/db/s/chunk_splitter.cpp
@@ -285,7 +285,7 @@ void ChunkSplitter::_runAutosplit(const NamespaceString& nss,
routingInfo.cm());
const auto cm = routingInfo.cm();
- auto chunk = cm->findIntersectingChunkWithSimpleCollation(min);
+ const auto chunk = cm->findIntersectingChunkWithSimpleCollation(min);
// Stop if chunk's range differs from the range we were expecting to split.
if ((0 != chunk->getMin().woCompare(min)) || (0 != chunk->getMax().woCompare(max)) ||
diff --git a/src/mongo/db/s/collection_metadata.h b/src/mongo/db/s/collection_metadata.h
index 38d5c11819f..fad4cfeae3d 100644
--- a/src/mongo/db/s/collection_metadata.h
+++ b/src/mongo/db/s/collection_metadata.h
@@ -29,15 +29,10 @@
#pragma once
#include "mongo/db/range_arithmetic.h"
-#include "mongo/s/catalog/type_chunk.h"
#include "mongo/s/chunk_manager.h"
-#include "mongo/s/chunk_version.h"
-#include "mongo/s/shard_key_pattern.h"
namespace mongo {
-class ChunkType;
-
/**
* The collection metadata has metadata information about a collection, in particular the
* sharding information. It's main goal in life is to be capable of answering if a certain
diff --git a/src/mongo/db/s/collection_sharding_state.cpp b/src/mongo/db/s/collection_sharding_state.cpp
index 2458d9861c5..a2495eb371f 100644
--- a/src/mongo/db/s/collection_sharding_state.cpp
+++ b/src/mongo/db/s/collection_sharding_state.cpp
@@ -602,8 +602,7 @@ uint64_t CollectionShardingState::_incrementChunkOnInsertOrUpdate(OperationConte
// Use the shard key to locate the chunk into which the document was updated, and increment the
// number of bytes tracked for the chunk. Note that we can assume the simple collation, because
// shard keys do not support non-simple collations.
- std::shared_ptr<Chunk> chunk = cm->findIntersectingChunkWithSimpleCollation(shardKey);
- invariant(chunk);
+ auto chunk = cm->findIntersectingChunkWithSimpleCollation(shardKey);
chunk->addBytesWritten(dataWritten);
// If the chunk becomes too large, then we call the ChunkSplitter to schedule a split. Then, we
@@ -612,6 +611,7 @@ uint64_t CollectionShardingState::_incrementChunkOnInsertOrUpdate(OperationConte
// TODO: call ChunkSplitter here
chunk->clearBytesWritten();
}
+
return chunk->getBytesWritten();
}
diff --git a/src/mongo/db/s/get_shard_version_command.cpp b/src/mongo/db/s/get_shard_version_command.cpp
index 7853b107279..7cdfa33f98c 100644
--- a/src/mongo/db/s/get_shard_version_command.cpp
+++ b/src/mongo/db/s/get_shard_version_command.cpp
@@ -54,7 +54,7 @@ public:
help << " example: { getShardVersion : 'alleyinsider.foo' } ";
}
- virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
+ bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
diff --git a/src/mongo/db/s/merge_chunks_command.cpp b/src/mongo/db/s/merge_chunks_command.cpp
index 60bc1918abf..2b3818d5d07 100644
--- a/src/mongo/db/s/merge_chunks_command.cpp
+++ b/src/mongo/db/s/merge_chunks_command.cpp
@@ -49,7 +49,6 @@
namespace mongo {
using std::string;
-using std::shared_ptr;
using std::vector;
using str::stream;
@@ -347,7 +346,8 @@ public:
bool slaveOk() const override {
return false;
}
- virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
+
+ bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
diff --git a/src/mongo/db/s/metadata_manager_test.cpp b/src/mongo/db/s/metadata_manager_test.cpp
index 2c09b55c69d..040d4638c70 100644
--- a/src/mongo/db/s/metadata_manager_test.cpp
+++ b/src/mongo/db/s/metadata_manager_test.cpp
@@ -114,7 +114,8 @@ protected:
invariant(!rangeMapOverlaps(metadata.getChunks(), minKey, maxKey));
auto cm = metadata.getChunkManager();
- auto chunkToSplit = cm->findIntersectingChunkWithSimpleCollation(minKey);
+
+ const auto chunkToSplit = cm->findIntersectingChunkWithSimpleCollation(minKey);
ASSERT(SimpleBSONObjComparator::kInstance.evaluate(maxKey <= chunkToSplit->getMax()))
<< "maxKey == " << maxKey
<< " and chunkToSplit->getMax() == " << chunkToSplit->getMax();
diff --git a/src/mongo/db/transaction_reaper.cpp b/src/mongo/db/transaction_reaper.cpp
index 9877fa4974d..21ce03f7c2a 100644
--- a/src/mongo/db/transaction_reaper.cpp
+++ b/src/mongo/db/transaction_reaper.cpp
@@ -235,7 +235,7 @@ public:
}
ShardId shardId;
if (_cm) {
- auto chunk = _cm->findIntersectingChunkWithSimpleCollation(lsid.toBSON());
+ const auto chunk = _cm->findIntersectingChunkWithSimpleCollation(lsid.toBSON());
shardId = chunk->getShardId();
} else {
shardId = _primary->getId();