summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2017-10-04 11:37:21 +0000
committerTor Egge <Tor.Egge@oath.com>2017-10-04 14:20:19 +0000
commit3f419f70b9ae6dffbb07c3f042a8482dc413c278 (patch)
tree0bfa00c37d2b0a00a3815536e3dc1f351e27d70b /storage
parent80d54b0d844c964b0ce1cf42cce3f0373ef327a4 (diff)
Use document::Bucket in storage::spi::Bucket to add bucket space.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/persistence/common/filestortestfixture.cpp5
-rw-r--r--storage/src/tests/persistence/filestorage/deactivatebucketstest.cpp5
-rw-r--r--storage/src/tests/persistence/filestorage/filestormanagertest.cpp20
-rw-r--r--storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp11
-rw-r--r--storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp7
-rw-r--r--storage/src/tests/persistence/legacyoperationhandlertest.cpp4
-rw-r--r--storage/src/tests/persistence/persistencetestutils.cpp22
-rw-r--r--storage/src/tests/persistence/persistencethread_splittest.cpp6
-rw-r--r--storage/src/tests/persistence/provider_error_wrapper_test.cpp5
-rw-r--r--storage/src/tests/persistence/splitbitdetectortest.cpp28
-rw-r--r--storage/src/tests/persistence/testandsettest.cpp4
-rw-r--r--storage/src/vespa/storage/persistence/diskmoveoperationhandler.cpp4
-rw-r--r--storage/src/vespa/storage/persistence/mergehandler.cpp10
-rw-r--r--storage/src/vespa/storage/persistence/persistencethread.cpp40
-rw-r--r--storage/src/vespa/storage/persistence/persistenceutil.cpp2
-rw-r--r--storage/src/vespa/storage/persistence/processallhandler.cpp5
16 files changed, 99 insertions, 79 deletions
diff --git a/storage/src/tests/persistence/common/filestortestfixture.cpp b/storage/src/tests/persistence/common/filestortestfixture.cpp
index b7a849e3381..b0225992a20 100644
--- a/storage/src/tests/persistence/common/filestortestfixture.cpp
+++ b/storage/src/tests/persistence/common/filestortestfixture.cpp
@@ -4,8 +4,11 @@
#include <vespa/storage/persistence/filestorage/filestormanager.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
+#include <vespa/persistence/spi/test.h>
#include <sstream>
+using storage::spi::test::makeBucket;
+
namespace storage {
spi::LoadType FileStorTestFixture::defaultLoadType = spi::LoadType(0, "default");
@@ -50,7 +53,7 @@ FileStorTestFixture::createBucket(const document::BucketId& bid)
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
_node->getPersistenceProvider().createBucket(
- spi::Bucket(bid, spi::PartitionId(0)), context);
+ makeBucket(bid), context);
StorBucketDatabase::WrappedEntry entry(
_node->getStorageBucketDatabase().get(bid, "foo",
diff --git a/storage/src/tests/persistence/filestorage/deactivatebucketstest.cpp b/storage/src/tests/persistence/filestorage/deactivatebucketstest.cpp
index 932443e1e5d..e76828c1eb2 100644
--- a/storage/src/tests/persistence/filestorage/deactivatebucketstest.cpp
+++ b/storage/src/tests/persistence/filestorage/deactivatebucketstest.cpp
@@ -3,10 +3,13 @@
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/storageapi/message/bucket.h>
#include <vespa/storageapi/message/state.h>
+#include <vespa/persistence/spi/test.h>
#include <tests/persistence/common/persistenceproviderwrapper.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
+using storage::spi::test::makeBucket;
+
namespace storage {
class DeactivateBucketsTest : public FileStorTestFixture
@@ -41,7 +44,7 @@ DeactivateBucketsTest::bucketsInDatabaseDeactivatedWhenNodeDownInClusterState()
lib::ClusterState::CSP(new lib::ClusterState(upState)));
document::BucketId bucket(8, 123);
- spi::Bucket spiBucket(bucket, spi::PartitionId(0));
+ spi::Bucket spiBucket(makeBucket(bucket));
createBucket(bucket);
api::BucketInfo serviceLayerInfo(1, 2, 3, 4, 5, true, true);
diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
index 4ac1d553ec1..0b8ee0113ea 100644
--- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
+++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
@@ -28,6 +28,7 @@
#include <vespa/storageapi/message/persistence.h>
#include <vespa/storageapi/message/removelocation.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/storageapi/message/batch.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/fastos/file.h>
@@ -38,6 +39,7 @@ LOG_SETUP(".filestormanagertest");
using std::unique_ptr;
using document::Document;
using namespace storage::api;
+using storage::spi::test::makeBucket;
#define ASSERT_SINGLE_REPLY(replytype, reply, link, time) \
reply = 0; \
@@ -154,7 +156,7 @@ struct FileStorManagerTest : public CppUnit::TestFixture {
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
_node->getPersistenceProvider().createBucket(
- spi::Bucket(bid, spi::PartitionId(disk)), context);
+ makeBucket(bid, spi::PartitionId(disk)), context);
StorBucketDatabase::WrappedEntry entry(
_node->getStorageBucketDatabase().get(bid, "foo",
@@ -1306,7 +1308,7 @@ FileStorManagerTest::testPriority()
spi::Trace::TraceLevel(0));
_node->getPersistenceProvider().createBucket(
- spi::Bucket(bucket, spi::PartitionId(0)), context);
+ makeBucket(bucket), context);
}
// Populate bucket with the given data
@@ -1395,7 +1397,7 @@ FileStorManagerTest::testSplit1()
documents[i]->getId()).getRawId());
_node->getPersistenceProvider().createBucket(
- spi::Bucket(bucket, spi::PartitionId(0)), context);
+ makeBucket(bucket), context);
std::shared_ptr<api::PutCommand> cmd(
new api::PutCommand(bucket, documents[i], 100 + i));
@@ -1570,7 +1572,7 @@ FileStorManagerTest::testSplitSingleGroup()
documents[i]->getId()).getRawId());
_node->getPersistenceProvider().createBucket(
- spi::Bucket(bucket, spi::PartitionId(0)), context);
+ makeBucket(bucket), context);
std::shared_ptr<api::PutCommand> cmd(
new api::PutCommand(bucket, documents[i], 100 + i));
@@ -1645,7 +1647,7 @@ FileStorManagerTest::putDoc(DummyStorageLink& top,
document::BucketId bucket(16, factory.getBucketId(docId).getRawId());
//std::cerr << "doc bucket is " << bucket << " vs source " << source << "\n";
_node->getPersistenceProvider().createBucket(
- spi::Bucket(target, spi::PartitionId(0)), context);
+ makeBucket(target), context);
Document::SP doc(new Document(*_testdoctype1, docId));
std::shared_ptr<api::PutCommand> cmd(
new api::PutCommand(target, doc, docNum+1));
@@ -1920,7 +1922,7 @@ createIterator(DummyStorageLink& link,
framework::MicroSecTime toTime = framework::MicroSecTime::max(),
bool headerOnly = false)
{
- spi::Bucket bucket(bucketId, spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(bucketId));
spi::Selection selection =
spi::Selection(spi::DocumentSelection(docSel));
@@ -2877,7 +2879,7 @@ FileStorManagerTest::testSetBucketActiveState()
createBucket(bid, disk);
spi::dummy::DummyPersistence& provider(
dynamic_cast<spi::dummy::DummyPersistence&>(_node->getPersistenceProvider()));
- CPPUNIT_ASSERT(!provider.isActive(spi::Bucket(bid, spi::PartitionId(disk))));
+ CPPUNIT_ASSERT(!provider.isActive(makeBucket(bid, spi::PartitionId(disk))));
{
std::shared_ptr<api::SetBucketStateCommand> cmd(
@@ -2895,7 +2897,7 @@ FileStorManagerTest::testSetBucketActiveState()
CPPUNIT_ASSERT_EQUAL(ReturnCode(ReturnCode::OK), reply->getResult());
}
- CPPUNIT_ASSERT(provider.isActive(spi::Bucket(bid, spi::PartitionId(disk))));
+ CPPUNIT_ASSERT(provider.isActive(makeBucket(bid, spi::PartitionId(disk))));
{
StorBucketDatabase::WrappedEntry entry(
_node->getStorageBucketDatabase().get(
@@ -2939,7 +2941,7 @@ FileStorManagerTest::testSetBucketActiveState()
CPPUNIT_ASSERT_EQUAL(ReturnCode(ReturnCode::OK), reply->getResult());
}
- CPPUNIT_ASSERT(!provider.isActive(spi::Bucket(bid, spi::PartitionId(disk))));
+ CPPUNIT_ASSERT(!provider.isActive(makeBucket(bid, spi::PartitionId(disk))));
{
StorBucketDatabase::WrappedEntry entry(
_node->getStorageBucketDatabase().get(
diff --git a/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp b/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp
index 0a195b4610a..856add700e7 100644
--- a/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp
+++ b/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp
@@ -3,10 +3,13 @@
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/storageapi/message/bucket.h>
#include <vespa/storage/persistence/filestorage/modifiedbucketchecker.h>
+#include <vespa/persistence/spi/test.h>
#include <tests/persistence/common/persistenceproviderwrapper.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
+using storage::spi::test::makeBucket;
+
namespace storage {
/**
@@ -73,7 +76,7 @@ FileStorModifiedBucketsTest::modifyBuckets(uint32_t first, uint32_t count)
for (uint32_t i = 0; i < count; ++i) {
buckets.push_back(document::BucketId(16, first + i));
_node->getPersistenceProvider().setActiveState(
- spi::Bucket(buckets[i], spi::PartitionId(0)),
+ makeBucket(buckets[i]),
spi::BucketInfo::ACTIVE);
}
@@ -91,7 +94,7 @@ FileStorModifiedBucketsTest::modifiedBucketsSendNotifyBucketChange()
for (uint32_t i = 0; i < numBuckets; ++i) {
document::BucketId bucket(16, i);
- createBucket(spi::Bucket(bucket, spi::PartitionId(0)));
+ createBucket(makeBucket(bucket));
c.sendPut(bucket, DocumentIndex(0), PutTimestamp(1000));
}
c.top.waitForMessages(numBuckets, MSG_WAIT_TIME);
@@ -119,7 +122,7 @@ FileStorModifiedBucketsTest::fileStorRepliesToRecheckBucketCommands()
setClusterState("storage:1 distributor:1");
document::BucketId bucket(16, 0);
- createBucket(spi::Bucket(bucket, spi::PartitionId(0)));
+ createBucket(makeBucket(bucket));
c.sendPut(bucket, DocumentIndex(0), PutTimestamp(1000));
c.top.waitForMessages(1, MSG_WAIT_TIME);
c.top.reset();
@@ -131,7 +134,7 @@ FileStorModifiedBucketsTest::fileStorRepliesToRecheckBucketCommands()
// If we don't reply to the recheck bucket commands, we won't trigger
// a new round of getModifiedBuckets and recheck commands.
c.top.reset();
- createBucket(spi::Bucket(document::BucketId(16, 1), spi::PartitionId(0)));
+ createBucket(makeBucket(document::BucketId(16, 1)));
modifyBuckets(1, 1);
c.top.waitForMessages(1, MSG_WAIT_TIME);
assertIsNotifyCommandWithActiveBucket(*c.top.getReply(0));
diff --git a/storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp b/storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp
index 5ae7250542a..ef49f7cd5dd 100644
--- a/storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp
+++ b/storage/src/tests/persistence/filestorage/sanitycheckeddeletetest.cpp
@@ -2,10 +2,13 @@
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/storageapi/message/bucket.h>
+#include <vespa/persistence/spi/test.h>
#include <tests/persistence/common/persistenceproviderwrapper.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/common/filestortestfixture.h>
+using storage::spi::test::makeBucket;
+
namespace storage {
class SanityCheckedDeleteTest : public FileStorTestFixture {
@@ -27,7 +30,7 @@ void SanityCheckedDeleteTest::delete_bucket_fails_when_provider_out_of_sync() {
TestFileStorComponents c(*this, "delete_bucket_fails_when_provider_out_of_sync");
document::BucketId bucket(8, 123);
document::BucketId syncBucket(8, 234);
- spi::Bucket spiBucket(bucket, spi::PartitionId(0));
+ spi::Bucket spiBucket(makeBucket(bucket));
// Send a put to ensure bucket isn't empty.
spi::BucketInfo infoBefore(send_put_and_get_bucket_info(c, spiBucket));
@@ -81,7 +84,7 @@ spi::BucketInfo SanityCheckedDeleteTest::send_put_and_get_bucket_info(
void SanityCheckedDeleteTest::differing_document_sizes_not_considered_out_of_sync() {
TestFileStorComponents c(*this, "differing_document_sizes_not_considered_out_of_sync");
document::BucketId bucket(8, 123);
- spi::Bucket spiBucket(bucket, spi::PartitionId(0));
+ spi::Bucket spiBucket(makeBucket(bucket));
spi::BucketInfo info_before(send_put_and_get_bucket_info(c, spiBucket));
// Expect 1 byte of reported size, which will mismatch with the actually put document.
diff --git a/storage/src/tests/persistence/legacyoperationhandlertest.cpp b/storage/src/tests/persistence/legacyoperationhandlertest.cpp
index c4d2f12014a..6ceff0661b1 100644
--- a/storage/src/tests/persistence/legacyoperationhandlertest.cpp
+++ b/storage/src/tests/persistence/legacyoperationhandlertest.cpp
@@ -5,11 +5,13 @@
#include <vespa/storage/persistence/messages.h>
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/storageapi/message/multioperation.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <tests/persistence/persistencetestutils.h>
using document::DocumentTypeRepo;
using document::TestDocRepo;
+using storage::spi::test::makeBucket;
namespace storage {
@@ -30,7 +32,7 @@ public:
spi::Context context(spi::LoadType(0, "default"), spi::Priority(0),
spi::Trace::TraceLevel(0));
getPersistenceProvider().createBucket(
- spi::Bucket(document::BucketId(16, 4), spi::PartitionId(0)),
+ makeBucket(document::BucketId(16, 4)),
context);
}
diff --git a/storage/src/tests/persistence/persistencetestutils.cpp b/storage/src/tests/persistence/persistencetestutils.cpp
index d8da1a63e9e..0fd5a30d8bd 100644
--- a/storage/src/tests/persistence/persistencetestutils.cpp
+++ b/storage/src/tests/persistence/persistencetestutils.cpp
@@ -4,12 +4,14 @@
#include <vespa/storageapi/message/persistence.h>
#include <tests/persistence/persistencetestutils.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/document/update/assignvalueupdate.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/exceptions.h>
using document::DocumentType;
using storage::framework::defaultimplementation::AllocationLogic;
+using storage::spi::test::makeBucket;
namespace storage {
@@ -78,7 +80,7 @@ PersistenceTestUtils::~PersistenceTestUtils()
std::string
PersistenceTestUtils::dumpBucket(const document::BucketId& bid,
uint16_t disk) {
- return dynamic_cast<spi::dummy::DummyPersistence&>(_env->_node.getPersistenceProvider()).dumpBucket(spi::Bucket(bid, spi::PartitionId(disk)));
+ return dynamic_cast<spi::dummy::DummyPersistence&>(_env->_node.getPersistenceProvider()).dumpBucket(makeBucket(bid, spi::PartitionId(disk)));
}
void
@@ -166,7 +168,7 @@ PersistenceTestUtils::doPutOnDisk(
{
document::Document::SP doc(createRandomDocumentAtLocation(
location, timestamp, minSize, maxSize));
- spi::Bucket b(document::BucketId(16, location), spi::PartitionId(disk));
+ spi::Bucket b(makeBucket(document::BucketId(16, location), spi::PartitionId(disk)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
@@ -190,12 +192,12 @@ PersistenceTestUtils::doRemoveOnDisk(
spi::Trace::TraceLevel(0));
if (persistRemove) {
spi::RemoveResult result = getPersistenceProvider().removeIfFound(
- spi::Bucket(bucketId, spi::PartitionId(disk)),
+ makeBucket(bucketId, spi::PartitionId(disk)),
timestamp, docId, context);
return result.wasFound();
}
spi::RemoveResult result = getPersistenceProvider().remove(
- spi::Bucket(bucketId, spi::PartitionId(disk)),
+ makeBucket(bucketId, spi::PartitionId(disk)),
timestamp, docId, context);
return result.wasFound();
@@ -211,7 +213,7 @@ PersistenceTestUtils::doUnrevertableRemoveOnDisk(
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
spi::RemoveResult result = getPersistenceProvider().remove(
- spi::Bucket(bucketId, spi::PartitionId(disk)),
+ makeBucket(bucketId, spi::PartitionId(disk)),
timestamp, docId, context);
return result.wasFound();
}
@@ -229,7 +231,7 @@ PersistenceTestUtils::doGetOnDisk(
if (headerOnly) {
fieldSet.reset(new document::HeaderFields());
}
- return getPersistenceProvider().get(spi::Bucket(
+ return getPersistenceProvider().get(makeBucket(
bucketId, spi::PartitionId(disk)), *fieldSet, docId, context);
}
@@ -305,7 +307,7 @@ PersistenceTestUtils::doPut(const document::Document::SP& doc,
spi::Timestamp time,
uint16_t disk)
{
- spi::Bucket b(bid, spi::PartitionId(disk));
+ spi::Bucket b(makeBucket(bid, spi::PartitionId(disk)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
getPersistenceProvider().createBucket(b, context);
@@ -321,7 +323,7 @@ PersistenceTestUtils::doUpdate(document::BucketId bid,
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
return getPersistenceProvider().update(
- spi::Bucket(bid, spi::PartitionId(disk)), time, update, context);
+ makeBucket(bid, spi::PartitionId(disk)), time, update, context);
}
void
@@ -337,10 +339,10 @@ PersistenceTestUtils::doRemove(const document::DocumentId& id, spi::Timestamp ti
spi::Trace::TraceLevel(0));
if (unrevertableRemove) {
getPersistenceProvider().remove(
- spi::Bucket(bucket, spi::PartitionId(disk)), time, id, context);
+ makeBucket(bucket, spi::PartitionId(disk)), time, id, context);
} else {
spi::RemoveResult result = getPersistenceProvider().removeIfFound(
- spi::Bucket(bucket, spi::PartitionId(disk)), time, id, context);
+ makeBucket(bucket, spi::PartitionId(disk)), time, id, context);
if (!result.wasFound()) {
throw vespalib::IllegalStateException(
"Attempted to remove non-existing doc " + id.toString(),
diff --git a/storage/src/tests/persistence/persistencethread_splittest.cpp b/storage/src/tests/persistence/persistencethread_splittest.cpp
index 7eeeeb1e909..df43b714dcb 100644
--- a/storage/src/tests/persistence/persistencethread_splittest.cpp
+++ b/storage/src/tests/persistence/persistencethread_splittest.cpp
@@ -3,8 +3,11 @@
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/storage/persistence/persistencethread.h>
#include <vespa/storageapi/message/bucketsplitting.h>
+#include <vespa/persistence/spi/test.h>
#include <tests/persistence/persistencetestutils.h>
+using storage::spi::test::makeBucket;
+
namespace storage {
namespace {
spi::LoadType defaultLoadType(0, "default");
@@ -174,8 +177,7 @@ PersistenceThread_SplitTest::doTest(SplitCase splitCase)
uint64_t splitMask = 1 << (splitLevelToDivide - 1);
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
- spi::Bucket bucket(document::BucketId(currentSplitLevel, 1),
- spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(currentSplitLevel, 1)));
spi::PersistenceProvider& spi(getPersistenceProvider());
spi.deleteBucket(bucket, context);
spi.createBucket(bucket, context);
diff --git a/storage/src/tests/persistence/provider_error_wrapper_test.cpp b/storage/src/tests/persistence/provider_error_wrapper_test.cpp
index 7a8f26cbe93..397bc740e55 100644
--- a/storage/src/tests/persistence/provider_error_wrapper_test.cpp
+++ b/storage/src/tests/persistence/provider_error_wrapper_test.cpp
@@ -1,9 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vdstestlib/cppunit/macros.h>
+#include <vespa/persistence/spi/test.h>
#include <tests/persistence/persistencetestutils.h>
#include <tests/persistence/common/persistenceproviderwrapper.h>
+using storage::spi::test::makeBucket;
+
namespace storage {
class ProviderErrorWrapperTest : public SingleDiskPersistenceTestUtils {
@@ -61,7 +64,7 @@ struct Fixture {
~Fixture() {}
void perform_spi_operation() {
- errorWrapper.getBucketInfo(spi::Bucket(document::BucketId(16, 1234), spi::PartitionId(0)));
+ errorWrapper.getBucketInfo(makeBucket(document::BucketId(16, 1234)));
}
void check_no_listener_invoked_for_error(MockErrorListener& listener, spi::Result::ErrorType error) {
diff --git a/storage/src/tests/persistence/splitbitdetectortest.cpp b/storage/src/tests/persistence/splitbitdetectortest.cpp
index 60f76c2df60..30904e3da3d 100644
--- a/storage/src/tests/persistence/splitbitdetectortest.cpp
+++ b/storage/src/tests/persistence/splitbitdetectortest.cpp
@@ -5,10 +5,12 @@
#include <vespa/storage/persistence/splitbitdetector.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/document/base/testdocman.h>
#include <vespa/document/bucket/bucketidfactory.h>
#include <algorithm>
+using storage::spi::test::makeBucket;
namespace storage {
@@ -61,8 +63,7 @@ SplitBitDetectorTest::testTwoUsers()
document::TestDocMan testDocMan;
spi::dummy::DummyPersistence provider(testDocMan.getTypeRepoSP(), 1);
provider.getPartitionStates();
- spi::Bucket bucket(document::BucketId(1, 1),
- spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(1, 1)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
@@ -95,8 +96,7 @@ SplitBitDetectorTest::testSingleUser()
document::TestDocMan testDocMan;
spi::dummy::DummyPersistence provider(testDocMan.getTypeRepoSP(), 1);
provider.getPartitionStates();
- spi::Bucket bucket(document::BucketId(1, 1),
- spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(1, 1)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
@@ -123,8 +123,7 @@ SplitBitDetectorTest::testMaxBits()
document::TestDocMan testDocMan;
spi::dummy::DummyPersistence provider(testDocMan.getTypeRepoSP(), 1);
provider.getPartitionStates();
- spi::Bucket bucket(document::BucketId(1, 1),
- spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(1, 1)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
int minContentSize = 1, maxContentSize = 1;
@@ -153,7 +152,7 @@ SplitBitDetectorTest::testMaxBitsOneBelowMax()
document::TestDocMan testDocMan;
spi::dummy::DummyPersistence provider(testDocMan.getTypeRepoSP(), 1);
provider.getPartitionStates();
- spi::Bucket bucket(document::BucketId(15, 1), spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(15, 1)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
int minContentSize = 1, maxContentSize = 1;
@@ -191,8 +190,7 @@ SplitBitDetectorTest::testUnsplittable()
document::TestDocMan testDocMan;
spi::dummy::DummyPersistence provider(testDocMan.getTypeRepoSP(), 1);
provider.getPartitionStates();
- spi::Bucket bucket(document::BucketId(1, 1),
- spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(1, 1)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
@@ -220,8 +218,7 @@ SplitBitDetectorTest::testUnsplittableMinCount()
document::TestDocMan testDocMan;
spi::dummy::DummyPersistence provider(testDocMan.getTypeRepoSP(), 1);
provider.getPartitionStates();
- spi::Bucket bucket(document::BucketId(1, 1),
- spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(1, 1)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
@@ -251,8 +248,7 @@ SplitBitDetectorTest::testEmpty()
document::TestDocMan testDocMan;
spi::dummy::DummyPersistence provider(testDocMan.getTypeRepoSP(), 1);
provider.getPartitionStates();
- spi::Bucket bucket(document::BucketId(1, 1),
- spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(1, 1)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
@@ -271,8 +267,7 @@ SplitBitDetectorTest::testZeroDocLimitFallbacksToOneBitIncreaseWith1Doc()
document::TestDocMan testDocMan;
spi::dummy::DummyPersistence provider(testDocMan.getTypeRepoSP(), 1);
provider.getPartitionStates();
- spi::Bucket bucket(document::BucketId(1, 1),
- spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(1, 1)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
@@ -295,8 +290,7 @@ SplitBitDetectorTest::testZeroDocLimitFallbacksToOneBitIncreaseOnGidCollision()
document::TestDocMan testDocMan;
spi::dummy::DummyPersistence provider(testDocMan.getTypeRepoSP(), 1);
provider.getPartitionStates();
- spi::Bucket bucket(document::BucketId(1, 1),
- spi::PartitionId(0));
+ spi::Bucket bucket(makeBucket(document::BucketId(1, 1)));
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
diff --git a/storage/src/tests/persistence/testandsettest.cpp b/storage/src/tests/persistence/testandsettest.cpp
index bdef347dc1c..2c1c15dee87 100644
--- a/storage/src/tests/persistence/testandsettest.cpp
+++ b/storage/src/tests/persistence/testandsettest.cpp
@@ -6,12 +6,14 @@
#include <vespa/documentapi/messagebus/messages/testandsetcondition.h>
#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/document/update/assignvalueupdate.h>
+#include <vespa/persistence/spi/test.h>
#include <functional>
using std::unique_ptr;
using std::shared_ptr;
using namespace std::string_literals;
+using storage::spi::test::makeBucket;
namespace storage {
@@ -42,7 +44,7 @@ public:
createBucket(BUCKET_ID);
getPersistenceProvider().createBucket(
- spi::Bucket(BUCKET_ID, spi::PartitionId(0)),
+ makeBucket(BUCKET_ID),
context);
thread = createPersistenceThread(0);
diff --git a/storage/src/vespa/storage/persistence/diskmoveoperationhandler.cpp b/storage/src/vespa/storage/persistence/diskmoveoperationhandler.cpp
index 35f49b6e618..86b04066a5a 100644
--- a/storage/src/vespa/storage/persistence/diskmoveoperationhandler.cpp
+++ b/storage/src/vespa/storage/persistence/diskmoveoperationhandler.cpp
@@ -45,8 +45,8 @@ DiskMoveOperationHandler::handleBucketDiskMove(BucketDiskMoveCommand& cmd,
bucket.toString().c_str(),
deviceIndex, targetDisk);
- spi::Bucket from(bucket, spi::PartitionId(deviceIndex));
- spi::Bucket to(bucket, spi::PartitionId(targetDisk));
+ spi::Bucket from(document::Bucket(document::BucketSpace::placeHolder(), bucket), spi::PartitionId(deviceIndex));
+ spi::Bucket to(document::Bucket(document::BucketSpace::placeHolder(), bucket), spi::PartitionId(targetDisk));
spi::Result result(
_provider.move(from, spi::PartitionId(targetDisk), context));
diff --git a/storage/src/vespa/storage/persistence/mergehandler.cpp b/storage/src/vespa/storage/persistence/mergehandler.cpp
index 37fc36c820a..36e417b65e4 100644
--- a/storage/src/vespa/storage/persistence/mergehandler.cpp
+++ b/storage/src/vespa/storage/persistence/mergehandler.cpp
@@ -956,7 +956,7 @@ MergeHandler::handleMergeBucket(api::MergeBucketCommand& cmd,
_env._component.getClock()));
const document::BucketId& id(cmd.getBucketId());
- spi::Bucket bucket(id, spi::PartitionId(_env._partition));
+ spi::Bucket bucket(document::Bucket(document::BucketSpace::placeHolder(), id), spi::PartitionId(_env._partition));
LOG(debug, "MergeBucket(%s) with max timestamp %" PRIu64 ".",
bucket.toString().c_str(), cmd.getMaxTimestamp());
@@ -1182,7 +1182,7 @@ MergeHandler::handleGetBucketDiff(api::GetBucketDiffCommand& cmd,
_env._metrics.getBucketDiff,
_env._component.getClock()));
const document::BucketId& id(cmd.getBucketId());
- spi::Bucket bucket(id, spi::PartitionId(_env._partition));
+ spi::Bucket bucket(document::Bucket(document::BucketSpace::placeHolder(), id), spi::PartitionId(_env._partition));
LOG(debug, "GetBucketDiff(%s)", bucket.toString().c_str());
checkResult(_spi.createBucket(bucket, context), bucket, "create bucket");
@@ -1305,7 +1305,7 @@ MergeHandler::handleGetBucketDiffReply(api::GetBucketDiffReply& reply,
{
++_env._metrics.getBucketDiffReply;
document::BucketId id(reply.getBucketId());
- spi::Bucket bucket(id, spi::PartitionId(_env._partition));
+ spi::Bucket bucket(document::Bucket(document::BucketSpace::placeHolder(), id), spi::PartitionId(_env._partition));
LOG(debug, "GetBucketDiffReply(%s)", bucket.toString().c_str());
if (!_env._fileStorHandler.isMerging(id)) {
@@ -1389,7 +1389,7 @@ MergeHandler::handleApplyBucketDiff(api::ApplyBucketDiffCommand& cmd,
_env._component.getClock()));
const document::BucketId& id(cmd.getBucketId());
- spi::Bucket bucket(id, spi::PartitionId(_env._partition));
+ spi::Bucket bucket(document::Bucket(document::BucketSpace::placeHolder(), id), spi::PartitionId(_env._partition));
LOG(debug, "%s", cmd.toString().c_str());
if (_env._fileStorHandler.isMerging(id)) {
@@ -1485,7 +1485,7 @@ MergeHandler::handleApplyBucketDiffReply(api::ApplyBucketDiffReply& reply,
{
++_env._metrics.applyBucketDiffReply;
document::BucketId id(reply.getBucketId());
- spi::Bucket bucket(id, spi::PartitionId(_env._partition));
+ spi::Bucket bucket(document::Bucket(document::BucketSpace::placeHolder(), id), spi::PartitionId(_env._partition));
std::vector<api::ApplyBucketDiffCommand::Entry>& diff(reply.getDiff());
LOG(debug, "%s", reply.toString().c_str());
diff --git a/storage/src/vespa/storage/persistence/persistencethread.cpp b/storage/src/vespa/storage/persistence/persistencethread.cpp
index 4755795526a..ff0bb378676 100644
--- a/storage/src/vespa/storage/persistence/persistencethread.cpp
+++ b/storage/src/vespa/storage/persistence/persistencethread.cpp
@@ -78,7 +78,7 @@ PersistenceThread::getBucket(const DocumentId& id,
+ "bucket " + bucket.toString() + ".", VESPA_STRLOC);
}
- return spi::Bucket(bucket, spi::PartitionId(_env._partition));
+ return spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), bucket), spi::PartitionId(_env._partition));
}
bool
@@ -231,7 +231,7 @@ PersistenceThread::handleRepairBucket(RepairBucketCommand& cmd)
(cmd.verifyBody() ? "Verifying body" : "Not verifying body"));
api::BucketInfo before = _env.getBucketInfo(cmd.getBucketId());
spi::Result result =
- _spi.maintain(spi::Bucket(cmd.getBucketId(),
+ _spi.maintain(spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()),
spi::PartitionId(_env._partition)),
cmd.verifyBody() ?
spi::HIGH : spi::LOW);
@@ -257,7 +257,7 @@ PersistenceThread::handleMultiOperation(api::MultiOperationCommand& cmd)
MessageTracker::UP tracker(new MessageTracker(
_env._metrics.multiOp[cmd.getLoadType()],
_env._component.getClock()));
- spi::Bucket b = spi::Bucket(cmd.getBucketId(),
+ spi::Bucket b = spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()),
spi::PartitionId(_env._partition));
long puts = 0;
long removes = 0;
@@ -314,7 +314,7 @@ PersistenceThread::handleRevert(api::RevertCommand& cmd)
MessageTracker::UP tracker(new MessageTracker(
_env._metrics.revert[cmd.getLoadType()],
_env._component.getClock()));
- spi::Bucket b = spi::Bucket(cmd.getBucketId(),
+ spi::Bucket b = spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()),
spi::PartitionId(_env._partition));
const std::vector<api::Timestamp> tokens = cmd.getRevertTokens();
for (uint32_t i = 0; i < tokens.size(); ++i) {
@@ -337,7 +337,7 @@ PersistenceThread::handleCreateBucket(api::CreateBucketCommand& cmd)
cmd.getBucketId().toString().c_str());
DUMP_LOGGED_BUCKET_OPERATIONS(cmd.getBucketId());
}
- spi::Bucket spiBucket(cmd.getBucketId(), spi::PartitionId(_env._partition));
+ spi::Bucket spiBucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()), spi::PartitionId(_env._partition));
_spi.createBucket(spiBucket, _context);
if (cmd.getActive()) {
_spi.setActiveState(spiBucket, spi::BucketInfo::ACTIVE);
@@ -406,7 +406,7 @@ PersistenceThread::handleDeleteBucket(api::DeleteBucketCommand& cmd)
api::ReturnCode(api::ReturnCode::ABORTED,
"Bucket was deleted during the merge"));
}
- spi::Bucket bucket(cmd.getBucketId(), spi::PartitionId(_env._partition));
+ spi::Bucket bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()), spi::PartitionId(_env._partition));
if (!checkProviderBucketInfoMatches(bucket, cmd.getBucketInfo())) {
return tracker;
}
@@ -497,7 +497,7 @@ PersistenceThread::handleCreateIterator(CreateIteratorCommand& cmd)
// _context is reset per command, so it's safe to modify it like this.
_context.setReadConsistency(cmd.getReadConsistency());
spi::CreateIteratorResult result(_spi.createIterator(
- spi::Bucket(cmd.getBucketId(), spi::PartitionId(_env._partition)),
+ spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()), spi::PartitionId(_env._partition)),
*fieldSet,
cmd.getSelection(),
cmd.getIncludedVersions(),
@@ -533,7 +533,7 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd)
return tracker;
}
- spi::Bucket spiBucket(cmd.getBucketId(), spi::PartitionId(_env._partition));
+ spi::Bucket spiBucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()), spi::PartitionId(_env._partition));
SplitBitDetector::Result targetInfo;
if (_env._config.enableMultibitSplitOptimalization) {
targetInfo = SplitBitDetector::detectSplit(
@@ -581,8 +581,8 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd)
#endif
spi::Result result = _spi.split(
spiBucket,
- spi::Bucket(target1, spi::PartitionId(lock1.disk)),
- spi::Bucket(target2, spi::PartitionId(lock2.disk)), _context);
+ spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), target1), spi::PartitionId(lock1.disk)),
+ spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), target2), spi::PartitionId(lock2.disk)), _context);
if (result.hasError()) {
tracker->fail(_env.convertErrorCode(result),
result.getErrorMessage());
@@ -646,7 +646,7 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd)
// to an empty target bucket, since the provider will have
// implicitly erased it by this point.
spi::Bucket createTarget(
- spi::Bucket(targets[i].second.bid,
+ spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), targets[i].second.bid),
spi::PartitionId(targets[i].second.diskIndex)));
LOG(debug,
"Split target %s was empty, but re-creating it since "
@@ -756,15 +756,15 @@ PersistenceThread::handleJoinBuckets(api::JoinBucketsCommand& cmd)
}
#endif
spi::Result result =
- _spi.join(spi::Bucket(firstBucket, spi::PartitionId(lock1.disk)),
- spi::Bucket(secondBucket, spi::PartitionId(lock2.disk)),
- spi::Bucket(cmd.getBucketId(),
+ _spi.join(spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), firstBucket), spi::PartitionId(lock1.disk)),
+ spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), secondBucket), spi::PartitionId(lock2.disk)),
+ spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()),
spi::PartitionId(_env._partition)),
_context);
if (!checkForError(result, *tracker)) {
return tracker;
}
- result = _spi.flush(spi::Bucket(cmd.getBucketId(),
+ result = _spi.flush(spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()),
spi::PartitionId(_env._partition)),
_context);
if (!checkForError(result, *tracker)) {
@@ -813,7 +813,7 @@ PersistenceThread::handleSetBucketState(api::SetBucketStateCommand& cmd)
NotificationGuard notifyGuard(*_bucketOwnershipNotifier);
LOG(debug, "handleSetBucketState(): %s", cmd.toString().c_str());
- spi::Bucket bucket(cmd.getBucketId(), spi::PartitionId(_env._partition));
+ spi::Bucket bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()), spi::PartitionId(_env._partition));
bool shouldBeActive(cmd.getState() == api::SetBucketStateCommand::ACTIVE);
spi::BucketInfo::ActiveState newState(
shouldBeActive
@@ -861,11 +861,11 @@ PersistenceThread::handleInternalBucketJoin(InternalBucketJoinCommand& cmd)
entry.write();
}
spi::Result result =
- _spi.join(spi::Bucket(cmd.getBucketId(),
+ _spi.join(spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()),
spi::PartitionId(cmd.getDiskOfInstanceToJoin())),
- spi::Bucket(cmd.getBucketId(),
+ spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()),
spi::PartitionId(cmd.getDiskOfInstanceToJoin())),
- spi::Bucket(cmd.getBucketId(),
+ spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()),
spi::PartitionId(cmd.getDiskOfInstanceToKeep())),
_context);
if (checkForError(result, *tracker)) {
@@ -1155,7 +1155,7 @@ PersistenceThread::flushAllReplies(
replies.size(), nputs, nremoves, nother));
}
#endif
- spi::Bucket b(bucketId, spi::PartitionId(_env._partition));
+ spi::Bucket b(document::Bucket(document::BucketSpace::placeHolder(), bucketId), spi::PartitionId(_env._partition));
spi::Result result = _spi.flush(b, _context);
uint32_t errorCode = _env.convertErrorCode(result);
if (errorCode != 0) {
diff --git a/storage/src/vespa/storage/persistence/persistenceutil.cpp b/storage/src/vespa/storage/persistence/persistenceutil.cpp
index 6f0833ef3cd..bc0b11ae15d 100644
--- a/storage/src/vespa/storage/persistence/persistenceutil.cpp
+++ b/storage/src/vespa/storage/persistence/persistenceutil.cpp
@@ -166,7 +166,7 @@ PersistenceUtil::getBucketInfo(const document::BucketId& bId, int disk) const
}
spi::BucketInfoResult response =
- _spi.getBucketInfo(spi::Bucket(bId, spi::PartitionId(disk)));
+ _spi.getBucketInfo(spi::Bucket(document::Bucket(document::BucketSpace::placeHolder(), bId), spi::PartitionId(disk)));
return convertBucketInfo(response.getBucketInfo());
}
diff --git a/storage/src/vespa/storage/persistence/processallhandler.cpp b/storage/src/vespa/storage/persistence/processallhandler.cpp
index fa7ea9f74a2..67b150ec70a 100644
--- a/storage/src/vespa/storage/persistence/processallhandler.cpp
+++ b/storage/src/vespa/storage/persistence/processallhandler.cpp
@@ -87,7 +87,8 @@ ProcessAllHandler::handleRemoveLocation(api::RemoveLocationCommand& cmd,
cmd.getBucketId().toString().c_str(),
cmd.getDocumentSelection().c_str());
- spi::Bucket bucket(cmd.getBucketId(),
+ spi::Bucket bucket(document::Bucket(document::BucketSpace::placeHolder(),
+ cmd.getBucketId()),
spi::PartitionId(_env._partition));
UnrevertableRemoveEntryProcessor processor(_spi, bucket, context);
BucketProcessor::iterateAll(_spi,
@@ -117,7 +118,7 @@ ProcessAllHandler::handleStatBucket(api::StatBucketCommand& cmd,
ost << "Persistence bucket " << cmd.getBucketId()
<< ", partition " << _env._partition << "\n";
- spi::Bucket bucket(cmd.getBucketId(),
+ spi::Bucket bucket(document::Bucket(document::BucketSpace::placeHolder(), cmd.getBucketId()),
spi::PartitionId(_env._partition));
StatEntryProcessor processor(ost);
BucketProcessor::iterateAll(_spi,