summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--documentapi/src/tests/messagebus/messagebus_test.cpp9
-rw-r--r--documentapi/src/tests/messages/messages50test.cpp14
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.cpp6
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.h14
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp2
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp6
-rw-r--r--storage/src/tests/storageserver/documentapiconvertertest.cpp12
-rw-r--r--storage/src/vespa/storage/storageserver/documentapiconverter.cpp3
8 files changed, 39 insertions, 27 deletions
diff --git a/documentapi/src/tests/messagebus/messagebus_test.cpp b/documentapi/src/tests/messagebus/messagebus_test.cpp
index fc4295278da..077ea52e255 100644
--- a/documentapi/src/tests/messagebus/messagebus_test.cpp
+++ b/documentapi/src/tests/messagebus/messagebus_test.cpp
@@ -1,12 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
#include <vespa/document/base/testdocrepo.h>
-#include <vespa/document/fieldvalue/document.h>
#include <vespa/document/datatype/documenttype.h>
-#include <vespa/document/test/make_document_bucket.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/documentapi/documentapi.h>
+#include <vespa/documentapi/loadtypes/loadtypeset.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/vespalib/testkit/testapp.h>
-#include <vespa/documentapi/loadtypes/loadtypeset.h>
using document::DocumentTypeRepo;
using document::readDocumenttypesConfig;
@@ -14,7 +14,6 @@ using namespace documentapi;
using mbus::Blob;
using mbus::Routable;
using mbus::IRoutingPolicy;
-using document::test::makeDocumentBucket;
class Test : public vespalib::TestApp {
DocumentTypeRepo::SP _repo;
@@ -115,6 +114,6 @@ void Test::stat_bucket_message_is_not_sequenced() {
}
void Test::get_bucket_list_message_is_not_sequenced() {
- GetBucketListMessage message(makeDocumentBucket(document::BucketId(16, 1)));
+ GetBucketListMessage message(document::BucketId(16, 1));
EXPECT_FALSE(message.hasSequenceId());
}
diff --git a/documentapi/src/tests/messages/messages50test.cpp b/documentapi/src/tests/messages/messages50test.cpp
index a3627522562..b50f30c1f91 100644
--- a/documentapi/src/tests/messages/messages50test.cpp
+++ b/documentapi/src/tests/messages/messages50test.cpp
@@ -1,17 +1,15 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "messages50test.h"
-#include <vespa/documentapi/documentapi.h>
-#include <vespa/vdslib/container/writabledocumentlist.h>
-#include <vespa/document/update/fieldpathupdates.h>
-#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/bucket/bucketidfactory.h>
+#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/select/parser.h>
-#include <vespa/document/test/make_document_bucket.h>
+#include <vespa/document/update/fieldpathupdates.h>
+#include <vespa/documentapi/documentapi.h>
+#include <vespa/vdslib/container/writabledocumentlist.h>
using document::DataType;
using document::DocumentTypeRepo;
-using document::test::makeDocumentBucket;
///////////////////////////////////////////////////////////////////////////////
//
@@ -90,7 +88,7 @@ createDoc(const DocumentTypeRepo &repo, const string &type_name, const string &i
bool
Messages50Test::testGetBucketListMessage()
{
- GetBucketListMessage msg(makeDocumentBucket(document::BucketId(16, 123)));
+ GetBucketListMessage msg(document::BucketId(16, 123));
msg.setLoadType(_loadTypes["foo"]);
EXPECT_EQUAL(string("foo"), msg.getLoadType().getName());
EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 12u, serialize("GetBucketListMessage", msg));
@@ -100,7 +98,7 @@ Messages50Test::testGetBucketListMessage()
if (EXPECT_TRUE(obj.get() != NULL)) {
GetBucketListMessage &ref = static_cast<GetBucketListMessage&>(*obj);
EXPECT_EQUAL(string("foo"), ref.getLoadType().getName());
- EXPECT_EQUAL(document::BucketId(16, 123), ref.getBucket().getBucketId());
+ EXPECT_EQUAL(document::BucketId(16, 123), ref.getBucketId());
}
}
return true;
diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.cpp b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.cpp
index 49e8e048db5..96408e9a204 100644
--- a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.cpp
@@ -6,11 +6,11 @@
namespace documentapi {
-GetBucketListMessage::GetBucketListMessage(const document::Bucket &bucket) :
+GetBucketListMessage::GetBucketListMessage(const document::BucketId &bucketId) :
DocumentMessage(),
- _bucket(bucket)
+ _bucketId(bucketId),
+ _bucketSpace()
{
- // empty
}
DocumentReply::UP
diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.h
index 6b70808aea5..8b49afd6672 100644
--- a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.h
+++ b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.h
@@ -2,13 +2,15 @@
#pragma once
#include "documentmessage.h"
-#include <vespa/document/bucket/bucket.h>
+#include <vespa/document/bucket/bucketid.h>
+#include <vespa/vespalib/stllike/string.h>
namespace documentapi {
class GetBucketListMessage : public DocumentMessage {
private:
- document::Bucket _bucket;
+ document::BucketId _bucketId;
+ vespalib::string _bucketSpace;
protected:
// Implements DocumentMessage.
@@ -18,17 +20,19 @@ public:
/**
* Constructs a new message with initial content.
*
- * @param bucket The bucket whose list to retrieve.
+ * @param bucketId The bucket whose list to retrieve.
*/
- GetBucketListMessage(const document::Bucket &bucket);
+ GetBucketListMessage(const document::BucketId &bucketId);
/**
* Returns the bucket whose list to retrieve.
*
* @return The bucket.
*/
- const document::Bucket &getBucket() const { return _bucket; }
+ const document::BucketId &getBucketId() const { return _bucketId; }
+ const vespalib::string &getBucketSpace() const { return _bucketSpace; }
+ void setBucketSpace(const vespalib::string &value) { _bucketSpace = value; }
uint32_t getType() const override;
string toString() const override { return "getbucketlistmessage"; }
};
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp
index 6ab3b1100c4..b7b451e8ddf 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp
@@ -143,7 +143,7 @@ StoragePolicy::doSelect(mbus::RoutingContext &context)
break;
case DocumentProtocol::MESSAGE_GETBUCKETLIST:
- id = static_cast<const GetBucketListMessage&>(msg).getBucket().getBucketId();
+ id = static_cast<const GetBucketListMessage&>(msg).getBucketId();
break;
case DocumentProtocol::MESSAGE_CREATEVISITOR:
diff --git a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp
index 028db2f02c0..4a022d8cabd 100644
--- a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp
@@ -10,7 +10,6 @@
using vespalib::nbostream;
using std::make_unique;
using std::make_shared;
-using document::BucketSpace;
namespace documentapi {
@@ -409,15 +408,14 @@ DocumentMessage::UP
RoutableFactories50::GetBucketListMessageFactory::doDecode(document::ByteBuffer &buf) const
{
document::BucketId bucketId(decodeLong(buf));
- document::Bucket bucket(BucketSpace::placeHolder(), bucketId);
- return std::make_unique<GetBucketListMessage>(bucket);
+ return std::make_unique<GetBucketListMessage>(bucketId);
}
bool
RoutableFactories50::GetBucketListMessageFactory::doEncode(const DocumentMessage &obj, vespalib::GrowableByteBuffer &buf) const
{
const GetBucketListMessage &msg = static_cast<const GetBucketListMessage&>(obj);
- buf.putLong(msg.getBucket().getBucketId().getRawId());
+ buf.putLong(msg.getBucketId().getRawId());
return true;
}
diff --git a/storage/src/tests/storageserver/documentapiconvertertest.cpp b/storage/src/tests/storageserver/documentapiconvertertest.cpp
index da0852eb298..c55e91a5f87 100644
--- a/storage/src/tests/storageserver/documentapiconvertertest.cpp
+++ b/storage/src/tests/storageserver/documentapiconvertertest.cpp
@@ -107,6 +107,7 @@ struct DocumentApiConverterTest : public CppUnit::TestFixture
void testMultiOperation();
void testBatchDocumentUpdate();
void testStatBucket();
+ void testGetBucketList();
CPPUNIT_TEST_SUITE(DocumentApiConverterTest);
CPPUNIT_TEST(testPut);
@@ -123,6 +124,7 @@ struct DocumentApiConverterTest : public CppUnit::TestFixture
CPPUNIT_TEST(testMultiOperation);
CPPUNIT_TEST(testBatchDocumentUpdate);
CPPUNIT_TEST(testStatBucket);
+ CPPUNIT_TEST(testGetBucketList);
CPPUNIT_TEST_SUITE_END();
};
@@ -490,4 +492,14 @@ DocumentApiConverterTest::testStatBucket()
CPPUNIT_ASSERT_EQUAL(defaultSpaceName, mbusMsg->getBucketSpace());
}
+void
+DocumentApiConverterTest::testGetBucketList()
+{
+ documentapi::GetBucketListMessage msg(BucketId(123));
+ msg.setBucketSpace(defaultSpaceName);
+
+ auto cmd = toStorageAPI<api::GetBucketListCommand>(msg);
+ CPPUNIT_ASSERT_EQUAL(Bucket(defaultBucketSpace, BucketId(123)), cmd->getBucket());
+}
+
}
diff --git a/storage/src/vespa/storage/storageserver/documentapiconverter.cpp b/storage/src/vespa/storage/storageserver/documentapiconverter.cpp
index 165c144ef9c..95c35ce988e 100644
--- a/storage/src/vespa/storage/storageserver/documentapiconverter.cpp
+++ b/storage/src/vespa/storage/storageserver/documentapiconverter.cpp
@@ -125,7 +125,8 @@ DocumentApiConverter::toStorageAPI(documentapi::DocumentMessage& fromMsg,
case DocumentProtocol::MESSAGE_GETBUCKETLIST:
{
documentapi::GetBucketListMessage& from(static_cast<documentapi::GetBucketListMessage&>(fromMsg));
- toMsg = std::make_unique<api::GetBucketListCommand>(from.getBucket());
+ document::Bucket bucket(_bucketResolver.bucketSpaceFromName(from.getBucketSpace()), from.getBucketId());
+ toMsg = std::make_unique<api::GetBucketListCommand>(bucket);
break;
}
case DocumentProtocol::MESSAGE_VISITORINFO: