aboutsummaryrefslogtreecommitdiffstats
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
parent80d54b0d844c964b0ce1cf42cce3f0373ef327a4 (diff)
Use document::Bucket in storage::spi::Bucket to add bucket space.
-rw-r--r--document/src/vespa/document/bucket/bucketspace.h5
-rw-r--r--memfilepersistence/src/tests/spi/basicoperationhandlertest.cpp38
-rw-r--r--memfilepersistence/src/tests/spi/iteratorhandlertest.cpp33
-rw-r--r--memfilepersistence/src/tests/spi/joinoperationhandlertest.cpp32
-rw-r--r--memfilepersistence/src/tests/spi/memfileautorepairtest.cpp9
-rw-r--r--memfilepersistence/src/tests/spi/memfiletestutils.cpp22
-rw-r--r--memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp20
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/spi/memfilepersistenceprovider.cpp3
-rw-r--r--persistence/src/tests/spi/clusterstatetest.cpp2
-rw-r--r--persistence/src/vespa/persistence/conformancetest/conformancetest.cpp128
-rw-r--r--persistence/src/vespa/persistence/spi/CMakeLists.txt1
-rw-r--r--persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp2
-rw-r--r--persistence/src/vespa/persistence/spi/bucket.h13
-rw-r--r--persistence/src/vespa/persistence/spi/test.cpp17
-rw-r--r--persistence/src/vespa/persistence/spi/test.h14
-rw-r--r--searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp4
-rw-r--r--searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp4
-rw-r--r--searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp6
-rw-r--r--searchcore/src/tests/proton/server/documentretriever_test.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/bucketfactory.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp5
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h7
-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
41 files changed, 316 insertions, 245 deletions
diff --git a/document/src/vespa/document/bucket/bucketspace.h b/document/src/vespa/document/bucket/bucketspace.h
index 8f93526afa7..c13c81dbd73 100644
--- a/document/src/vespa/document/bucket/bucketspace.h
+++ b/document/src/vespa/document/bucket/bucketspace.h
@@ -32,6 +32,11 @@ public:
return std::hash<Type>()(bs.getId());
}
};
+
+ /*
+ * Temporary placeholder value while wiring in use of BucketSpace in APIs.
+ */
+ static BucketSpace placeHolder() { return BucketSpace(0); }
private:
Type _id;
};
diff --git a/memfilepersistence/src/tests/spi/basicoperationhandlertest.cpp b/memfilepersistence/src/tests/spi/basicoperationhandlertest.cpp
index 8011255324b..07bff2038e0 100644
--- a/memfilepersistence/src/tests/spi/basicoperationhandlertest.cpp
+++ b/memfilepersistence/src/tests/spi/basicoperationhandlertest.cpp
@@ -5,8 +5,10 @@
#include "options_builder.h"
#include <vespa/document/fieldset/fieldsetrepo.h>
#include <vespa/document/fieldset/fieldsets.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/vdstestlib/cppunit/macros.h>
+using storage::spi::test::makeBucket;
namespace storage {
namespace memfile {
@@ -142,8 +144,7 @@ BasicOperationHandlerTest::testRemove()
Timestamp(2),
OperationHandler::PERSIST_REMOVE_IF_FOUND));
- getPersistenceProvider().flush(
- spi::Bucket(bucketId, spi::PartitionId(0)), context);
+ getPersistenceProvider().flush(makeBucket(bucketId), context);
env()._cache.clear();
@@ -177,8 +178,7 @@ BasicOperationHandlerTest::doTestRemoveWithNonMatchingTimestamp(
Timestamp(1233),
persistRemove));
- getPersistenceProvider().flush(
- spi::Bucket(bucketId, spi::PartitionId(0)), context);
+ getPersistenceProvider().flush(makeBucket(bucketId), context);
MemFilePtr file(getMemFile(bucketId));
CPPUNIT_ASSERT_EQUAL(
@@ -241,8 +241,7 @@ BasicOperationHandlerTest::testRemoveForExistingRemoveSameTimestamp()
Timestamp(1235),
OperationHandler::PERSIST_REMOVE_IF_FOUND));
- getPersistenceProvider().flush(
- spi::Bucket(bucketId, spi::PartitionId(0)), context);
+ getPersistenceProvider().flush(makeBucket(bucketId), context);
// Should only be one remove entry still
MemFilePtr file(getMemFile(bucketId));
@@ -272,8 +271,7 @@ BasicOperationHandlerTest::doTestRemoveForExistingRemoveNewTimestamp(
Timestamp(1236),
persistRemove));
- getPersistenceProvider().flush(
- spi::Bucket(bucketId, spi::PartitionId(0)), context);
+ getPersistenceProvider().flush(makeBucket(bucketId), context);
MemFilePtr file(getMemFile(bucketId));
CPPUNIT_ASSERT_EQUAL(
@@ -327,16 +325,14 @@ BasicOperationHandlerTest::testRemoveExistingOlderDocumentVersion()
Timestamp(1235),
OperationHandler::ALWAYS_PERSIST_REMOVE));
- getPersistenceProvider().flush(
- spi::Bucket(bucketId, spi::PartitionId(0)), context);
+ getPersistenceProvider().flush(makeBucket(bucketId), context);
CPPUNIT_ASSERT_EQUAL(true, doRemove(bucketId,
doc->getId(),
Timestamp(1234),
OperationHandler::ALWAYS_PERSIST_REMOVE));
- getPersistenceProvider().flush(
- spi::Bucket(bucketId, spi::PartitionId(0)), context);
+ getPersistenceProvider().flush(makeBucket(bucketId), context);
// Should now be two remove entries.
MemFilePtr file(getMemFile(bucketId));
@@ -366,8 +362,7 @@ BasicOperationHandlerTest::doTestRemoveDocumentNotFound(
Timestamp(1235),
persistRemove));
- getPersistenceProvider().flush(
- spi::Bucket(bucketId, spi::PartitionId(0)), context);
+ getPersistenceProvider().flush(makeBucket(bucketId), context);
MemFilePtr file(getMemFile(bucketId));
CPPUNIT_ASSERT_EQUAL(
@@ -581,12 +576,8 @@ BasicOperationHandlerTest::testRemoveEntry()
Document::SP doc = doPut(4, Timestamp(2345));
doPut(4, Timestamp(3456));
- getPersistenceProvider().removeEntry(
- spi::Bucket(bucketId, spi::PartitionId(0)),
- spi::Timestamp(1234), context);
- getPersistenceProvider().removeEntry(
- spi::Bucket(bucketId, spi::PartitionId(0)),
- spi::Timestamp(3456), context);
+ getPersistenceProvider().removeEntry(makeBucket(bucketId), spi::Timestamp(1234), context);
+ getPersistenceProvider().removeEntry(makeBucket(bucketId), spi::Timestamp(3456), context);
flush(bucketId);
memfile::MemFilePtr file(getMemFile(bucketId));
@@ -683,9 +674,7 @@ BasicOperationHandlerTest::testEraseFromCacheOnMaintainException()
std::unique_ptr<Environment::LazyFileFactory>(
new SimulatedFailureLazyFile::Factory);
- spi::Result result = getPersistenceProvider().maintain(
- spi::Bucket(bucketId, spi::PartitionId(0)),
- spi::HIGH);
+ spi::Result result = getPersistenceProvider().maintain(makeBucket(bucketId), spi::HIGH);
CPPUNIT_ASSERT(result.hasError());
CPPUNIT_ASSERT(result.getErrorMessage().find("A simulated I/O write")
!= vespalib::string::npos);
@@ -720,8 +709,7 @@ BasicOperationHandlerTest::testEraseFromCacheOnDeleteBucketException()
std::unique_ptr<Environment::LazyFileFactory>(factory);
// loadFile will fail
- spi::Result result = getPersistenceProvider().deleteBucket(
- spi::Bucket(bucketId, spi::PartitionId(0)), context);
+ spi::Result result = getPersistenceProvider().deleteBucket(makeBucket(bucketId), context);
CPPUNIT_ASSERT(result.hasError());
CPPUNIT_ASSERT(result.getErrorMessage().find("A simulated I/O read")
!= vespalib::string::npos);
diff --git a/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp b/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp
index 622625be864..6deabc3dfe1 100644
--- a/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp
+++ b/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp
@@ -4,8 +4,11 @@
#include <tests/spi/memfiletestutils.h>
#include <tests/spi/simulatedfailurefile.h>
#include <tests/spi/options_builder.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/document/select/parser.h>
+using storage::spi::test::makeBucket;
+
namespace storage {
namespace memfile {
namespace {
@@ -119,7 +122,7 @@ IteratorHandlerTest::createSelection(const std::string& docSel) const
void
IteratorHandlerTest::testCreateIterator()
{
- spi::Bucket b(BucketId(16, 1234), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 1234)));
spi::CreateIteratorResult iter1(create(b, createSelection("true")));
CPPUNIT_ASSERT_EQUAL(spi::IteratorId(1), iter1.getIteratorId());
@@ -287,7 +290,7 @@ IteratorHandlerTest::testSomeSlotsRemovedBetweenInvocations()
{
std::vector<DocAndTimestamp> docs = feedDocs(100, 4096, 4096);
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
spi::Selection sel(createSelection("true"));
spi::CreateIteratorResult iter(create(b, sel));
@@ -327,7 +330,7 @@ IteratorHandlerTest::testAllSlotsRemovedBetweenInvocations()
{
std::vector<DocAndTimestamp> docs = feedDocs(100, 4096, 4096);
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
spi::Selection sel(createSelection("true"));
spi::CreateIteratorResult iter(create(b, sel));
@@ -359,7 +362,7 @@ IteratorHandlerTest::testAllSlotsRemovedBetweenInvocations()
void
IteratorHandlerTest::testIterateMetadataOnly()
{
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
std::vector<DocAndTimestamp> docs = feedDocs(10);
CPPUNIT_ASSERT(
@@ -415,7 +418,7 @@ IteratorHandlerTest::testIterateHeadersOnly()
clearBody(*docs[i].first);
}
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
spi::Selection sel(createSelection("true"));
spi::CreateIteratorResult iter(create(b, sel, spi::NEWEST_DOCUMENT_ONLY,
@@ -436,7 +439,7 @@ IteratorHandlerTest::testIterateLargeDocument()
std::vector<DocAndTimestamp> largedoc;
largedoc.push_back(docs.back());
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
spi::Selection sel(createSelection("true"));
spi::CreateIteratorResult iter(create(b, sel));
@@ -455,7 +458,7 @@ IteratorHandlerTest::testDocumentsRemovedBetweenInvocations()
int docCount = 100;
std::vector<DocAndTimestamp> docs = feedDocs(docCount);
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
spi::Selection sel(createSelection("true"));
spi::CreateIteratorResult iter(create(b, sel));
@@ -497,7 +500,7 @@ IteratorHandlerTest::doTestUnrevertableRemoveBetweenInvocations(bool includeRemo
int docCount = 100;
std::vector<DocAndTimestamp> docs = feedDocs(docCount);
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
spi::Selection sel(createSelection("true"));
spi::CreateIteratorResult iter(
create(b, sel,
@@ -591,7 +594,7 @@ IteratorHandlerTest::testMatchTimestampRangeDocAltered()
OperationHandler::PERSIST_REMOVE_IF_FOUND));
flush(bucketId);
- spi::Bucket b(bucketId, spi::PartitionId(0));
+ spi::Bucket b(makeBucket(bucketId));
{
spi::Selection sel(createSelection("true"));
@@ -696,7 +699,7 @@ IteratorHandlerTest::testMatchTimestampRangeDocAltered()
void
IteratorHandlerTest::testIterateAllVersions()
{
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
std::vector<DocAndTimestamp> docs;
Document::SP originalDoc(createRandomDocumentAtLocation(
@@ -733,7 +736,7 @@ IteratorHandlerTest::testIterateAllVersions()
void
IteratorHandlerTest::testFieldSetFiltering()
{
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
Document::SP doc(createRandomDocumentAtLocation(
4, 1001, 110, 110));
doc->setValue(doc->getField("headerval"), document::IntFieldValue(42));
@@ -760,7 +763,7 @@ IteratorHandlerTest::testFieldSetFiltering()
void
IteratorHandlerTest::testIteratorInactiveOnException()
{
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
feedDocs(10);
env()._cache.clear();
@@ -787,7 +790,7 @@ IteratorHandlerTest::testIteratorInactiveOnException()
void
IteratorHandlerTest::testDocsCachedBeforeDocumentSelection()
{
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
std::vector<DocAndTimestamp> docs = feedDocs(100, 4096, 4096);
env()._cache.clear();
@@ -816,7 +819,7 @@ IteratorHandlerTest::testDocsCachedBeforeDocumentSelection()
void
IteratorHandlerTest::testTimestampRangeLimitedPrefetch()
{
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
// Feed docs with timestamp range [1000, 1100)
feedDocs(100, 4096, 4096);
@@ -904,7 +907,7 @@ IteratorHandlerTest::testCachePrefetchRequirements()
void
IteratorHandlerTest::testBucketEvictedFromCacheOnIterateException()
{
- spi::Bucket b(BucketId(16, 4), spi::PartitionId(0));
+ spi::Bucket b(makeBucket(BucketId(16, 4)));
feedDocs(10);
env()._cache.clear();
diff --git a/memfilepersistence/src/tests/spi/joinoperationhandlertest.cpp b/memfilepersistence/src/tests/spi/joinoperationhandlertest.cpp
index ce11667f75f..07c2bab5bae 100644
--- a/memfilepersistence/src/tests/spi/joinoperationhandlertest.cpp
+++ b/memfilepersistence/src/tests/spi/joinoperationhandlertest.cpp
@@ -2,8 +2,10 @@
#include "memfiletestutils.h"
#include <vespa/document/datatype/documenttype.h>
+#include <vespa/persistence/spi/test.h>
using document::DocumentType;
+using storage::spi::test::makeBucket;
namespace storage {
namespace memfile {
@@ -138,9 +140,9 @@ JoinOperationHandlerTest::doJoin(const document::BucketId to,
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
return getPersistenceProvider().join(
- spi::Bucket(from1, spi::PartitionId(0)),
- spi::Bucket(from2, spi::PartitionId(0)),
- spi::Bucket(to, spi::PartitionId(0)),
+ makeBucket(from1),
+ makeBucket(from2),
+ makeBucket(to),
context);
}
@@ -250,9 +252,9 @@ JoinOperationHandlerTest::testMultiDisk()
setupDisks(10);
feedMultiDisk();
- getPersistenceProvider().join(spi::Bucket(SOURCE2, spi::PartitionId(7)),
- spi::Bucket(SOURCE1, spi::PartitionId(4)),
- spi::Bucket(TARGET, spi::PartitionId(3)),
+ getPersistenceProvider().join(makeBucket(SOURCE2, spi::PartitionId(7)),
+ makeBucket(SOURCE1, spi::PartitionId(4)),
+ makeBucket(TARGET, spi::PartitionId(3)),
context);
CPPUNIT_ASSERT_EQUAL(
@@ -276,9 +278,9 @@ JoinOperationHandlerTest::testMultiDiskFlushed()
env()._cache.flushDirtyEntries();
env()._cache.clear();
- getPersistenceProvider().join(spi::Bucket(SOURCE2, spi::PartitionId(7)),
- spi::Bucket(SOURCE1, spi::PartitionId(4)),
- spi::Bucket(TARGET, spi::PartitionId(3)),
+ getPersistenceProvider().join(makeBucket(SOURCE2, spi::PartitionId(7)),
+ makeBucket(SOURCE1, spi::PartitionId(4)),
+ makeBucket(TARGET, spi::PartitionId(3)),
context);
CPPUNIT_ASSERT_EQUAL(
@@ -322,9 +324,9 @@ JoinOperationHandlerTest::testInternalJoin()
mon->overrideRealStat(512, 100000, 50000);
CPPUNIT_ASSERT(!mon->isFull(0, .80f));
- getPersistenceProvider().join(spi::Bucket(SOURCE1, spi::PartitionId(4)),
- spi::Bucket(SOURCE1, spi::PartitionId(4)),
- spi::Bucket(SOURCE1, spi::PartitionId(5)),
+ getPersistenceProvider().join(makeBucket(SOURCE1, spi::PartitionId(4)),
+ makeBucket(SOURCE1, spi::PartitionId(4)),
+ makeBucket(SOURCE1, spi::PartitionId(5)),
context);
env()._cache.clear();
@@ -368,9 +370,9 @@ JoinOperationHandlerTest::testInternalJoinDiskFull()
CPPUNIT_ASSERT(mon->isFull(0, .08f));
spi::Result result =
- getPersistenceProvider().join(spi::Bucket(SOURCE1, spi::PartitionId(4)),
- spi::Bucket(SOURCE1, spi::PartitionId(4)),
- spi::Bucket(SOURCE1, spi::PartitionId(5)),
+ getPersistenceProvider().join(makeBucket(SOURCE1, spi::PartitionId(4)),
+ makeBucket(SOURCE1, spi::PartitionId(4)),
+ makeBucket(SOURCE1, spi::PartitionId(5)),
context);
CPPUNIT_ASSERT(result.hasError());
diff --git a/memfilepersistence/src/tests/spi/memfileautorepairtest.cpp b/memfilepersistence/src/tests/spi/memfileautorepairtest.cpp
index 9984452caed..1bae9d929e3 100644
--- a/memfilepersistence/src/tests/spi/memfileautorepairtest.cpp
+++ b/memfilepersistence/src/tests/spi/memfileautorepairtest.cpp
@@ -4,6 +4,9 @@
#include <vespa/memfilepersistence/mapper/memfile_v1_serializer.h>
#include <vespa/memfilepersistence/mapper/memfile_v1_verifier.h>
#include <tests/spi/memfiletestutils.h>
+#include <vespa/persistence/spi/test.h>
+
+using storage::spi::test::makeBucket;
namespace storage {
namespace memfile {
@@ -223,7 +226,7 @@ MemFileAutoRepairTest::testRepairFailureInMaintainEvictsBucketFromCache()
prepareBucket(*this, *_file);
corruptBodyBlock();
spi::Result result(getPersistenceProvider().maintain(
- spi::Bucket(_bucket, spi::PartitionId(0)), spi::HIGH));
+ makeBucket(_bucket), spi::HIGH));
// File being successfully repaired does not constitute a failure of
// the maintain() call.
CPPUNIT_ASSERT_EQUAL(spi::Result::NONE, result.getErrorCode());
@@ -240,7 +243,7 @@ MemFileAutoRepairTest::testZeroLengthFileIsDeleted()
// No way to deal with zero-length files aside from deleting them.
spi::Result result(getPersistenceProvider().maintain(
- spi::Bucket(_bucket, spi::PartitionId(0)), spi::HIGH));
+ makeBucket(_bucket), spi::HIGH));
CPPUNIT_ASSERT_EQUAL(spi::Result::NONE, result.getErrorCode());
CPPUNIT_ASSERT(!env()._cache.contains(_bucket));
CPPUNIT_ASSERT(!vespalib::fileExists(_file->getPath()));
@@ -272,7 +275,7 @@ MemFileAutoRepairTest::assertDocumentIsSilentlyRemoved(
{
// Corrupted (truncated) slot should be transparently removed during
// loadFile and it should be as if it was never there!
- spi::Bucket spiBucket(bucket, spi::PartitionId(0));
+ spi::Bucket spiBucket(makeBucket(bucket));
spi::GetResult res(doGet(spiBucket, docId, document::AllFields()));
CPPUNIT_ASSERT_EQUAL(spi::Result::NONE, res.getErrorCode());
CPPUNIT_ASSERT(!res.hasDocument());
diff --git a/memfilepersistence/src/tests/spi/memfiletestutils.cpp b/memfilepersistence/src/tests/spi/memfiletestutils.cpp
index 28e8987a2fa..f8e182c1bcb 100644
--- a/memfilepersistence/src/tests/spi/memfiletestutils.cpp
+++ b/memfilepersistence/src/tests/spi/memfiletestutils.cpp
@@ -7,11 +7,13 @@
#include <vespa/memfilepersistence/memfile/memfilecache.h>
#include <vespa/storageframework/defaultimplementation/memory/simplememorylogic.h>
#include <vespa/document/update/assignvalueupdate.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/exceptions.h>
#include <sys/time.h>
using document::DocumentType;
+using storage::spi::test::makeBucket;
namespace storage {
namespace memfile {
@@ -136,7 +138,7 @@ MemFileTestUtils::flush(const document::BucketId& id, uint16_t disk)
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
return getPersistenceProvider().flush(
- spi::Bucket(id, spi::PartitionId(disk)), context);
+ makeBucket(id, spi::PartitionId(disk)), context);
}
document::Document::SP
@@ -152,7 +154,7 @@ MemFileTestUtils::doPutOnDisk(
document::Document::SP doc(createRandomDocumentAtLocation(
location, timestamp.getTime(), minSize, maxSize));
getPersistenceProvider().put(
- spi::Bucket(document::BucketId(16, location), spi::PartitionId(disk)),
+ makeBucket(document::BucketId(16, location), spi::PartitionId(disk)),
spi::Timestamp(timestamp.getTime()),
doc,
context);
@@ -171,14 +173,14 @@ MemFileTestUtils::doRemoveOnDisk(
spi::Trace::TraceLevel(0));
if (persistRemove == OperationHandler::PERSIST_REMOVE_IF_FOUND) {
spi::RemoveResult result = getPersistenceProvider().removeIfFound(
- spi::Bucket(bucketId, spi::PartitionId(disk)),
+ makeBucket(bucketId, spi::PartitionId(disk)),
spi::Timestamp(timestamp.getTime()),
docId,
context);
return result.wasFound();
}
spi::RemoveResult result = getPersistenceProvider().remove(
- spi::Bucket(bucketId, spi::PartitionId(disk)),
+ makeBucket(bucketId, spi::PartitionId(disk)),
spi::Timestamp(timestamp.getTime()),
docId,
context);
@@ -197,7 +199,7 @@ MemFileTestUtils::doUnrevertableRemoveOnDisk(
spi::Trace::TraceLevel(0));
spi::RemoveResult result =
getPersistenceProvider().remove(
- spi::Bucket(bucketId, spi::PartitionId(disk)),
+ makeBucket(bucketId, spi::PartitionId(disk)),
spi::Timestamp(timestamp.getTime()),
docId, context);
@@ -214,7 +216,7 @@ MemFileTestUtils::doGetOnDisk(
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
return getPersistenceProvider().get(
- spi::Bucket(bucketId, spi::PartitionId(disk)),
+ makeBucket(bucketId, spi::PartitionId(disk)),
fields, docId, context);
}
@@ -272,7 +274,7 @@ MemFileTestUtils::doPut(const document::Document::SP& doc,
{
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
- getPersistenceProvider().put(spi::Bucket(bid, spi::PartitionId(disk)),
+ getPersistenceProvider().put(makeBucket(bid, spi::PartitionId(disk)),
spi::Timestamp(time.getTime()), doc, context);
}
@@ -285,7 +287,7 @@ MemFileTestUtils::doUpdate(document::BucketId bid,
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
return getPersistenceProvider().update(
- spi::Bucket(bid, spi::PartitionId(disk)),
+ makeBucket(bid, spi::PartitionId(disk)),
spi::Timestamp(time.getTime()), update, context);
}
@@ -301,12 +303,12 @@ MemFileTestUtils::doRemove(const document::DocumentId& id, Timestamp time,
if (unrevertableRemove) {
getPersistenceProvider().remove(
- spi::Bucket(bucket, spi::PartitionId(disk)),
+ makeBucket(bucket, spi::PartitionId(disk)),
spi::Timestamp(time.getTime()),
id, context);
} else {
spi::RemoveResult result = getPersistenceProvider().removeIfFound(
- spi::Bucket(bucket, spi::PartitionId(disk)),
+ makeBucket(bucket, spi::PartitionId(disk)),
spi::Timestamp(time.getTime()),
id, context);
diff --git a/memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp b/memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp
index 43094d80928..98f722e749c 100644
--- a/memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp
+++ b/memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp
@@ -2,8 +2,10 @@
#include "memfiletestutils.h"
#include <vespa/document/datatype/documenttype.h>
+#include <vespa/persistence/spi/test.h>
using document::DocumentType;
+using storage::spi::test::makeBucket;
namespace storage {
namespace memfile {
@@ -60,9 +62,9 @@ SplitOperationHandlerTest::testSimple()
SplitOperationHandler handler(env());
spi::Result result = getPersistenceProvider().split(
- spi::Bucket(sourceBucket, spi::PartitionId(0)),
- spi::Bucket(target1, spi::PartitionId(0)),
- spi::Bucket(target2, spi::PartitionId(0)),
+ makeBucket(sourceBucket),
+ makeBucket(target1),
+ makeBucket(target2),
context);
env()._cache.clear();
@@ -116,9 +118,9 @@ SplitOperationHandlerTest::doTestMultiDisk(uint16_t sourceDisk,
SplitOperationHandler handler(env());
spi::Result result = getPersistenceProvider().split(
- spi::Bucket(sourceBucket, spi::PartitionId(sourceDisk)),
- spi::Bucket(target1, spi::PartitionId(targetDisk0)),
- spi::Bucket(target2, spi::PartitionId(targetDisk1)),
+ makeBucket(sourceBucket, spi::PartitionId(sourceDisk)),
+ makeBucket(target1, spi::PartitionId(targetDisk0)),
+ makeBucket(target2, spi::PartitionId(targetDisk1)),
context);
env()._cache.clear();
@@ -183,9 +185,9 @@ SplitOperationHandlerTest::testExceptionDuringSplittingEvictsAllBuckets()
try {
SplitOperationHandler handler(env());
spi::Result result = getPersistenceProvider().split(
- spi::Bucket(sourceBucket, spi::PartitionId(0)),
- spi::Bucket(target1, spi::PartitionId(0)),
- spi::Bucket(target2, spi::PartitionId(0)),
+ makeBucket(sourceBucket),
+ makeBucket(target1),
+ makeBucket(target2),
context);
CPPUNIT_FAIL("Exception not thrown on flush failure");
} catch (std::exception&) {
diff --git a/memfilepersistence/src/vespa/memfilepersistence/spi/memfilepersistenceprovider.cpp b/memfilepersistence/src/vespa/memfilepersistence/spi/memfilepersistenceprovider.cpp
index ab9a329e92a..09d1e46dc27 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/spi/memfilepersistenceprovider.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/spi/memfilepersistenceprovider.cpp
@@ -210,7 +210,8 @@ private:
void
MemFilePersistenceProvider::handleBucketCorruption(const FileSpecification& file) const
{
- spi::Bucket fixBucket(file.getBucketId(),
+ spi::Bucket fixBucket(document::Bucket(document::BucketSpace::placeHolder(),
+ file.getBucketId()),
spi::PartitionId(file.getDirectory().getIndex()));
// const_cast is nasty, but maintain() must necessarily be able to
diff --git a/persistence/src/tests/spi/clusterstatetest.cpp b/persistence/src/tests/spi/clusterstatetest.cpp
index a829035b61d..2fdaf25abf6 100644
--- a/persistence/src/tests/spi/clusterstatetest.cpp
+++ b/persistence/src/tests/spi/clusterstatetest.cpp
@@ -169,7 +169,7 @@ ClusterStateTest::testReady()
{
lib::ClusterState s("version:1 storage:3 distributor:3");
- Bucket b(document::BucketId(16, 1), PartitionId(0));
+ Bucket b(document::Bucket(document::BucketSpace::placeHolder(), document::BucketId(16, 1)), PartitionId(0));
// With 3 copies, this bucket has ideal state 0, 2, 1
diff --git a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp
index a0176fe88f2..1ef8956d3d8 100644
--- a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp
+++ b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp
@@ -2,6 +2,7 @@
#include <vespa/document/base/testdocman.h>
#include <vespa/persistence/conformancetest/conformancetest.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/document/fieldset/fieldsets.h>
#include <vespa/document/update/documentupdate.h>
@@ -16,6 +17,7 @@
#include <limits>
using document::BucketId;
+using storage::spi::test::makeBucket;
namespace storage::spi {
@@ -309,7 +311,7 @@ void ConformanceTest::testBasics() {
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2);
spi->createBucket(bucket, context);
@@ -395,9 +397,9 @@ void ConformanceTest::testListBuckets() {
BucketId bucketId1(8, 0x01);
BucketId bucketId2(8, 0x02);
BucketId bucketId3(8, 0x03);
- Bucket bucket1(bucketId1, partId);
- Bucket bucket2(bucketId2, partId);
- Bucket bucket3(bucketId3, partId);
+ Bucket bucket1(makeBucket(bucketId1, partId));
+ Bucket bucket2(makeBucket(bucketId2, partId));
+ Bucket bucket3(makeBucket(bucketId3, partId));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x02, 2);
@@ -435,7 +437,7 @@ void ConformanceTest::testBucketInfo() {
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2);
@@ -493,7 +495,7 @@ ConformanceTest::testOrderIndependentBucketInfo()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2);
@@ -538,7 +540,7 @@ void ConformanceTest::testPut() {
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2);
spi->createBucket(bucket, context);
@@ -563,7 +565,7 @@ void ConformanceTest::testPutNewDocumentVersion() {
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Document::SP doc2(doc1->clone());
doc2->setValue("content", document::StringFieldValue("hiho silver"));
@@ -614,7 +616,7 @@ void ConformanceTest::testPutOlderDocumentVersion() {
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Document::SP doc2(doc1->clone());
doc2->setValue("content", document::StringFieldValue("hiho silver"));
@@ -658,7 +660,7 @@ void ConformanceTest::testPutDuplicate() {
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
spi->createBucket(bucket, context);
CPPUNIT_ASSERT_EQUAL(Result(),
@@ -691,7 +693,7 @@ void ConformanceTest::testRemove() {
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2);
spi->createBucket(bucket, context);
@@ -787,7 +789,7 @@ void ConformanceTest::testRemoveMerge() {
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
DocumentId removeId("id:fraggle:testdoctype1:n=1:rock");
spi->createBucket(bucket, context);
@@ -884,7 +886,7 @@ void ConformanceTest::testUpdate() {
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
spi->createBucket(bucket, context);
const document::DocumentType *docType(
@@ -960,7 +962,7 @@ void ConformanceTest::testGet() {
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
spi->createBucket(bucket, context);
{
@@ -1000,7 +1002,7 @@ ConformanceTest::testIterateCreateIterator()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
spi::CreateIteratorResult result(
@@ -1020,7 +1022,7 @@ ConformanceTest::testIterateWithUnknownId()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
IteratorId unknownId(123);
@@ -1035,7 +1037,7 @@ ConformanceTest::testIterateDestroyIterator()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
CreateIteratorResult iter(createIterator(*spi, b, createSelection("")));
@@ -1068,7 +1070,7 @@ ConformanceTest::testIterateAllDocs()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
std::vector<DocAndTimestamp> docs(feedDocs(*spi, testDocMan, b, 100));
@@ -1087,7 +1089,7 @@ ConformanceTest::testIterateAllDocsNewestVersionOnly()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
std::vector<DocAndTimestamp> docs(feedDocs(*spi, testDocMan, b, 100));
@@ -1117,7 +1119,7 @@ ConformanceTest::testIterateChunked()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
std::vector<DocAndTimestamp> docs(feedDocs(*spi, testDocMan, b, 100));
@@ -1138,7 +1140,7 @@ ConformanceTest::testMaxByteSize()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
std::vector<DocAndTimestamp> docs(
@@ -1167,7 +1169,7 @@ ConformanceTest::testIterateMatchTimestampRange()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
std::vector<DocAndTimestamp> docsToVisit;
@@ -1207,7 +1209,7 @@ ConformanceTest::testIterateExplicitTimestampSubset()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
std::vector<DocAndTimestamp> docsToVisit;
@@ -1258,7 +1260,7 @@ ConformanceTest::testIterateRemoves()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
int docCount = 10;
@@ -1311,7 +1313,7 @@ ConformanceTest::testIterateMatchSelection()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
std::vector<DocAndTimestamp> docsToVisit;
@@ -1347,7 +1349,7 @@ ConformanceTest::testIterationRequiringDocumentIdOnlyMatching()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
feedDocs(*spi, testDocMan, b, 100);
@@ -1381,7 +1383,7 @@ ConformanceTest::testIterateBadDocumentSelection()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
{
CreateIteratorResult iter(
@@ -1423,7 +1425,7 @@ ConformanceTest::testIterateAlreadyCompleted()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
std::vector<DocAndTimestamp> docs = feedDocs(*spi, testDocMan, b, 10);
@@ -1448,7 +1450,7 @@ ConformanceTest::testIterateEmptyBucket()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket b(document::BucketId(8, 0x1), PartitionId(0));
+ Bucket b(makeBucket(BucketId(8, 0x1)));
spi->createBucket(b, context);
Selection sel(createSelection(""));
@@ -1471,7 +1473,7 @@ ConformanceTest::testDeleteBucket()
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
spi->createBucket(bucket, context);
spi->put(bucket, Timestamp(3), doc1, context);
@@ -1515,10 +1517,10 @@ ConformanceTest::testSplitNormalCase()
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0));
- Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0));
+ Bucket bucketA(makeBucket(BucketId(3, 0x02)));
+ Bucket bucketB(makeBucket(BucketId(3, 0x06)));
- Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0));
+ Bucket bucketC(makeBucket(BucketId(2, 0x02)));
spi->createBucket(bucketC, context);
TimestampList tsList;
@@ -1591,11 +1593,11 @@ ConformanceTest::testSplitTargetExists()
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0));
- Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0));
+ Bucket bucketA(makeBucket(BucketId(3, 0x02)));
+ Bucket bucketB(makeBucket(BucketId(3, 0x06)));
spi->createBucket(bucketB, context);
- Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0));
+ Bucket bucketC(makeBucket(BucketId(2, 0x02)));
spi->createBucket(bucketC, context);
TimestampList tsList;
@@ -1683,10 +1685,10 @@ ConformanceTest::testSplitSingleDocumentInSource()
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket target1(document::BucketId(3, 0x02), PartitionId(0));
- Bucket target2(document::BucketId(3, 0x06), PartitionId(0));
+ Bucket target1(makeBucket(BucketId(3, 0x02)));
+ Bucket target2(makeBucket(BucketId(3, 0x06)));
- Bucket source(document::BucketId(2, 0x02), PartitionId(0));
+ Bucket source(makeBucket(BucketId(2, 0x02)));
spi->createBucket(source, context);
// Create doc belonging in target2 after split.
@@ -1791,18 +1793,18 @@ ConformanceTest::doTestJoinNormalCase(const Bucket& source1,
void
ConformanceTest::testJoinNormalCase()
{
- Bucket source1(document::BucketId(3, 0x02), PartitionId(0));
- Bucket source2(document::BucketId(3, 0x06), PartitionId(0));
- Bucket target(document::BucketId(2, 0x02), PartitionId(0));
+ Bucket source1(makeBucket(BucketId(3, 0x02)));
+ Bucket source2(makeBucket(BucketId(3, 0x06)));
+ Bucket target(makeBucket(BucketId(2, 0x02)));
doTestJoinNormalCase(source1, source2, target);
}
void
ConformanceTest::testJoinNormalCaseWithMultipleBitsDecreased()
{
- Bucket source1(document::BucketId(3, 0x02), PartitionId(0));
- Bucket source2(document::BucketId(3, 0x06), PartitionId(0));
- Bucket target(document::BucketId(1, 0x00), PartitionId(0));
+ Bucket source1(makeBucket(BucketId(3, 0x02)));
+ Bucket source2(makeBucket(BucketId(3, 0x06)));
+ Bucket target(makeBucket(BucketId(1, 0x00)));
doTestJoinNormalCase(source1, source2, target);
}
@@ -1849,13 +1851,13 @@ ConformanceTest::testJoinTargetExists()
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0));
+ Bucket bucketA(makeBucket(BucketId(3, 0x02)));
spi->createBucket(bucketA, context);
- Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0));
+ Bucket bucketB(makeBucket(BucketId(3, 0x06)));
spi->createBucket(bucketB, context);
- Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0));
+ Bucket bucketC(makeBucket(BucketId(2, 0x02)));
spi->createBucket(bucketC, context);
for (uint32_t i = 0; i < 10; ++i) {
@@ -1953,11 +1955,11 @@ ConformanceTest::testJoinOneBucket()
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0));
+ Bucket bucketA(makeBucket(BucketId(3, 0x02)));
spi->createBucket(bucketA, context);
- Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0));
- Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0));
+ Bucket bucketB(makeBucket(BucketId(3, 0x06)));
+ Bucket bucketC(makeBucket(BucketId(2, 0x02)));
populateBucket(bucketA, *spi, context, 0, 10, testDocMan);
@@ -2030,16 +2032,16 @@ ConformanceTest::doTestJoinSameSourceBuckets(const Bucket& source,
void
ConformanceTest::testJoinSameSourceBuckets()
{
- Bucket source(document::BucketId(3, 0x02), PartitionId(0));
- Bucket target(document::BucketId(2, 0x02), PartitionId(0));
+ Bucket source(makeBucket(BucketId(3, 0x02)));
+ Bucket target(makeBucket(BucketId(2, 0x02)));
doTestJoinSameSourceBuckets(source, target);
}
void
ConformanceTest::testJoinSameSourceBucketsWithMultipleBitsDecreased()
{
- Bucket source(document::BucketId(3, 0x02), PartitionId(0));
- Bucket target(document::BucketId(1, 0x00), PartitionId(0));
+ Bucket source(makeBucket(BucketId(3, 0x02)));
+ Bucket target(makeBucket(BucketId(1, 0x00)));
doTestJoinSameSourceBuckets(source, target);
}
@@ -2072,10 +2074,10 @@ ConformanceTest::testJoinSameSourceBucketsTargetExists()
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket source(document::BucketId(3, 0x02), PartitionId(0));
+ Bucket source(makeBucket(BucketId(3, 0x02)));
spi->createBucket(source, context);
- Bucket target(document::BucketId(2, 0x02), PartitionId(0));
+ Bucket target(makeBucket(BucketId(2, 0x02)));
spi->createBucket(target, context);
populateBucket(source, *spi, context, 0, 10, testDocMan);
@@ -2101,7 +2103,7 @@ void ConformanceTest::testMaintain()
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
spi->createBucket(bucket, context);
spi->put(bucket, Timestamp(3), doc1, context);
@@ -2130,7 +2132,7 @@ void ConformanceTest::testBucketActivation()
_factory->clear();
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
spi->setClusterState(createClusterState());
spi->createBucket(bucket, context);
@@ -2174,9 +2176,9 @@ void ConformanceTest::testBucketActivationSplitAndJoin()
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0));
- Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0));
- Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0));
+ Bucket bucketA(makeBucket(BucketId(3, 0x02)));
+ Bucket bucketB(makeBucket(BucketId(3, 0x06)));
+ Bucket bucketC(makeBucket(BucketId(2, 0x02)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x02, 1);
Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x06, 2);
@@ -2253,7 +2255,7 @@ void ConformanceTest::testRemoveEntry()
PersistenceProvider::UP spi(getSpi(*_factory, testDocMan));
Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0));
- Bucket bucket(document::BucketId(8, 0x01), PartitionId(0));
+ Bucket bucket(makeBucket(BucketId(8, 0x01)));
Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1);
Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2);
spi->createBucket(bucket, context);
diff --git a/persistence/src/vespa/persistence/spi/CMakeLists.txt b/persistence/src/vespa/persistence/spi/CMakeLists.txt
index 598ed757efb..a8b1faadcd3 100644
--- a/persistence/src/vespa/persistence/spi/CMakeLists.txt
+++ b/persistence/src/vespa/persistence/spi/CMakeLists.txt
@@ -13,6 +13,7 @@ vespa_add_library(persistence_spi OBJECT
read_consistency.cpp
result
selection.cpp
+ test.cpp
docentry
DEPENDS
)
diff --git a/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp b/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp
index 3782d17ea50..9e687f52363 100644
--- a/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp
+++ b/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp
@@ -52,7 +52,7 @@ AbstractPersistenceProvider::getModifiedBuckets() const
Result
AbstractPersistenceProvider::move(const Bucket& source, PartitionId target, Context& context)
{
- spi::Bucket to(source.getBucketId(), spi::PartitionId(target));
+ spi::Bucket to(source.getBucket(), spi::PartitionId(target));
return join(source, source, to, context);
}
diff --git a/persistence/src/vespa/persistence/spi/bucket.h b/persistence/src/vespa/persistence/spi/bucket.h
index e4cbbeae075..4e234e4dc49 100644
--- a/persistence/src/vespa/persistence/spi/bucket.h
+++ b/persistence/src/vespa/persistence/spi/bucket.h
@@ -15,25 +15,26 @@
#pragma once
#include <persistence/spi/types.h>
-#include <vespa/document/bucket/bucketid.h>
+#include <vespa/document/bucket/bucket.h>
namespace storage {
namespace spi {
class Bucket {
- document::BucketId _bucket;
+ document::Bucket _bucket;
PartitionId _partition;
public:
- Bucket() : _bucket(0), _partition(0) {}
- Bucket(const document::BucketId& b, PartitionId p)
+ Bucket() : _bucket(document::BucketSpace::placeHolder(), document::BucketId(0)), _partition(0) {}
+ Bucket(const document::Bucket& b, PartitionId p)
: _bucket(b), _partition(p) {}
- const document::BucketId& getBucketId() const { return _bucket; }
+ const document::Bucket &getBucket() const { return _bucket; }
+ document::BucketId getBucketId() const { return _bucket.getBucketId(); }
PartitionId getPartition() const { return _partition; }
/** Convert easily to a document bucket id to make class easy to use. */
- operator const document::BucketId&() const { return _bucket; }
+ operator document::BucketId() const { return _bucket.getBucketId(); }
bool operator==(const Bucket& o) const {
return (_bucket == o._bucket && _partition == o._partition);
diff --git a/persistence/src/vespa/persistence/spi/test.cpp b/persistence/src/vespa/persistence/spi/test.cpp
new file mode 100644
index 00000000000..73dd33f06bf
--- /dev/null
+++ b/persistence/src/vespa/persistence/spi/test.cpp
@@ -0,0 +1,17 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "test.h"
+
+namespace storage::spi::test {
+
+Bucket makeBucket(document::BucketId bucketId, PartitionId partitionId)
+{
+ return Bucket(document::Bucket(document::BucketSpace::placeHolder(), bucketId), partitionId);
+}
+
+Bucket makeBucket(document::BucketId bucketId)
+{
+ return makeBucket(bucketId, PartitionId(0));
+}
+
+}
diff --git a/persistence/src/vespa/persistence/spi/test.h b/persistence/src/vespa/persistence/spi/test.h
new file mode 100644
index 00000000000..f3fc7b7f379
--- /dev/null
+++ b/persistence/src/vespa/persistence/spi/test.h
@@ -0,0 +1,14 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "bucket.h"
+
+namespace storage::spi::test {
+
+// Helper functions used by unit tests
+
+Bucket makeBucket(document::BucketId bucketId, PartitionId partitionId);
+Bucket makeBucket(document::BucketId bucketId);
+
+}
diff --git a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
index 3c891ff4c11..bef65add869 100644
--- a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
+++ b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
@@ -6,6 +6,7 @@
#include <vespa/persistence/spi/bucket.h>
#include <vespa/persistence/spi/docentry.h>
#include <vespa/persistence/spi/result.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/searchcore/proton/common/attrupdate.h>
#include <vespa/searchcore/proton/persistenceengine/document_iterator.h>
#include <vespa/searchcore/proton/server/commit_and_wait_document_retriever.h>
@@ -43,6 +44,7 @@ using storage::spi::IterateResult;
using storage::spi::PartitionId;
using storage::spi::Selection;
using storage::spi::Timestamp;
+using storage::spi::test::makeBucket;
using namespace proton;
using namespace search::index;
@@ -50,7 +52,7 @@ using namespace search::index;
const uint64_t largeNum = 10000000;
Bucket bucket(size_t x) {
- return Bucket(BucketId(x), PartitionId(0));
+ return makeBucket(BucketId(x));
}
Selection selectAll() {
diff --git a/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp b/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp
index 6fda983e88c..950571df6a4 100644
--- a/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp
@@ -5,6 +5,7 @@ LOG_SETUP("buckethandler_test");
#include <vespa/searchcore/proton/server/ibucketstatechangedhandler.h>
#include <vespa/searchcore/proton/server/ibucketmodifiedhandler.h>
#include <vespa/searchcore/proton/test/test.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/vespalib/testkit/testapp.h>
using namespace proton;
@@ -14,6 +15,7 @@ using storage::spi::Bucket;
using storage::spi::BucketInfo;
using storage::spi::PartitionId;
using storage::spi::Timestamp;
+using storage::spi::test::makeBucket;
using vespalib::ThreadStackExecutor;
using proton::test::BucketStateCalculator;
@@ -144,7 +146,7 @@ struct Fixture
}
void sync() { _exec.sync(); }
void handleGetBucketInfo(const BucketId &bucket) {
- _handler.handleGetBucketInfo(Bucket(bucket, PART_ID), _bucketInfo);
+ _handler.handleGetBucketInfo(makeBucket(bucket, PART_ID), _bucketInfo);
}
void
setNodeUp(bool value)
diff --git a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp
index a7c4b0e5774..2e7e50c3464 100644
--- a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp
+++ b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp
@@ -2,6 +2,7 @@
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/datatype/documenttype.h>
#include <vespa/persistence/spi/documentselection.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/searchcore/proton/persistenceengine/bucket_guard.h>
#include <vespa/searchcore/proton/persistenceengine/ipersistenceengineowner.h>
#include <vespa/searchcore/proton/persistenceengine/persistenceengine.h>
@@ -35,6 +36,7 @@ using storage::spi::Result;
using storage::spi::Selection;
using storage::spi::Timestamp;
using storage::spi::UpdateResult;
+using storage::spi::test::makeBucket;
using namespace proton;
using namespace vespalib;
@@ -378,8 +380,8 @@ BucketId bckId1(1);
BucketId bckId2(2);
BucketId bckId3(3);
Bucket bucket0;
-Bucket bucket1(bckId1, partId);
-Bucket bucket2(bckId2, partId);
+Bucket bucket1(makeBucket(bckId1, partId));
+Bucket bucket2(makeBucket(bckId2, partId));
BucketChecksum checksum1(1);
BucketChecksum checksum2(2);
BucketChecksum checksum3(1+2);
diff --git a/searchcore/src/tests/proton/server/documentretriever_test.cpp b/searchcore/src/tests/proton/server/documentretriever_test.cpp
index df444d26f8c..b949046e8b6 100644
--- a/searchcore/src/tests/proton/server/documentretriever_test.cpp
+++ b/searchcore/src/tests/proton/server/documentretriever_test.cpp
@@ -19,6 +19,7 @@
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/persistence/spi/bucket.h>
#include <vespa/persistence/spi/result.h>
+#include <vespa/persistence/spi/test.h>
#include <vespa/searchcommon/common/schema.h>
#include <vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h>
#include <vespa/searchcore/proton/server/documentretriever.h>
@@ -69,6 +70,7 @@ using storage::spi::Bucket;
using storage::spi::GetResult;
using storage::spi::PartitionId;
using storage::spi::Timestamp;
+using storage::spi::test::makeBucket;
using vespalib::make_string;
using vespalib::string;
using namespace document::config_builder;
@@ -324,12 +326,12 @@ TEST_F("require that document retriever can retrieve document meta data",
TEST_F("require that document retriever can retrieve bucket meta data",
Fixture) {
DocumentMetaData::Vector result;
- f._retriever->getBucketMetaData(Bucket(f.bucket_id, PartitionId(0)), result);
+ f._retriever->getBucketMetaData(makeBucket(f.bucket_id, PartitionId(0)), result);
ASSERT_EQUAL(1u, result.size());
EXPECT_EQUAL(f.lid, result[0].lid);
EXPECT_EQUAL(f.timestamp, result[0].timestamp);
result.clear();
- f._retriever->getBucketMetaData(Bucket(BucketId(f.bucket_id.getId() + 1),
+ f._retriever->getBucketMetaData(makeBucket(BucketId(f.bucket_id.getId() + 1),
PartitionId(0)), result);
EXPECT_EQUAL(0u, result.size());
}
diff --git a/searchcore/src/vespa/searchcore/proton/common/bucketfactory.cpp b/searchcore/src/vespa/searchcore/proton/common/bucketfactory.cpp
index b80332d97a9..e7048b74b10 100644
--- a/searchcore/src/vespa/searchcore/proton/common/bucketfactory.cpp
+++ b/searchcore/src/vespa/searchcore/proton/common/bucketfactory.cpp
@@ -21,7 +21,7 @@ BucketFactory::getBucketId(const DocumentId &docId)
Bucket
BucketFactory::getBucket(const DocumentId &docId)
{
- return Bucket(getBucketId(docId), PartitionId(0));
+ return Bucket(document::Bucket(document::BucketSpace::placeHolder(), getBucketId(docId)), PartitionId(0));
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp
index f36c2add23a..7320b48140e 100644
--- a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp
@@ -67,7 +67,7 @@ BucketMoveJob::checkBucket(const BucketId &bucket,
if (_calc->nodeRetired() && !isActive) {
return;
}
- const bool shouldBeReady = _calc->shouldBeReady(bucket);
+ const bool shouldBeReady = _calc->shouldBeReady(document::Bucket(document::BucketSpace::placeHolder(), bucket));
const bool wantReady = shouldBeReady || isActive;
LOG(spam, "checkBucket(): bucket(%s), shouldBeReady(%s), active(%s)",
bucket.toString().c_str(), bool2str(shouldBeReady), bool2str(isActive));
@@ -213,7 +213,7 @@ BucketMoveJob::maybeCancelMover(DocumentBucketMover &mover)
if (!mover.bucketDone()) {
bool ready = mover.getSource() == &_ready;
if (isBlocked() ||
- _calc->shouldBeReady(mover.getBucket()) == ready) {
+ _calc->shouldBeReady(document::Bucket(document::BucketSpace::placeHolder(), mover.getBucket())) == ready) {
mover.cancel();
}
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp b/searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp
index 3b3437b4346..fa0e0f33469 100644
--- a/searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp
@@ -39,7 +39,7 @@ public:
_nodeRetired(_calc.nodeRetired())
{
}
- bool shouldBeReady(const document::BucketId &bucket) const override {
+ bool shouldBeReady(const document::Bucket &bucket) const override {
return _calc.shouldBeReady(Bucket(bucket, PartitionId(0)));
}
bool clusterUp() const override { return _clusterUp; }
diff --git a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp
index 7439081f4e6..a9dfeb12ed7 100644
--- a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp
@@ -273,17 +273,18 @@ CombiningFeedView::setCalculator(const IBucketStateCalculator::SP &newCalc)
bool
CombiningFeedView::shouldBeReady(const document::BucketId &bucket) const
{
+ document::Bucket dbucket(document::BucketSpace::placeHolder(), bucket);
LOG(debug,
"shouldBeReady(%s): forceReady(%s), clusterUp(%s), calcReady(%s)",
bucket.toString().c_str(),
(_forceReady ? "true" : "false"),
(_clusterUp ? "true" : "false"),
(_calc.get() != NULL ?
- (_calc->shouldBeReady(bucket) ? "true" : "false") : "null"));
+ (_calc->shouldBeReady(dbucket) ? "true" : "false") : "null"));
const documentmetastore::IBucketHandler *readyMetaStore =
_metaStores[getReadyFeedViewId()];
bool isActive = readyMetaStore->getBucketDB().takeGuard()->isActiveBucket(bucket);
- return _forceReady || isActive || _calc->shouldBeReady(bucket);
+ return _forceReady || isActive || _calc->shouldBeReady(dbucket);
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h b/searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h
index 70e352b4d41..10c0b194aac 100644
--- a/searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h
+++ b/searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h
@@ -4,14 +4,14 @@
#include <memory>
-namespace document { class BucketId; }
+namespace document { class Bucket; }
namespace proton {
struct IBucketStateCalculator
{
typedef std::shared_ptr<IBucketStateCalculator> SP;
- virtual bool shouldBeReady(const document::BucketId &bucket) const = 0;
+ virtual bool shouldBeReady(const document::Bucket &bucket) const = 0;
virtual bool clusterUp() const = 0;
virtual bool nodeUp() const = 0;
virtual bool nodeInitializing() const = 0;
diff --git a/searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h b/searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h
index 314c375ec2c..8a5a46946d8 100644
--- a/searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h
+++ b/searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h
@@ -3,6 +3,7 @@
#include <vespa/searchcore/proton/server/ibucketstatecalculator.h>
#include <vespa/document/bucket/bucketidlist.h>
+#include <vespa/document/bucket/bucket.h>
namespace proton::test {
@@ -56,9 +57,9 @@ public:
void resetAsked() { _asked.clear(); }
// Implements IBucketStateCalculator
- bool shouldBeReady(const document::BucketId &bucket) const override {
- _asked.push_back(bucket);
- return _ready.count(bucket) == 1;
+ bool shouldBeReady(const document::Bucket &bucket) const override {
+ _asked.push_back(bucket.getBucketId());
+ return _ready.count(bucket.getBucketId()) == 1;
}
bool clusterUp() const override { return _clusterUp; }
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,