summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/metadata_loader.h
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@10gen.com>2017-02-21 15:54:10 -0500
committerDianna Hohensee <dianna.hohensee@10gen.com>2017-03-01 11:14:23 -0500
commita887cc06efb80e746a476d6e5a12a1e2033df8b2 (patch)
tree18e1d5960e64fc7fdb70045c0d76ab21b14eb494 /src/mongo/db/s/metadata_loader.h
parentd29e95a056c2522f4bfd57e417970e7ecf18266c (diff)
downloadmongo-a887cc06efb80e746a476d6e5a12a1e2033df8b2.tar.gz
SERVER-27704 persist chunk metadata on shard primary
Diffstat (limited to 'src/mongo/db/s/metadata_loader.h')
-rw-r--r--src/mongo/db/s/metadata_loader.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mongo/db/s/metadata_loader.h b/src/mongo/db/s/metadata_loader.h
index e4624a73f8f..8c12233da2e 100644
--- a/src/mongo/db/s/metadata_loader.h
+++ b/src/mongo/db/s/metadata_loader.h
@@ -29,14 +29,18 @@
#pragma once
#include <string>
+#include <vector>
#include "mongo/base/status.h"
namespace mongo {
class ShardingCatalogClient;
+class ChunkType;
class CollectionMetadata;
class CollectionType;
+class NamespaceString;
+class OID;
class OperationContext;
/**
@@ -125,6 +129,29 @@ private:
const std::string& shard,
const CollectionMetadata* oldMetadata,
CollectionMetadata* metadata);
+
+
+ /**
+ * Takes a vector of 'chunks' and updates the config.chunks.ns collection specified by 'nss'.
+ * Any chunk documents in config.chunks.ns that overlap with a chunk in 'chunks' is removed
+ * as the new chunk document is inserted. If the epoch of any chunk in 'chunks' does not match
+ * 'currEpoch', the chunk metadata is dropped.
+ *
+ * @nss - the regular collection namespace for which chunk metadata is being updated.
+ * @chunks - a range of chunks retrieved from the config server, sorted in ascending chunk
+ * version order.
+ * @currEpoch - what this shard server knows to be the collection epoch.
+ *
+ * Returns:
+ * - OK if not primary and no writes are needed.
+ * - RemoteChangeDetected if the chunk version epoch of any chunk in 'chunks' is different than
+ * 'currEpoch'
+ * - Other errors in writes/reads to the config.chunks.ns collection fails.
+ */
+ static Status _writeNewChunksIfPrimary(OperationContext* txn,
+ const NamespaceString& nss,
+ const std::vector<ChunkType>& chunks,
+ const OID& currEpoch);
};
} // namespace mongo