summaryrefslogtreecommitdiffstats
path: root/storageapi
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2017-10-13 13:59:32 +0000
committerTor Egge <Tor.Egge@oath.com>2017-10-13 14:11:26 +0000
commite3f14147291b22bf13ec7fa2cafda748a80dd950 (patch)
tree01175987a4e98aac5652cfef441bc168b06d4f1b /storageapi
parent025b759b5cf0146cd0cf3f44f686eeace1b28d09 (diff)
Adjust API for storage messages: Replace virtual getBucketId() method with
virtual getBucket() method that also contains bucket space. Adjust BucketCommand/BucketReply intermediate storage message classes to use document::Bucket members instead of document::BucketId.
Diffstat (limited to 'storageapi')
-rw-r--r--storageapi/src/vespa/storageapi/message/batch.h4
-rw-r--r--storageapi/src/vespa/storageapi/message/datagram.h4
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp23
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketcommand.h15
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp16
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketreply.h9
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagemessage.h7
7 files changed, 53 insertions, 25 deletions
diff --git a/storageapi/src/vespa/storageapi/message/batch.h b/storageapi/src/vespa/storageapi/message/batch.h
index 164b5eb8eff..4af4fc4c70a 100644
--- a/storageapi/src/vespa/storageapi/message/batch.h
+++ b/storageapi/src/vespa/storageapi/message/batch.h
@@ -159,9 +159,9 @@ public:
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
/**
- Returns a bucket id suitable for routing this message.
+ Returns a bucket suitable for routing this message.
*/
- document::BucketId getBucketId() const override { return _bucketId; }
+ document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
bool hasSingleBucketId() const override { return true; }
DECLARE_STORAGECOMMAND(BatchDocumentUpdateCommand, onBatchDocumentUpdate)
diff --git a/storageapi/src/vespa/storageapi/message/datagram.h b/storageapi/src/vespa/storageapi/message/datagram.h
index b769b0877e2..202d67bb156 100644
--- a/storageapi/src/vespa/storageapi/message/datagram.h
+++ b/storageapi/src/vespa/storageapi/message/datagram.h
@@ -34,7 +34,7 @@ public:
{ assert(_docBlock.getBufferSize() > 0); return _docBlock; }
void setDocumentBlock(vdslib::DocumentList& block) { _docBlock = block; }
- document::BucketId getBucketId() const override { return _bucketId; }
+ document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
bool hasSingleBucketId() const override { return true; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
bool keepTimeStamps() const { return _keepTimeStamps; }
@@ -119,7 +119,7 @@ private:
std::vector<Entry> _documents;
public:
DocumentListCommand(const document::BucketId& bid);
- const document::BucketId& getBucketId() { return _bucketId; }
+ document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
std::vector<Entry>& getDocuments() { return _documents; }
const std::vector<Entry>& getDocuments() const { return _documents; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp
index 9b40dde6f1a..e91864e284d 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.cpp
@@ -3,14 +3,35 @@
#include "bucketcommand.h"
#include <ostream>
+using document::Bucket;
+using document::BucketId;
+using document::BucketSpace;
+
namespace storage {
namespace api {
+BucketCommand::BucketCommand(const MessageType& type, const BucketId& id)
+ : StorageCommand(type),
+ _bucket(BucketSpace::placeHolder(), id),
+ _originalBucket()
+{
+}
+
+void
+BucketCommand::remapBucketId(const BucketId& bucket)
+{
+ if (_originalBucket.getRawId() == 0) {
+ _originalBucket = _bucket.getBucketId();
+ }
+ Bucket newBucket(_bucket.getBucketSpace(), bucket);
+ _bucket = newBucket;
+}
+
void
BucketCommand::print(std::ostream& out,
bool verbose, const std::string& indent) const
{
- out << "BucketCommand(" << _bucket;
+ out << "BucketCommand(" << _bucket.getBucketId();
if (hasBeenRemapped()) {
out << " <- " << _originalBucket;
}
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h
index 49982eb3f3e..b31bcf5e88c 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h
@@ -9,27 +9,22 @@
#pragma once
#include "storagecommand.h"
+#include <vespa/document/bucket/bucket.h>
namespace storage::api {
class BucketCommand : public StorageCommand {
- document::BucketId _bucket;
+ document::Bucket _bucket;
document::BucketId _originalBucket;
protected:
- BucketCommand(const MessageType& type, const document::BucketId& id)
- : StorageCommand(type), _bucket(id), _originalBucket()
- {}
+ BucketCommand(const MessageType& type, const document::BucketId& id);
public:
DECLARE_POINTER_TYPEDEFS(BucketCommand);
- void remapBucketId(const document::BucketId& bucket) {
- if (_originalBucket.getRawId() == 0) _originalBucket = _bucket;
- _bucket = bucket;
- }
-
- document::BucketId getBucketId() const override { return _bucket; }
+ void remapBucketId(const document::BucketId& bucket);
+ document::Bucket getBucket() const override { return _bucket; }
bool hasBeenRemapped() const { return (_originalBucket.getRawId() != 0); }
const document::BucketId& getOriginalBucketId() const { return _originalBucket; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp b/storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp
index 460395972d0..1385fc331ac 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp
@@ -4,22 +4,34 @@
#include "bucketcommand.h"
#include <ostream>
+using document::Bucket;
+using document::BucketId;
+
namespace storage {
namespace api {
BucketReply::BucketReply(const BucketCommand& cmd,
const ReturnCode& code)
: StorageReply(cmd, code),
- _bucket(cmd.getBucketId()),
+ _bucket(cmd.getBucket()),
_originalBucket(cmd.getOriginalBucketId())
{
}
void
+BucketReply::remapBucketId(const BucketId& bucket) {
+ if (_originalBucket.getRawId() == 0) {
+ _originalBucket = _bucket.getBucketId();
+ }
+ Bucket newBucket(_bucket.getBucketSpace(), bucket);
+ _bucket = newBucket;
+}
+
+void
BucketReply::print(std::ostream& out, bool verbose,
const std::string& indent) const
{
- out << "BucketReply(" << _bucket;
+ out << "BucketReply(" << _bucket.getBucketId();
if (hasBeenRemapped()) {
out << " <- " << _originalBucket;
}
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h
index a5af54a7055..b0f98d91152 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h
@@ -16,7 +16,7 @@ namespace api {
class BucketCommand;
class BucketReply : public StorageReply {
- document::BucketId _bucket;
+ document::Bucket _bucket;
document::BucketId _originalBucket;
protected:
@@ -26,7 +26,7 @@ protected:
public:
DECLARE_POINTER_TYPEDEFS(BucketReply);
- document::BucketId getBucketId() const override { return _bucket; }
+ document::Bucket getBucket() const override { return _bucket; }
virtual bool hasSingleBucketId() const override { return true; }
bool hasBeenRemapped() const { return (_originalBucket.getRawId() != 0); }
@@ -34,10 +34,7 @@ public:
{ return _originalBucket; }
/** The deserialization code need access to set the remapping. */
- void remapBucketId(const document::BucketId& bucket) {
- if (_originalBucket.getRawId() == 0) _originalBucket = _bucket;
- _bucket = bucket;
- }
+ void remapBucketId(const document::BucketId& bucket);
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};
diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
index 20697c4be72..0fb3e71b09f 100644
--- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
+++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
@@ -17,7 +17,7 @@
#include <vespa/messagebus/routing/route.h>
#include <vespa/messagebus/trace.h>
#include <vespa/vdslib/state/nodetype.h>
-#include <vespa/document/bucket/bucketid.h>
+#include <vespa/document/bucket/bucket.h>
#include <vespa/vespalib/util/printable.h>
#include <map>
@@ -350,6 +350,8 @@ protected:
StorageMessage(const MessageType& code, Id id);
StorageMessage(const StorageMessage&, Id id);
+ static document::Bucket getPlaceHolderBucket(document::BucketId bucketId) { return document::Bucket(document::BucketSpace::placeHolder(), bucketId); }
+ static document::Bucket getDummyBucket() { return getPlaceHolderBucket(document::BucketId()); }
public:
virtual ~StorageMessage();
@@ -420,7 +422,8 @@ public:
*/
virtual vespalib::string getSummary() const;
- virtual document::BucketId getBucketId() const { return document::BucketId(); }
+ virtual document::Bucket getBucket() const { return getDummyBucket(); }
+ document::BucketId getBucketId() const { return getBucket().getBucketId(); }
virtual bool hasSingleBucketId() const { return false; }
};