summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--storage/src/tests/bucketdb/bucketmanagertest.cpp46
-rw-r--r--storage/src/tests/common/CMakeLists.txt1
-rw-r--r--storage/src/tests/common/make_document_bucket.cpp16
-rw-r--r--storage/src/tests/common/make_document_bucket.h13
-rw-r--r--storage/src/tests/common/storagelinktest.cpp5
-rw-r--r--storage/src/tests/distributor/bucketdbupdatertest.cpp18
-rw-r--r--storage/src/tests/distributor/distributortest.cpp17
-rw-r--r--storage/src/tests/distributor/externaloperationhandlertest.cpp15
-rw-r--r--storage/src/tests/distributor/getoperationtest.cpp4
-rw-r--r--storage/src/tests/distributor/idealstatemanagertest.cpp4
-rw-r--r--storage/src/tests/distributor/mergeoperationtest.cpp4
-rw-r--r--storage/src/tests/distributor/pendingmessagetrackertest.cpp17
-rw-r--r--storage/src/tests/distributor/putoperationtest.cpp6
-rw-r--r--storage/src/tests/distributor/removelocationtest.cpp5
-rw-r--r--storage/src/tests/distributor/removeoperationtest.cpp5
-rw-r--r--storage/src/tests/distributor/splitbuckettest.cpp4
-rw-r--r--storage/src/tests/distributor/statoperationtest.cpp7
-rw-r--r--storage/src/tests/distributor/twophaseupdateoperationtest.cpp5
-rw-r--r--storage/src/tests/distributor/updateoperationtest.cpp4
-rw-r--r--storage/src/tests/persistence/common/filestortestfixture.cpp8
-rw-r--r--storage/src/tests/persistence/filestorage/deletebuckettest.cpp5
-rw-r--r--storage/src/tests/persistence/filestorage/filestormanagertest.cpp130
-rw-r--r--storage/src/tests/persistence/filestorage/mergeblockingtest.cpp9
-rw-r--r--storage/src/tests/persistence/filestorage/operationabortingtest.cpp7
-rw-r--r--storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp6
-rw-r--r--storage/src/tests/persistence/filestorage/singlebucketjointest.cpp5
-rw-r--r--storage/src/tests/persistence/legacyoperationhandlertest.cpp12
-rw-r--r--storage/src/tests/persistence/mergehandlertest.cpp41
-rw-r--r--storage/src/tests/persistence/persistencequeuetest.cpp5
-rw-r--r--storage/src/tests/persistence/persistencetestutils.cpp4
-rw-r--r--storage/src/tests/persistence/persistencethread_splittest.cpp4
-rw-r--r--storage/src/tests/persistence/processalltest.cpp17
-rw-r--r--storage/src/tests/persistence/testandsettest.cpp22
-rw-r--r--storage/src/tests/storageserver/bouncertest.cpp10
-rw-r--r--storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp17
-rw-r--r--storage/src/tests/storageserver/communicationmanagertest.cpp7
-rw-r--r--storage/src/tests/storageserver/documentapiconvertertest.cpp4
-rw-r--r--storage/src/tests/storageserver/mergethrottlertest.cpp70
-rw-r--r--storage/src/tests/visiting/visitormanagertest.cpp9
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/getoperation.cpp5
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/multioperationoperation.cpp5
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/putoperation.cpp10
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/removelocationoperation.cpp3
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/removeoperation.cpp3
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/statbucketoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp10
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/updateoperation.cpp3
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h4
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/persistencemessagetracker.cpp3
-rw-r--r--storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp4
-rw-r--r--storage/src/vespa/storage/persistence/mergehandler.cpp12
-rw-r--r--storage/src/vespa/storage/storageserver/documentapiconverter.cpp18
-rw-r--r--storage/src/vespa/storage/storageserver/mergethrottler.cpp2
-rw-r--r--storageapi/src/tests/mbusprot/storageprotocoltest.cpp87
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization4_2.cpp53
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp17
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp13
-rw-r--r--storageapi/src/vespa/storageapi/message/batch.cpp4
-rw-r--r--storageapi/src/vespa/storageapi/message/batch.h2
-rw-r--r--storageapi/src/vespa/storageapi/message/bucket.cpp26
-rw-r--r--storageapi/src/vespa/storageapi/message/bucket.h14
-rw-r--r--storageapi/src/vespa/storageapi/message/bucketsplitting.cpp6
-rw-r--r--storageapi/src/vespa/storageapi/message/bucketsplitting.h4
-rw-r--r--storageapi/src/vespa/storageapi/message/multioperation.cpp10
-rw-r--r--storageapi/src/vespa/storageapi/message/multioperation.h4
-rw-r--r--storageapi/src/vespa/storageapi/message/persistence.cpp24
-rw-r--r--storageapi/src/vespa/storageapi/message/persistence.h12
-rw-r--r--storageapi/src/vespa/storageapi/message/removelocation.cpp4
-rw-r--r--storageapi/src/vespa/storageapi/message/removelocation.h2
-rw-r--r--storageapi/src/vespa/storageapi/message/stat.cpp8
-rw-r--r--storageapi/src/vespa/storageapi/message/stat.h4
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp4
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketcommand.h2
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h4
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h4
-rw-r--r--storageserver/src/tests/storageservertest.cpp19
82 files changed, 606 insertions, 405 deletions
diff --git a/storage/src/tests/bucketdb/bucketmanagertest.cpp b/storage/src/tests/bucketdb/bucketmanagertest.cpp
index b69415af756..9b3ef4bf2e8 100644
--- a/storage/src/tests/bucketdb/bucketmanagertest.cpp
+++ b/storage/src/tests/bucketdb/bucketmanagertest.cpp
@@ -14,6 +14,7 @@
#include <tests/common/teststorageapp.h>
#include <tests/common/dummystoragelink.h>
#include <tests/common/testhelper.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/vdslib/state/random.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/testkit/testapp.h>
@@ -29,6 +30,7 @@ using document::DocumenttypesConfig;
using config::FileSpec;
using document::DocumentType;
using document::DocumentTypeRepo;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -306,7 +308,7 @@ BucketManagerTest::wasBlockedDueToLastModified(api::StorageMessage* msg,
void BucketManagerTest::testRemoveLastModifiedOK()
{
CPPUNIT_ASSERT(!wasBlockedDueToLastModified(
- new api::RemoveCommand(document::BucketId(16, 1),
+ new api::RemoveCommand(makeDocumentBucket(document::BucketId(16, 1)),
document::DocumentId("userdoc:m:1:foo"),
api::Timestamp(1235)),
1235));
@@ -316,7 +318,7 @@ void BucketManagerTest::testRemoveLastModifiedOK()
void BucketManagerTest::testRemoveLastModifiedFailed()
{
CPPUNIT_ASSERT(wasBlockedDueToLastModified(
- new api::RemoveCommand(document::BucketId(16, 1),
+ new api::RemoveCommand(makeDocumentBucket(document::BucketId(16, 1)),
document::DocumentId("userdoc:m:1:foo"),
api::Timestamp(1233)),
1233));
@@ -344,7 +346,7 @@ void BucketManagerTest::testDistributionBitChangeOnCreateBucket()
CPPUNIT_ASSERT_EQUAL(16u, _node->getStateUpdater().getReportedNodeState()->getMinUsedBits());
std::shared_ptr<api::CreateBucketCommand> cmd(
- new api::CreateBucketCommand(document::BucketId(4, 5678)));
+ new api::CreateBucketCommand(makeDocumentBucket(document::BucketId(4, 5678))));
_top->sendDown(cmd);
CPPUNIT_ASSERT_EQUAL(4u, _node->getStateUpdater().getReportedNodeState()->getMinUsedBits());
}
@@ -367,7 +369,7 @@ void BucketManagerTest::testMinUsedBitsFromComponentIsHonored()
// 12 >= 10, so no update of reported state (left at 13; this should of
// course not happen in practice, but used for faking in the test)
std::shared_ptr<api::CreateBucketCommand> cmd(
- new api::CreateBucketCommand(document::BucketId(12, 5678)));
+ new api::CreateBucketCommand(makeDocumentBucket(document::BucketId(12, 5678))));
_top->sendDown(cmd);
CPPUNIT_ASSERT_EQUAL(13u, _node->getStateUpdater().getReportedNodeState()->getMinUsedBits());
}
@@ -593,7 +595,7 @@ BucketManagerTest::testSwallowNotifyBucketChangeReply()
_node->getDoneInitializeHandler().notifyDoneInitializing();
_top->doneInit();
- api::NotifyBucketChangeCommand cmd(document::BucketId(1, 16),
+ api::NotifyBucketChangeCommand cmd(makeDocumentBucket(document::BucketId(1, 16)),
api::BucketInfo());
std::shared_ptr<api::NotifyBucketChangeReply> reply(
new api::NotifyBucketChangeReply(cmd));
@@ -705,7 +707,7 @@ public:
// Note: this is a dummy message; its contained document ID will not
// map to the provided bucket ID (at least it's extremely unlikely..)
return std::make_shared<api::RemoveCommand>(
- bucket,
+ makeDocumentBucket(bucket),
document::DocumentId("id:foo:testdoctype1::bar"),
timestamp);
}
@@ -714,7 +716,7 @@ public:
auto doc = _self._node->getTestDocMan().createDocument(
"a foo walks into a bar", "id:foo:testdoctype1::bar1");
return std::make_shared<api::PutCommand>(
- bucket, std::move(doc), api::Timestamp(123456));
+ makeDocumentBucket(bucket), std::move(doc), api::Timestamp(123456));
}
auto createUpdateCommand(const document::BucketId& bucket) const {
@@ -723,7 +725,7 @@ public:
.getDocumentType("testdoctype1"),
document::DocumentId("id:foo:testdoctype1::bar2"));
return std::make_shared<api::UpdateCommand>(
- bucket, update, api::Timestamp(123456));
+ makeDocumentBucket(bucket), update, api::Timestamp(123456));
}
auto createFullFetchCommand() const {
@@ -817,7 +819,7 @@ BucketManagerTest::testSplitReplyOrderedAfterBucketReply()
// Split bucket A to model a concurrent modification to an already fetched
// bucket.
- auto splitCmd = std::make_shared<api::SplitBucketCommand>(bucketA);
+ auto splitCmd = std::make_shared<api::SplitBucketCommand>(makeDocumentBucket(bucketA));
_top->sendDown(splitCmd);
fixture.bounceWithReply(*splitCmd);
// Let bucket manager breathe again.
@@ -839,7 +841,7 @@ BucketManagerTest::testJoinReplyOrderedAfterBucketReply()
.add(bucketB, api::BucketInfo(100, 200, 400)));
auto guard = fixture.acquireBucketLockAndSendInfoRequest(bucketB);
- auto joinCmd = std::make_shared<api::JoinBucketsCommand>(parent);
+ auto joinCmd = std::make_shared<api::JoinBucketsCommand>(makeDocumentBucket(parent));
joinCmd->getSourceBuckets().assign({bucketA, bucketB});
_top->sendDown(joinCmd);
fixture.bounceWithReply(*joinCmd);
@@ -863,7 +865,7 @@ BucketManagerTest::testDeleteReplyOrderedAfterBucketReply()
.add(bucketB, api::BucketInfo(100, 200, 400)));
auto guard = fixture.acquireBucketLockAndSendInfoRequest(bucketB);
- auto deleteCmd = std::make_shared<api::DeleteBucketCommand>(bucketA);
+ auto deleteCmd = std::make_shared<api::DeleteBucketCommand>(makeDocumentBucket(bucketA));
_top->sendDown(deleteCmd);
fixture.bounceWithReply(*deleteCmd);
@@ -882,7 +884,7 @@ BucketManagerTest::testOnlyEnqueueWhenProcessingRequest()
.add(bucketA, api::BucketInfo(50, 100, 200)));
// Process delete command _before_ processing bucket requests.
- auto deleteCmd = std::make_shared<api::DeleteBucketCommand>(bucketA);
+ auto deleteCmd = std::make_shared<api::DeleteBucketCommand>(makeDocumentBucket(bucketA));
_top->sendDown(deleteCmd);
fixture.bounceWithReply(*deleteCmd);
// Should arrive happily on the top.
@@ -914,7 +916,7 @@ BucketManagerTest::testOrderRepliesAfterBucketSpecificRequest()
waitUntilRequestsAreProcessing();
// Barrier: roundtrip thread now blocked. Send a split whose reply shall
// be enqueued since there's a RequestBucketInfo currently doing its thing.
- auto splitCmd = std::make_shared<api::SplitBucketCommand>(bucketA);
+ auto splitCmd = std::make_shared<api::SplitBucketCommand>(makeDocumentBucket(bucketA));
_top->sendDown(splitCmd);
// Enqueuing happens synchronously in this thread, so no need for further
// synchronization.
@@ -955,7 +957,7 @@ BucketManagerTest::testQueuedRepliesOnlyDispatchedWhenAllProcessingDone()
_top->waitForMessages(3, MESSAGE_WAIT_TIME);
});
waitUntilRequestsAreProcessing(2);
- auto splitCmd = std::make_shared<api::SplitBucketCommand>(bucketA);
+ auto splitCmd = std::make_shared<api::SplitBucketCommand>(makeDocumentBucket(bucketA));
_top->sendDown(splitCmd);
fixture.bounceWithReply(*splitCmd);
@@ -1049,7 +1051,7 @@ BucketManagerTest::testMutationRepliesForSplitBucketAreEnqueued()
document::BucketId bucket(17, 0);
doTestConflictingReplyIsEnqueued(
bucket,
- std::make_shared<api::SplitBucketCommand>(bucket),
+ std::make_shared<api::SplitBucketCommand>(makeDocumentBucket(bucket)),
api::MessageType::SPLITBUCKET_REPLY);
}
@@ -1059,7 +1061,7 @@ BucketManagerTest::testMutationRepliesForDeletedBucketAreEnqueued()
document::BucketId bucket(17, 0);
doTestConflictingReplyIsEnqueued(
bucket,
- std::make_shared<api::DeleteBucketCommand>(bucket),
+ std::make_shared<api::DeleteBucketCommand>(makeDocumentBucket(bucket)),
api::MessageType::DELETEBUCKET_REPLY);
}
@@ -1072,7 +1074,7 @@ BucketManagerTest::testMutationRepliesForJoinedBucketAreEnqueued()
document::BucketId parent(16, 0);
// We only test for the parent bucket, since that's what queued operations
// will be remapped to after a successful join.
- auto joinCmd = std::make_shared<api::JoinBucketsCommand>(parent);
+ auto joinCmd = std::make_shared<api::JoinBucketsCommand>(makeDocumentBucket(parent));
joinCmd->getSourceBuckets().assign({bucketA, bucketB});
auto params = TestParams()
@@ -1095,7 +1097,7 @@ BucketManagerTest::testConflictingPutRepliesAreEnqueued()
auto params = TestParams()
.bucket(bucket)
.documentMutation(fixture.createPutCommand(bucket))
- .treeMutation(std::make_shared<api::SplitBucketCommand>(bucket))
+ .treeMutation(std::make_shared<api::SplitBucketCommand>(makeDocumentBucket(bucket)))
.expectedOrdering({&api::MessageType::REQUESTBUCKETINFO_REPLY,
&api::MessageType::SPLITBUCKET_REPLY,
&api::MessageType::PUT_REPLY});
@@ -1112,7 +1114,7 @@ BucketManagerTest::testConflictingUpdateRepliesAreEnqueued()
auto params = TestParams()
.bucket(bucket)
.documentMutation(fixture.createUpdateCommand(bucket))
- .treeMutation(std::make_shared<api::SplitBucketCommand>(bucket))
+ .treeMutation(std::make_shared<api::SplitBucketCommand>(makeDocumentBucket(bucket)))
.expectedOrdering({&api::MessageType::REQUESTBUCKETINFO_REPLY,
&api::MessageType::SPLITBUCKET_REPLY,
&api::MessageType::UPDATE_REPLY});
@@ -1137,7 +1139,7 @@ BucketManagerTest::testRemappedMutationIsCheckedAgainstOriginalBucket()
.bucket(bucket)
.documentMutation(fixture.createRemoveCommand(bucket))
.remappedTo(remappedToBucket)
- .treeMutation(std::make_shared<api::SplitBucketCommand>(bucket))
+ .treeMutation(std::make_shared<api::SplitBucketCommand>(makeDocumentBucket(bucket)))
.expectedOrdering({&api::MessageType::REQUESTBUCKETINFO_REPLY,
&api::MessageType::SPLITBUCKET_REPLY,
&api::MessageType::REMOVE_REPLY});
@@ -1159,7 +1161,7 @@ BucketManagerTest::scheduleBucketInfoRequestWithConcurrentOps(
bucketForRemove);
auto conflictingOp(
- std::make_shared<api::SplitBucketCommand>(bucketForSplit));
+ std::make_shared<api::SplitBucketCommand>(makeDocumentBucket(bucketForSplit)));
_top->sendDown(conflictingOp);
fixture.bounceWithReply(*conflictingOp);
fixture.bounceWithReply(*mutation);
@@ -1242,7 +1244,7 @@ BucketManagerTest::testConflictSetOnlyClearedAfterAllBucketRequestsDone()
// guards holding their desired bucket locks.
waitUntilRequestsAreProcessing(2);
- auto conflictingOp = std::make_shared<api::SplitBucketCommand>(bucketA);
+ auto conflictingOp = std::make_shared<api::SplitBucketCommand>(makeDocumentBucket(bucketA));
_top->sendDown(conflictingOp);
fixture.bounceWithReply(*conflictingOp);
// Releasing guard A (and allowing the request for A to go through) should
diff --git a/storage/src/tests/common/CMakeLists.txt b/storage/src/tests/common/CMakeLists.txt
index c7243e68146..dc322c345e3 100644
--- a/storage/src/tests/common/CMakeLists.txt
+++ b/storage/src/tests/common/CMakeLists.txt
@@ -3,6 +3,7 @@ vespa_add_library(storage_testcommon TEST
SOURCES
dummystoragelink.cpp
testhelper.cpp
+ make_document_bucket.cpp
metricstest.cpp
storagelinktest.cpp
testnodestateupdater.cpp
diff --git a/storage/src/tests/common/make_document_bucket.cpp b/storage/src/tests/common/make_document_bucket.cpp
new file mode 100644
index 00000000000..cef33c515ee
--- /dev/null
+++ b/storage/src/tests/common/make_document_bucket.cpp
@@ -0,0 +1,16 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "make_document_bucket.h"
+
+using document::Bucket;
+using document::BucketId;
+using document::BucketSpace;
+
+namespace storage::test {
+
+Bucket makeDocumentBucket(BucketId bucketId)
+{
+ return Bucket(BucketSpace::placeHolder(), bucketId);
+}
+
+}
diff --git a/storage/src/tests/common/make_document_bucket.h b/storage/src/tests/common/make_document_bucket.h
new file mode 100644
index 00000000000..a95bc501c65
--- /dev/null
+++ b/storage/src/tests/common/make_document_bucket.h
@@ -0,0 +1,13 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/document/bucket/bucket.h>
+
+namespace storage::test {
+
+// Helper function used by unit tests
+
+document::Bucket makeDocumentBucket(document::BucketId bucketId);
+
+}
diff --git a/storage/src/tests/common/storagelinktest.cpp b/storage/src/tests/common/storagelinktest.cpp
index 88b66339127..0490581d7ff 100644
--- a/storage/src/tests/common/storagelinktest.cpp
+++ b/storage/src/tests/common/storagelinktest.cpp
@@ -1,10 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <tests/common/storagelinktest.h>
+#include <tests/common/make_document_bucket.h>
#include <iostream>
#include <string>
#include <vespa/storageapi/message/stat.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
CPPUNIT_TEST_SUITE_REGISTRATION(StorageLinkTest);
@@ -41,7 +44,7 @@ void StorageLinkTest::testNotImplemented() {
// Test that a message that nobody handles fails with NOT_IMPLEMENTED
_replier->setIgnore(true);
_feeder->sendDown(api::StorageCommand::SP(
- new api::StatBucketCommand(document::BucketId(0), "")));
+ new api::StatBucketCommand(makeDocumentBucket(document::BucketId(0)), "")));
_feeder->close();
_feeder->flush();
CPPUNIT_ASSERT_EQUAL((size_t) 1, _feeder->getNumReplies());
diff --git a/storage/src/tests/distributor/bucketdbupdatertest.cpp b/storage/src/tests/distributor/bucketdbupdatertest.cpp
index e4b23f9d46d..54a5f3ec4b1 100644
--- a/storage/src/tests/distributor/bucketdbupdatertest.cpp
+++ b/storage/src/tests/distributor/bucketdbupdatertest.cpp
@@ -8,12 +8,14 @@
#include <vespa/storageframework/defaultimplementation/clock/realclock.h>
#include <vespa/storage/storageutil/distributorstatecache.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/distributor/simpleclusterinformation.h>
#include <vespa/storage/distributor/distributor.h>
#include <vespa/vespalib/text/stringtokenizer.h>
using namespace storage::api;
using namespace storage::lib;
+using storage::test::makeDocumentBucket;
namespace storage {
namespace distributor {
@@ -1102,7 +1104,7 @@ BucketDBUpdaterTest::testNotifyBucketChange()
{
api::BucketInfo info(1, 2, 3, 4, 5, true, true);
auto cmd(std::make_shared<api::NotifyBucketChangeCommand>(
- document::BucketId(16, 1), info));
+ makeDocumentBucket(document::BucketId(16, 1)), info));
cmd->setSourceIndex(0);
getBucketDBUpdater().onNotifyBucketChange(cmd);
}
@@ -1110,7 +1112,7 @@ BucketDBUpdaterTest::testNotifyBucketChange()
{
api::BucketInfo info(10, 11, 12, 13, 14, false, false);
auto cmd(std::make_shared<api::NotifyBucketChangeCommand>(
- document::BucketId(16, 2), info));
+ makeDocumentBucket(document::BucketId(16, 2)), info));
cmd->setSourceIndex(0);
getBucketDBUpdater().onNotifyBucketChange(cmd);
}
@@ -1173,7 +1175,7 @@ BucketDBUpdaterTest::testNotifyBucketChangeFromNodeDown()
{
api::BucketInfo info(8999, 300, 3000, 500, 5000, false, false);
auto cmd(std::make_shared<api::NotifyBucketChangeCommand>(
- document::BucketId(16, 1), info));
+ makeDocumentBucket(document::BucketId(16, 1)), info));
cmd->setSourceIndex(0);
getBucketDBUpdater().onNotifyBucketChange(cmd);
}
@@ -1230,7 +1232,7 @@ BucketDBUpdaterTest::testNotifyChangeWithPendingStateQueuesBucketInfoRequests()
{
api::BucketInfo info(8999, 300, 3000, 500, 5000, false, false);
auto cmd(std::make_shared<api::NotifyBucketChangeCommand>(
- document::BucketId(16, 1), info));
+ makeDocumentBucket(document::BucketId(16, 1)), info));
cmd->setSourceIndex(0);
getBucketDBUpdater().onNotifyBucketChange(cmd);
}
@@ -1279,7 +1281,7 @@ BucketDBUpdaterTest::testMergeReply()
nodes.push_back(api::MergeBucketCommand::Node(1));
nodes.push_back(api::MergeBucketCommand::Node(2));
- api::MergeBucketCommand cmd(document::BucketId(16, 1234), nodes, 0);
+ api::MergeBucketCommand cmd(makeDocumentBucket(document::BucketId(16, 1234)), nodes, 0);
auto reply(std::make_shared<api::MergeBucketReply>(cmd));
@@ -1325,7 +1327,7 @@ BucketDBUpdaterTest::testMergeReplyNodeDown()
nodes.push_back(api::MergeBucketCommand::Node(i));
}
- api::MergeBucketCommand cmd(document::BucketId(16, 1234), nodes, 0);
+ api::MergeBucketCommand cmd(makeDocumentBucket(document::BucketId(16, 1234)), nodes, 0);
auto reply(std::make_shared<api::MergeBucketReply>(cmd));
@@ -1372,7 +1374,7 @@ BucketDBUpdaterTest::testMergeReplyNodeDownAfterRequestSent()
nodes.push_back(api::MergeBucketCommand::Node(i));
}
- api::MergeBucketCommand cmd(document::BucketId(16, 1234), nodes, 0);
+ api::MergeBucketCommand cmd(makeDocumentBucket(document::BucketId(16, 1234)), nodes, 0);
auto reply(std::make_shared<api::MergeBucketReply>(cmd));
@@ -1421,7 +1423,7 @@ BucketDBUpdaterTest::testFlush()
nodes.push_back(api::MergeBucketCommand::Node(i));
}
- api::MergeBucketCommand cmd(document::BucketId(16, 1234),
+ api::MergeBucketCommand cmd(makeDocumentBucket(document::BucketId(16, 1234)),
nodes,
0);
diff --git a/storage/src/tests/distributor/distributortest.cpp b/storage/src/tests/distributor/distributortest.cpp
index d0941571a6a..e40add9b76d 100644
--- a/storage/src/tests/distributor/distributortest.cpp
+++ b/storage/src/tests/distributor/distributortest.cpp
@@ -9,11 +9,14 @@
#include <vespa/storageapi/message/removelocation.h>
#include <vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/config/config-stor-distributormanager.h>
#include <tests/common/dummystoragelink.h>
#include <vespa/storage/distributor/distributor.h>
#include <vespa/vespalib/text/stringtokenizer.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
namespace distributor {
@@ -202,7 +205,7 @@ Distributor_Test::testOperationGeneration()
CPPUNIT_ASSERT_EQUAL(std::string("Remove"),
testOp(new api::RemoveCommand(
- bid,
+ makeDocumentBucket(bid),
document::DocumentId("userdoc:m:1:foo"),
api::Timestamp(1234))));
@@ -285,7 +288,7 @@ Distributor_Test::testHandleUnknownMaintenanceReply()
{
api::SplitBucketCommand::SP cmd(
- new api::SplitBucketCommand(document::BucketId(16, 1234)));
+ new api::SplitBucketCommand(makeDocumentBucket(document::BucketId(16, 1234))));
api::SplitBucketReply::SP reply(new api::SplitBucketReply(*cmd));
CPPUNIT_ASSERT(_distributor->handleReply(reply));
@@ -295,7 +298,7 @@ Distributor_Test::testHandleUnknownMaintenanceReply()
// RemoveLocationReply must be treated as a maintenance reply since
// it's what GC is currently built around.
auto cmd = std::make_shared<api::RemoveLocationCommand>(
- "false", document::BucketId(30, 1234));
+ "false", makeDocumentBucket(document::BucketId(30, 1234)));
auto reply = std::shared_ptr<api::StorageReply>(cmd->makeReply());
CPPUNIT_ASSERT(_distributor->handleReply(reply));
}
@@ -733,7 +736,7 @@ namespace {
auto makeDummyRemoveCommand() {
return std::make_shared<api::RemoveCommand>(
- document::BucketId(0),
+ makeDocumentBucket(document::BucketId(0)),
document::DocumentId("id:foo:testdoctype1:n=1:foo"),
api::Timestamp(0));
}
@@ -881,7 +884,7 @@ void Distributor_Test::external_client_requests_are_handled_individually_in_prio
document::DocumentId id("id:foo:testdoctype1:n=1:foo");
vespalib::stringref field_set = "";
for (auto pri : priorities) {
- auto cmd = std::make_shared<api::GetCommand>(document::BucketId(), id, field_set);
+ auto cmd = std::make_shared<api::GetCommand>(makeDocumentBucket(document::BucketId()), id, field_set);
cmd->setPriority(pri);
// onDown appends to internal message FIFO queue, awaiting hand-off.
_distributor->onDown(cmd);
@@ -912,7 +915,7 @@ void Distributor_Test::internal_messages_are_started_in_fifo_order_batch() {
std::vector<api::StorageMessage::Priority> priorities({50, 255, 10, 40, 1});
for (auto pri : priorities) {
api::BucketInfo fake_info(pri, pri, pri);
- auto cmd = std::make_shared<api::NotifyBucketChangeCommand>(bucket, fake_info);
+ auto cmd = std::make_shared<api::NotifyBucketChangeCommand>(makeDocumentBucket(bucket), fake_info);
cmd->setSourceIndex(0);
cmd->setPriority(pri);
_distributor->onDown(cmd);
@@ -937,7 +940,7 @@ void Distributor_Test::closing_aborts_priority_queued_client_requests() {
document::DocumentId id("id:foo:testdoctype1:n=1:foo");
vespalib::stringref field_set = "";
for (int i = 0; i < 10; ++i) {
- auto cmd = std::make_shared<api::GetCommand>(document::BucketId(), id, field_set);
+ auto cmd = std::make_shared<api::GetCommand>(makeDocumentBucket(document::BucketId()), id, field_set);
_distributor->onDown(cmd);
}
tickDistributorNTimes(1);
diff --git a/storage/src/tests/distributor/externaloperationhandlertest.cpp b/storage/src/tests/distributor/externaloperationhandlertest.cpp
index 73b1ff7d356..a66a22c7eb1 100644
--- a/storage/src/tests/distributor/externaloperationhandlertest.cpp
+++ b/storage/src/tests/distributor/externaloperationhandlertest.cpp
@@ -5,6 +5,9 @@
#include <vespa/storage/distributor/operation_sequencer.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/storage/distributor/distributor.h>
+#include <tests/common/make_document_bucket.h>
+
+using storage::test::makeDocumentBucket;
namespace storage {
namespace distributor {
@@ -177,13 +180,13 @@ ExternalOperationHandlerTest::findOwned1stNotOwned2ndInStates(
std::shared_ptr<api::GetCommand>
ExternalOperationHandlerTest::makeGetCommand(const vespalib::string& id) const {
- return std::make_shared<api::GetCommand>(document::BucketId(0), DocumentId(id), "[all]");
+ return std::make_shared<api::GetCommand>(makeDocumentBucket(document::BucketId(0)), DocumentId(id), "[all]");
}
std::shared_ptr<api::GetCommand>
ExternalOperationHandlerTest::makeGetCommandForUser(uint64_t id) const {
DocumentId docId(document::UserDocIdString(vespalib::make_string("userdoc:foo:%lu:bar", id)));
- return std::make_shared<api::GetCommand>(document::BucketId(0), docId, "[all]");
+ return std::make_shared<api::GetCommand>(makeDocumentBucket(document::BucketId(0)), docId, "[all]");
}
std::shared_ptr<api::UpdateCommand> ExternalOperationHandlerTest::makeUpdateCommand(
@@ -193,7 +196,7 @@ std::shared_ptr<api::UpdateCommand> ExternalOperationHandlerTest::makeUpdateComm
*_testDocMan.getTypeRepo().getDocumentType(doc_type),
document::DocumentId(id));
return std::make_shared<api::UpdateCommand>(
- document::BucketId(0), std::move(update), api::Timestamp(0));
+ makeDocumentBucket(document::BucketId(0)), std::move(update), api::Timestamp(0));
}
std::shared_ptr<api::UpdateCommand>
@@ -206,11 +209,11 @@ std::shared_ptr<api::PutCommand> ExternalOperationHandlerTest::makePutCommand(
const vespalib::string& id) const {
auto doc = _testDocMan.createDocument(doc_type, id);
return std::make_shared<api::PutCommand>(
- document::BucketId(0), std::move(doc), api::Timestamp(0));
+ makeDocumentBucket(document::BucketId(0)), std::move(doc), api::Timestamp(0));
}
std::shared_ptr<api::RemoveCommand> ExternalOperationHandlerTest::makeRemoveCommand(const vespalib::string& id) const {
- return std::make_shared<api::RemoveCommand>(document::BucketId(0), DocumentId(id), api::Timestamp(0));
+ return std::make_shared<api::RemoveCommand>(makeDocumentBucket(document::BucketId(0)), DocumentId(id), api::Timestamp(0));
}
void
@@ -331,7 +334,7 @@ void ExternalOperationHandlerTest::mutation_not_rejected_when_safe_point_reached
DocumentId id("id:foo:testdoctype1::bar");
getExternalOperationHandler().handleMessage(
std::make_shared<api::RemoveCommand>(
- document::BucketId(0), id, api::Timestamp(0)),
+ makeDocumentBucket(document::BucketId(0)), id, api::Timestamp(0)),
generated);
CPPUNIT_ASSERT(generated.get() != nullptr);
CPPUNIT_ASSERT_EQUAL(size_t(0), _sender.replies.size());
diff --git a/storage/src/tests/distributor/getoperationtest.cpp b/storage/src/tests/distributor/getoperationtest.cpp
index f9040df0ec2..315152e4683 100644
--- a/storage/src/tests/distributor/getoperationtest.cpp
+++ b/storage/src/tests/distributor/getoperationtest.cpp
@@ -8,6 +8,7 @@
#include <tests/distributor/distributortestutil.h>
#include <vespa/storageapi/message/persistence.h>
#include <tests/common/dummystoragelink.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/config/helper/configgetter.hpp>
@@ -20,6 +21,7 @@ using std::shared_ptr;
using config::ConfigGetter;
using document::DocumenttypesConfig;
using config::FileSpec;
+using storage::test::makeDocumentBucket;
namespace storage {
namespace distributor {
@@ -70,7 +72,7 @@ public:
void sendGet() {
std::shared_ptr<api::GetCommand> msg(
- new api::GetCommand(document::BucketId(0), docId, "[all]"));
+ new api::GetCommand(makeDocumentBucket(document::BucketId(0)), docId, "[all]"));
op.reset(new GetOperation(getExternalOperationHandler(),
msg,
diff --git a/storage/src/tests/distributor/idealstatemanagertest.cpp b/storage/src/tests/distributor/idealstatemanagertest.cpp
index 83b147f4125..8f4b99d9d7f 100644
--- a/storage/src/tests/distributor/idealstatemanagertest.cpp
+++ b/storage/src/tests/distributor/idealstatemanagertest.cpp
@@ -9,7 +9,9 @@
#include <vespa/storageapi/message/visitor.h>
#include <vespa/storageapi/message/bucketsplitting.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
+using storage::test::makeDocumentBucket;
namespace storage {
namespace distributor {
@@ -240,7 +242,7 @@ IdealStateManagerTest::testBlockCheckForAllOperationsToSpecificBucket()
document::BucketId bid(16, 1234);
{
- auto msg = std::make_shared<api::JoinBucketsCommand>(bid);
+ auto msg = std::make_shared<api::JoinBucketsCommand>(makeDocumentBucket(bid));
msg->setAddress(
api::StorageMessageAddress("storage", lib::NodeType::STORAGE, 4));
tracker.insert(msg);
diff --git a/storage/src/tests/distributor/mergeoperationtest.cpp b/storage/src/tests/distributor/mergeoperationtest.cpp
index 7e7ca52635e..d33ee64a883 100644
--- a/storage/src/tests/distributor/mergeoperationtest.cpp
+++ b/storage/src/tests/distributor/mergeoperationtest.cpp
@@ -8,10 +8,12 @@
#include <vespa/storage/distributor/operations/idealstate/mergeoperation.h>
#include <vespa/storage/distributor/bucketdbupdater.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/distributor/distributor.h>
#include <vespa/vespalib/text/stringtokenizer.h>
using std::shared_ptr;
+using storage::test::makeDocumentBucket;
namespace storage {
namespace distributor {
@@ -320,7 +322,7 @@ MergeOperationTest::doNotRemoveCopiesWithPendingMessages() {
// Removes are blocked by all and any operation types, so can just choose
// at will.
api::StorageMessage::SP msg(
- new api::SetBucketStateCommand(bucket, api::SetBucketStateCommand::ACTIVE));
+ new api::SetBucketStateCommand(makeDocumentBucket(bucket), api::SetBucketStateCommand::ACTIVE));
msg->setAddress(api::StorageMessageAddress("storage", lib::NodeType::STORAGE, 1));
_pendingTracker->insert(msg);
diff --git a/storage/src/tests/distributor/pendingmessagetrackertest.cpp b/storage/src/tests/distributor/pendingmessagetrackertest.cpp
index fa36b4e6305..1fc12821e1d 100644
--- a/storage/src/tests/distributor/pendingmessagetrackertest.cpp
+++ b/storage/src/tests/distributor/pendingmessagetrackertest.cpp
@@ -7,9 +7,12 @@
#include <vespa/storageapi/message/persistence.h>
#include <vespa/storageframework/defaultimplementation/clock/fakeclock.h>
#include <tests/common/dummystoragelink.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/vdslib/state/random.h>
#include <vespa/vdstestlib/cppunit/macros.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
namespace distributor {
@@ -185,7 +188,7 @@ private:
std::shared_ptr<api::PutCommand> createPutToNode(uint16_t node) const {
document::BucketId bucket(16, 1234);
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket,
+ new api::PutCommand(makeDocumentBucket(bucket),
createDummyDocumentForBucket(bucket),
api::Timestamp(123456)));
cmd->setAddress(makeStorageAddress(node));
@@ -197,7 +200,7 @@ private:
{
document::BucketId bucket(16, 1234);
std::shared_ptr<api::RemoveCommand> cmd(
- new api::RemoveCommand(bucket,
+ new api::RemoveCommand(makeDocumentBucket(bucket),
document::DocumentId(
createDummyIdString(bucket)),
api::Timestamp(123456)));
@@ -239,7 +242,7 @@ PendingMessageTrackerTest::testSimple()
std::shared_ptr<api::RemoveCommand> remove(
new api::RemoveCommand(
- document::BucketId(16, 1234),
+ makeDocumentBucket(document::BucketId(16, 1234)),
document::DocumentId("userdoc:footype:1234:foo"), 1001));
remove->setAddress(
api::StorageMessageAddress("storage", lib::NodeType::STORAGE, 0));
@@ -280,7 +283,7 @@ PendingMessageTrackerTest::insertMessages(PendingMessageTracker& tracker)
ost << "userdoc:footype:1234:" << i;
std::shared_ptr<api::RemoveCommand> remove(
new api::RemoveCommand(
- document::BucketId(16, 1234),
+ makeDocumentBucket(document::BucketId(16, 1234)),
document::DocumentId(ost.str()), 1000 + i));
remove->setAddress(
api::StorageMessageAddress("storage",
@@ -291,7 +294,7 @@ PendingMessageTrackerTest::insertMessages(PendingMessageTracker& tracker)
for (uint32_t i = 0; i < 4; i++) {
std::ostringstream ost;
ost << "userdoc:footype:4567:" << i;
- std::shared_ptr<api::RemoveCommand> remove(new api::RemoveCommand(document::BucketId(16, 4567), document::DocumentId(ost.str()), 2000 + i));
+ std::shared_ptr<api::RemoveCommand> remove(new api::RemoveCommand(makeDocumentBucket(document::BucketId(16, 4567)), document::DocumentId(ost.str()), 2000 + i));
remove->setAddress(api::StorageMessageAddress("storage", lib::NodeType::STORAGE, i % 2));
tracker.insert(remove);
}
@@ -434,7 +437,7 @@ PendingMessageTrackerTest::testGetPendingMessageTypes()
std::shared_ptr<api::RemoveCommand> remove(
new api::RemoveCommand(
- bid,
+ makeDocumentBucket(bid),
document::DocumentId("userdoc:footype:1234:foo"), 1001));
remove->setAddress(
api::StorageMessageAddress("storage", lib::NodeType::STORAGE, 0));
@@ -474,7 +477,7 @@ PendingMessageTrackerTest::testHasPendingMessage()
{
std::shared_ptr<api::RemoveCommand> remove(
new api::RemoveCommand(
- bid,
+ makeDocumentBucket(bid),
document::DocumentId("userdoc:footype:1234:foo"), 1001));
remove->setAddress(
api::StorageMessageAddress("storage", lib::NodeType::STORAGE, 1));
diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp
index bec07c299d9..156fc2fc8ca 100644
--- a/storage/src/tests/distributor/putoperationtest.cpp
+++ b/storage/src/tests/distributor/putoperationtest.cpp
@@ -10,6 +10,7 @@
#include <vespa/storageapi/message/state.h>
#include <tests/distributor/distributortestutil.h>
#include <tests/common/dummystoragelink.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/vespalib/text/stringtokenizer.h>
#include <vespa/vespalib/testkit/test_kit.h>
@@ -26,6 +27,7 @@ using namespace storage;
using namespace storage::api;
using namespace storage::lib;
using namespace std::literals::string_literals;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -148,7 +150,7 @@ public:
const Document::SP doc) const
{
return std::shared_ptr<api::PutCommand>(
- new api::PutCommand(document::BucketId(0), doc, 100));
+ new api::PutCommand(makeDocumentBucket(document::BucketId(0)), doc, 100));
}
};
@@ -164,7 +166,7 @@ PutOperationTest::createAndSendSampleDocument(uint32_t timeout) {
addIdealNodes(id);
std::shared_ptr<api::PutCommand> msg(
- new api::PutCommand(document::BucketId(0),
+ new api::PutCommand(makeDocumentBucket(document::BucketId(0)),
doc,
0));
msg->setTimestamp(100);
diff --git a/storage/src/tests/distributor/removelocationtest.cpp b/storage/src/tests/distributor/removelocationtest.cpp
index 28283b62120..975d77d870f 100644
--- a/storage/src/tests/distributor/removelocationtest.cpp
+++ b/storage/src/tests/distributor/removelocationtest.cpp
@@ -6,8 +6,11 @@
#include <vespa/storageapi/message/removelocation.h>
#include <vespa/storage/distributor/operations/external/removelocationoperation.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/distributor/distributor.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
namespace distributor {
@@ -34,7 +37,7 @@ public:
void sendRemoveLocation(const std::string& selection) {
std::shared_ptr<api::RemoveLocationCommand> msg(
- new api::RemoveLocationCommand(selection, document::BucketId(0)));
+ new api::RemoveLocationCommand(selection, makeDocumentBucket(document::BucketId(0))));
op.reset(new RemoveLocationOperation(getExternalOperationHandler(),
msg,
diff --git a/storage/src/tests/distributor/removeoperationtest.cpp b/storage/src/tests/distributor/removeoperationtest.cpp
index ae4feb0d03a..013d62bac14 100644
--- a/storage/src/tests/distributor/removeoperationtest.cpp
+++ b/storage/src/tests/distributor/removeoperationtest.cpp
@@ -6,8 +6,11 @@
#include <vespa/storage/distributor/distributor.h>
#include <vespa/storageapi/message/persistence.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/distributor/operations/external/removeoperation.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
namespace distributor {
@@ -52,7 +55,7 @@ public:
void sendRemove(document::DocumentId dId) {
std::shared_ptr<api::RemoveCommand> msg(
- new api::RemoveCommand(document::BucketId(0), dId, 100));
+ new api::RemoveCommand(makeDocumentBucket(document::BucketId(0)), dId, 100));
op.reset(new RemoveOperation(getExternalOperationHandler(),
msg,
diff --git a/storage/src/tests/distributor/splitbuckettest.cpp b/storage/src/tests/distributor/splitbuckettest.cpp
index 17a59b620a2..e4c90dcbbe3 100644
--- a/storage/src/tests/distributor/splitbuckettest.cpp
+++ b/storage/src/tests/distributor/splitbuckettest.cpp
@@ -9,10 +9,12 @@
#include <vespa/storage/distributor/idealstatemanager.h>
#include <vespa/storageapi/message/multioperation.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/distributor/distributor.h>
using std::shared_ptr;
using namespace document;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -317,7 +319,7 @@ SplitOperationTest::testOperationBlockedByPendingJoin()
std::vector<document::BucketId> joinSources = {
document::BucketId(3, 1), document::BucketId(3, 5)
};
- auto joinCmd = std::make_shared<api::JoinBucketsCommand>(joinTarget);
+ auto joinCmd = std::make_shared<api::JoinBucketsCommand>(makeDocumentBucket(joinTarget));
joinCmd->getSourceBuckets() = joinSources;
joinCmd->setAddress(
api::StorageMessageAddress("storage", lib::NodeType::STORAGE, 0));
diff --git a/storage/src/tests/distributor/statoperationtest.cpp b/storage/src/tests/distributor/statoperationtest.cpp
index bbfac1e69fd..e9364b06085 100644
--- a/storage/src/tests/distributor/statoperationtest.cpp
+++ b/storage/src/tests/distributor/statoperationtest.cpp
@@ -4,10 +4,13 @@
#include <vespa/storageapi/message/stat.h>
#include <vespa/vdstestlib/cppunit/macros.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/distributor/operations/external/statbucketoperation.h>
#include <vespa/storage/distributor/operations/external/statbucketlistoperation.h>
#include <vespa/storage/distributor/distributor.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
namespace distributor {
@@ -44,7 +47,7 @@ StatOperationTest::testBucketInfo()
StatBucketOperation op(
getExternalOperationHandler(),
std::shared_ptr<api::StatBucketCommand>(
- new api::StatBucketCommand(document::BucketId(16, 5), "")));
+ new api::StatBucketCommand(makeDocumentBucket(document::BucketId(16, 5)), "")));
op.start(_sender, framework::MilliSecTime(0));
@@ -84,7 +87,7 @@ StatOperationTest::testBucketList() {
}
std::shared_ptr<api::GetBucketListCommand> msg(
- new api::GetBucketListCommand(document::BucketId(16, 5)));
+ new api::GetBucketListCommand(makeDocumentBucket(document::BucketId(16, 5))));
StatBucketListOperation op(
getExternalOperationHandler().getBucketDatabase(),
diff --git a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
index 9df7888a3d0..7d3c61d5674 100644
--- a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
+++ b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
@@ -13,8 +13,11 @@
#include <vespa/storage/distributor/operations/external/twophaseupdateoperation.h>
#include <vespa/storageapi/message/batch.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/distributor/distributor.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
namespace distributor {
@@ -321,7 +324,7 @@ TwoPhaseUpdateOperationTest::sendUpdate(const std::string& bucketState,
}
auto msg(std::make_shared<api::UpdateCommand>(
- document::BucketId(0), update, api::Timestamp(0)));
+ makeDocumentBucket(document::BucketId(0)), update, api::Timestamp(0)));
// Misc settings for checking that propagation works.
msg->getTrace().setLevel(6);
msg->setTimeout(6789);
diff --git a/storage/src/tests/distributor/updateoperationtest.cpp b/storage/src/tests/distributor/updateoperationtest.cpp
index fdb6012800f..425751ee0d0 100644
--- a/storage/src/tests/distributor/updateoperationtest.cpp
+++ b/storage/src/tests/distributor/updateoperationtest.cpp
@@ -7,6 +7,7 @@
#include <vespa/storageapi/message/state.h>
#include <vespa/storageapi/message/bucket.h>
#include <tests/distributor/distributortestutil.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/distributor/operations/external/updateoperation.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/storage/distributor/distributor.h>
@@ -22,6 +23,7 @@ using namespace storage::lib;
using config::ConfigGetter;
using config::FileSpec;
using vespalib::string;
+using storage::test::makeDocumentBucket;
class UpdateOperation_Test : public CppUnit::TestFixture,
public DistributorTestUtil
@@ -84,7 +86,7 @@ UpdateOperation_Test::sendUpdate(const std::string& bucketState)
addNodesToBucketDB(_bId, bucketState);
std::shared_ptr<api::UpdateCommand> msg(
- new api::UpdateCommand(document::BucketId(0),
+ new api::UpdateCommand(makeDocumentBucket(document::BucketId(0)),
update,
100));
diff --git a/storage/src/tests/persistence/common/filestortestfixture.cpp b/storage/src/tests/persistence/common/filestortestfixture.cpp
index b0225992a20..2fd070de394 100644
--- a/storage/src/tests/persistence/common/filestortestfixture.cpp
+++ b/storage/src/tests/persistence/common/filestortestfixture.cpp
@@ -4,10 +4,12 @@
#include <vespa/storage/persistence/filestorage/filestormanager.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/persistence/spi/test.h>
#include <sstream>
using storage::spi::test::makeBucket;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -99,7 +101,7 @@ FileStorTestFixture::TestFileStorComponents::sendDummyGet(
std::ostringstream id;
id << "id:foo:testdoctype1:n=" << bid.getId() << ":0";
std::shared_ptr<api::GetCommand> cmd(
- new api::GetCommand(bid, document::DocumentId(id.str()), "[all]"));
+ new api::GetCommand(makeDocumentBucket(bid), document::DocumentId(id.str()), "[all]"));
cmd->setAddress(makeSelfAddress());
cmd->setPriority(255);
top.sendDown(cmd);
@@ -113,7 +115,7 @@ FileStorTestFixture::TestFileStorComponents::sendDummyGetDiff(
nodes.push_back(0);
nodes.push_back(1);
std::shared_ptr<api::GetBucketDiffCommand> cmd(
- new api::GetBucketDiffCommand(bid, nodes, 12345));
+ new api::GetBucketDiffCommand(makeDocumentBucket(bid), nodes, 12345));
cmd->setAddress(makeSelfAddress());
cmd->setPriority(255);
top.sendDown(cmd);
@@ -130,7 +132,7 @@ FileStorTestFixture::TestFileStorComponents::sendPut(
document::Document::SP doc(
_fixture._node->getTestDocMan().createDocument("foobar", id.str()));
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, timestamp));
+ new api::PutCommand(makeDocumentBucket(bid), doc, timestamp));
cmd->setAddress(makeSelfAddress());
top.sendDown(cmd);
}
diff --git a/storage/src/tests/persistence/filestorage/deletebuckettest.cpp b/storage/src/tests/persistence/filestorage/deletebuckettest.cpp
index 4aad3f5c41b..e6da51e103a 100644
--- a/storage/src/tests/persistence/filestorage/deletebuckettest.cpp
+++ b/storage/src/tests/persistence/filestorage/deletebuckettest.cpp
@@ -4,11 +4,14 @@
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/storageapi/message/bucket.h>
#include <tests/persistence/common/persistenceproviderwrapper.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
LOG_SETUP(".deletebuckettest");
+using storage::test::makeDocumentBucket;
+
namespace storage {
class DeleteBucketTest : public FileStorTestFixture
@@ -38,7 +41,7 @@ DeleteBucketTest::testDeleteAbortsOperationsForBucket()
// Put will be queued since thread now must know it's paused.
c.sendPut(bucket, DocumentIndex(1), PutTimestamp(1000));
- auto deleteMsg = std::make_shared<api::DeleteBucketCommand>(bucket);
+ auto deleteMsg = std::make_shared<api::DeleteBucketCommand>(makeDocumentBucket(bucket));
c.top.sendDown(deleteMsg);
// We should now have two put replies. The first one will either be OK
// or BUCKET_DELETED depending on whether it raced. The second (which is
diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
index 0b8ee0113ea..87655d8bd35 100644
--- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
+++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
@@ -4,6 +4,7 @@
#include <tests/common/storagelinktest.h>
#include <tests/common/teststorageapp.h>
#include <tests/persistence/filestorage/forwardingmessagesender.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/storageserver/statemanager.h>
#include <vespa/storage/bucketdb/bucketmanager.h>
#include <vespa/storage/persistence/persistencethread.h>
@@ -40,6 +41,7 @@ using std::unique_ptr;
using document::Document;
using namespace storage::api;
using storage::spi::test::makeBucket;
+using storage::test::makeDocumentBucket;
#define ASSERT_SINGLE_REPLY(replytype, reply, link, time) \
reply = 0; \
@@ -342,7 +344,7 @@ FileStorManagerTest::testHeaderOnlyPut()
// Putting it
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 105));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 105));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -359,7 +361,7 @@ FileStorManagerTest::testHeaderOnlyPut()
// Putting it again, this time with header only
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 124));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 124));
cmd->setUpdateTimestamp(105);
cmd->setAddress(address);
top.sendDown(cmd);
@@ -375,7 +377,7 @@ FileStorManagerTest::testHeaderOnlyPut()
// Getting it
{
std::shared_ptr<api::GetCommand> cmd(new api::GetCommand(
- bid, doc->getId(), "[all]"));
+ makeDocumentBucket(bid), doc->getId(), "[all]"));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -422,7 +424,7 @@ FileStorManagerTest::testPut()
// Putting it
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 105));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 105));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -460,7 +462,7 @@ FileStorManagerTest::testDiskMove()
// Putting it
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 105));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 105));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -558,7 +560,7 @@ FileStorManagerTest::testRepairNotifiesDistributorOnChange()
document::DocumentId docId(vespalib::make_string("userdoc:ns:1:%d", i));
Document::SP doc(new Document(*_testdoctype1, docId));
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(document::BucketId(16, 1), doc, i + 1));
+ new api::PutCommand(makeDocumentBucket(document::BucketId(16, 1)), doc, i + 1));
cmd->setAddress(address);
top.sendDown(cmd);
}
@@ -606,7 +608,7 @@ FileStorManagerTest::testFlush()
std::vector<std::shared_ptr<api::StorageCommand> > _commands;
for (uint32_t i=0; i<msgCount; ++i) {
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, i+1));
+ new api::PutCommand(makeDocumentBucket(bid), doc, i+1));
cmd->setAddress(address);
_commands.push_back(cmd);
}
@@ -653,7 +655,7 @@ FileStorManagerTest::testHandlerPriority()
// Populate bucket with the given data
for (uint32_t i = 1; i < 6; i++) {
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bucket), doc, 100));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -689,7 +691,7 @@ public:
_doc->getId()).getRawId());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, _doc, 100));
+ new api::PutCommand(makeDocumentBucket(bucket), _doc, 100));
_handler.schedule(cmd, 0);
FastOS_Thread::Sleep(1);
}
@@ -822,7 +824,7 @@ FileStorManagerTest::testHandlerPause()
// Populate bucket with the given data
for (uint32_t i = 1; i < 6; i++) {
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bucket), doc, 100));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -890,9 +892,9 @@ FileStorManagerTest::testRemapSplit()
// Populate bucket with the given data
for (uint32_t i = 1; i < 4; i++) {
filestorHandler.schedule(
- api::StorageMessage::SP(new api::PutCommand(bucket1, doc1, i)), 0);
+ api::StorageMessage::SP(new api::PutCommand(makeDocumentBucket(bucket1), doc1, i)), 0);
filestorHandler.schedule(
- api::StorageMessage::SP(new api::PutCommand(bucket2, doc2, i + 10)), 0);
+ api::StorageMessage::SP(new api::PutCommand(makeDocumentBucket(bucket2), doc2, i + 10)), 0);
}
CPPUNIT_ASSERT_EQUAL(std::string("BucketId(0x40000000000004d2): Put(BucketId(0x40000000000004d2), userdoc:footype:1234:bar, timestamp 1, size 108) (priority: 127)\n"
@@ -958,9 +960,9 @@ FileStorManagerTest::testHandlerMulti()
// Populate bucket with the given data
for (uint32_t i = 1; i < 10; i++) {
filestorHandler.schedule(
- api::StorageMessage::SP(new api::PutCommand(bucket1, doc1, i)), 0);
+ api::StorageMessage::SP(new api::PutCommand(makeDocumentBucket(bucket1), doc1, i)), 0);
filestorHandler.schedule(
- api::StorageMessage::SP(new api::PutCommand(bucket2, doc2, i + 10)), 0);
+ api::StorageMessage::SP(new api::PutCommand(makeDocumentBucket(bucket2), doc2, i + 10)), 0);
}
{
@@ -1019,7 +1021,7 @@ FileStorManagerTest::testHandlerTimeout()
// Populate bucket with the given data
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bucket), doc, 100));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -1031,7 +1033,7 @@ FileStorManagerTest::testHandlerTimeout()
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bucket), doc, 100));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -1089,7 +1091,7 @@ FileStorManagerTest::testHandlerPriorityBlocking()
document::BucketId bucket(16, factory.getBucketId(
doc->getId()).getRawId());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bucket), doc, 100));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -1117,7 +1119,7 @@ FileStorManagerTest::testHandlerPriorityBlocking()
document::BucketId bucket(16, factory.getBucketId(
doc->getId()).getRawId());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bucket), doc, 100));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -1204,7 +1206,7 @@ FileStorManagerTest::testHandlerPriorityPreempt()
document::BucketId bucket(16, factory.getBucketId(
doc->getId()).getRawId());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bucket), doc, 100));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -1226,7 +1228,7 @@ FileStorManagerTest::testHandlerPriorityPreempt()
document::BucketId bucket(16, factory.getBucketId(
doc->getId()).getRawId());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bucket), doc, 100));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -1317,7 +1319,7 @@ FileStorManagerTest::testPriority()
documents[i]->getId()).getRawId());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, documents[i], 100 + i));
+ new api::PutCommand(makeDocumentBucket(bucket), documents[i], 100 + i));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -1400,7 +1402,7 @@ FileStorManagerTest::testSplit1()
makeBucket(bucket), context);
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, documents[i], 100 + i));
+ new api::PutCommand(makeDocumentBucket(bucket), documents[i], 100 + i));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -1423,7 +1425,7 @@ FileStorManagerTest::testSplit1()
if (i % 5 == 0) {
std::shared_ptr<api::RemoveCommand> rcmd(
new api::RemoveCommand(
- bucket, documents[i]->getId(), 1000000 + 100 + i));
+ makeDocumentBucket(bucket), documents[i]->getId(), 1000000 + 100 + i));
rcmd->setAddress(*address);
filestorHandler.schedule(rcmd, 0);
filestorHandler.flush(true);
@@ -1442,7 +1444,7 @@ FileStorManagerTest::testSplit1()
// Perform a split, check that locations are split
{
std::shared_ptr<api::SplitBucketCommand> cmd(
- new api::SplitBucketCommand(document::BucketId(16, 1)));
+ new api::SplitBucketCommand(makeDocumentBucket(document::BucketId(16, 1))));
cmd->setSourceIndex(0);
filestorHandler.schedule(cmd, 0);
filestorHandler.flush(true);
@@ -1461,7 +1463,7 @@ FileStorManagerTest::testSplit1()
document::BucketId bucket(
17, i % 3 == 0 ? 0x10001 : 0x0100001);
std::shared_ptr<api::GetCommand> cmd(
- new api::GetCommand(bucket, documents[i]->getId(), "[all]"));
+ new api::GetCommand(makeDocumentBucket(bucket), documents[i]->getId(), "[all]"));
api::StorageMessageAddress address(
"storage", lib::NodeType::STORAGE, 3);
cmd->setAddress(address);
@@ -1480,7 +1482,7 @@ FileStorManagerTest::testSplit1()
for (int i=17; i<=32; ++i) {
std::shared_ptr<api::SplitBucketCommand> cmd(
new api::SplitBucketCommand(
- document::BucketId(i, 0x0100001)));
+ makeDocumentBucket(document::BucketId(i, 0x0100001))));
cmd->setSourceIndex(0);
filestorHandler.schedule(cmd, 0);
filestorHandler.flush(true);
@@ -1504,7 +1506,7 @@ FileStorManagerTest::testSplit1()
documents[i]->getId()).getRawId());
}
std::shared_ptr<api::GetCommand> cmd(
- new api::GetCommand(bucket, documents[i]->getId(), "[all]"));
+ new api::GetCommand(makeDocumentBucket(bucket), documents[i]->getId(), "[all]"));
api::StorageMessageAddress address(
"storage", lib::NodeType::STORAGE, 3);
cmd->setAddress(address);
@@ -1575,7 +1577,7 @@ FileStorManagerTest::testSplitSingleGroup()
makeBucket(bucket), context);
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, documents[i], 100 + i));
+ new api::PutCommand(makeDocumentBucket(bucket), documents[i], 100 + i));
api::StorageMessageAddress address(
"storage", lib::NodeType::STORAGE, 3);
cmd->setAddress(address);
@@ -1593,7 +1595,7 @@ FileStorManagerTest::testSplitSingleGroup()
// Perform a split, check that locations are split
{
std::shared_ptr<api::SplitBucketCommand> cmd(
- new api::SplitBucketCommand(document::BucketId(16, 1)));
+ new api::SplitBucketCommand(makeDocumentBucket(document::BucketId(16, 1))));
cmd->setSourceIndex(0);
filestorHandler.schedule(cmd, 0);
filestorHandler.flush(true);
@@ -1612,7 +1614,7 @@ FileStorManagerTest::testSplitSingleGroup()
for (uint32_t i=0; i<documents.size(); ++i) {
document::BucketId bucket(17, state ? 0x10001 : 0x00001);
std::shared_ptr<api::GetCommand> cmd(
- new api::GetCommand(bucket, documents[i]->getId(), "[all]"));
+ new api::GetCommand(makeDocumentBucket(bucket), documents[i]->getId(), "[all]"));
api::StorageMessageAddress address(
"storage", lib::NodeType::STORAGE, 3);
cmd->setAddress(address);
@@ -1650,7 +1652,7 @@ FileStorManagerTest::putDoc(DummyStorageLink& top,
makeBucket(target), context);
Document::SP doc(new Document(*_testdoctype1, docId));
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(target, doc, docNum+1));
+ new api::PutCommand(makeDocumentBucket(target), doc, docNum+1));
cmd->setAddress(address);
cmd->setPriority(120);
filestorHandler.schedule(cmd, 0);
@@ -1704,7 +1706,7 @@ FileStorManagerTest::testSplitEmptyTargetWithRemappedOps()
new ResumeGuard(filestorHandler.pause()));
std::shared_ptr<api::SplitBucketCommand> splitCmd(
- new api::SplitBucketCommand(source));
+ new api::SplitBucketCommand(makeDocumentBucket(source)));
splitCmd->setPriority(120);
splitCmd->setSourceIndex(0);
@@ -1712,7 +1714,7 @@ FileStorManagerTest::testSplitEmptyTargetWithRemappedOps()
vespalib::make_string("userdoc:ns:%d:1234", 0x100001));
Document::SP doc(new Document(*_testdoctype1, docId));
std::shared_ptr<api::PutCommand> putCmd(
- new api::PutCommand(source, doc, 1001));
+ new api::PutCommand(makeDocumentBucket(source), doc, 1001));
putCmd->setAddress(address);
putCmd->setPriority(120);
@@ -1771,7 +1773,7 @@ FileStorManagerTest::testNotifyOnSplitSourceOwnershipChanged()
}
std::shared_ptr<api::SplitBucketCommand> splitCmd(
- new api::SplitBucketCommand(source));
+ new api::SplitBucketCommand(makeDocumentBucket(source)));
splitCmd->setPriority(120);
splitCmd->setSourceIndex(0); // Source not owned by this distributor.
@@ -1836,7 +1838,7 @@ FileStorManagerTest::testJoin()
document::BucketId bucket(17, factory.getBucketId(
documents[i]->getId()).getRawId());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bucket, documents[i], 100 + i));
+ new api::PutCommand(makeDocumentBucket(bucket), documents[i], 100 + i));
std::unique_ptr<api::StorageMessageAddress> address(
new api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 3));
@@ -1855,7 +1857,7 @@ FileStorManagerTest::testJoin()
if (i % 5 == 0) {
std::shared_ptr<api::RemoveCommand> rcmd(
new api::RemoveCommand(
- bucket, documents[i]->getId(), 1000000 + 100 + i));
+ makeDocumentBucket(bucket), documents[i]->getId(), 1000000 + 100 + i));
rcmd->setAddress(*address);
filestorHandler.schedule(rcmd, 0);
filestorHandler.flush(true);
@@ -1874,7 +1876,7 @@ FileStorManagerTest::testJoin()
// Perform a join, check that other files are gone
{
std::shared_ptr<api::JoinBucketsCommand> cmd(
- new api::JoinBucketsCommand(document::BucketId(16, 1)));
+ new api::JoinBucketsCommand(makeDocumentBucket(document::BucketId(16, 1))));
cmd->getSourceBuckets().push_back(document::BucketId(17, 0x00001));
cmd->getSourceBuckets().push_back(document::BucketId(17, 0x10001));
filestorHandler.schedule(cmd, 0);
@@ -1892,7 +1894,7 @@ FileStorManagerTest::testJoin()
for (uint32_t i=0; i<documents.size(); ++i) {
document::BucketId bucket(16, 1);
std::shared_ptr<api::GetCommand> cmd(
- new api::GetCommand(bucket, documents[i]->getId(), "[all]"));
+ new api::GetCommand(makeDocumentBucket(bucket), documents[i]->getId(), "[all]"));
api::StorageMessageAddress address(
"storage", lib::NodeType::STORAGE, 3);
cmd->setAddress(address);
@@ -1985,7 +1987,7 @@ FileStorManagerTest::testVisiting()
document::StringFieldValue("Jane Doe"));
}
std::shared_ptr<api::PutCommand> cmd(new api::PutCommand(
- ids[i < 3 ? 0 : 1], doc, i+1));
+ makeDocumentBucket(ids[i < 3 ? 0 : 1]), doc, i+1));
top.sendDown(cmd);
}
top.waitForMessages(docCount, _waitTime);
@@ -2135,7 +2137,7 @@ FileStorManagerTest::testRemoveLocation()
Document::SP doc(createDocument(
"some content", docid.str()).release());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 1000 + i));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 1000 + i));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2151,7 +2153,7 @@ FileStorManagerTest::testRemoveLocation()
// Issuing remove location command
{
std::shared_ptr<api::RemoveLocationCommand> cmd(
- new api::RemoveLocationCommand("id.user % 512 == 0", bid));
+ new api::RemoveLocationCommand("id.user % 512 == 0", makeDocumentBucket(bid)));
//new api::RemoveLocationCommand("id.user == 1", bid));
cmd->setAddress(address);
top.sendDown(cmd);
@@ -2189,7 +2191,7 @@ void FileStorManagerTest::testDeleteBucket()
// Putting it
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 105));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 105));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2208,7 +2210,7 @@ void FileStorManagerTest::testDeleteBucket()
// Delete bucket
{
std::shared_ptr<api::DeleteBucketCommand> cmd(
- new api::DeleteBucketCommand(bid));
+ new api::DeleteBucketCommand(makeDocumentBucket(bid)));
cmd->setAddress(address);
cmd->setBucketInfo(bucketInfo);
top.sendDown(cmd);
@@ -2246,7 +2248,7 @@ FileStorManagerTest::testDeleteBucketRejectOutdatedBucketInfo()
// Putting it
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 105));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 105));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2265,7 +2267,7 @@ FileStorManagerTest::testDeleteBucketRejectOutdatedBucketInfo()
// Attempt to delete bucket, but with non-matching bucketinfo
{
std::shared_ptr<api::DeleteBucketCommand> cmd(
- new api::DeleteBucketCommand(bid));
+ new api::DeleteBucketCommand(makeDocumentBucket(bid)));
cmd->setBucketInfo(api::BucketInfo(0xf000baaa, 1, 123, 1, 456));
cmd->setAddress(address);
top.sendDown(cmd);
@@ -2308,7 +2310,7 @@ FileStorManagerTest::testDeleteBucketWithInvalidBucketInfo()
// Putting it
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 105));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 105));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2325,7 +2327,7 @@ FileStorManagerTest::testDeleteBucketWithInvalidBucketInfo()
// Attempt to delete bucket with invalid bucketinfo
{
std::shared_ptr<api::DeleteBucketCommand> cmd(
- new api::DeleteBucketCommand(bid));
+ new api::DeleteBucketCommand(makeDocumentBucket(bid)));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2488,7 +2490,7 @@ FileStorManagerTest::testNoTimestamps()
// Putting it
{
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 0));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 0));
cmd->setAddress(address);
CPPUNIT_ASSERT_EQUAL((api::Timestamp)0, cmd->getTimestamp());
top.sendDown(cmd);
@@ -2505,7 +2507,7 @@ FileStorManagerTest::testNoTimestamps()
// Removing it
{
std::shared_ptr<api::RemoveCommand> cmd(
- new api::RemoveCommand(bid, doc->getId(), 0));
+ new api::RemoveCommand(makeDocumentBucket(bid), doc->getId(), 0));
cmd->setAddress(address);
CPPUNIT_ASSERT_EQUAL((api::Timestamp)0, cmd->getTimestamp());
top.sendDown(cmd);
@@ -2544,7 +2546,7 @@ FileStorManagerTest::testEqualTimestamps()
"some content", "userdoc:crawler:4000:http://www.ntnu.no/")
.release());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 100));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2565,7 +2567,7 @@ FileStorManagerTest::testEqualTimestamps()
"some content", "userdoc:crawler:4000:http://www.ntnu.no/")
.release());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 100));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2584,7 +2586,7 @@ FileStorManagerTest::testEqualTimestamps()
"some content", "userdoc:crawler:4000:http://www.ntnu.nu/")
.release());
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, doc, 100));
+ new api::PutCommand(makeDocumentBucket(bid), doc, 100));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2623,7 +2625,7 @@ FileStorManagerTest::testMultiOp()
doc->set("headerval", (int) i);
doc->set("content", "some content");
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(document::BucketId(16, 0), doc, 100 + i));
+ new api::PutCommand(makeDocumentBucket(document::BucketId(16, 0)), doc, 100 + i));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2686,7 +2688,7 @@ FileStorManagerTest::testMultiOp()
{
std::shared_ptr<api::MultiOperationCommand> cmd(
new api::MultiOperationCommand(
- repo, document::BucketId(16, 0), buffer));
+ repo, makeDocumentBucket(document::BucketId(16, 0)), buffer));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2705,7 +2707,7 @@ FileStorManagerTest::testMultiOp()
std::ostringstream did;
did << "userdoc:crawler:0:http://www.ntnu.no/" << i;
std::shared_ptr<api::GetCommand> cmd(new api::GetCommand(
- document::BucketId(16, 0), document::DocumentId(did.str()),
+ makeDocumentBucket(document::BucketId(16, 0)), document::DocumentId(did.str()),
"[all]"));
cmd->setAddress(address);
top.sendDown(cmd);
@@ -2781,7 +2783,7 @@ FileStorManagerTest::testGetIter()
// Putting all docs to have something to visit
for (uint32_t i=0; i<docs.size(); ++i) {
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, docs[i], 100 + i));
+ new api::PutCommand(makeDocumentBucket(bid), docs[i], 100 + i));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2822,7 +2824,7 @@ FileStorManagerTest::testGetIter()
// Testing specific situation where file is deleted while visiting here
{
std::shared_ptr<api::DeleteBucketCommand> cmd(
- new api::DeleteBucketCommand(bid));
+ new api::DeleteBucketCommand(makeDocumentBucket(bid)));
cmd->setBucketInfo(bucketInfo);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2884,7 +2886,7 @@ FileStorManagerTest::testSetBucketActiveState()
{
std::shared_ptr<api::SetBucketStateCommand> cmd(
new api::SetBucketStateCommand(
- bid, api::SetBucketStateCommand::ACTIVE));
+ makeDocumentBucket(bid), api::SetBucketStateCommand::ACTIVE));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2928,7 +2930,7 @@ FileStorManagerTest::testSetBucketActiveState()
{
std::shared_ptr<api::SetBucketStateCommand> cmd(
new api::SetBucketStateCommand(
- bid, api::SetBucketStateCommand::INACTIVE));
+ makeDocumentBucket(bid), api::SetBucketStateCommand::INACTIVE));
cmd->setAddress(address);
top.sendDown(cmd);
top.waitForMessages(1, _waitTime);
@@ -2971,7 +2973,7 @@ FileStorManagerTest::testNotifyOwnerDistributorOnOutdatedSetBucketState()
std::shared_ptr<api::SetBucketStateCommand> cmd(
new api::SetBucketStateCommand(
- bid, api::SetBucketStateCommand::ACTIVE));
+ makeDocumentBucket(bid), api::SetBucketStateCommand::ACTIVE));
cmd->setAddress(api::StorageMessageAddress(
"cluster", lib::NodeType::STORAGE, 1));
cmd->setSourceIndex(0);
@@ -3024,7 +3026,7 @@ FileStorManagerTest::testGetBucketDiffImplicitCreateBucket()
nodes.push_back(0);
std::shared_ptr<api::GetBucketDiffCommand> cmd(
- new api::GetBucketDiffCommand(bid, nodes, Timestamp(1000)));
+ new api::GetBucketDiffCommand(makeDocumentBucket(bid), nodes, Timestamp(1000)));
cmd->setAddress(api::StorageMessageAddress(
"cluster", lib::NodeType::STORAGE, 1));
cmd->setSourceIndex(0);
@@ -3064,7 +3066,7 @@ FileStorManagerTest::testMergeBucketImplicitCreateBucket()
nodes.push_back(2);
std::shared_ptr<api::MergeBucketCommand> cmd(
- new api::MergeBucketCommand(bid, nodes, Timestamp(1000)));
+ new api::MergeBucketCommand(makeDocumentBucket(bid), nodes, Timestamp(1000)));
cmd->setAddress(api::StorageMessageAddress(
"cluster", lib::NodeType::STORAGE, 1));
cmd->setSourceIndex(0);
@@ -3098,7 +3100,7 @@ FileStorManagerTest::testNewlyCreatedBucketIsReady()
document::BucketId bid(16, 4000);
std::shared_ptr<api::CreateBucketCommand> cmd(
- new api::CreateBucketCommand(bid));
+ new api::CreateBucketCommand(makeDocumentBucket(bid)));
cmd->setAddress(api::StorageMessageAddress(
"cluster", lib::NodeType::STORAGE, 1));
cmd->setSourceIndex(0);
@@ -3126,7 +3128,7 @@ FileStorManagerTest::testCreateBucketSetsActiveFlagInDatabaseAndReply()
document::BucketId bid(16, 4000);
std::shared_ptr<api::CreateBucketCommand> cmd(
- new api::CreateBucketCommand(bid));
+ new api::CreateBucketCommand(makeDocumentBucket(bid)));
cmd->setAddress(api::StorageMessageAddress(
"cluster", lib::NodeType::STORAGE, 1));
cmd->setSourceIndex(0);
diff --git a/storage/src/tests/persistence/filestorage/mergeblockingtest.cpp b/storage/src/tests/persistence/filestorage/mergeblockingtest.cpp
index ea2f56a7d4f..8bf8ac087b9 100644
--- a/storage/src/tests/persistence/filestorage/mergeblockingtest.cpp
+++ b/storage/src/tests/persistence/filestorage/mergeblockingtest.cpp
@@ -6,6 +6,9 @@
#include <tests/persistence/common/persistenceproviderwrapper.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
+#include <tests/common/make_document_bucket.h>
+
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -82,7 +85,7 @@ getNodesWithForwarding() {
std::shared_ptr<api::MergeBucketCommand>
createMerge(const document::BucketId& bucket) {
std::shared_ptr<api::MergeBucketCommand> cmd(
- new api::MergeBucketCommand(bucket, getNodes(), api::Timestamp(1000)));
+ new api::MergeBucketCommand(makeDocumentBucket(bucket), getNodes(), api::Timestamp(1000)));
assignCommandMeta(*cmd);
return cmd;
}
@@ -92,7 +95,7 @@ createGetDiff(const document::BucketId& bucket,
const std::vector<api::MergeBucketCommand::Node>& nodes)
{
std::shared_ptr<api::GetBucketDiffCommand> cmd(
- new api::GetBucketDiffCommand(bucket, nodes, api::Timestamp(1000)));
+ new api::GetBucketDiffCommand(makeDocumentBucket(bucket), nodes, api::Timestamp(1000)));
assignCommandMeta(*cmd);
return cmd;
}
@@ -101,7 +104,7 @@ std::shared_ptr<api::ApplyBucketDiffCommand>
createApplyDiff(const document::BucketId& bucket,
const std::vector<api::MergeBucketCommand::Node>& nodes) {
std::shared_ptr<api::ApplyBucketDiffCommand> cmd(
- new api::ApplyBucketDiffCommand(bucket, nodes, 1024*1024));
+ new api::ApplyBucketDiffCommand(makeDocumentBucket(bucket), nodes, 1024*1024));
assignCommandMeta(*cmd);
return cmd;
}
diff --git a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp
index a62c7b00a34..9a71fe16a15 100644
--- a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp
+++ b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp
@@ -5,6 +5,7 @@
#include <tests/persistence/common/persistenceproviderwrapper.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/vespalib/util/barrier.h>
#include <vespa/vespalib/util/thread.h>
#include <vespa/vespalib/stllike/hash_set_insert.hpp>
@@ -12,6 +13,8 @@
#include <vespa/log/log.h>
LOG_SETUP(".operationabortingtest");
+using storage::test::makeDocumentBucket;
+
namespace storage {
namespace {
@@ -335,7 +338,7 @@ OperationAbortingTest::testDoNotAbortCreateBucketCommands()
{
document::BucketId bucket(16, 1);
std::vector<api::StorageMessage::SP> msgs;
- msgs.push_back(api::StorageMessage::SP(new api::CreateBucketCommand(bucket)));
+ msgs.push_back(api::StorageMessage::SP(new api::CreateBucketCommand(makeDocumentBucket(bucket))));
bool shouldCreateBucketInitially(false);
doTestSpecificOperationsNotAborted(
@@ -373,7 +376,7 @@ OperationAbortingTest::testDoNotAbortDeleteBucketCommands()
{
document::BucketId bucket(16, 1);
std::vector<api::StorageMessage::SP> msgs;
- api::DeleteBucketCommand::SP cmd(new api::DeleteBucketCommand(bucket));
+ api::DeleteBucketCommand::SP cmd(new api::DeleteBucketCommand(makeDocumentBucket(bucket)));
msgs.push_back(cmd);
bool shouldCreateBucketInitially(true);
diff --git a/storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp b/storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp
index ef49f7cd5dd..cbb1cb48f3e 100644
--- a/storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp
+++ b/storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp
@@ -4,10 +4,12 @@
#include <vespa/storageapi/message/bucket.h>
#include <vespa/persistence/spi/test.h>
#include <tests/persistence/common/persistenceproviderwrapper.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
using storage::spi::test::makeBucket;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -47,7 +49,7 @@ void SanityCheckedDeleteTest::delete_bucket_fails_when_provider_out_of_sync() {
entry.write();
}
- auto cmd = std::make_shared<api::DeleteBucketCommand>(bucket);
+ auto cmd = std::make_shared<api::DeleteBucketCommand>(makeDocumentBucket(bucket));
cmd->setBucketInfo(serviceLayerInfo);
c.top.sendDown(cmd);
@@ -90,7 +92,7 @@ void SanityCheckedDeleteTest::differing_document_sizes_not_considered_out_of_syn
// Expect 1 byte of reported size, which will mismatch with the actually put document.
api::BucketInfo info_with_size_diff(info_before.getChecksum(), info_before.getDocumentCount(), 1u);
- auto delete_cmd = std::make_shared<api::DeleteBucketCommand>(bucket);
+ auto delete_cmd = std::make_shared<api::DeleteBucketCommand>(makeDocumentBucket(bucket));
delete_cmd->setBucketInfo(info_with_size_diff);
c.top.sendDown(delete_cmd);
diff --git a/storage/src/tests/persistence/filestorage/singlebucketjointest.cpp b/storage/src/tests/persistence/filestorage/singlebucketjointest.cpp
index a71362878df..83d79ab4d77 100644
--- a/storage/src/tests/persistence/filestorage/singlebucketjointest.cpp
+++ b/storage/src/tests/persistence/filestorage/singlebucketjointest.cpp
@@ -7,9 +7,12 @@
#include <tests/persistence/common/persistenceproviderwrapper.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
+#include <tests/common/make_document_bucket.h>
LOG_SETUP(".singlebucketjointest");
+using storage::test::makeDocumentBucket;
+
namespace storage {
class SingleBucketJoinTest : public FileStorTestFixture
@@ -37,7 +40,7 @@ SingleBucketJoinTest::testPersistenceCanHandleSingleBucketJoin()
expectOkReply<api::PutReply>(c.top);
c.top.getRepliesOnce();
- auto cmd = std::make_shared<api::JoinBucketsCommand>(targetBucket);
+ auto cmd = std::make_shared<api::JoinBucketsCommand>(makeDocumentBucket(targetBucket));
cmd->getSourceBuckets().push_back(sourceBucket);
cmd->getSourceBuckets().push_back(sourceBucket);
diff --git a/storage/src/tests/persistence/legacyoperationhandlertest.cpp b/storage/src/tests/persistence/legacyoperationhandlertest.cpp
index 6ceff0661b1..ff331d44ecd 100644
--- a/storage/src/tests/persistence/legacyoperationhandlertest.cpp
+++ b/storage/src/tests/persistence/legacyoperationhandlertest.cpp
@@ -8,10 +8,12 @@
#include <vespa/persistence/spi/test.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/persistencetestutils.h>
+#include <tests/common/make_document_bucket.h>
using document::DocumentTypeRepo;
using document::TestDocRepo;
using storage::spi::test::makeBucket;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -62,7 +64,7 @@ LegacyOperationHandlerTest::testMultioperationSingleBodyPut()
vdslib::WritableDocumentList block(getTypeRepo(), &buffer[0], buffer.size());
block.addPut(*doc, api::Timestamp(1234));
- api::MultiOperationCommand cmd(getTypeRepo(), bucketId, 0);
+ api::MultiOperationCommand cmd(getTypeRepo(), makeDocumentBucket(bucketId), 0);
cmd.setOperations(block);
thread->handleMultiOperation(cmd);
@@ -83,7 +85,7 @@ LegacyOperationHandlerTest::testMultioperationSingleRemove()
vdslib::WritableDocumentList block(getTypeRepo(), &buffer[0], buffer.size());
block.addRemove(doc->getId(), spi::Timestamp(1235));
- api::MultiOperationCommand cmd(getTypeRepo(), bucketId, 0);
+ api::MultiOperationCommand cmd(getTypeRepo(), makeDocumentBucket(bucketId), 0);
cmd.setOperations(block);
thread->handleMultiOperation(cmd);
@@ -110,7 +112,7 @@ LegacyOperationHandlerTest::testMultioperationSingleUpdate()
vdslib::WritableDocumentList block(getTypeRepo(), &buffer[0], buffer.size());
block.addUpdate(*update, api::Timestamp(1235));
- api::MultiOperationCommand cmd(getTypeRepo(), bucketId, 0);
+ api::MultiOperationCommand cmd(getTypeRepo(), makeDocumentBucket(bucketId), 0);
cmd.setOperations(block);
thread->handleMultiOperation(cmd);
@@ -135,7 +137,7 @@ LegacyOperationHandlerTest::testMultioperationUpdateNotFound()
vdslib::WritableDocumentList block(getTypeRepo(), &buffer[0], buffer.size());
block.addUpdate(*update, api::Timestamp(1235));
- api::MultiOperationCommand cmd(getTypeRepo(), bucketId, 0);
+ api::MultiOperationCommand cmd(getTypeRepo(), makeDocumentBucket(bucketId), 0);
cmd.setOperations(block);
thread->handleMultiOperation(cmd);
@@ -171,7 +173,7 @@ LegacyOperationHandlerTest::testMultioperationMixedOperations()
api::Timestamp(4568));
block.addPut(*putDoc, api::Timestamp(5678));
- api::MultiOperationCommand cmd(getTypeRepo(), bucketId, 0);
+ api::MultiOperationCommand cmd(getTypeRepo(), makeDocumentBucket(bucketId), 0);
cmd.setOperations(block);
thread->handleMultiOperation(cmd);
diff --git a/storage/src/tests/persistence/mergehandlertest.cpp b/storage/src/tests/persistence/mergehandlertest.cpp
index 0720504f140..3c00a7796ba 100644
--- a/storage/src/tests/persistence/mergehandlertest.cpp
+++ b/storage/src/tests/persistence/mergehandlertest.cpp
@@ -6,12 +6,15 @@
#include <tests/persistence/persistencetestutils.h>
#include <tests/persistence/common/persistenceproviderwrapper.h>
#include <tests/distributor/messagesenderstub.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <cmath>
#include <vespa/log/log.h>
LOG_SETUP(".test.persistence.handler.merge");
+using storage::test::makeDocumentBucket;
+
namespace storage {
struct MergeHandlerTest : public SingleDiskPersistenceTestUtils
@@ -264,7 +267,7 @@ MergeHandlerTest::testMergeBucketCommand()
MergeHandler handler(getPersistenceProvider(), getEnv());
LOG(info, "Handle a merge bucket command");
- api::MergeBucketCommand cmd(_bucket, _nodes, _maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(_bucket), _nodes, _maxTimestamp);
cmd.setSourceIndex(1234);
MessageTracker::UP tracker = handler.handleMergeBucket(cmd, *_context);
@@ -291,7 +294,7 @@ MergeHandlerTest::testGetBucketDiffChain(bool midChain)
MergeHandler handler(getPersistenceProvider(), getEnv());
LOG(info, "Verifying that get bucket diff is sent on");
- api::GetBucketDiffCommand cmd(_bucket, _nodes, _maxTimestamp);
+ api::GetBucketDiffCommand cmd(makeDocumentBucket(_bucket), _nodes, _maxTimestamp);
MessageTracker::UP tracker1 = handler.handleGetBucketDiff(cmd, *_context);
api::StorageMessage::SP replySent = tracker1->getReply();
@@ -335,7 +338,7 @@ MergeHandlerTest::testApplyBucketDiffChain(bool midChain)
MergeHandler handler(getPersistenceProvider(), getEnv());
LOG(info, "Verifying that apply bucket diff is sent on");
- api::ApplyBucketDiffCommand cmd(_bucket, _nodes, _maxTimestamp);
+ api::ApplyBucketDiffCommand cmd(makeDocumentBucket(_bucket), _nodes, _maxTimestamp);
MessageTracker::UP tracker1 = handler.handleApplyBucketDiff(cmd, *_context);
api::StorageMessage::SP replySent = tracker1->getReply();
@@ -379,7 +382,7 @@ MergeHandlerTest::testMasterMessageFlow()
MergeHandler handler(getPersistenceProvider(), getEnv());
LOG(info, "Handle a merge bucket command");
- api::MergeBucketCommand cmd(_bucket, _nodes, _maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(_bucket), _nodes, _maxTimestamp);
handler.handleMergeBucket(cmd, *_context);
LOG(info, "Check state");
@@ -641,7 +644,7 @@ MergeHandlerTest::testChunkedApplyBucketDiff()
MergeHandler handler(getPersistenceProvider(), getEnv(), maxChunkSize);
LOG(info, "Handle a merge bucket command");
- api::MergeBucketCommand cmd(_bucket, _nodes, _maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(_bucket), _nodes, _maxTimestamp);
handler.handleMergeBucket(cmd, *_context);
std::shared_ptr<api::GetBucketDiffCommand> getBucketDiffCmd(
@@ -729,7 +732,7 @@ MergeHandlerTest::testChunkLimitPartiallyFilledDiff()
setUpChain(MIDDLE);
std::shared_ptr<api::ApplyBucketDiffCommand> applyBucketDiffCmd(
- new api::ApplyBucketDiffCommand(_bucket, _nodes, maxChunkSize));
+ new api::ApplyBucketDiffCommand(makeDocumentBucket(_bucket), _nodes, maxChunkSize));
applyBucketDiffCmd->getDiff() = applyDiff;
MergeHandler handler(
@@ -750,7 +753,7 @@ MergeHandlerTest::testMaxTimestamp()
MergeHandler handler(getPersistenceProvider(), getEnv());
- api::MergeBucketCommand cmd(_bucket, _nodes, _maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(_bucket), _nodes, _maxTimestamp);
handler.handleMergeBucket(cmd, *_context);
std::shared_ptr<api::GetBucketDiffCommand> getCmd(
@@ -817,7 +820,7 @@ MergeHandlerTest::createDummyApplyDiff(int timestampOffset,
}
std::shared_ptr<api::ApplyBucketDiffCommand> applyBucketDiffCmd(
- new api::ApplyBucketDiffCommand(_bucket, _nodes, 1024*1024));
+ new api::ApplyBucketDiffCommand(makeDocumentBucket(_bucket), _nodes, 1024*1024));
applyBucketDiffCmd->getDiff() = applyDiff;
return applyBucketDiffCmd;
}
@@ -853,7 +856,7 @@ MergeHandlerTest::createDummyGetBucketDiff(int timestampOffset,
}
std::shared_ptr<api::GetBucketDiffCommand> getBucketDiffCmd(
- new api::GetBucketDiffCommand(_bucket, _nodes, 1024*1024));
+ new api::GetBucketDiffCommand(makeDocumentBucket(_bucket), _nodes, 1024*1024));
getBucketDiffCmd->getDiff() = diff;
return getBucketDiffCmd;
}
@@ -895,7 +898,7 @@ MergeHandlerTest::testBucketNotFoundInDb()
{
MergeHandler handler(getPersistenceProvider(), getEnv());
// Send merge for unknown bucket
- api::MergeBucketCommand cmd(document::BucketId(16, 6789), _nodes, _maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(document::BucketId(16, 6789)), _nodes, _maxTimestamp);
MessageTracker::UP tracker = handler.handleMergeBucket(cmd, *_context);
CPPUNIT_ASSERT(tracker->getResult().isBucketDisappearance());
}
@@ -904,7 +907,7 @@ void
MergeHandlerTest::testMergeProgressSafeGuard()
{
MergeHandler handler(getPersistenceProvider(), getEnv());
- api::MergeBucketCommand cmd(_bucket, _nodes, _maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(_bucket), _nodes, _maxTimestamp);
handler.handleMergeBucket(cmd, *_context);
std::shared_ptr<api::GetBucketDiffCommand> getBucketDiffCmd(
@@ -940,7 +943,7 @@ MergeHandlerTest::testSafeGuardNotInvokedWhenHasMaskChanges()
_nodes.push_back(api::MergeBucketCommand::Node(0, false));
_nodes.push_back(api::MergeBucketCommand::Node(1, false));
_nodes.push_back(api::MergeBucketCommand::Node(2, false));
- api::MergeBucketCommand cmd(_bucket, _nodes, _maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(_bucket), _nodes, _maxTimestamp);
handler.handleMergeBucket(cmd, *_context);
std::shared_ptr<api::GetBucketDiffCommand> getBucketDiffCmd(
@@ -988,7 +991,7 @@ MergeHandlerTest::testEntryRemovedAfterGetBucketDiff()
}
setUpChain(BACK);
std::shared_ptr<api::ApplyBucketDiffCommand> applyBucketDiffCmd(
- new api::ApplyBucketDiffCommand(_bucket, _nodes, 1024*1024));
+ new api::ApplyBucketDiffCommand(makeDocumentBucket(_bucket), _nodes, 1024*1024));
applyBucketDiffCmd->getDiff() = applyDiff;
MessageTracker::UP tracker = handler.handleApplyBucketDiff(*applyBucketDiffCmd, *_context);
@@ -1083,7 +1086,7 @@ MergeHandlerTest::HandleMergeBucketInvoker::invoke(
MergeHandler& handler,
spi::Context& context)
{
- api::MergeBucketCommand cmd(test._bucket, test._nodes, test._maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(test._bucket), test._nodes, test._maxTimestamp);
handler.handleMergeBucket(cmd, context);
}
@@ -1123,7 +1126,7 @@ MergeHandlerTest::HandleGetBucketDiffInvoker::invoke(
MergeHandler& handler,
spi::Context& context)
{
- api::GetBucketDiffCommand cmd(test._bucket, test._nodes, test._maxTimestamp);
+ api::GetBucketDiffCommand cmd(makeDocumentBucket(test._bucket), test._nodes, test._maxTimestamp);
handler.handleGetBucketDiff(cmd, context);
}
@@ -1212,7 +1215,7 @@ MergeHandlerTest::HandleGetBucketDiffReplyInvoker::beforeInvoke(
MergeHandler& handler,
spi::Context& context)
{
- api::MergeBucketCommand cmd(test._bucket, test._nodes, test._maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(test._bucket), test._nodes, test._maxTimestamp);
handler.handleMergeBucket(cmd, context);
_diffCmd = test.fetchSingleMessage<api::GetBucketDiffCommand>();
}
@@ -1284,7 +1287,7 @@ MergeHandlerTest::HandleApplyBucketDiffReplyInvoker::beforeInvoke(
++_counter;
_stub.clear();
if (getChainPos() == FRONT) {
- api::MergeBucketCommand cmd(test._bucket, test._nodes, test._maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(test._bucket), test._nodes, test._maxTimestamp);
handler.handleMergeBucket(cmd, context);
std::shared_ptr<api::GetBucketDiffCommand> diffCmd(
test.fetchSingleMessage<api::GetBucketDiffCommand>());
@@ -1467,7 +1470,7 @@ MergeHandlerTest::testRemovePutOnExistingTimestamp()
}
std::shared_ptr<api::ApplyBucketDiffCommand> applyBucketDiffCmd(
- new api::ApplyBucketDiffCommand(_bucket, _nodes, 1024*1024));
+ new api::ApplyBucketDiffCommand(makeDocumentBucket(_bucket), _nodes, 1024*1024));
applyBucketDiffCmd->getDiff() = applyDiff;
MessageTracker::UP tracker = handler.handleApplyBucketDiff(*applyBucketDiffCmd, *_context);
@@ -1477,7 +1480,7 @@ MergeHandlerTest::testRemovePutOnExistingTimestamp()
tracker->getReply()));
CPPUNIT_ASSERT(applyBucketDiffReply.get());
- api::MergeBucketCommand cmd(_bucket, _nodes, _maxTimestamp);
+ api::MergeBucketCommand cmd(makeDocumentBucket(_bucket), _nodes, _maxTimestamp);
handler.handleMergeBucket(cmd, *_context);
std::shared_ptr<api::GetBucketDiffCommand> getBucketDiffCmd(
diff --git a/storage/src/tests/persistence/persistencequeuetest.cpp b/storage/src/tests/persistence/persistencequeuetest.cpp
index c01a5df22e2..a86cfd38cda 100644
--- a/storage/src/tests/persistence/persistencequeuetest.cpp
+++ b/storage/src/tests/persistence/persistencequeuetest.cpp
@@ -7,9 +7,12 @@
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
#include <tests/persistence/filestorage/forwardingmessagesender.h>
+#include <tests/common/make_document_bucket.h>
LOG_SETUP(".persistencequeuetest");
+using storage::test::makeDocumentBucket;
+
namespace storage {
class PersistenceQueueTest : public FileStorTestFixture
@@ -53,7 +56,7 @@ PersistenceQueueTest::createPut(uint64_t bucket, uint64_t docIdx)
document::Document::SP doc(
_node->getTestDocMan().createDocument("foobar", id.str()));
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(document::BucketId(16, bucket), doc, 1234));
+ new api::PutCommand(makeDocumentBucket(document::BucketId(16, bucket)), doc, 1234));
cmd->setAddress(api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 0));
return cmd;
diff --git a/storage/src/tests/persistence/persistencetestutils.cpp b/storage/src/tests/persistence/persistencetestutils.cpp
index 6be021a549c..d8df03602ef 100644
--- a/storage/src/tests/persistence/persistencetestutils.cpp
+++ b/storage/src/tests/persistence/persistencetestutils.cpp
@@ -3,6 +3,7 @@
#include <vespa/document/datatype/documenttype.h>
#include <vespa/storageapi/message/persistence.h>
#include <tests/persistence/persistencetestutils.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <vespa/persistence/spi/test.h>
#include <vespa/document/update/assignvalueupdate.h>
@@ -12,6 +13,7 @@
using document::DocumentType;
using storage::framework::defaultimplementation::AllocationLogic;
using storage::spi::test::makeBucket;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -113,7 +115,7 @@ PersistenceTestUtils::schedulePut(
location, timestamp, minSize, maxSize));
std::shared_ptr<api::StorageMessage> msg(
new api::PutCommand(
- document::BucketId(16, location), doc, timestamp));
+ makeDocumentBucket(document::BucketId(16, location)), doc, timestamp));
fsHandler().schedule(msg, disk);
return doc;
}
diff --git a/storage/src/tests/persistence/persistencethread_splittest.cpp b/storage/src/tests/persistence/persistencethread_splittest.cpp
index df43b714dcb..50fedee1d0a 100644
--- a/storage/src/tests/persistence/persistencethread_splittest.cpp
+++ b/storage/src/tests/persistence/persistencethread_splittest.cpp
@@ -5,8 +5,10 @@
#include <vespa/storageapi/message/bucketsplitting.h>
#include <vespa/persistence/spi/test.h>
#include <tests/persistence/persistencetestutils.h>
+#include <tests/common/make_document_bucket.h>
using storage::spi::test::makeBucket;
+using storage::test::makeDocumentBucket;
namespace storage {
namespace {
@@ -201,7 +203,7 @@ PersistenceThread_SplitTest::doTest(SplitCase splitCase)
getNode().getStateUpdater().setClusterState(
lib::ClusterState::CSP(
new lib::ClusterState("distributor:1 storage:1")));
- api::SplitBucketCommand cmd(document::BucketId(currentSplitLevel, 1));
+ api::SplitBucketCommand cmd(makeDocumentBucket(document::BucketId(currentSplitLevel, 1)));
cmd.setMaxSplitBits(maxBits);
cmd.setMinSplitBits(minBits);
cmd.setMinByteSize(maxSize);
diff --git a/storage/src/tests/persistence/processalltest.cpp b/storage/src/tests/persistence/processalltest.cpp
index e38505c2768..4b300c12dd3 100644
--- a/storage/src/tests/persistence/processalltest.cpp
+++ b/storage/src/tests/persistence/processalltest.cpp
@@ -6,6 +6,9 @@
#include <vespa/storage/persistence/messages.h>
#include <vespa/documentapi/loadtypes/loadtype.h>
#include <tests/persistence/persistencetestutils.h>
+#include <tests/common/make_document_bucket.h>
+
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -41,7 +44,7 @@ ProcessAllHandlerTest::testRemoveLocation()
doPut(4, spi::Timestamp(1234));
doPut(4, spi::Timestamp(2345));
- api::RemoveLocationCommand removeLocation("id.user == 4", bucketId);
+ api::RemoveLocationCommand removeLocation("id.user == 4", makeDocumentBucket(bucketId));
ProcessAllHandler handler(getEnv(), getPersistenceProvider());
spi::Context context(documentapi::LoadType::DEFAULT, 0, 0);
handler.handleRemoveLocation(removeLocation, context);
@@ -67,7 +70,7 @@ ProcessAllHandlerTest::testRemoveLocationDocumentSubset()
}
api::RemoveLocationCommand
- removeLocation("testdoctype1.headerval % 2 == 0", bucketId);
+ removeLocation("testdoctype1.headerval % 2 == 0", makeDocumentBucket(bucketId));
spi::Context context(documentapi::LoadType::DEFAULT, 0, 0);
handler.handleRemoveLocation(removeLocation, context);
@@ -92,7 +95,7 @@ ProcessAllHandlerTest::testRemoveLocationUnknownDocType()
doPut(4, spi::Timestamp(1234));
api::RemoveLocationCommand
- removeLocation("unknowndoctype.headerval % 2 == 0", bucketId);
+ removeLocation("unknowndoctype.headerval % 2 == 0", makeDocumentBucket(bucketId));
bool gotException = false;
try {
@@ -115,7 +118,7 @@ ProcessAllHandlerTest::testRemoveLocationBogusSelection()
document::BucketId bucketId(16, 4);
doPut(4, spi::Timestamp(1234));
- api::RemoveLocationCommand removeLocation("id.bogus != badgers", bucketId);
+ api::RemoveLocationCommand removeLocation("id.bogus != badgers", makeDocumentBucket(bucketId));
bool gotException = false;
try {
@@ -145,7 +148,7 @@ ProcessAllHandlerTest::testStat()
doPut(doc, bucketId, spi::Timestamp(100 + i), 0);
}
- api::StatBucketCommand statBucket(bucketId,
+ api::StatBucketCommand statBucket(makeDocumentBucket(bucketId),
"testdoctype1.headerval % 2 == 0");
spi::Context context(documentapi::LoadType::DEFAULT, 0, 0);
MessageTracker::UP tracker = handler.handleStatBucket(statBucket, context);
@@ -184,7 +187,7 @@ ProcessAllHandlerTest::testStatWithRemove()
true);
}
- api::StatBucketCommand statBucket(bucketId, "true");
+ api::StatBucketCommand statBucket(makeDocumentBucket(bucketId), "true");
spi::Context context(documentapi::LoadType::DEFAULT, 0, 0);
MessageTracker::UP tracker = handler.handleStatBucket(statBucket, context);
@@ -233,7 +236,7 @@ ProcessAllHandlerTest::testStatWholeBucket()
doPut(doc, bucketId, spi::Timestamp(100 + i), 0);
}
- api::StatBucketCommand statBucket(bucketId, "true");
+ api::StatBucketCommand statBucket(makeDocumentBucket(bucketId), "true");
spi::Context context(documentapi::LoadType::DEFAULT, 0, 0);
MessageTracker::UP tracker = handler.handleStatBucket(statBucket, context);
diff --git a/storage/src/tests/persistence/testandsettest.cpp b/storage/src/tests/persistence/testandsettest.cpp
index 2c1c15dee87..2332596263b 100644
--- a/storage/src/tests/persistence/testandsettest.cpp
+++ b/storage/src/tests/persistence/testandsettest.cpp
@@ -3,6 +3,7 @@
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/storage/persistence/persistencethread.h>
#include <tests/persistence/persistencetestutils.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/documentapi/messagebus/messages/testandsetcondition.h>
#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/document/update/assignvalueupdate.h>
@@ -14,6 +15,7 @@ using std::shared_ptr;
using namespace std::string_literals;
using storage::spi::test::makeBucket;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -109,7 +111,7 @@ void TestAndSetTest::conditional_put_not_executed_on_condition_mismatch()
// Conditionally replace document, but fail due to lack of woofy dog
api::Timestamp timestampTwo = 1;
- api::PutCommand putTwo(BUCKET_ID, testDoc, timestampTwo);
+ api::PutCommand putTwo(makeDocumentBucket(BUCKET_ID), testDoc, timestampTwo);
setTestCondition(putTwo);
CPPUNIT_ASSERT(thread->handlePut(putTwo)->getResult() == api::ReturnCode::Result::TEST_AND_SET_CONDITION_FAILED);
@@ -129,7 +131,7 @@ void TestAndSetTest::conditional_put_executed_on_condition_match()
// Conditionally replace document with updated version, succeed in doing so
api::Timestamp timestampTwo = 1;
- api::PutCommand putTwo(BUCKET_ID, testDoc, timestampTwo);
+ api::PutCommand putTwo(makeDocumentBucket(BUCKET_ID), testDoc, timestampTwo);
setTestCondition(putTwo);
CPPUNIT_ASSERT(thread->handlePut(putTwo)->getResult() == api::ReturnCode::Result::OK);
@@ -150,7 +152,7 @@ void TestAndSetTest::conditional_remove_not_executed_on_condition_mismatch()
// Conditionally remove document, fail in doing so
api::Timestamp timestampTwo = 1;
- api::RemoveCommand remove(BUCKET_ID, testDocId, timestampTwo);
+ api::RemoveCommand remove(makeDocumentBucket(BUCKET_ID), testDocId, timestampTwo);
setTestCondition(remove);
CPPUNIT_ASSERT(thread->handleRemove(remove)->getResult() == api::ReturnCode::Result::TEST_AND_SET_CONDITION_FAILED);
@@ -170,7 +172,7 @@ void TestAndSetTest::conditional_remove_executed_on_condition_match()
// Conditionally remove document, succeed in doing so
api::Timestamp timestampTwo = 1;
- api::RemoveCommand remove(BUCKET_ID, testDocId, timestampTwo);
+ api::RemoveCommand remove(makeDocumentBucket(BUCKET_ID), testDocId, timestampTwo);
setTestCondition(remove);
CPPUNIT_ASSERT(thread->handleRemove(remove)->getResult() == api::ReturnCode::Result::OK);
@@ -191,7 +193,7 @@ std::unique_ptr<api::UpdateCommand> TestAndSetTest::conditional_update_test(
fieldUpdate.addUpdate(document::AssignValueUpdate(NEW_CONTENT));
docUpdate->addUpdate(fieldUpdate);
- auto updateUp = std::make_unique<api::UpdateCommand>(BUCKET_ID, docUpdate, timestampTwo);
+ auto updateUp = std::make_unique<api::UpdateCommand>(makeDocumentBucket(BUCKET_ID), docUpdate, timestampTwo);
setTestCondition(*updateUp);
return updateUp;
}
@@ -228,7 +230,7 @@ void TestAndSetTest::invalid_document_selection_should_fail()
// Conditionally replace nonexisting document
// Fail early since document selection is invalid
api::Timestamp timestamp = 0;
- api::PutCommand put(BUCKET_ID, testDoc, timestamp);
+ api::PutCommand put(makeDocumentBucket(BUCKET_ID), testDoc, timestamp);
put.setCondition(documentapi::TestAndSetCondition("bjarne"));
CPPUNIT_ASSERT(thread->handlePut(put)->getResult() == api::ReturnCode::Result::ILLEGAL_PARAMETERS);
@@ -240,7 +242,7 @@ void TestAndSetTest::non_existing_document_should_fail()
// Conditionally replace nonexisting document
// Fail since no document exists to match with test and set
api::Timestamp timestamp = 0;
- api::PutCommand put(BUCKET_ID, testDoc, timestamp);
+ api::PutCommand put(makeDocumentBucket(BUCKET_ID), testDoc, timestamp);
setTestCondition(put);
thread->handlePut(put);
@@ -254,7 +256,7 @@ void TestAndSetTest::document_with_no_type_should_fail()
// Fail since no document exists to match with test and set
api::Timestamp timestamp = 0;
document::DocumentId legacyDocId("doc:mail:3619.html");
- api::RemoveCommand remove(BUCKET_ID, legacyDocId, timestamp);
+ api::RemoveCommand remove(makeDocumentBucket(BUCKET_ID), legacyDocId, timestamp);
setTestCondition(remove);
auto code = thread->handleRemove(remove)->getResult();
@@ -281,7 +283,7 @@ TestAndSetTest::createTestDocument()
document::Document::SP TestAndSetTest::retrieveTestDocument()
{
- api::GetCommand get(BUCKET_ID, testDocId, "[all]");
+ api::GetCommand get(makeDocumentBucket(BUCKET_ID), testDocId, "[all]");
auto tracker = thread->handleGet(get);
CPPUNIT_ASSERT(tracker->getResult() == api::ReturnCode::Result::OK);
@@ -301,7 +303,7 @@ void TestAndSetTest::putTestDocument(bool matchingHeader, api::Timestamp timesta
testDoc->setValue(testDoc->getField("hstringval"), MATCHING_HEADER);
}
- api::PutCommand put(BUCKET_ID, testDoc, timestamp);
+ api::PutCommand put(makeDocumentBucket(BUCKET_ID), testDoc, timestamp);
thread->handlePut(put);
}
diff --git a/storage/src/tests/storageserver/bouncertest.cpp b/storage/src/tests/storageserver/bouncertest.cpp
index 7a668971857..44d2dc889ab 100644
--- a/storage/src/tests/storageserver/bouncertest.cpp
+++ b/storage/src/tests/storageserver/bouncertest.cpp
@@ -8,9 +8,11 @@
#include <tests/common/teststorageapp.h>
#include <tests/common/testhelper.h>
#include <tests/common/dummystoragelink.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/config/common/exceptions.h>
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -110,7 +112,7 @@ BouncerTest::createDummyFeedMessage(api::Timestamp timestamp,
api::StorageMessage::Priority priority)
{
auto cmd = std::make_shared<api::RemoveCommand>(
- document::BucketId(0),
+ makeDocumentBucket(document::BucketId(0)),
document::DocumentId("doc:foo:bar"),
timestamp);
cmd->setPriority(priority);
@@ -165,7 +167,7 @@ BouncerTest::testAllowNotifyBucketChangeEvenWhenDistributorDown()
document::BucketId bucket(16, 1234);
api::BucketInfo info(0x1, 0x2, 0x3);
- auto cmd = std::make_shared<api::NotifyBucketChangeCommand>(bucket, info);
+ auto cmd = std::make_shared<api::NotifyBucketChangeCommand>(makeDocumentBucket(bucket), info);
_upper->sendDown(cmd);
CPPUNIT_ASSERT_EQUAL(size_t(0), _upper->getNumReplies());
@@ -246,7 +248,7 @@ BouncerTest::readOnlyOperationsAreNotRejected()
// StatBucket is an external operation, but it's not a mutating operation
// and should therefore not be blocked.
auto cmd = std::make_shared<api::StatBucketCommand>(
- document::BucketId(16, 5), "");
+ makeDocumentBucket(document::BucketId(16, 5)), "");
cmd->setPriority(Priority(2));
_upper->sendDown(cmd);
assertMessageNotBounced();
@@ -258,7 +260,7 @@ BouncerTest::internalOperationsAreNotRejected()
configureRejectionThreshold(Priority(1));
document::BucketId bucket(16, 1234);
api::BucketInfo info(0x1, 0x2, 0x3);
- auto cmd = std::make_shared<api::NotifyBucketChangeCommand>(bucket, info);
+ auto cmd = std::make_shared<api::NotifyBucketChangeCommand>(makeDocumentBucket(bucket), info);
cmd->setPriority(Priority(2));
_upper->sendDown(cmd);
assertMessageNotBounced();
diff --git a/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp b/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp
index e99e97a1e88..53d41051fae 100644
--- a/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp
+++ b/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp
@@ -13,8 +13,11 @@
#include <tests/common/teststorageapp.h>
#include <tests/common/testhelper.h>
#include <tests/common/dummystoragelink.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/storageserver/changedbucketownershiphandler.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
class ChangedBucketOwnershipHandlerTest : public CppUnit::TestFixture
@@ -79,8 +82,8 @@ class ChangedBucketOwnershipHandlerTest : public CppUnit::TestFixture
const lib::ClusterState& state,
const document::BucketId& lastId) const;
- document::BucketId getBucketToAbort() const;
- document::BucketId getBucketToAllow() const;
+ document::Bucket getBucketToAbort() const;
+ document::Bucket getBucketToAllow() const;
void sendAndExpectAbortedCreateBucket(uint16_t fromDistributorIndex);
@@ -383,7 +386,7 @@ ChangedBucketOwnershipHandlerTest::sendAndExpectAbortedCreateBucket(
uint16_t fromDistributorIndex)
{
document::BucketId bucket(16, 6786);
- auto msg = std::make_shared<api::CreateBucketCommand>(bucket);
+ auto msg = std::make_shared<api::CreateBucketCommand>(makeDocumentBucket(bucket));
msg->setSourceIndex(fromDistributorIndex);
_top->sendDown(msg);
@@ -450,22 +453,22 @@ ChangedBucketOwnershipHandlerTest::changeAbortsMessage(MsgParams&&... params)
* Returns a bucket that is not owned by the sending distributor (1). More
* specifically, it returns a bucket that is owned by distributor 2.
*/
-document::BucketId
+document::Bucket
ChangedBucketOwnershipHandlerTest::getBucketToAbort() const
{
lib::ClusterState state(getDefaultTestClusterState());
- return nextOwnedBucket(2, state, document::BucketId());
+ return makeDocumentBucket(nextOwnedBucket(2, state, document::BucketId()));
}
/**
* Returns a bucket that _is_ owned by distributor 1 and should thus be
* allowed through.
*/
-document::BucketId
+document::Bucket
ChangedBucketOwnershipHandlerTest::getBucketToAllow() const
{
lib::ClusterState state(getDefaultTestClusterState());
- return nextOwnedBucket(1, state, document::BucketId());
+ return makeDocumentBucket(nextOwnedBucket(1, state, document::BucketId()));
}
void
diff --git a/storage/src/tests/storageserver/communicationmanagertest.cpp b/storage/src/tests/storageserver/communicationmanagertest.cpp
index c9b3dfeb229..4f9a68a69c2 100644
--- a/storage/src/tests/storageserver/communicationmanagertest.cpp
+++ b/storage/src/tests/storageserver/communicationmanagertest.cpp
@@ -10,8 +10,11 @@
#include <tests/common/teststorageapp.h>
#include <tests/common/dummystoragelink.h>
#include <tests/common/testhelper.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/vdstestlib/cppunit/macros.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
struct CommunicationManagerTest : public CppUnit::TestFixture {
@@ -28,7 +31,7 @@ struct CommunicationManagerTest : public CppUnit::TestFixture {
std::shared_ptr<api::StorageCommand> createDummyCommand(
api::StorageMessage::Priority priority)
{
- auto cmd = std::make_shared<api::GetCommand>(document::BucketId(0),
+ auto cmd = std::make_shared<api::GetCommand>(makeDocumentBucket(document::BucketId(0)),
document::DocumentId("doc::mydoc"),
"[all]");
cmd->setAddress(api::StorageMessageAddress("storage", lib::NodeType::STORAGE, 1));
@@ -78,7 +81,7 @@ void CommunicationManagerTest::testSimple()
// Send a message through from distributor to storage
std::shared_ptr<api::StorageCommand> cmd(
new api::GetCommand(
- document::BucketId(0), document::DocumentId("doc::mydoc"), "[all]"));
+ makeDocumentBucket(document::BucketId(0)), document::DocumentId("doc::mydoc"), "[all]"));
cmd->setAddress(api::StorageMessageAddress(
"storage", lib::NodeType::STORAGE, 1));
distributorLink->sendUp(cmd);
diff --git a/storage/src/tests/storageserver/documentapiconvertertest.cpp b/storage/src/tests/storageserver/documentapiconvertertest.cpp
index 3830d3b71cb..ff261e88922 100644
--- a/storage/src/tests/storageserver/documentapiconvertertest.cpp
+++ b/storage/src/tests/storageserver/documentapiconvertertest.cpp
@@ -13,6 +13,7 @@
#include <vespa/document/bucket/bucketidfactory.h>
#include <vespa/config/subscription/configuri.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <tests/common/make_document_bucket.h>
using document::DataType;
using document::DocIdString;
@@ -20,6 +21,7 @@ using document::Document;
using document::DocumentId;
using document::DocumentTypeRepo;
using document::readDocumenttypesConfig;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -374,7 +376,7 @@ DocumentApiConverterTest::testMultiOperation()
}
{
- api::MultiOperationCommand mocmd(_repo, bucketId, 10000, false);
+ api::MultiOperationCommand mocmd(_repo, makeDocumentBucket(bucketId), 10000, false);
mocmd.getOperations().addPut(*doc, 100);
// Convert it to documentapi
diff --git a/storage/src/tests/storageserver/mergethrottlertest.cpp b/storage/src/tests/storageserver/mergethrottlertest.cpp
index aa0c0667b0d..17503200d10 100644
--- a/storage/src/tests/storageserver/mergethrottlertest.cpp
+++ b/storage/src/tests/storageserver/mergethrottlertest.cpp
@@ -6,6 +6,7 @@
#include <tests/common/storagelinktest.h>
#include <tests/common/teststorageapp.h>
#include <tests/common/dummystoragelink.h>
+#include <tests/common/make_document_bucket.h>
#include <vespa/storage/storageserver/mergethrottler.h>
#include <vespa/storage/persistence/messages.h>
#include <vespa/storageapi/message/bucket.h>
@@ -21,6 +22,7 @@
using namespace document;
using namespace storage::api;
+using storage::test::makeDocumentBucket;
namespace storage {
@@ -99,7 +101,7 @@ struct MergeBuilder {
n.emplace_back(node, source_only);
}
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(_bucket, n, _maxTimestamp,
+ new MergeBucketCommand(makeDocumentBucket(_bucket), n, _maxTimestamp,
_clusterStateVersion, _chain));
StorageMessageAddress address("storage", lib::NodeType::STORAGE, _nodes[0]);
cmd->setAddress(address);
@@ -327,7 +329,7 @@ MergeThrottlerTest::testChain()
}
//std::cout << "\n";
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(bid, nodes, UINT_MAX, 123));
+ new MergeBucketCommand(makeDocumentBucket(bid), nodes, UINT_MAX, 123));
cmd->setPriority(7);
cmd->setTimeout(54321);
StorageMessageAddress address("storage", lib::NodeType::STORAGE, 0);
@@ -486,7 +488,7 @@ MergeThrottlerTest::testWithSourceOnlyNode()
nodes.push_back(2);
nodes.push_back(MergeBucketCommand::Node(1, true));
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(bid, nodes, UINT_MAX, 123));
+ new MergeBucketCommand(makeDocumentBucket(bid), nodes, UINT_MAX, 123));
cmd->setAddress(address);
_topLinks[0]->sendDown(cmd);
@@ -536,7 +538,7 @@ MergeThrottlerTest::test42DistributorBehavior()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(bid, nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(bid), nodes, 1234));
// Send to node 1, which is not the lowest index
StorageMessageAddress address("storage", lib::NodeType::STORAGE, 1);
@@ -579,7 +581,7 @@ MergeThrottlerTest::test42DistributorBehaviorDoesNotTakeOwnership()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(bid, nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(bid), nodes, 1234));
// Send to node 1, which is not the lowest index
StorageMessageAddress address("storage", lib::NodeType::STORAGE, 1);
@@ -637,7 +639,7 @@ MergeThrottlerTest::testEndOfChainExecutionDoesNotTakeOwnership()
chain.push_back(0);
chain.push_back(1);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(bid, nodes, 1234, 1, chain));
+ new MergeBucketCommand(makeDocumentBucket(bid), nodes, 1234, 1, chain));
// Send to last node, which is not the lowest index
StorageMessageAddress address("storage", lib::NodeType::STORAGE, 3);
@@ -692,7 +694,7 @@ MergeThrottlerTest::testResendHandling()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(bid, nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(bid), nodes, 1234));
StorageMessageAddress address("storage", lib::NodeType::STORAGE, 1);
@@ -753,7 +755,7 @@ MergeThrottlerTest::testPriorityQueuing()
CPPUNIT_ASSERT(maxPending >= 4u);
for (std::size_t i = 0; i < maxPending; ++i) {
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00baa00 + i), nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baa00 + i)), nodes, 1234));
cmd->setPriority(100);
_topLinks[0]->sendDown(cmd);
}
@@ -767,7 +769,7 @@ MergeThrottlerTest::testPriorityQueuing()
int sortedPris[4] = { 120, 150, 200, 240 };
for (int i = 0; i < 4; ++i) {
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, i), nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, i)), nodes, 1234));
cmd->setPriority(priorities[i]);
_topLinks[0]->sendDown(cmd);
}
@@ -815,7 +817,7 @@ MergeThrottlerTest::testCommandInQueueDuplicateOfKnownMerge()
nodes.push_back(2 + i);
nodes.push_back(5 + i);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00baa00 + i), nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baa00 + i)), nodes, 1234));
cmd->setPriority(100 - i);
_topLinks[0]->sendDown(cmd);
}
@@ -831,7 +833,7 @@ MergeThrottlerTest::testCommandInQueueDuplicateOfKnownMerge()
nodes.push_back(12);
nodes.push_back(123);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf000feee), nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf000feee)), nodes, 1234));
_topLinks[0]->sendDown(cmd);
}
{
@@ -840,7 +842,7 @@ MergeThrottlerTest::testCommandInQueueDuplicateOfKnownMerge()
nodes.push_back(124); // Different node set doesn't matter
nodes.push_back(14);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf000feee), nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf000feee)), nodes, 1234));
_topLinks[0]->sendDown(cmd);
}
@@ -901,7 +903,7 @@ MergeThrottlerTest::testInvalidReceiverNode()
nodes.push_back(5);
nodes.push_back(9);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00baaaa), nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baaaa)), nodes, 1234));
// Send to node with index 0
_topLinks[0]->sendDown(cmd);
@@ -930,7 +932,7 @@ MergeThrottlerTest::testForwardQueuedMerge()
nodes.push_back(2 + i);
nodes.push_back(5 + i);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00baa00 + i), nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baa00 + i)), nodes, 1234));
cmd->setPriority(100 - i);
_topLinks[0]->sendDown(cmd);
}
@@ -1003,7 +1005,7 @@ MergeThrottlerTest::testExecuteQueuedMerge()
nodes.push_back(5 + i);
nodes.push_back(7 + i);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00baa00 + i), nodes, 1234, 1));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baa00 + i)), nodes, 1234, 1));
cmd->setPriority(250 - i + 5);
topLink.sendDown(cmd);
}
@@ -1021,7 +1023,7 @@ MergeThrottlerTest::testExecuteQueuedMerge()
std::vector<uint16_t> chain;
chain.push_back(0);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0x1337), nodes, 1234, 1, chain));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0x1337)), nodes, 1234, 1, chain));
cmd->setPriority(0);
topLink.sendDown(cmd);
}
@@ -1092,7 +1094,7 @@ MergeThrottlerTest::testFlush()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00baa00 + i), nodes, 1234, 1));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baa00 + i)), nodes, 1234, 1));
_topLinks[0]->sendDown(cmd);
}
@@ -1138,7 +1140,7 @@ MergeThrottlerTest::testUnseenMergeWithNodeInChain()
chain.push_back(5);
chain.push_back(9);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xdeadbeef), nodes, 1234, 1, chain));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xdeadbeef)), nodes, 1234, 1, chain));
StorageMessageAddress address("storage", lib::NodeType::STORAGE, 9);
@@ -1162,7 +1164,7 @@ MergeThrottlerTest::testUnseenMergeWithNodeInChain()
_throttlers[0]->getThrottlePolicy().getMaxPendingCount());
for (std::size_t i = 0; i < maxPending; ++i) {
std::shared_ptr<MergeBucketCommand> fillCmd(
- new MergeBucketCommand(BucketId(32, 0xf00baa00 + i), nodes, 1234));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baa00 + i)), nodes, 1234));
_topLinks[0]->sendDown(fillCmd);
}
}
@@ -1190,7 +1192,7 @@ MergeThrottlerTest::testMergeWithNewerClusterStateFlushesOutdatedQueued()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00baa00 + i), nodes, 1234, 1));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baa00 + i)), nodes, 1234, 1));
ids.push_back(cmd->getMsgId());
_topLinks[0]->sendDown(cmd);
}
@@ -1206,7 +1208,7 @@ MergeThrottlerTest::testMergeWithNewerClusterStateFlushesOutdatedQueued()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0x12345678), nodes, 1234, 2));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0x12345678)), nodes, 1234, 2));
ids.push_back(cmd->getMsgId());
_topLinks[0]->sendDown(cmd);
}
@@ -1241,7 +1243,7 @@ MergeThrottlerTest::testUpdatedClusterStateFlushesOutdatedQueued()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00baa00 + i), nodes, 1234, 2));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baa00 + i)), nodes, 1234, 2));
ids.push_back(cmd->getMsgId());
_topLinks[0]->sendDown(cmd);
}
@@ -1284,7 +1286,7 @@ MergeThrottlerTest::test42MergesDoNotTriggerFlush()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00baa00 + i), nodes, 1234, 1));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00baa00 + i)), nodes, 1234, 1));
_topLinks[0]->sendDown(cmd);
}
@@ -1307,7 +1309,7 @@ MergeThrottlerTest::test42MergesDoNotTriggerFlush()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xbaaadbed), nodes, 1234, 0));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xbaaadbed)), nodes, 1234, 0));
_topLinks[0]->sendDown(cmd);
}
@@ -1334,7 +1336,7 @@ MergeThrottlerTest::testOutdatedClusterStateMergesAreRejectedOnArrival()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xfeef00), nodes, 1234, 9));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xfeef00)), nodes, 1234, 9));
_topLinks[0]->sendDown(cmd);
}
@@ -1364,7 +1366,7 @@ MergeThrottlerTest::testUnknownMergeWithSelfInChain()
std::vector<uint16_t> chain;
chain.push_back(0);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(bid, nodes, 1234, 1, chain));
+ new MergeBucketCommand(makeDocumentBucket(bid), nodes, 1234, 1, chain));
StorageMessageAddress address("storage", lib::NodeType::STORAGE, 1);
@@ -1391,7 +1393,7 @@ MergeThrottlerTest::testBusyReturnedOnFullQueue()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf00000 + i), nodes, 1234, 1));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf00000 + i)), nodes, 1234, 1));
_topLinks[0]->sendDown(cmd);
}
@@ -1408,7 +1410,7 @@ MergeThrottlerTest::testBusyReturnedOnFullQueue()
nodes.push_back(1);
nodes.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xf000baaa), nodes, 1234, 1));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xf000baaa)), nodes, 1234, 1));
_topLinks[0]->sendDown(cmd);
}
_topLinks[0]->waitForMessage(MessageType::MERGEBUCKET_REPLY, _messageWaitTime);
@@ -1441,7 +1443,7 @@ MergeThrottlerTest::testBrokenCycle()
std::vector<uint16_t> chain;
chain.push_back(0);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xfeef00), nodes, 1234, 1, chain));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xfeef00)), nodes, 1234, 1, chain));
_topLinks[1]->sendDown(cmd);
}
@@ -1456,7 +1458,7 @@ MergeThrottlerTest::testBrokenCycle()
chain.push_back(1);
chain.push_back(2);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xfeef00), nodes, 1234, 1, chain));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xfeef00)), nodes, 1234, 1, chain));
_topLinks[1]->sendDown(cmd);
}
@@ -1491,7 +1493,7 @@ MergeThrottlerTest::testBrokenCycle()
std::vector<uint16_t> chain;
chain.push_back(0);
std::shared_ptr<MergeBucketCommand> cmd(
- new MergeBucketCommand(BucketId(32, 0xfeef00), nodes, 1234, 1, chain));
+ new MergeBucketCommand(makeDocumentBucket(BucketId(32, 0xfeef00)), nodes, 1234, 1, chain));
_topLinks[1]->sendDown(cmd);
}
@@ -1521,7 +1523,7 @@ MergeThrottlerTest::testGetBucketDiffCommandNotInActiveSetIsRejected()
document::BucketId bucket(16, 1234);
std::vector<api::GetBucketDiffCommand::Node> nodes;
std::shared_ptr<api::GetBucketDiffCommand> getDiffCmd(
- new api::GetBucketDiffCommand(bucket, nodes, api::Timestamp(1234)));
+ new api::GetBucketDiffCommand(makeDocumentBucket(bucket), nodes, api::Timestamp(1234)));
sendAndExpectReply(getDiffCmd,
api::MessageType::GETBUCKETDIFF_REPLY,
@@ -1535,7 +1537,7 @@ MergeThrottlerTest::testApplyBucketDiffCommandNotInActiveSetIsRejected()
document::BucketId bucket(16, 1234);
std::vector<api::GetBucketDiffCommand::Node> nodes;
std::shared_ptr<api::ApplyBucketDiffCommand> applyDiffCmd(
- new api::ApplyBucketDiffCommand(bucket, nodes, api::Timestamp(1234)));
+ new api::ApplyBucketDiffCommand(makeDocumentBucket(bucket), nodes, api::Timestamp(1234)));
sendAndExpectReply(applyDiffCmd,
api::MessageType::APPLYBUCKETDIFF_REPLY,
@@ -1571,7 +1573,7 @@ MergeThrottlerTest::testNewClusterStateAbortsAllOutdatedActiveMerges()
// Trying to diff the bucket should now fail
{
std::shared_ptr<api::GetBucketDiffCommand> getDiffCmd(
- new api::GetBucketDiffCommand(bucket, {}, api::Timestamp(123)));
+ new api::GetBucketDiffCommand(makeDocumentBucket(bucket), {}, api::Timestamp(123)));
sendAndExpectReply(getDiffCmd,
api::MessageType::GETBUCKETDIFF_REPLY,
diff --git a/storage/src/tests/visiting/visitormanagertest.cpp b/storage/src/tests/visiting/visitormanagertest.cpp
index 3f1e9b69963..017da4e4904 100644
--- a/storage/src/tests/visiting/visitormanagertest.cpp
+++ b/storage/src/tests/visiting/visitormanagertest.cpp
@@ -12,6 +12,7 @@
#include <tests/common/teststorageapp.h>
#include <tests/common/testhelper.h>
#include <tests/common/dummystoragelink.h>
+#include <tests/common/make_document_bucket.h>
#include <tests/storageserver/testvisitormessagesession.h>
#include <vespa/documentapi/messagebus/messages/multioperationmessage.h>
#include <vespa/documentapi/messagebus/messages/putdocumentmessage.h>
@@ -19,6 +20,8 @@
#include <vespa/config/common/exceptions.h>
#include <vespa/vespalib/util/exceptions.h>
+using storage::test::makeDocumentBucket;
+
namespace storage {
namespace {
typedef std::vector<api::StorageMessage::SP> msg_ptr_vector;
@@ -182,7 +185,7 @@ VisitorManagerTest::initializeTest()
document::BucketId bid(16, i);
std::shared_ptr<api::CreateBucketCommand> cmd(
- new api::CreateBucketCommand(bid));
+ new api::CreateBucketCommand(makeDocumentBucket(bid)));
cmd->setAddress(address);
cmd->setSourceIndex(0);
_top->sendDown(cmd);
@@ -199,7 +202,7 @@ VisitorManagerTest::initializeTest()
document::BucketId bid(16, i);
std::shared_ptr<api::PutCommand> cmd(
- new api::PutCommand(bid, _documents[i], i+1));
+ new api::PutCommand(makeDocumentBucket(bid), _documents[i], i+1));
cmd->setAddress(address);
_top->sendDown(cmd);
_top->waitForMessages(1, 60);
@@ -224,7 +227,7 @@ VisitorManagerTest::addSomeRemoves(bool removeAll)
document::BucketId bid(16, i % 10);
std::shared_ptr<api::RemoveCommand> cmd(
new api::RemoveCommand(
- bid, _documents[i]->getId(), clock.getTimeInMicros().getTime() + docCount + i + 1));
+ makeDocumentBucket(bid), _documents[i]->getId(), clock.getTimeInMicros().getTime() + docCount + i + 1));
cmd->setAddress(address);
_top->sendDown(cmd);
_top->waitForMessages(1, 60);
diff --git a/storage/src/vespa/storage/distributor/operations/external/getoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/getoperation.cpp
index ec1a9bb9afe..20a804180f5 100644
--- a/storage/src/vespa/storage/distributor/operations/external/getoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/getoperation.cpp
@@ -9,6 +9,8 @@
#include <vespa/log/log.h>
LOG_SETUP(".distributor.callback.doc.get");
+using document::BucketSpace;
+
namespace storage::distributor {
GetOperation::GroupId::GroupId(const document::BucketId& id,
@@ -98,9 +100,10 @@ GetOperation::sendForChecksum(DistributorMessageSender& sender,
const int best = findBestUnsentTarget(res);
if (best != -1) {
+ document::Bucket bucket(BucketSpace::placeHolder(), id);
std::shared_ptr<api::GetCommand> command(
std::make_shared<api::GetCommand>(
- id,
+ bucket,
_msg->getDocumentId(),
_msg->getFieldSet(),
_msg->getBeforeTimestamp()));
diff --git a/storage/src/vespa/storage/distributor/operations/external/multioperationoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/multioperationoperation.cpp
index 2252ba85ad3..a3fb083890b 100644
--- a/storage/src/vespa/storage/distributor/operations/external/multioperationoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/multioperationoperation.cpp
@@ -8,6 +8,8 @@
#include <vespa/log/log.h>
LOG_SETUP(".distributor.callback.doc.multioperation");
+using document::BucketSpace;
+
namespace storage::distributor {
MultiOperationOperation::MultiOperationOperation(
@@ -190,11 +192,12 @@ MultiOperationOperation::onStart(DistributorMessageSender& sender)
}
assert(blockSize > 4);
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketIt->first);
//now create a MultiOperationCommand with the new DocumentList
std::shared_ptr<api::MultiOperationCommand>
command(new api::MultiOperationCommand(
_manager.getTypeRepo(),
- bucketIt->first, blockSize));
+ bucket, blockSize));
copyMessageSettings(*_msg, *command);
LOG(debug, "Block size %d", blockSize);
diff --git a/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp
index 2b5820303fb..9b6390c149a 100644
--- a/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp
@@ -18,6 +18,7 @@ LOG_SETUP(".distributor.callback.doc.put");
using namespace storage::distributor;
using namespace storage;
+using document::BucketSpace;
PutOperation::PutOperation(DistributorComponent& manager,
const std::shared_ptr<api::PutCommand> & msg,
@@ -115,8 +116,9 @@ PutOperation::checkCreateBucket(const lib::Distribution& dist,
// Send create buckets for all nodes in ideal state where we don't
// currently have copies.
for (uint32_t i = 0; i < createNodes.size(); i++) {
+ document::Bucket bucket(BucketSpace::placeHolder(), entry.getBucketId());
std::shared_ptr<api::CreateBucketCommand> cbc(
- new api::CreateBucketCommand(entry.getBucketId()));
+ new api::CreateBucketCommand(bucket));
if (active.contains(createNodes[i])) {
BucketCopy copy(*entry->getNode(createNodes[i]));
copy.setActive(true);
@@ -205,8 +207,9 @@ PutOperation::insertDatabaseEntryAndScheduleCreateBucket(
}
for (uint32_t i=0, n=copies.size(); i<n; ++i) {
if (!copies[i].isNewCopy()) continue;
+ document::Bucket bucket(BucketSpace::placeHolder(), copies[i].getBucketId());
std::shared_ptr<api::CreateBucketCommand> cbc(
- new api::CreateBucketCommand(copies[i].getBucketId()));
+ new api::CreateBucketCommand(bucket));
if (setOneActive && active.contains(copies[i].getNode().getIndex())) {
cbc->setActive(true);
}
@@ -225,9 +228,10 @@ PutOperation::sendPutToBucketOnNode(
const uint16_t node,
std::vector<PersistenceMessageTracker::ToSend>& putBatch)
{
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
std::shared_ptr<api::PutCommand> command(
new api::PutCommand(
- bucketId,
+ bucket,
_msg->getDocument(),
_msg->getTimestamp()));
LOG(debug,
diff --git a/storage/src/vespa/storage/distributor/operations/external/removelocationoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/removelocationoperation.cpp
index fecfc368e22..8f19dabea92 100644
--- a/storage/src/vespa/storage/distributor/operations/external/removelocationoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/removelocationoperation.cpp
@@ -13,6 +13,7 @@ LOG_SETUP(".distributor.callback.doc.removelocation");
using namespace storage::distributor;
using namespace storage;
+using document::BucketSpace;
RemoveLocationOperation::RemoveLocationOperation(
DistributorComponent& manager,
@@ -79,7 +80,7 @@ RemoveLocationOperation::onStart(DistributorMessageSender& sender)
std::shared_ptr<api::RemoveLocationCommand> command(
new api::RemoveLocationCommand(
_msg->getDocumentSelection(),
- e.getBucketId()));
+ document::Bucket(BucketSpace::placeHolder(), e.getBucketId())));
copyMessageSettings(*_msg, *command);
_tracker.queueCommand(command, nodes[i]);
diff --git a/storage/src/vespa/storage/distributor/operations/external/removeoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/removeoperation.cpp
index 12c899816ad..84df38efad6 100644
--- a/storage/src/vespa/storage/distributor/operations/external/removeoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/removeoperation.cpp
@@ -8,6 +8,7 @@ LOG_SETUP(".distributor.operation.external.remove");
using namespace storage::distributor;
using namespace storage;
+using document::BucketSpace;
RemoveOperation::RemoveOperation(DistributorComponent& manager,
const std::shared_ptr<api::RemoveCommand> & msg,
@@ -45,7 +46,7 @@ RemoveOperation::onStart(DistributorMessageSender& sender)
for (uint32_t i = 0; i < e->getNodeCount(); i++) {
std::shared_ptr<api::RemoveCommand> command(new api::RemoveCommand(
- e.getBucketId(),
+ document::Bucket(BucketSpace::placeHolder(), e.getBucketId()),
_msg->getDocumentId(),
_msg->getTimestamp()));
diff --git a/storage/src/vespa/storage/distributor/operations/external/statbucketoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/statbucketoperation.cpp
index 2698d8f1720..cb395d42c9a 100644
--- a/storage/src/vespa/storage/distributor/operations/external/statbucketoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/statbucketoperation.cpp
@@ -51,7 +51,7 @@ StatBucketOperation::onStart(DistributorMessageSender& sender)
for (uint32_t i = 0; i < nodes.size(); i++) {
std::shared_ptr<api::StatBucketCommand> cmd(
new api::StatBucketCommand(
- _command->getBucketId(),
+ _command->getBucket(),
_command->getDocumentSelection()));
messages.push_back(cmd);
diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
index 5ca874d33d5..c05bddc83de 100644
--- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
@@ -15,6 +15,7 @@
LOG_SETUP(".distributor.callback.twophaseupdate");
using namespace std::literals::string_literals;
+using document::BucketSpace;
namespace storage {
namespace distributor {
@@ -180,9 +181,10 @@ TwoPhaseUpdateOperation::startSafePathUpdate(DistributorMessageSender& sender)
_updateCmd->getDocumentId().toString().c_str());
_mode = Mode::SLOW_PATH;
+ document::Bucket bucket(BucketSpace::placeHolder(), document::BucketId(0));
std::shared_ptr<api::GetCommand> get(
std::make_shared<api::GetCommand>(
- document::BucketId(0),
+ bucket,
_updateCmd->getDocumentId(),
"[all]"));
copyMessageSettings(*_updateCmd, *get);
@@ -249,8 +251,9 @@ TwoPhaseUpdateOperation::schedulePutsWithUpdatedDocument(
sendLostOwnershipTransientErrorReply(sender);
return;
}
+ document::Bucket bucket(BucketSpace::placeHolder(), document::BucketId(0));
std::shared_ptr<api::PutCommand> put(
- new api::PutCommand(document::BucketId(0), doc, putTimestamp));
+ new api::PutCommand(bucket, doc, putTimestamp));
copyMessageSettings(*_updateCmd, *put);
std::shared_ptr<PutOperation> putOperation(
new PutOperation(_manager, put, _putMetric));
@@ -336,8 +339,9 @@ TwoPhaseUpdateOperation::handleFastPathReceive(
_updateCmd->getDocumentId().toString().c_str());
_updateReply = intermediate._reply;
+ document::Bucket bucket(BucketSpace::placeHolder(), bestNode.first);
std::shared_ptr<api::GetCommand> cmd(
- new api::GetCommand(bestNode.first,
+ new api::GetCommand(bucket,
_updateCmd->getDocumentId(),
"[all]"));
copyMessageSettings(*_updateCmd, *cmd);
diff --git a/storage/src/vespa/storage/distributor/operations/external/updateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/updateoperation.cpp
index 44106836500..f2aca874691 100644
--- a/storage/src/vespa/storage/distributor/operations/external/updateoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/updateoperation.cpp
@@ -12,6 +12,7 @@ LOG_SETUP(".distributor.callback.doc.update");
using namespace storage::distributor;
using namespace storage;
+using document::BucketSpace;
UpdateOperation::UpdateOperation(DistributorComponent& manager,
const std::shared_ptr<api::UpdateCommand> & msg,
@@ -90,7 +91,7 @@ UpdateOperation::onStart(DistributorMessageSender& sender)
for (uint32_t i = 0; i < nodes.size(); i++) {
std::shared_ptr<api::UpdateCommand> command(
- new api::UpdateCommand(entries[j].getBucketId(),
+ new api::UpdateCommand(document::Bucket(BucketSpace::placeHolder(), entries[j].getBucketId()),
_msg->getUpdate(),
_msg->getTimestamp()));
copyMessageSettings(*_msg, *command);
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp
index 92a3f05cae5..c1d95ac1c92 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp
@@ -28,7 +28,7 @@ GarbageCollectionOperation::onStart(DistributorMessageSender& sender)
std::shared_ptr<api::RemoveLocationCommand> command(
new api::RemoveLocationCommand(
_manager->getDistributorComponent().getDistributor().getConfig().getGarbageCollectionSelection(),
- getBucketId()));
+ getBucket()));
command->setPriority(_priority);
_tracker.queueCommand(command, nodes[i]);
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h
index a409b14e70a..e0d96296b83 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h
@@ -57,6 +57,8 @@ public:
*/
const document::BucketId& getBucketId() const { return _id; }
+ document::Bucket getBucket() const { return document::Bucket(document::BucketSpace::placeHolder(), _id); }
+
/**
Returns the target nodes
@@ -142,6 +144,8 @@ public:
*/
const document::BucketId& getBucketId() const { return _bucketAndNodes.getBucketId(); }
+ document::Bucket getBucket() const { return _bucketAndNodes.getBucket(); }
+
/**
Returns the target of the operation.
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp
index 536c9d764be..a73048e822a 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp
@@ -74,7 +74,7 @@ JoinOperation::enqueueJoinMessagePerTargetNode(
}
for (const auto& node : nodeToBuckets) {
std::shared_ptr<api::JoinBucketsCommand> msg(
- new api::JoinBucketsCommand(getBucketId()));
+ new api::JoinBucketsCommand(getBucket()));
msg->getSourceBuckets() = node.second;
msg->setTimeout(INT_MAX);
setCommandMeta(*msg);
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
index 28381af4021..1b161b2c5f7 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
@@ -138,7 +138,7 @@ MergeOperation::onStart(DistributorMessageSender& sender)
if (_mnodes.size() > 1) {
auto msg = std::make_shared<api::MergeBucketCommand>(
- getBucketId(),
+ getBucket(),
_mnodes,
_manager->getDistributorComponent().getUniqueTimestamp(),
clusterState.getVersion());
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.cpp
index 78fd2f1917a..e3b19848a89 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.cpp
@@ -30,7 +30,7 @@ RemoveBucketOperation::onStartInternal(DistributorMessageSender& sender)
getBucketId().toString().c_str(),
node);
std::shared_ptr<api::DeleteBucketCommand> msg(
- new api::DeleteBucketCommand(getBucketId()));
+ new api::DeleteBucketCommand(getBucket()));
setCommandMeta(*msg);
msg->setBucketInfo(copy->getBucketInfo());
msgs.push_back(std::make_pair(node, msg));
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp
index 4bbb061b113..f3528d30aba 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp
@@ -22,7 +22,7 @@ void
SetBucketStateOperation::enqueueSetBucketStateCommand(uint16_t node, bool active) {
std::shared_ptr<api::SetBucketStateCommand> msg(
new api::SetBucketStateCommand(
- getBucketId(),
+ getBucket(),
active
? api::SetBucketStateCommand::ACTIVE
: api::SetBucketStateCommand::INACTIVE));
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp
index a75a56b63c9..1e6fc84adbd 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp
@@ -31,7 +31,7 @@ SplitOperation::onStart(DistributorMessageSender& sender)
for (uint32_t i = 0; i < entry->getNodeCount(); i++) {
std::shared_ptr<api::SplitBucketCommand> msg(
- new api::SplitBucketCommand(getBucketId()));
+ new api::SplitBucketCommand(getBucket()));
msg->setMaxSplitBits(_maxBits);
msg->setMinDocCount(_splitCount);
msg->setMinByteSize(_splitSize);
diff --git a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
index a35a19b4f71..446a80f85ab 100644
--- a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
+++ b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
@@ -93,8 +93,9 @@ PersistenceMessageTrackerImpl::revert(
reverts.push_back(_revertTimestamp);
for (uint32_t i = 0; i < revertNodes.size(); i++) {
+ document::Bucket bucket(document::BucketSpace::placeHolder(), revertNodes[i].first);
std::shared_ptr<api::RevertCommand> toRevert(
- new api::RevertCommand(revertNodes[i].first, reverts));
+ new api::RevertCommand(bucket, reverts));
toRevert->setPriority(_priority);
queueCommand(toRevert, revertNodes[i].second);
}
diff --git a/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp b/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp
index c492dd4b55e..c2669e4b43c 100644
--- a/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp
+++ b/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp
@@ -10,6 +10,8 @@
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".persistence.bucketownershipnotifier");
+using document::BucketSpace;
+
namespace storage {
uint16_t
@@ -59,7 +61,7 @@ BucketOwnershipNotifier::sendNotifyBucketToDistributor(
return;
}
api::NotifyBucketChangeCommand::SP notifyCmd(
- new api::NotifyBucketChangeCommand(bucket, infoToSend));
+ new api::NotifyBucketChangeCommand(document::Bucket(BucketSpace::placeHolder(), bucket), infoToSend));
notifyCmd->setAddress(api::StorageMessageAddress(
_component.getClusterName(),
diff --git a/storage/src/vespa/storage/persistence/mergehandler.cpp b/storage/src/vespa/storage/persistence/mergehandler.cpp
index 88bca44558c..0b3b1558562 100644
--- a/storage/src/vespa/storage/persistence/mergehandler.cpp
+++ b/storage/src/vespa/storage/persistence/mergehandler.cpp
@@ -808,7 +808,7 @@ MergeHandler::processBucketMerge(const spi::Bucket& bucket, MergeStatus& status,
: _maxChunkSize);
cmd.reset(new api::ApplyBucketDiffCommand(
- bucket.getBucketId(), nodes, maxSize));
+ bucket.getBucket(), nodes, maxSize));
cmd->setAddress(createAddress(_env._component.getClusterName(),
nodes[1].index));
findCandidates(bucket.getBucketId(),
@@ -885,7 +885,7 @@ MergeHandler::processBucketMerge(const spi::Bucket& bucket, MergeStatus& status,
? std::numeric_limits<uint32_t>().max()
: _maxChunkSize);
cmd.reset(new api::ApplyBucketDiffCommand(
- bucket.getBucketId(), nodes, maxSize));
+ bucket.getBucket(), nodes, maxSize));
cmd->setAddress(
createAddress(_env._component.getClusterName(),
nodes[1].index));
@@ -901,7 +901,7 @@ MergeHandler::processBucketMerge(const spi::Bucket& bucket, MergeStatus& status,
// If we found no group big enough to handle on its own, do a common
// merge to merge the remaining data.
if (cmd.get() == 0) {
- cmd.reset(new api::ApplyBucketDiffCommand(bucket.getBucketId(),
+ cmd.reset(new api::ApplyBucketDiffCommand(bucket.getBucket(),
status.nodeList,
_maxChunkSize));
cmd->setAddress(createAddress(_env._component.getClusterName(),
@@ -1008,7 +1008,7 @@ MergeHandler::handleMergeBucket(api::MergeBucketCommand& cmd,
s->startTime = framework::MilliSecTimer(_env._component.getClock());
std::shared_ptr<api::GetBucketDiffCommand> cmd2(
- new api::GetBucketDiffCommand(id,
+ new api::GetBucketDiffCommand(bucket.getBucket(),
s->nodeList,
s->maxTimestamp.getTime()));
if (!buildBucketInfoList(bucket,
@@ -1255,7 +1255,7 @@ MergeHandler::handleGetBucketDiff(api::GetBucketDiffCommand& cmd,
local.size() - remote.size());
std::shared_ptr<api::GetBucketDiffCommand> cmd2(
new api::GetBucketDiffCommand(
- id, cmd.getNodes(), cmd.getMaxTimestamp()));
+ bucket.getBucket(), cmd.getNodes(), cmd.getMaxTimestamp()));
cmd2->setAddress(createAddress(_env._component.getClusterName(),
cmd.getNodes()[index + 1].index));
cmd2->getDiff().swap(local);
@@ -1463,7 +1463,7 @@ MergeHandler::handleApplyBucketDiff(api::ApplyBucketDiffCommand& cmd,
bucket.toString().c_str(), cmd.getNodes()[index + 1].index);
std::shared_ptr<api::ApplyBucketDiffCommand> cmd2(
new api::ApplyBucketDiffCommand(
- id, cmd.getNodes(), cmd.getMaxBufferSize()));
+ bucket.getBucket(), cmd.getNodes(), cmd.getMaxBufferSize()));
cmd2->setAddress(createAddress(_env._component.getClusterName(),
cmd.getNodes()[index + 1].index));
cmd2->getDiff().swap(cmd.getDiff());
diff --git a/storage/src/vespa/storage/storageserver/documentapiconverter.cpp b/storage/src/vespa/storage/storageserver/documentapiconverter.cpp
index 59f3a1f6a27..0602cb6de38 100644
--- a/storage/src/vespa/storage/storageserver/documentapiconverter.cpp
+++ b/storage/src/vespa/storage/storageserver/documentapiconverter.cpp
@@ -17,6 +17,8 @@
#include <vespa/log/log.h>
LOG_SETUP(".documentapiconverter");
+using document::BucketSpace;
+
namespace storage {
DocumentApiConverter::DocumentApiConverter(const config::ConfigUri & configUri)
@@ -36,7 +38,7 @@ DocumentApiConverter::toStorageAPI(documentapi::DocumentMessage& fromMsg,
case DocumentProtocol::MESSAGE_PUTDOCUMENT:
{
documentapi::PutDocumentMessage& from(static_cast<documentapi::PutDocumentMessage&>(fromMsg));
- auto to = std::make_unique<api::PutCommand>(document::BucketId(0), from.stealDocument(), from.getTimestamp());
+ auto to = std::make_unique<api::PutCommand>(document::Bucket(BucketSpace::placeHolder(), document::BucketId(0)), from.stealDocument(), from.getTimestamp());
to->setCondition(from.getCondition());
toMsg = std::move(to);
break;
@@ -44,7 +46,7 @@ DocumentApiConverter::toStorageAPI(documentapi::DocumentMessage& fromMsg,
case DocumentProtocol::MESSAGE_UPDATEDOCUMENT:
{
documentapi::UpdateDocumentMessage& from(static_cast<documentapi::UpdateDocumentMessage&>(fromMsg));
- auto to = std::make_unique<api::UpdateCommand>(document::BucketId(0), from.stealDocumentUpdate(),
+ auto to = std::make_unique<api::UpdateCommand>(document::Bucket(BucketSpace::placeHolder(), document::BucketId(0)), from.stealDocumentUpdate(),
from.getNewTimestamp());
to->setOldTimestamp(from.getOldTimestamp());
to->setCondition(from.getCondition());
@@ -54,7 +56,7 @@ DocumentApiConverter::toStorageAPI(documentapi::DocumentMessage& fromMsg,
case DocumentProtocol::MESSAGE_REMOVEDOCUMENT:
{
documentapi::RemoveDocumentMessage& from(static_cast<documentapi::RemoveDocumentMessage&>(fromMsg));
- auto to = std::make_unique<api::RemoveCommand>(document::BucketId(0), from.getDocumentId(), 0);
+ auto to = std::make_unique<api::RemoveCommand>(document::Bucket(BucketSpace::placeHolder(), document::BucketId(0)), from.getDocumentId(), 0);
to->setCondition(from.getCondition());
toMsg = std::move(to);
break;
@@ -62,7 +64,7 @@ DocumentApiConverter::toStorageAPI(documentapi::DocumentMessage& fromMsg,
case DocumentProtocol::MESSAGE_GETDOCUMENT:
{
documentapi::GetDocumentMessage& from(static_cast<documentapi::GetDocumentMessage&>(fromMsg));
- auto to = std::make_unique<api::GetCommand>(document::BucketId(0), from.getDocumentId(), from.getFieldSet());
+ auto to = std::make_unique<api::GetCommand>(document::Bucket(BucketSpace::placeHolder(), document::BucketId(0)), from.getDocumentId(), from.getFieldSet());
toMsg.reset(to.release());
break;
}
@@ -97,7 +99,7 @@ DocumentApiConverter::toStorageAPI(documentapi::DocumentMessage& fromMsg,
case DocumentProtocol::MESSAGE_MULTIOPERATION:
{
documentapi::MultiOperationMessage& from(static_cast<documentapi::MultiOperationMessage&>(fromMsg));
- toMsg = std::make_unique<api::MultiOperationCommand>(repo, from.getBucketId(), from.getBuffer(),
+ toMsg = std::make_unique<api::MultiOperationCommand>(repo, document::Bucket(BucketSpace::placeHolder(), from.getBucketId()), from.getBuffer(),
from.keepTimeStamps());
break;
}
@@ -110,13 +112,13 @@ DocumentApiConverter::toStorageAPI(documentapi::DocumentMessage& fromMsg,
case DocumentProtocol::MESSAGE_STATBUCKET:
{
documentapi::StatBucketMessage& from(static_cast<documentapi::StatBucketMessage&>(fromMsg));
- toMsg = std::make_unique<api::StatBucketCommand>(from.getBucketId(), from.getDocumentSelection());
+ toMsg = std::make_unique<api::StatBucketCommand>(document::Bucket(BucketSpace::placeHolder(), from.getBucketId()), from.getDocumentSelection());
break;
}
case DocumentProtocol::MESSAGE_GETBUCKETLIST:
{
documentapi::GetBucketListMessage& from(static_cast<documentapi::GetBucketListMessage&>(fromMsg));
- toMsg = std::make_unique<api::GetBucketListCommand>(from.getBucketId());
+ toMsg = std::make_unique<api::GetBucketListCommand>(document::Bucket(BucketSpace::placeHolder(), from.getBucketId()));
break;
}
case DocumentProtocol::MESSAGE_VISITORINFO:
@@ -135,7 +137,7 @@ DocumentApiConverter::toStorageAPI(documentapi::DocumentMessage& fromMsg,
case DocumentProtocol::MESSAGE_REMOVELOCATION:
{
documentapi::RemoveLocationMessage& from(static_cast<documentapi::RemoveLocationMessage&>(fromMsg));
- api::RemoveLocationCommand::UP to(new api::RemoveLocationCommand(from.getDocumentSelection(), document::BucketId(0)));
+ api::RemoveLocationCommand::UP to(new api::RemoveLocationCommand(from.getDocumentSelection(), document::Bucket(BucketSpace::placeHolder(), document::BucketId(0))));
toMsg.reset(to.release());
break;
}
diff --git a/storage/src/vespa/storage/storageserver/mergethrottler.cpp b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
index 943059c00fc..be30c459bdf 100644
--- a/storage/src/vespa/storage/storageserver/mergethrottler.cpp
+++ b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
@@ -368,7 +368,7 @@ MergeThrottler::forwardCommandToNode(
std::shared_ptr<api::MergeBucketCommand> fwdMerge(
std::make_shared<api::MergeBucketCommand>(
- mergeCmd.getBucketId(),
+ mergeCmd.getBucket(),
mergeCmd.getNodes(),
mergeCmd.getMaxTimestamp(),
mergeCmd.getClusterStateVersion(),
diff --git a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp
index 4d5a33b1dec..f03c59f0887 100644
--- a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp
+++ b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp
@@ -22,6 +22,7 @@
#include <sstream>
using std::shared_ptr;
+using document::BucketSpace;
using document::ByteBuffer;
using document::Document;
using document::DocumentId;
@@ -33,11 +34,20 @@ using vespalib::string;
namespace storage {
namespace api {
+namespace {
+
+document::Bucket makeDocumentBucket(document::BucketId bucketId)
+{
+ return document::Bucket(BucketSpace::placeHolder(), bucketId);
+}
+
+}
+
struct StorageProtocolTest : public CppUnit::TestFixture {
document::TestDocMan _docMan;
document::Document::SP _testDoc;
document::DocumentId _testDocId;
- document::BucketId _bucket{16, 0x51};
+ document::Bucket _bucket;
vespalib::Version _version5_0{5, 0, 12};
vespalib::Version _version5_1{5, 1, 0};
vespalib::Version _version5_2{5, 93, 30};
@@ -52,6 +62,7 @@ struct StorageProtocolTest : public CppUnit::TestFixture {
: _docMan(),
_testDoc(_docMan.createDocument()),
_testDocId(_testDoc->getId()),
+ _bucket(makeDocumentBucket(document::BucketId(16, 0x51))),
_protocol(_docMan.getTypeRepoSP(), _loadTypes)
{
_loadTypes.addLoadType(34, "foo", documentapi::Priority::PRI_NORMAL_2);
@@ -427,8 +438,10 @@ StorageProtocolTest::testNotifyBucketChange51()
{
ScopedName test("testNotifyBucketChange51");
BucketInfo info(2, 3, 4);
+ document::BucketId modifiedBucketId(20, 1000);
+ document::Bucket modifiedBucket(makeDocumentBucket(modifiedBucketId));
NotifyBucketChangeCommand::SP cmd(new NotifyBucketChangeCommand(
- document::BucketId(20, 1000), info));
+ modifiedBucket, info));
NotifyBucketChangeCommand::SP cmd2(copyCommand(cmd, _version5_1));
CPPUNIT_ASSERT_EQUAL(document::BucketId(20, 1000),
cmd2->getBucketId());
@@ -446,15 +459,16 @@ void
StorageProtocolTest::testCreateBucket51()
{
ScopedName test("testCreateBucket51");
- document::BucketId id(623);
+ document::BucketId bucketId(623);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
- CreateBucketCommand::SP cmd(new CreateBucketCommand(id));
+ CreateBucketCommand::SP cmd(new CreateBucketCommand(bucket));
CreateBucketCommand::SP cmd2(copyCommand(cmd, _version5_1));
- CPPUNIT_ASSERT_EQUAL(id, cmd2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, cmd2->getBucketId());
CreateBucketReply::SP reply(new CreateBucketReply(*cmd));
CreateBucketReply::SP reply2(copyReply(reply));
- CPPUNIT_ASSERT_EQUAL(id, reply2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, reply2->getBucketId());
recordOutput(*cmd2);
recordOutput(*reply2);
@@ -465,20 +479,21 @@ void
StorageProtocolTest::testDeleteBucket51()
{
ScopedName test("testDeleteBucket51");
- document::BucketId id(623);
+ document::BucketId bucketId(623);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
- DeleteBucketCommand::SP cmd(new DeleteBucketCommand(id));
+ DeleteBucketCommand::SP cmd(new DeleteBucketCommand(bucket));
BucketInfo info(0x100, 200, 300);
cmd->setBucketInfo(info);
DeleteBucketCommand::SP cmd2(copyCommand(cmd, _version5_1));
- CPPUNIT_ASSERT_EQUAL(id, cmd2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, cmd2->getBucketId());
CPPUNIT_ASSERT_EQUAL(info, cmd2->getBucketInfo());
DeleteBucketReply::SP reply(new DeleteBucketReply(*cmd));
// Not set automatically by constructor
reply->setBucketInfo(cmd2->getBucketInfo());
DeleteBucketReply::SP reply2(copyReply(reply));
- CPPUNIT_ASSERT_EQUAL(id, reply2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, reply2->getBucketId());
CPPUNIT_ASSERT_EQUAL(info, reply2->getBucketInfo());
recordOutput(*cmd2);
@@ -490,7 +505,8 @@ void
StorageProtocolTest::testMergeBucket51()
{
ScopedName test("testMergeBucket51");
- document::BucketId id(623);
+ document::BucketId bucketId(623);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
typedef api::MergeBucketCommand::Node Node;
std::vector<Node> nodes;
@@ -504,9 +520,9 @@ StorageProtocolTest::testMergeBucket51()
chain.push_back(14);
MergeBucketCommand::SP cmd(
- new MergeBucketCommand(id, nodes, Timestamp(1234), 567, chain));
+ new MergeBucketCommand(bucket, nodes, Timestamp(1234), 567, chain));
MergeBucketCommand::SP cmd2(copyCommand(cmd, _version5_1));
- CPPUNIT_ASSERT_EQUAL(id, cmd2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, cmd2->getBucketId());
CPPUNIT_ASSERT_EQUAL(nodes, cmd2->getNodes());
CPPUNIT_ASSERT_EQUAL(Timestamp(1234), cmd2->getMaxTimestamp());
CPPUNIT_ASSERT_EQUAL(uint32_t(567), cmd2->getClusterStateVersion());
@@ -514,7 +530,7 @@ StorageProtocolTest::testMergeBucket51()
MergeBucketReply::SP reply(new MergeBucketReply(*cmd));
MergeBucketReply::SP reply2(copyReply(reply));
- CPPUNIT_ASSERT_EQUAL(id, reply2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, reply2->getBucketId());
CPPUNIT_ASSERT_EQUAL(nodes, reply2->getNodes());
CPPUNIT_ASSERT_EQUAL(Timestamp(1234), reply2->getMaxTimestamp());
CPPUNIT_ASSERT_EQUAL(uint32_t(567), reply2->getClusterStateVersion());
@@ -530,7 +546,8 @@ StorageProtocolTest::testSplitBucket51()
{
ScopedName test("testSplitBucket51");
- document::BucketId bucket(16, 0);
+ document::BucketId bucketId(16, 0);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
SplitBucketCommand::SP cmd(new SplitBucketCommand(bucket));
CPPUNIT_ASSERT_EQUAL(0u, (uint32_t) cmd->getMinSplitBits());
CPPUNIT_ASSERT_EQUAL(58u, (uint32_t) cmd->getMaxSplitBits());
@@ -555,7 +572,7 @@ StorageProtocolTest::testSplitBucket51()
document::BucketId(17, 1), BucketInfo(101, 1001, 10001, true, true)));
SplitBucketReply::SP reply2(copyReply(reply));
- CPPUNIT_ASSERT_EQUAL(bucket, reply2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, reply2->getBucketId());
CPPUNIT_ASSERT_EQUAL(size_t(2), reply2->getSplitInfo().size());
CPPUNIT_ASSERT_EQUAL(document::BucketId(17, 0),
reply2->getSplitInfo()[0].first);
@@ -575,7 +592,8 @@ void
StorageProtocolTest::testJoinBuckets51()
{
ScopedName test("testJoinBuckets51");
- document::BucketId bucket(16, 0);
+ document::BucketId bucketId(16, 0);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
std::vector<document::BucketId> sources;
sources.push_back(document::BucketId(17, 0));
sources.push_back(document::BucketId(17, 1));
@@ -591,7 +609,7 @@ StorageProtocolTest::testJoinBuckets51()
CPPUNIT_ASSERT_EQUAL(sources, reply2->getSourceBuckets());
CPPUNIT_ASSERT_EQUAL(3, (int)cmd2->getMinJoinBits());
CPPUNIT_ASSERT_EQUAL(BucketInfo(3,4,5), reply2->getBucketInfo());
- CPPUNIT_ASSERT_EQUAL(bucket, reply2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, reply2->getBucketId());
recordOutput(*cmd2);
recordOutput(*reply2);
@@ -619,12 +637,14 @@ void
StorageProtocolTest::testRemoveLocation51()
{
ScopedName test("testRemoveLocation51");
+ document::BucketId bucketId(16, 1234);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
RemoveLocationCommand::SP cmd(
- new RemoveLocationCommand("id.group == \"mygroup\"", document::BucketId(16, 1234)));
+ new RemoveLocationCommand("id.group == \"mygroup\"", bucket));
RemoveLocationCommand::SP cmd2(copyCommand(cmd, _version5_1));
CPPUNIT_ASSERT_EQUAL(vespalib::string("id.group == \"mygroup\""), cmd2->getDocumentSelection());
- CPPUNIT_ASSERT_EQUAL(document::BucketId(16, 1234), cmd2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, cmd2->getBucketId());
RemoveLocationReply::SP reply(new RemoveLocationReply(*cmd2));
RemoveLocationReply::SP reply2(copyReply(reply));
@@ -689,7 +709,8 @@ void
StorageProtocolTest::testGetBucketDiff51()
{
ScopedName test("testGetBucketDiff51");
- document::BucketId id(623);
+ document::BucketId bucketId(623);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
std::vector<api::MergeBucketCommand::Node> nodes;
nodes.push_back(4);
@@ -709,7 +730,7 @@ StorageProtocolTest::testGetBucketDiff51()
" header size: 100, body size: 65536, flags 0x1)"),
entries.back().toString(true));
- GetBucketDiffCommand::SP cmd(new GetBucketDiffCommand(id, nodes, 1056));
+ GetBucketDiffCommand::SP cmd(new GetBucketDiffCommand(bucket, nodes, 1056));
cmd->getDiff() = entries;
GetBucketDiffCommand::SP cmd2(copyCommand(cmd, _version5_1));
@@ -730,7 +751,8 @@ void
StorageProtocolTest::testApplyBucketDiff51()
{
ScopedName test("testApplyBucketDiff51");
- document::BucketId id(16, 623);
+ document::BucketId bucketId(16, 623);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
std::vector<api::MergeBucketCommand::Node> nodes;
nodes.push_back(4);
@@ -738,7 +760,7 @@ StorageProtocolTest::testApplyBucketDiff51()
std::vector<ApplyBucketDiffCommand::Entry> entries;
entries.push_back(ApplyBucketDiffCommand::Entry());
- ApplyBucketDiffCommand::SP cmd(new ApplyBucketDiffCommand(id, nodes, 1234));
+ ApplyBucketDiffCommand::SP cmd(new ApplyBucketDiffCommand(bucket, nodes, 1234));
cmd->getDiff() = entries;
ApplyBucketDiffCommand::SP cmd2(copyCommand(cmd, _version5_1));
@@ -759,13 +781,14 @@ StorageProtocolTest::testMultiOperation51()
{
ScopedName test("testMultiOperation51");
- document::BucketId bucket(20, 0xf1f1f1f1f1ull);
+ document::BucketId bucketId(20, 0xf1f1f1f1f1ull);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
DocumentTypeRepo::SP repo(new DocumentTypeRepo);
MultiOperationCommand::SP
cmd(new MultiOperationCommand(repo, bucket, 10000));
cmd->getOperations().addPut(*_testDoc);
MultiOperationCommand::SP cmd2(copyCommand(cmd, _version5_1));
- CPPUNIT_ASSERT_EQUAL(bucket, cmd2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, cmd2->getBucketId());
CPPUNIT_ASSERT_EQUAL(*_testDoc,
*cmd2->getOperations().begin()->getDocument());
@@ -782,14 +805,15 @@ StorageProtocolTest::testBatchPutRemove51()
{
ScopedName test("testBatchPutRemove51");
- document::BucketId bucket(20, 0xf1f1f1f1f1ull);
+ document::BucketId bucketId(20, 0xf1f1f1f1f1ull);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
BatchPutRemoveCommand::SP cmd(new BatchPutRemoveCommand(bucket));
cmd->addPut(_testDoc, 100);
cmd->addHeaderUpdate(_testDoc, 101, 1234);
cmd->addRemove(_testDoc->getId(), 102);
cmd->forceMsgId(556677);
BatchPutRemoveCommand::SP cmd2(copyCommand(cmd, _version5_1));
- CPPUNIT_ASSERT_EQUAL(bucket, cmd2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, cmd2->getBucketId());
CPPUNIT_ASSERT_EQUAL(3, (int)cmd2->getOperationCount());
CPPUNIT_ASSERT_EQUAL(*_testDoc, *(dynamic_cast<const BatchPutRemoveCommand::PutOperation&>(cmd2->getOperation(0)).document));
CPPUNIT_ASSERT_EQUAL((uint64_t)100, cmd2->getOperation(0).timestamp);
@@ -872,7 +896,8 @@ void
StorageProtocolTest::testSetBucketState51()
{
ScopedName test("testSetBucketState51");
- document::BucketId bucket(16, 0);
+ document::BucketId bucketId(16, 0);
+ document::Bucket bucket(makeDocumentBucket(bucketId));
SetBucketStateCommand::SP cmd(
new SetBucketStateCommand(bucket, SetBucketStateCommand::ACTIVE));
SetBucketStateCommand::SP cmd2(copyCommand(cmd, _version5_1));
@@ -881,8 +906,8 @@ StorageProtocolTest::testSetBucketState51()
SetBucketStateReply::SP reply2(copyReply(reply));
CPPUNIT_ASSERT_EQUAL(SetBucketStateCommand::ACTIVE, cmd2->getState());
- CPPUNIT_ASSERT_EQUAL(bucket, cmd2->getBucketId());
- CPPUNIT_ASSERT_EQUAL(bucket, reply2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, cmd2->getBucketId());
+ CPPUNIT_ASSERT_EQUAL(bucketId, reply2->getBucketId());
recordOutput(*cmd2);
recordOutput(*reply2);
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization4_2.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization4_2.cpp
index 6725e6a46d7..d207b307593 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization4_2.cpp
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization4_2.cpp
@@ -22,6 +22,8 @@
#include <vespa/log/log.h>
LOG_SETUP(".storage.api.mbusprot.serialization.4_2");
+using document::BucketSpace;
+
namespace storage {
namespace mbusprot {
@@ -50,7 +52,8 @@ ProtocolSerialization4_2::onDecodeMultiOperationCommand(BBuf& buf) const
std::vector<char> buffer(length);
buf.getBytes(&buffer[0], length);
bool keepTimestamps = SH::getBoolean(buf);
- document::BucketId bucket(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::MultiOperationCommand::UP msg(
new api::MultiOperationCommand(getTypeRepoSp(),
bucket, buffer, keepTimestamps));
@@ -98,7 +101,9 @@ api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeBatchPutRemoveCommand(BBuf& buf) const
{
SH::getByte(buf);
- std::unique_ptr<api::BatchPutRemoveCommand> cmd(new api::BatchPutRemoveCommand(document::BucketId(SH::getLong(buf))));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
+ std::unique_ptr<api::BatchPutRemoveCommand> cmd(new api::BatchPutRemoveCommand(bucket));
int length = SH::getInt(buf);
for (int i = 0; i < length; i++) {
@@ -169,7 +174,8 @@ api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeGetCommand(BBuf& buf) const
{
document::DocumentId did(SH::getString(buf));
- document::BucketId bucket(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::Timestamp beforeTimestamp(SH::getLong(buf));
bool headerOnly(SH::getBoolean(buf));
api::GetCommand::UP msg(
@@ -191,7 +197,8 @@ api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeRemoveCommand(BBuf& buf) const
{
document::DocumentId did(SH::getString(buf));
- document::BucketId bucket(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::Timestamp timestamp(SH::getLong(buf));
api::RemoveCommand::UP msg(new api::RemoveCommand(bucket, did, timestamp));
onDecodeBucketInfoCommand(buf, *msg);
@@ -212,12 +219,13 @@ void ProtocolSerialization4_2::onEncode(
api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeRevertCommand(BBuf& buf) const
{
- document::BucketId bid(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
std::vector<api::Timestamp> tokens(SH::getInt(buf));
for (uint32_t i=0, n=tokens.size(); i<n; ++i) {
tokens[i] = SH::getLong(buf);
}
- api::RevertCommand::UP msg(new api::RevertCommand(bid, tokens));
+ api::RevertCommand::UP msg(new api::RevertCommand(bucket, tokens));
onDecodeBucketInfoCommand(buf, *msg);
return api::StorageCommand::UP(msg.release());
}
@@ -232,8 +240,9 @@ void ProtocolSerialization4_2::onEncode(
api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeCreateBucketCommand(BBuf& buf) const
{
- document::BucketId bid(SH::getLong(buf));
- api::CreateBucketCommand::UP msg(new api::CreateBucketCommand(bid));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
+ api::CreateBucketCommand::UP msg(new api::CreateBucketCommand(bucket));
onDecodeBucketInfoCommand(buf, *msg);
return api::StorageCommand::UP(msg.release());
}
@@ -256,7 +265,8 @@ api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeMergeBucketCommand(BBuf& buf) const
{
typedef api::MergeBucketCommand::Node Node;
- document::BucketId bid(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
uint16_t nodeCount = SH::getShort(buf);
std::vector<Node> nodes;
nodes.reserve(nodeCount);
@@ -267,7 +277,7 @@ ProtocolSerialization4_2::onDecodeMergeBucketCommand(BBuf& buf) const
}
api::Timestamp timestamp(SH::getLong(buf));
api::MergeBucketCommand::UP msg(
- new api::MergeBucketCommand(bid, nodes, timestamp));
+ new api::MergeBucketCommand(bucket, nodes, timestamp));
onDecodeCommand(buf, *msg);
return api::StorageCommand::UP(msg.release());
}
@@ -295,7 +305,8 @@ api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeGetBucketDiffCommand(BBuf& buf) const
{
typedef api::MergeBucketCommand::Node Node;
- document::BucketId bid(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
uint16_t nodeCount = SH::getShort(buf);
std::vector<Node> nodes;
nodes.reserve(nodeCount);
@@ -306,7 +317,7 @@ ProtocolSerialization4_2::onDecodeGetBucketDiffCommand(BBuf& buf) const
}
api::Timestamp timestamp = SH::getLong(buf);
api::GetBucketDiffCommand::UP msg(
- new api::GetBucketDiffCommand(bid, nodes, timestamp));
+ new api::GetBucketDiffCommand(bucket, nodes, timestamp));
std::vector<api::GetBucketDiffCommand::Entry>& entries(msg->getDiff());
uint32_t entryCount = SH::getInt(buf);
if (entryCount > buf.getRemaining()) {
@@ -352,7 +363,8 @@ api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeApplyBucketDiffCommand(BBuf& buf) const
{
typedef api::MergeBucketCommand::Node Node;
- document::BucketId bid(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
uint16_t nodeCount = SH::getShort(buf);
std::vector<Node> nodes;
nodes.reserve(nodeCount);
@@ -363,7 +375,7 @@ ProtocolSerialization4_2::onDecodeApplyBucketDiffCommand(BBuf& buf) const
}
uint32_t maxBufferSize(SH::getInt(buf));
api::ApplyBucketDiffCommand::UP msg(
- new api::ApplyBucketDiffCommand(bid, nodes, maxBufferSize));
+ new api::ApplyBucketDiffCommand(bucket, nodes, maxBufferSize));
std::vector<api::ApplyBucketDiffCommand::Entry>& entries(msg->getDiff());
uint32_t entryCount = SH::getInt(buf);
if (entryCount > buf.getRemaining()) {
@@ -436,7 +448,8 @@ void ProtocolSerialization4_2::onEncode(
api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeNotifyBucketChangeCommand(BBuf& buf) const
{
- document::BucketId bucket(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::BucketInfo info(getBucketInfo(buf));
api::NotifyBucketChangeCommand::UP msg(
new api::NotifyBucketChangeCommand(bucket, info));
@@ -474,8 +487,9 @@ void ProtocolSerialization4_2::onEncode(
api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeSplitBucketCommand(BBuf& buf) const
{
- document::BucketId id(SH::getLong(buf));
- api::SplitBucketCommand::UP msg(new api::SplitBucketCommand(id));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
+ api::SplitBucketCommand::UP msg(new api::SplitBucketCommand(bucket));
msg->setMinSplitBits(SH::getByte(buf));
msg->setMaxSplitBits(SH::getByte(buf));
msg->setMinByteSize(SH::getInt(buf));
@@ -631,10 +645,11 @@ api::StorageCommand::UP
ProtocolSerialization4_2::onDecodeRemoveLocationCommand(BBuf& buf) const
{
vespalib::stringref documentSelection = SH::getString(buf);
- uint64_t bucketId = SH::getLong(buf);
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::RemoveLocationCommand::UP msg;
- msg.reset(new api::RemoveLocationCommand(documentSelection, document::BucketId(bucketId)));
+ msg.reset(new api::RemoveLocationCommand(documentSelection, bucket));
onDecodeCommand(buf, *msg);
return api::StorageCommand::UP(msg.release());
}
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp
index 192d23d1ec6..2bd160b1aab 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp
@@ -7,6 +7,7 @@
#include <vespa/storageapi/message/bucketsplitting.h>
#include <vespa/storageapi/message/multioperation.h>
+using document::BucketSpace;
namespace storage {
namespace mbusprot {
@@ -102,9 +103,10 @@ api::StorageCommand::UP
ProtocolSerialization5_0::onDecodePutCommand(BBuf& buf) const
{
document::Document::SP doc(SH::getDocument(buf, getTypeRepo()));
- document::BucketId id(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::Timestamp ts(SH::getLong(buf));
- api::PutCommand::UP msg(new api::PutCommand(id, doc, ts));
+ api::PutCommand::UP msg(new api::PutCommand(bucket, doc, ts));
msg->setUpdateTimestamp(SH::getLong(buf));
onDecodeBucketInfoCommand(buf, *msg);
return api::StorageCommand::UP(msg.release());
@@ -222,7 +224,8 @@ ProtocolSerialization5_0::onDecodeUpdateCommand(BBuf& buf) const
SERIALIZE_HEAD));
}
- document::BucketId bucket(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::Timestamp timestamp(SH::getLong(buf));
api::UpdateCommand::UP msg(
new api::UpdateCommand(bucket, update, timestamp));
@@ -275,8 +278,9 @@ ProtocolSerialization5_0::onEncode(
api::StorageCommand::UP
ProtocolSerialization5_0::onDecodeDeleteBucketCommand(BBuf& buf) const
{
- document::BucketId bid(SH::getLong(buf));
- api::DeleteBucketCommand::UP msg(new api::DeleteBucketCommand(bid));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
+ api::DeleteBucketCommand::UP msg(new api::DeleteBucketCommand(bucket));
onDecodeBucketInfoCommand(buf, *msg);
if (buf.getRemaining() >= SH::BUCKET_INFO_SERIALIZED_SIZE) {
msg->setBucketInfo(getBucketInfo(buf));
@@ -503,7 +507,8 @@ ProtocolSerialization5_0::onEncode(
api::StorageCommand::UP
ProtocolSerialization5_0::onDecodeJoinBucketsCommand(BBuf& buf) const
{
- document::BucketId bucket(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::JoinBucketsCommand::UP msg(new api::JoinBucketsCommand(bucket));
uint32_t size = SH::getInt(buf);
if (size > buf.getRemaining()) {
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp
index 6d5a4b3102e..4f84eff0ab8 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp
@@ -17,6 +17,8 @@
#include <vespa/document/select/orderingspecification.h>
#include <vespa/storageapi/messageapi/returncode.h>
+using document::BucketSpace;
+
namespace storage {
namespace mbusprot {
@@ -70,7 +72,8 @@ void ProtocolSerialization5_1::onEncode(
api::StorageCommand::UP
ProtocolSerialization5_1::onDecodeSetBucketStateCommand(BBuf& buf) const
{
- document::BucketId bucket(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::SetBucketStateCommand::BUCKET_STATE state(
static_cast<api::SetBucketStateCommand::BUCKET_STATE>(
SH::getByte(buf)));
@@ -110,7 +113,8 @@ api::StorageCommand::UP
ProtocolSerialization5_1::onDecodeGetCommand(BBuf& buf) const
{
document::DocumentId did(SH::getString(buf));
- document::BucketId bucket(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
api::Timestamp beforeTimestamp(SH::getLong(buf));
std::string fieldSet(SH::getString(buf));
api::GetCommand::UP msg(
@@ -211,9 +215,10 @@ void ProtocolSerialization5_1::onEncode(
api::StorageCommand::UP
ProtocolSerialization5_1::onDecodeCreateBucketCommand(BBuf& buf) const
{
- document::BucketId bid(SH::getLong(buf));
+ document::BucketId bucketId(SH::getLong(buf));
+ document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
bool setActive = SH::getBoolean(buf);
- api::CreateBucketCommand::UP msg(new api::CreateBucketCommand(bid));
+ api::CreateBucketCommand::UP msg(new api::CreateBucketCommand(bucket));
msg->setActive(setActive);
onDecodeBucketInfoCommand(buf, *msg);
return api::StorageCommand::UP(msg.release());
diff --git a/storageapi/src/vespa/storageapi/message/batch.cpp b/storageapi/src/vespa/storageapi/message/batch.cpp
index a813d737702..f92d88e179e 100644
--- a/storageapi/src/vespa/storageapi/message/batch.cpp
+++ b/storageapi/src/vespa/storageapi/message/batch.cpp
@@ -39,8 +39,8 @@ BatchPutRemoveCommand::RemoveOperation::RemoveOperation(const document::Document
{
}
-BatchPutRemoveCommand::BatchPutRemoveCommand(const document::BucketId& bucketId)
- : BucketInfoCommand(MessageType::BATCHPUTREMOVE, bucketId),
+BatchPutRemoveCommand::BatchPutRemoveCommand(const document::Bucket &bucket)
+ : BucketInfoCommand(MessageType::BATCHPUTREMOVE, bucket),
_approxSize(0)
{
}
diff --git a/storageapi/src/vespa/storageapi/message/batch.h b/storageapi/src/vespa/storageapi/message/batch.h
index a1aec538e27..372d1bdb340 100644
--- a/storageapi/src/vespa/storageapi/message/batch.h
+++ b/storageapi/src/vespa/storageapi/message/batch.h
@@ -35,7 +35,7 @@ public:
virtual const document::DocumentId& getDocumentId() const = 0;
};
- explicit BatchPutRemoveCommand(const document::BucketId& id);
+ explicit BatchPutRemoveCommand(const document::Bucket &bucket);
class PutOperation : public Operation {
public:
diff --git a/storageapi/src/vespa/storageapi/message/bucket.cpp b/storageapi/src/vespa/storageapi/message/bucket.cpp
index 76d14946f36..983a65114b3 100644
--- a/storageapi/src/vespa/storageapi/message/bucket.cpp
+++ b/storageapi/src/vespa/storageapi/message/bucket.cpp
@@ -26,8 +26,8 @@ IMPLEMENT_REPLY(NotifyBucketChangeReply)
IMPLEMENT_COMMAND(SetBucketStateCommand, SetBucketStateReply)
IMPLEMENT_REPLY(SetBucketStateReply)
-CreateBucketCommand::CreateBucketCommand(const document::BucketId& id)
- : MaintenanceCommand(MessageType::CREATEBUCKET, id),
+CreateBucketCommand::CreateBucketCommand(const document::Bucket &bucket)
+ : MaintenanceCommand(MessageType::CREATEBUCKET, bucket),
_active(false)
{ }
@@ -65,8 +65,8 @@ CreateBucketReply::print(std::ostream& out, bool verbose,
}
}
-DeleteBucketCommand::DeleteBucketCommand(const document::BucketId& id)
- : MaintenanceCommand(MessageType::DELETEBUCKET, id)
+DeleteBucketCommand::DeleteBucketCommand(const document::Bucket &bucket)
+ : MaintenanceCommand(MessageType::DELETEBUCKET, bucket)
{ }
void
@@ -98,10 +98,10 @@ DeleteBucketReply::print(std::ostream& out, bool verbose,
}
MergeBucketCommand::MergeBucketCommand(
- const document::BucketId& id, const std::vector<Node>& nodes,
+ const document::Bucket &bucket, const std::vector<Node>& nodes,
Timestamp maxTimestamp, uint32_t clusterStateVersion,
const std::vector<uint16_t>& chain)
- : MaintenanceCommand(MessageType::MERGEBUCKET, id),
+ : MaintenanceCommand(MessageType::MERGEBUCKET, bucket),
_nodes(nodes),
_maxTimestamp(maxTimestamp),
_clusterStateVersion(clusterStateVersion),
@@ -204,9 +204,9 @@ bool GetBucketDiffCommand::Entry::operator==(const Entry& e) const
}
GetBucketDiffCommand::GetBucketDiffCommand(
- const document::BucketId& id, const std::vector<Node>& nodes,
+ const document::Bucket &bucket, const std::vector<Node>& nodes,
Timestamp maxTimestamp)
- : BucketCommand(MessageType::GETBUCKETDIFF, id),
+ : BucketCommand(MessageType::GETBUCKETDIFF, bucket),
_nodes(nodes),
_maxTimestamp(maxTimestamp)
{}
@@ -340,9 +340,9 @@ ApplyBucketDiffCommand::Entry::operator==(const Entry& e) const
}
ApplyBucketDiffCommand::ApplyBucketDiffCommand(
- const document::BucketId& id, const std::vector<Node>& nodes,
+ const document::Bucket &bucket, const std::vector<Node>& nodes,
uint32_t maxBufferSize)
- : BucketInfoCommand(MessageType::APPLYBUCKETDIFF, id),
+ : BucketInfoCommand(MessageType::APPLYBUCKETDIFF, bucket),
_nodes(nodes),
_diff(),
_maxBufferSize(maxBufferSize)
@@ -534,8 +534,8 @@ RequestBucketInfoReply::print(std::ostream& out, bool verbose,
}
NotifyBucketChangeCommand::NotifyBucketChangeCommand(
- const document::BucketId& id, const BucketInfo& info)
- : BucketCommand(MessageType::NOTIFYBUCKETCHANGE, id),
+ const document::Bucket &bucket, const BucketInfo& info)
+ : BucketCommand(MessageType::NOTIFYBUCKETCHANGE, bucket),
_info(info)
{
}
@@ -571,7 +571,7 @@ NotifyBucketChangeReply::print(std::ostream& out, bool verbose,
}
SetBucketStateCommand::SetBucketStateCommand(
- const document::BucketId& bucket,
+ const document::Bucket &bucket,
BUCKET_STATE state)
: MaintenanceCommand(MessageType::SETBUCKETSTATE, bucket),
_state(state)
diff --git a/storageapi/src/vespa/storageapi/message/bucket.h b/storageapi/src/vespa/storageapi/message/bucket.h
index d571cfb48ec..d2bf97e7768 100644
--- a/storageapi/src/vespa/storageapi/message/bucket.h
+++ b/storageapi/src/vespa/storageapi/message/bucket.h
@@ -31,7 +31,7 @@ class CreateBucketCommand : public MaintenanceCommand {
bool _active;
public:
- explicit CreateBucketCommand(const document::BucketId& id);
+ explicit CreateBucketCommand(const document::Bucket &bucket);
void setActive(bool active) { _active = active; }
bool getActive() const { return _active; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
@@ -60,7 +60,7 @@ public:
class DeleteBucketCommand : public MaintenanceCommand {
BucketInfo _info;
public:
- explicit DeleteBucketCommand(const document::BucketId& id);
+ explicit DeleteBucketCommand(const document::Bucket &bucket);
const BucketInfo& getBucketInfo() const { return _info; }
void setBucketInfo(const BucketInfo& info) { _info = info; }
@@ -118,7 +118,7 @@ private:
std::vector<uint16_t> _chain;
public:
- MergeBucketCommand(const document::BucketId&,
+ MergeBucketCommand(const document::Bucket &bucket,
const std::vector<Node>&,
Timestamp maxTimestamp,
uint32_t clusterStateVersion = 0,
@@ -196,7 +196,7 @@ private:
std::vector<Entry> _diff;
public:
- GetBucketDiffCommand(const document::BucketId&,
+ GetBucketDiffCommand(const document::Bucket &bucket,
const std::vector<Node>&,
Timestamp maxTimestamp);
~GetBucketDiffCommand();
@@ -279,7 +279,7 @@ private:
uint32_t _maxBufferSize;
public:
- ApplyBucketDiffCommand(const document::BucketId& id,
+ ApplyBucketDiffCommand(const document::Bucket &bucket,
const std::vector<Node>& nodes,
uint32_t maxBufferSize);
~ApplyBucketDiffCommand();
@@ -413,7 +413,7 @@ public:
class NotifyBucketChangeCommand : public BucketCommand {
BucketInfo _info;
public:
- NotifyBucketChangeCommand(const document::BucketId& bucket,
+ NotifyBucketChangeCommand(const document::Bucket &bucket,
const BucketInfo& bucketInfo);
const BucketInfo& getBucketInfo() const { return _info; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
@@ -454,7 +454,7 @@ public:
private:
BUCKET_STATE _state;
public:
- SetBucketStateCommand(const document::BucketId& bucket, BUCKET_STATE state);
+ SetBucketStateCommand(const document::Bucket &bucket, BUCKET_STATE state);
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
BUCKET_STATE getState() const { return _state; }
DECLARE_STORAGECOMMAND(SetBucketStateCommand, onSetBucketState)
diff --git a/storageapi/src/vespa/storageapi/message/bucketsplitting.cpp b/storageapi/src/vespa/storageapi/message/bucketsplitting.cpp
index 3cbc0a3ab03..60c338d4d61 100644
--- a/storageapi/src/vespa/storageapi/message/bucketsplitting.cpp
+++ b/storageapi/src/vespa/storageapi/message/bucketsplitting.cpp
@@ -11,8 +11,8 @@ IMPLEMENT_REPLY(SplitBucketReply)
IMPLEMENT_COMMAND(JoinBucketsCommand, JoinBucketsReply)
IMPLEMENT_REPLY(JoinBucketsReply)
-SplitBucketCommand::SplitBucketCommand(const document::BucketId& id)
- : MaintenanceCommand(MessageType::SPLITBUCKET, id),
+SplitBucketCommand::SplitBucketCommand(const document::Bucket &bucket)
+ : MaintenanceCommand(MessageType::SPLITBUCKET, bucket),
_minSplitBits(0),
_maxSplitBits(58),
_minByteSize(std::numeric_limits<uint32_t>::max()),
@@ -70,7 +70,7 @@ SplitBucketReply::print(std::ostream& out, bool verbose,
}
}
-JoinBucketsCommand::JoinBucketsCommand(const document::BucketId& target)
+JoinBucketsCommand::JoinBucketsCommand(const document::Bucket &target)
: MaintenanceCommand(MessageType::JOINBUCKETS, target),
_minJoinBits(0)
{
diff --git a/storageapi/src/vespa/storageapi/message/bucketsplitting.h b/storageapi/src/vespa/storageapi/message/bucketsplitting.h
index c9f6ff68cee..115cd9f01bb 100644
--- a/storageapi/src/vespa/storageapi/message/bucketsplitting.h
+++ b/storageapi/src/vespa/storageapi/message/bucketsplitting.h
@@ -45,7 +45,7 @@ private:
uint32_t _minDocCount;
public:
- SplitBucketCommand(const document::BucketId& id);
+ SplitBucketCommand(const document::Bucket& bucket);
uint8_t getMinSplitBits() const { return _minSplitBits; }
uint8_t getMaxSplitBits() const { return _maxSplitBits; }
@@ -93,7 +93,7 @@ class JoinBucketsCommand : public MaintenanceCommand {
std::vector<document::BucketId> _sources;
uint8_t _minJoinBits;
public:
- explicit JoinBucketsCommand(const document::BucketId& target);
+ explicit JoinBucketsCommand(const document::Bucket &target);
std::vector<document::BucketId>& getSourceBuckets() { return _sources; }
const std::vector<document::BucketId>& getSourceBuckets() const { return _sources; }
void setMinJoinBits(uint8_t minJoinBits) { _minJoinBits = minJoinBits; }
diff --git a/storageapi/src/vespa/storageapi/message/multioperation.cpp b/storageapi/src/vespa/storageapi/message/multioperation.cpp
index d8044eae86e..a6494002e18 100644
--- a/storageapi/src/vespa/storageapi/message/multioperation.cpp
+++ b/storageapi/src/vespa/storageapi/message/multioperation.cpp
@@ -11,10 +11,10 @@ IMPLEMENT_COMMAND(MultiOperationCommand, MultiOperationReply)
IMPLEMENT_REPLY(MultiOperationReply)
MultiOperationCommand::MultiOperationCommand(const DocumentTypeRepo::SP &repo,
- const document::BucketId& id,
+ const document::Bucket &bucket,
int bufferSize,
bool keepTimeStamps_)
- : BucketInfoCommand(MessageType::MULTIOPERATION, id),
+ : BucketInfoCommand(MessageType::MULTIOPERATION, bucket),
_buffer(),
_operations(repo, 0, 0),
_keepTimeStamps(keepTimeStamps_)
@@ -27,10 +27,10 @@ MultiOperationCommand::MultiOperationCommand(const DocumentTypeRepo::SP &repo,
}
MultiOperationCommand::MultiOperationCommand(const DocumentTypeRepo::SP &repo,
- const document::BucketId& id,
+ const document::Bucket &bucket,
const std::vector<char>& buffer,
bool keepTimeStamps_)
- : BucketInfoCommand(MessageType::MULTIOPERATION, id),
+ : BucketInfoCommand(MessageType::MULTIOPERATION, bucket),
_buffer(buffer),
_operations(repo, 0, 0),
_keepTimeStamps(keepTimeStamps_)
@@ -42,7 +42,7 @@ MultiOperationCommand::MultiOperationCommand(const DocumentTypeRepo::SP &repo,
}
MultiOperationCommand::MultiOperationCommand(const MultiOperationCommand& o)
- : BucketInfoCommand(MessageType::MULTIOPERATION, o.getBucketId()),
+ : BucketInfoCommand(MessageType::MULTIOPERATION, o.getBucket()),
_buffer(o._buffer),
_operations(o._operations.getTypeRepo(),0, 0),
_keepTimeStamps(o._keepTimeStamps)
diff --git a/storageapi/src/vespa/storageapi/message/multioperation.h b/storageapi/src/vespa/storageapi/message/multioperation.h
index 3376a7cb036..3d80cd042ea 100644
--- a/storageapi/src/vespa/storageapi/message/multioperation.h
+++ b/storageapi/src/vespa/storageapi/message/multioperation.h
@@ -28,11 +28,11 @@ private:
public:
explicit MultiOperationCommand(const document::DocumentTypeRepo::SP &repo,
- const document::BucketId& id,
+ const document::Bucket &bucket,
int bufferSize,
bool keepTimeStamps = false);
explicit MultiOperationCommand(const document::DocumentTypeRepo::SP &repo,
- const document::BucketId& id,
+ const document::Bucket &bucket,
const std::vector<char>& buffer,
bool keepTimeStamps = false);
explicit MultiOperationCommand(const MultiOperationCommand& template_);
diff --git a/storageapi/src/vespa/storageapi/message/persistence.cpp b/storageapi/src/vespa/storageapi/message/persistence.cpp
index ffb284012fb..10dbc9f1313 100644
--- a/storageapi/src/vespa/storageapi/message/persistence.cpp
+++ b/storageapi/src/vespa/storageapi/message/persistence.cpp
@@ -19,14 +19,14 @@ IMPLEMENT_REPLY(RemoveReply)
IMPLEMENT_COMMAND(RevertCommand, RevertReply)
IMPLEMENT_REPLY(RevertReply)
-TestAndSetCommand::TestAndSetCommand(const MessageType & messageType, const document::BucketId & id)
- : BucketInfoCommand(messageType, id)
+TestAndSetCommand::TestAndSetCommand(const MessageType & messageType, const document::Bucket &bucket)
+ : BucketInfoCommand(messageType, bucket)
{}
TestAndSetCommand::~TestAndSetCommand() { }
-PutCommand::PutCommand(const document::BucketId& id,
+PutCommand::PutCommand(const document::Bucket &bucket,
const document::Document::SP& doc, Timestamp time)
- : TestAndSetCommand(MessageType::PUT, id),
+ : TestAndSetCommand(MessageType::PUT, bucket),
_doc(doc),
_timestamp(time),
_updateTimestamp(0)
@@ -97,10 +97,10 @@ PutReply::print(std::ostream& out, bool verbose,
}
}
-UpdateCommand::UpdateCommand(const document::BucketId& id,
+UpdateCommand::UpdateCommand(const document::Bucket &bucket,
const document::DocumentUpdate::SP& update,
Timestamp time)
- : TestAndSetCommand(MessageType::UPDATE, id),
+ : TestAndSetCommand(MessageType::UPDATE, bucket),
_update(update),
_timestamp(time),
_oldTimestamp(0)
@@ -176,10 +176,10 @@ UpdateReply::print(std::ostream& out, bool verbose,
}
}
-GetCommand::GetCommand(const document::BucketId& bid,
+GetCommand::GetCommand(const document::Bucket &bucket,
const document::DocumentId& docId,
const vespalib::stringref & fieldSet, Timestamp before)
- : BucketInfoCommand(MessageType::GET, bid),
+ : BucketInfoCommand(MessageType::GET, bucket),
_docId(docId),
_beforeTimestamp(before),
_fieldSet(fieldSet)
@@ -238,10 +238,10 @@ GetReply::print(std::ostream& out, bool verbose,
}
}
-RemoveCommand::RemoveCommand(const document::BucketId& bid,
+RemoveCommand::RemoveCommand(const document::Bucket &bucket,
const document::DocumentId& docId,
Timestamp timestamp)
- : TestAndSetCommand(MessageType::REMOVE, bid),
+ : TestAndSetCommand(MessageType::REMOVE, bucket),
_docId(docId),
_timestamp(timestamp)
{
@@ -297,9 +297,9 @@ RemoveReply::print(std::ostream& out, bool verbose,
}
}
-RevertCommand::RevertCommand(const document::BucketId& id,
+RevertCommand::RevertCommand(const document::Bucket &bucket,
const std::vector<Timestamp>& revertTokens)
- : BucketInfoCommand(MessageType::REVERT, id),
+ : BucketInfoCommand(MessageType::REVERT, bucket),
_tokens(revertTokens)
{
}
diff --git a/storageapi/src/vespa/storageapi/message/persistence.h b/storageapi/src/vespa/storageapi/message/persistence.h
index 9add004c730..7d18a01d748 100644
--- a/storageapi/src/vespa/storageapi/message/persistence.h
+++ b/storageapi/src/vespa/storageapi/message/persistence.h
@@ -22,7 +22,7 @@ class TestAndSetCommand : public BucketInfoCommand {
TestAndSetCondition _condition;
public:
- TestAndSetCommand(const MessageType & messageType, const document::BucketId & id);
+ TestAndSetCommand(const MessageType & messageType, const document::Bucket &bucket);
~TestAndSetCommand();
void setCondition(const TestAndSetCondition & condition) { _condition = condition; }
@@ -47,7 +47,7 @@ class PutCommand : public TestAndSetCommand {
Timestamp _updateTimestamp;
public:
- PutCommand(const document::BucketId&, const document::Document::SP&, Timestamp);
+ PutCommand(const document::Bucket &bucket, const document::Document::SP&, Timestamp);
~PutCommand();
void setTimestamp(Timestamp ts) { _timestamp = ts; }
@@ -116,7 +116,7 @@ class UpdateCommand : public TestAndSetCommand {
Timestamp _oldTimestamp;
public:
- UpdateCommand(const document::BucketId&,
+ UpdateCommand(const document::Bucket &bucket,
const document::DocumentUpdate::SP&, Timestamp);
~UpdateCommand();
@@ -194,7 +194,7 @@ class GetCommand : public BucketInfoCommand {
vespalib::string _fieldSet;
public:
- GetCommand(const document::BucketId&, const document::DocumentId&,
+ GetCommand(const document::Bucket &bucket, const document::DocumentId&,
const vespalib::stringref & fieldSet, Timestamp before = MAX_TIMESTAMP);
~GetCommand();
void setBeforeTimestamp(Timestamp ts) { _beforeTimestamp = ts; }
@@ -254,7 +254,7 @@ class RemoveCommand : public TestAndSetCommand {
Timestamp _timestamp;
public:
- RemoveCommand(const document::BucketId&, const document::DocumentId& docId, Timestamp timestamp);
+ RemoveCommand(const document::Bucket &bucket, const document::DocumentId& docId, Timestamp timestamp);
~RemoveCommand();
void setTimestamp(Timestamp ts) { _timestamp = ts; }
@@ -297,7 +297,7 @@ public:
class RevertCommand : public BucketInfoCommand {
std::vector<Timestamp> _tokens;
public:
- RevertCommand(const document::BucketId& bucket,
+ RevertCommand(const document::Bucket &bucket,
const std::vector<Timestamp>& revertTokens);
~RevertCommand();
const std::vector<Timestamp>& getRevertTokens() const { return _tokens; }
diff --git a/storageapi/src/vespa/storageapi/message/removelocation.cpp b/storageapi/src/vespa/storageapi/message/removelocation.cpp
index 74149932bd3..38b56101f04 100644
--- a/storageapi/src/vespa/storageapi/message/removelocation.cpp
+++ b/storageapi/src/vespa/storageapi/message/removelocation.cpp
@@ -10,8 +10,8 @@ IMPLEMENT_COMMAND(RemoveLocationCommand, RemoveLocationReply)
IMPLEMENT_REPLY(RemoveLocationReply)
RemoveLocationCommand::RemoveLocationCommand(const vespalib::stringref & documentSelection,
- const document::BucketId& id)
- : BucketInfoCommand(MessageType::REMOVELOCATION, id),
+ const document::Bucket &bucket)
+ : BucketInfoCommand(MessageType::REMOVELOCATION, bucket),
_documentSelection(documentSelection)
{}
diff --git a/storageapi/src/vespa/storageapi/message/removelocation.h b/storageapi/src/vespa/storageapi/message/removelocation.h
index 7ff1e70586d..4a3dec2e0f6 100644
--- a/storageapi/src/vespa/storageapi/message/removelocation.h
+++ b/storageapi/src/vespa/storageapi/message/removelocation.h
@@ -11,7 +11,7 @@ namespace api {
class RemoveLocationCommand : public BucketInfoCommand
{
public:
- RemoveLocationCommand(const vespalib::stringref & documentSelection, const document::BucketId&);
+ RemoveLocationCommand(const vespalib::stringref & documentSelection, const document::Bucket &bucket);
~RemoveLocationCommand();
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
diff --git a/storageapi/src/vespa/storageapi/message/stat.cpp b/storageapi/src/vespa/storageapi/message/stat.cpp
index 7c8a5541313..b061be885ff 100644
--- a/storageapi/src/vespa/storageapi/message/stat.cpp
+++ b/storageapi/src/vespa/storageapi/message/stat.cpp
@@ -11,9 +11,9 @@ IMPLEMENT_REPLY(StatBucketReply)
IMPLEMENT_COMMAND(GetBucketListCommand, GetBucketListReply)
IMPLEMENT_REPLY(GetBucketListReply)
-StatBucketCommand::StatBucketCommand(const document::BucketId& id,
+StatBucketCommand::StatBucketCommand(const document::Bucket& bucket,
const vespalib::stringref & documentSelection)
- : BucketCommand(MessageType::STATBUCKET, id),
+ : BucketCommand(MessageType::STATBUCKET, bucket),
_docSelection(documentSelection)
{
}
@@ -59,8 +59,8 @@ StatBucketReply::print(std::ostream& out, bool verbose,
}
}
-GetBucketListCommand::GetBucketListCommand(const document::BucketId& id)
- : BucketCommand(MessageType::GETBUCKETLIST, id)
+GetBucketListCommand::GetBucketListCommand(const document::Bucket &bucket)
+ : BucketCommand(MessageType::GETBUCKETLIST, bucket)
{
}
diff --git a/storageapi/src/vespa/storageapi/message/stat.h b/storageapi/src/vespa/storageapi/message/stat.h
index 4bff4b5a823..637c43255b8 100644
--- a/storageapi/src/vespa/storageapi/message/stat.h
+++ b/storageapi/src/vespa/storageapi/message/stat.h
@@ -21,7 +21,7 @@ class StatBucketCommand : public BucketCommand {
private:
vespalib::string _docSelection;
public:
- StatBucketCommand(const document::BucketId& bucket,
+ StatBucketCommand(const document::Bucket &bucket,
const vespalib::stringref & documentSelection);
~StatBucketCommand();
@@ -51,7 +51,7 @@ public:
*/
class GetBucketListCommand : public BucketCommand {
public:
- GetBucketListCommand(const document::BucketId& bucket);
+ GetBucketListCommand(const document::Bucket &bucket);
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
DECLARE_STORAGECOMMAND(GetBucketListCommand, onGetBucketList);
};
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp
index e91864e284d..5c041649484 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp
@@ -10,9 +10,9 @@ using document::BucketSpace;
namespace storage {
namespace api {
-BucketCommand::BucketCommand(const MessageType& type, const BucketId& id)
+BucketCommand::BucketCommand(const MessageType& type, const Bucket &bucket)
: StorageCommand(type),
- _bucket(BucketSpace::placeHolder(), id),
+ _bucket(bucket),
_originalBucket()
{
}
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h
index b31bcf5e88c..c098bc53751 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h
@@ -18,7 +18,7 @@ class BucketCommand : public StorageCommand {
document::BucketId _originalBucket;
protected:
- BucketCommand(const MessageType& type, const document::BucketId& id);
+ BucketCommand(const MessageType& type, const document::Bucket &bucket);
public:
DECLARE_POINTER_TYPEDEFS(BucketCommand);
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h b/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h
index a6e2ba363ec..25fa01758ca 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h
@@ -19,8 +19,8 @@ namespace api {
class BucketInfoCommand : public BucketCommand {
protected:
- BucketInfoCommand(const MessageType& type, const document::BucketId& id)
- : BucketCommand(type, id) {}
+ BucketInfoCommand(const MessageType& type, const document::Bucket &bucket)
+ : BucketCommand(type, bucket) {}
public:
DECLARE_POINTER_TYPEDEFS(BucketInfoCommand);
diff --git a/storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h b/storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h
index 377b85bef2f..7e9a41e6220 100644
--- a/storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h
+++ b/storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h
@@ -9,8 +9,8 @@ namespace api {
class MaintenanceCommand : public BucketInfoCommand
{
public:
- MaintenanceCommand(const MessageType& type, const document::BucketId& id)
- : BucketInfoCommand(type, id)
+ MaintenanceCommand(const MessageType& type, const document::Bucket &bucket)
+ : BucketInfoCommand(type, bucket)
{}
MaintenanceCommand(MaintenanceCommand &&) = default;
MaintenanceCommand & operator = (MaintenanceCommand &&) = default;
diff --git a/storageserver/src/tests/storageservertest.cpp b/storageserver/src/tests/storageservertest.cpp
index 21b190d9e76..66f2c546a42 100644
--- a/storageserver/src/tests/storageservertest.cpp
+++ b/storageserver/src/tests/storageservertest.cpp
@@ -650,6 +650,11 @@ namespace {
monitor.signal();
return true;
}
+
+ static document::Bucket makeDocumentBucket(document::BucketId bucketId) {
+ return document::Bucket(document::BucketSpace::placeHolder(), bucketId);
+ }
+
void run() override {
uint32_t seed = 0;
uint32_t maxDocSize = 65536;
@@ -686,7 +691,7 @@ namespace {
entries[bucket].write();
entries[bucket] = _bucketDB.get(bucket, "foo");
CPPUNIT_ASSERT(entries[bucket].exist());
- cmd.reset(new api::CreateBucketCommand(bucket));
+ cmd.reset(new api::CreateBucketCommand(makeDocumentBucket(bucket)));
sendList.push_back(new mbusprot::StorageCommand(cmd));
}
CPPUNIT_ASSERT_EQUAL(size_t(1), entries.size());
@@ -695,7 +700,7 @@ namespace {
auto *entry = entry_wrapper->get();
if (seed % 95 == 93) { // Delete bucket
if ((entry->getBucketInfo().getChecksum() & 2) == 0) {
- cmd.reset(new api::DeleteBucketCommand(bucket));
+ cmd.reset(new api::DeleteBucketCommand(makeDocumentBucket(bucket)));
entry->setChecksum(
entry->getBucketInfo().getChecksum() | 2);
entry_wrapper->write();
@@ -714,7 +719,7 @@ namespace {
bucket.getRawId());
super = super.stripUnused();
api::JoinBucketsCommand::SP jcmd(
- new api::JoinBucketsCommand(super));
+ new api::JoinBucketsCommand(makeDocumentBucket(super)));
entries = _bucketDB.getAll(super, "foo");
bool foundAnyLocked = false;
for (std::map<document::BucketId,
@@ -747,7 +752,7 @@ namespace {
// Use _checksum == 1 to mean that we have a pending
// maintenance operation to this bucket.
if (entry->getBucketInfo().getChecksum() == 0) {
- cmd.reset(new api::SplitBucketCommand(bucket));
+ cmd.reset(new api::SplitBucketCommand(makeDocumentBucket(bucket)));
entry->setChecksum(1);
entry_wrapper->write();
sendList.push_back(
@@ -755,7 +760,7 @@ namespace {
}
} else if (seed % 7 == 5) { // Remove
if ((entry->getBucketInfo().getChecksum() & 2) == 0) {
- cmd.reset(new api::RemoveCommand(bucket,
+ cmd.reset(new api::RemoveCommand(makeDocumentBucket(bucket),
doc->getId(), 1000ull * seed + 2));
sendList.push_back(
new mbusprot::StorageCommand(cmd));
@@ -763,14 +768,14 @@ namespace {
} else if (seed % 5 == 3) { // Get
if ((entry->getBucketInfo().getChecksum() & 2) == 0) {
cmd.reset(new api::GetCommand(
- bucket, doc->getId(), "[all]"));
+ makeDocumentBucket(bucket), doc->getId(), "[all]"));
sendList.push_back(
new mbusprot::StorageCommand(cmd));
}
} else { // Put
if ((entry->getBucketInfo().getChecksum() & 2) == 0) {
cmd.reset(new api::PutCommand(
- bucket, doc, 1000ull * seed + 1));
+ makeDocumentBucket(bucket), doc, 1000ull * seed + 1));
sendList.push_back(
new mbusprot::StorageCommand(cmd));
}