summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2017-10-16 12:27:24 +0000
committerTor Egge <Tor.Egge@oath.com>2017-10-16 12:27:24 +0000
commit90af05394305493539104ef01f8e39275815d419 (patch)
tree2bd15d0d82b766ceab25b74944e97c72c614dff8 /storage
parent6ac5a9c0f069287422e617be88e36b3d769ba014 (diff)
Add bucket space to more storage commands.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/vespa/storage/common/bucketmessages.cpp41
-rw-r--r--storage/src/vespa/storage/common/bucketmessages.h36
-rw-r--r--storage/src/vespa/storage/persistence/messages.cpp22
-rw-r--r--storage/src/vespa/storage/persistence/messages.h24
4 files changed, 71 insertions, 52 deletions
diff --git a/storage/src/vespa/storage/common/bucketmessages.cpp b/storage/src/vespa/storage/common/bucketmessages.cpp
index 7bbfe8380da..c7e013392f7 100644
--- a/storage/src/vespa/storage/common/bucketmessages.cpp
+++ b/storage/src/vespa/storage/common/bucketmessages.cpp
@@ -3,6 +3,8 @@
#include "bucketmessages.h"
#include <vespa/vespalib/stllike/asciistream.h>
+using document::BucketSpace;
+
namespace storage {
ReadBucketList::ReadBucketList(spi::PartitionId partition)
@@ -44,7 +46,8 @@ ReadBucketList::makeReply() {
}
ReadBucketInfo::ReadBucketInfo(const document::BucketId& bucketId)
- : api::InternalCommand(ID), _bucketId(bucketId)
+ : api::InternalCommand(ID),
+ _bucket(BucketSpace::placeHolder(), bucketId)
{ }
ReadBucketInfo::~ReadBucketInfo() { }
@@ -52,7 +55,7 @@ ReadBucketInfo::~ReadBucketInfo() { }
void
ReadBucketInfo::print(std::ostream& out, bool verbose, const std::string& indent) const
{
- out << "ReadBucketInfo(" << _bucketId << ")";
+ out << "ReadBucketInfo(" << _bucket.getBucketId() << ")";
if (verbose) {
out << " : ";
@@ -63,14 +66,14 @@ ReadBucketInfo::print(std::ostream& out, bool verbose, const std::string& indent
vespalib::string
ReadBucketInfo::getSummary() const {
vespalib::string s("ReadBucketInfo(");
- s.append(_bucketId.toString());
+ s.append(_bucket.toString());
s.append(')');
return s;
}
ReadBucketInfoReply::ReadBucketInfoReply(const ReadBucketInfo& cmd)
: api::InternalReply(ID, cmd),
- _bucketId(cmd.getBucketId())
+ _bucket(cmd.getBucket())
{ }
ReadBucketInfoReply::~ReadBucketInfoReply() { }
@@ -90,7 +93,7 @@ std::unique_ptr<api::StorageReply> ReadBucketInfo::makeReply() {
RepairBucketCommand::RepairBucketCommand(const document::BucketId& bucket, uint16_t disk)
: api::InternalCommand(ID),
- _bucket(bucket),
+ _bucket(BucketSpace::placeHolder(), bucket),
_disk(disk),
_verifyBody(false),
_moveToIdealDisk(false)
@@ -109,6 +112,13 @@ RepairBucketCommand::print(std::ostream& out, bool verbose, const std::string& i
}
}
+void
+RepairBucketCommand::setBucketId(const document::BucketId& id)
+{
+ document::Bucket newBucket(_bucket.getBucketSpace(), id);
+ _bucket = newBucket;
+}
+
vespalib::string
RepairBucketCommand::getSummary() const {
vespalib::asciistream s;
@@ -121,7 +131,7 @@ RepairBucketCommand::getSummary() const {
RepairBucketReply::RepairBucketReply(const RepairBucketCommand& cmd, const api::BucketInfo& bucketInfo)
: api::InternalReply(ID, cmd),
- _bucket(cmd.getBucketId()),
+ _bucket(cmd.getBucket()),
_bucketInfo(bucketInfo),
_disk(cmd.getDisk()),
_altered(false)
@@ -147,7 +157,7 @@ RepairBucketCommand::makeReply() {
BucketDiskMoveCommand::BucketDiskMoveCommand(const document::BucketId& bucket,
uint16_t srcDisk, uint16_t dstDisk)
: api::InternalCommand(ID),
- _bucket(bucket),
+ _bucket(BucketSpace::placeHolder(), bucket),
_srcDisk(srcDisk),
_dstDisk(dstDisk)
{
@@ -157,8 +167,15 @@ BucketDiskMoveCommand::BucketDiskMoveCommand(const document::BucketId& bucket,
BucketDiskMoveCommand::~BucketDiskMoveCommand() { }
void
+BucketDiskMoveCommand::setBucketId(const document::BucketId& id)
+{
+ document::Bucket newBucket(_bucket.getBucketSpace(), id);
+ _bucket = newBucket;
+}
+
+void
BucketDiskMoveCommand::print(std::ostream& out, bool, const std::string&) const {
- out << "BucketDiskMoveCommand(" << _bucket << ", source " << _srcDisk
+ out << "BucketDiskMoveCommand(" << _bucket.getBucketId() << ", source " << _srcDisk
<< ", target " << _dstDisk << ")";
}
@@ -167,7 +184,7 @@ BucketDiskMoveReply::BucketDiskMoveReply(const BucketDiskMoveCommand& cmd,
uint32_t sourceFileSize,
uint32_t destinationFileSize)
: api::InternalReply(ID, cmd),
- _bucket(cmd.getBucketId()),
+ _bucket(cmd.getBucket()),
_bucketInfo(bucketInfo),
_fileSizeOnSrc(sourceFileSize),
_fileSizeOnDst(destinationFileSize),
@@ -180,7 +197,7 @@ BucketDiskMoveReply::~BucketDiskMoveReply() { }
void
BucketDiskMoveReply::print(std::ostream& out, bool, const std::string&) const
{
- out << "BucketDiskMoveReply(" << _bucket << ", source " << _srcDisk
+ out << "BucketDiskMoveReply(" << _bucket.getBucketId() << ", source " << _srcDisk
<< ", target " << _dstDisk << ", " << _bucketInfo << ", "
<< getResult() << ")";
}
@@ -195,7 +212,7 @@ BucketDiskMoveCommand::makeReply()
InternalBucketJoinCommand::InternalBucketJoinCommand(const document::BucketId& bucket,
uint16_t keepOnDisk, uint16_t joinFromDisk)
: api::InternalCommand(ID),
- _bucket(bucket),
+ _bucket(BucketSpace::placeHolder(), bucket),
_keepOnDisk(keepOnDisk),
_joinFromDisk(joinFromDisk)
{
@@ -218,7 +235,7 @@ InternalBucketJoinCommand::print(std::ostream& out, bool verbose, const std::str
InternalBucketJoinReply::InternalBucketJoinReply(const InternalBucketJoinCommand& cmd,
const api::BucketInfo& info)
: api::InternalReply(ID, cmd),
- _bucket(cmd.getBucketId()),
+ _bucket(cmd.getBucket()),
_bucketInfo(info)
{ }
diff --git a/storage/src/vespa/storage/common/bucketmessages.h b/storage/src/vespa/storage/common/bucketmessages.h
index abfadb77c4a..9eef9ed6068 100644
--- a/storage/src/vespa/storage/common/bucketmessages.h
+++ b/storage/src/vespa/storage/common/bucketmessages.h
@@ -70,7 +70,7 @@ public:
* used to retrieve such information.
*/
class ReadBucketInfo : public api::InternalCommand {
- document::BucketId _bucketId;
+ document::Bucket _bucket;
public:
static const uint32_t ID = 2005;
@@ -78,7 +78,7 @@ public:
ReadBucketInfo(const document::BucketId& bucketId);
~ReadBucketInfo();
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
+ document::Bucket getBucket() const override { return _bucket; }
bool hasSingleBucketId() const override { return true; }
std::unique_ptr<api::StorageReply> makeReply() override;
@@ -94,7 +94,7 @@ private:
* @ingroup common
*/
class ReadBucketInfoReply : public api::InternalReply {
- document::BucketId _bucketId;
+ document::Bucket _bucket;
public:
static const uint32_t ID = 2006;
@@ -102,7 +102,7 @@ public:
ReadBucketInfoReply(const ReadBucketInfo& cmd);
~ReadBucketInfoReply();
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
+ document::Bucket getBucket() const override { return _bucket; }
bool hasSingleBucketId() const override { return true; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
@@ -119,7 +119,7 @@ public:
* Errors found are reported back.
*/
class RepairBucketCommand : public api::InternalCommand {
- document::BucketId _bucket;
+ document::Bucket _bucket;
uint16_t _disk;
bool _verifyBody; // Optional as it is expensive
bool _moveToIdealDisk; // Optional as it is expensive
@@ -133,13 +133,13 @@ public:
~RepairBucketCommand();
bool hasSingleBucketId() const override { return true; }
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucket); }
+ document::Bucket getBucket() const override { return _bucket; }
uint16_t getDisk() const { return _disk; }
bool verifyBody() const { return _verifyBody; }
bool moveToIdealDisk() const { return _moveToIdealDisk; }
- void setBucketId(const document::BucketId& id) { _bucket = id; }
+ void setBucketId(const document::BucketId& id);
void verifyBody(bool doIt) { _verifyBody = doIt; }
void moveToIdealDisk(bool doIt) { _moveToIdealDisk = doIt; }
@@ -155,7 +155,7 @@ private:
* @ingroup common
*/
class RepairBucketReply : public api::InternalReply {
- document::BucketId _bucket;
+ document::Bucket _bucket;
api::BucketInfo _bucketInfo;
uint16_t _disk;
bool _altered;
@@ -166,7 +166,7 @@ public:
RepairBucketReply(const RepairBucketCommand& cmd, const api::BucketInfo& bucketInfo = api::BucketInfo());
~RepairBucketReply();
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucket); }
+ document::Bucket getBucket() const override { return _bucket; }
bool hasSingleBucketId() const override { return true; }
const api::BucketInfo& getBucketInfo() const { return _bucketInfo; }
@@ -188,7 +188,7 @@ public:
* Size of the bucket moved is reported back.
*/
class BucketDiskMoveCommand : public api::InternalCommand {
- document::BucketId _bucket;
+ document::Bucket _bucket;
uint16_t _srcDisk;
uint16_t _dstDisk;
@@ -199,13 +199,13 @@ public:
BucketDiskMoveCommand(const document::BucketId& bucket, uint16_t srcDisk, uint16_t dstDisk);
~BucketDiskMoveCommand();
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucket); }
+ document::Bucket getBucket() const override { return _bucket; }
bool hasSingleBucketId() const override { return true; }
uint16_t getSrcDisk() const { return _srcDisk; }
uint16_t getDstDisk() const { return _dstDisk; }
- void setBucketId(const document::BucketId& id) { _bucket = id; }
+ void setBucketId(const document::BucketId& id);
std::unique_ptr<api::StorageReply> makeReply() override;
@@ -217,7 +217,7 @@ public:
* @ingroup common
*/
class BucketDiskMoveReply : public api::InternalReply {
- document::BucketId _bucket;
+ document::Bucket _bucket;
api::BucketInfo _bucketInfo;
uint64_t _fileSizeOnSrc;
uint64_t _fileSizeOnDst;
@@ -234,7 +234,7 @@ public:
uint32_t destinationFileSize = 0);
~BucketDiskMoveReply();
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucket); }
+ document::Bucket getBucket() const override { return _bucket; }
bool hasSingleBucketId() const override { return true; }
const api::BucketInfo& getBucketInfo() const { return _bucketInfo; }
@@ -260,7 +260,7 @@ public:
* while storage is running.
*/
class InternalBucketJoinCommand : public api::InternalCommand {
- document::BucketId _bucket;
+ document::Bucket _bucket;
uint16_t _keepOnDisk;
uint16_t _joinFromDisk;
@@ -270,7 +270,7 @@ public:
InternalBucketJoinCommand(const document::BucketId& bucket, uint16_t keepOnDisk, uint16_t joinFromDisk);
~InternalBucketJoinCommand();
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucket); }
+ document::Bucket getBucket() const override { return _bucket; }
bool hasSingleBucketId() const override { return true; }
uint16_t getDiskOfInstanceToKeep() const { return _keepOnDisk; }
@@ -286,7 +286,7 @@ public:
* @ingroup common
*/
class InternalBucketJoinReply : public api::InternalReply {
- document::BucketId _bucket;
+ document::Bucket _bucket;
api::BucketInfo _bucketInfo;
public:
@@ -296,7 +296,7 @@ public:
const api::BucketInfo& info = api::BucketInfo());
~InternalBucketJoinReply();
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucket); }
+ document::Bucket getBucket() const override { return _bucket; }
bool hasSingleBucketId() const override { return true; }
const api::BucketInfo& getBucketInfo() const { return _bucketInfo; }
diff --git a/storage/src/vespa/storage/persistence/messages.cpp b/storage/src/vespa/storage/persistence/messages.cpp
index 9711d852ce8..5a7f679a0bf 100644
--- a/storage/src/vespa/storage/persistence/messages.cpp
+++ b/storage/src/vespa/storage/persistence/messages.cpp
@@ -2,6 +2,8 @@
#include "messages.h"
+using document::BucketSpace;
+
namespace storage {
GetIterCommand::GetIterCommand(framework::MemoryToken::UP token,
@@ -10,7 +12,7 @@ GetIterCommand::GetIterCommand(framework::MemoryToken::UP token,
uint32_t maxByteSize)
: api::InternalCommand(ID),
_token(std::move(token)),
- _bucketId(bucketId),
+ _bucket(BucketSpace::placeHolder(), bucketId),
_iteratorId(iteratorId),
_maxByteSize(maxByteSize)
{
@@ -37,7 +39,7 @@ GetIterCommand::makeReply() {
GetIterReply::GetIterReply(GetIterCommand& cmd)
: api::InternalReply(ID, cmd),
_token(cmd.releaseMemoryToken()),
- _bucketId(cmd.getBucketId()),
+ _bucket(cmd.getBucket()),
_completed(false)
{ }
@@ -58,7 +60,7 @@ CreateIteratorCommand::CreateIteratorCommand(const document::BucketId& bucketId,
const std::string& fields,
spi::IncludedVersions includedVersions)
: api::InternalCommand(ID),
- _bucketId(bucketId),
+ _bucket(BucketSpace::placeHolder(), bucketId),
_selection(selection),
_fieldSet(fields),
_includedVersions(includedVersions),
@@ -69,7 +71,7 @@ CreateIteratorCommand::~CreateIteratorCommand() { }
void
CreateIteratorCommand::print(std::ostream& out, bool, const std::string &) const {
- out << "CreateIteratorCommand(" << _bucketId << ")";
+ out << "CreateIteratorCommand(" << _bucket.getBucketId() << ")";
}
std::unique_ptr<api::StorageReply>
@@ -80,7 +82,7 @@ CreateIteratorCommand::makeReply() {
CreateIteratorReply::CreateIteratorReply(const CreateIteratorCommand& cmd, spi::IteratorId iteratorId)
: api::InternalReply(ID, cmd),
- _bucketId(cmd.getBucketId()),
+ _bucket(cmd.getBucket()),
_iteratorId(iteratorId)
{ }
@@ -88,7 +90,7 @@ CreateIteratorReply::~CreateIteratorReply() { }
void
CreateIteratorReply::print(std::ostream& out, bool, const std::string &) const {
- out << "CreateIteratorReply(" << _bucketId << ")";
+ out << "CreateIteratorReply(" << _bucket.getBucketId() << ")";
}
DestroyIteratorCommand::DestroyIteratorCommand(spi::IteratorId iteratorId)
@@ -122,26 +124,26 @@ DestroyIteratorCommand::makeReply() {
RecheckBucketInfoCommand::RecheckBucketInfoCommand(const document::BucketId& bucketId)
: api::InternalCommand(ID),
- _bucketId(bucketId)
+ _bucket(BucketSpace::placeHolder(), bucketId)
{ }
RecheckBucketInfoCommand::~RecheckBucketInfoCommand() { }
void
RecheckBucketInfoCommand::print(std::ostream& out, bool, const std::string &) const {
- out << "RecheckBucketInfoCommand(" << _bucketId << ")";
+ out << "RecheckBucketInfoCommand(" << _bucket.getBucketId() << ")";
}
RecheckBucketInfoReply::RecheckBucketInfoReply(const RecheckBucketInfoCommand& cmd)
: api::InternalReply(ID, cmd),
- _bucketId(cmd.getBucketId())
+ _bucket(cmd.getBucket())
{ }
RecheckBucketInfoReply::~RecheckBucketInfoReply() { }
void
RecheckBucketInfoReply::print(std::ostream& out, bool, const std::string &) const {
- out << "RecheckBucketInfoReply(" << _bucketId << ")";
+ out << "RecheckBucketInfoReply(" << _bucket.getBucketId() << ")";
}
std::unique_ptr<api::StorageReply>
diff --git a/storage/src/vespa/storage/persistence/messages.h b/storage/src/vespa/storage/persistence/messages.h
index d574eaa2108..7f38839d80c 100644
--- a/storage/src/vespa/storage/persistence/messages.h
+++ b/storage/src/vespa/storage/persistence/messages.h
@@ -15,7 +15,7 @@ namespace storage {
class GetIterCommand : public api::InternalCommand {
private:
mutable framework::MemoryToken::UP _token;
- document::BucketId _bucketId;
+ document::Bucket _bucket;
spi::IteratorId _iteratorId;
uint32_t _maxByteSize;
@@ -32,7 +32,7 @@ public:
std::unique_ptr<api::StorageReply> makeReply() override;
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
+ document::Bucket getBucket() const override { return _bucket; }
bool hasSingleBucketId() const override { return true; }
spi::IteratorId getIteratorId() const { return _iteratorId; }
@@ -51,7 +51,7 @@ private:
class GetIterReply : public api::InternalReply {
private:
framework::MemoryToken::UP _token;
- document::BucketId _bucketId;
+ document::Bucket _bucket;
std::vector<spi::DocEntry::UP> _entries;
bool _completed;
@@ -64,7 +64,7 @@ public:
~GetIterReply();
bool hasSingleBucketId() const override { return true; }
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
+ document::Bucket getBucket() const override { return _bucket; }
const std::vector<spi::DocEntry::UP>& getEntries() const {
return _entries;
@@ -82,7 +82,7 @@ public:
class CreateIteratorCommand : public api::InternalCommand
{
- document::BucketId _bucketId;
+ document::Bucket _bucket;
spi::Selection _selection;
std::string _fieldSet;
spi::IncludedVersions _includedVersions;
@@ -99,7 +99,7 @@ public:
spi::IncludedVersions includedVersions);
~CreateIteratorCommand();
bool hasSingleBucketId() const override { return true; }
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
+ document::Bucket getBucket() const override { return _bucket; }
const spi::Selection& getSelection() const { return _selection; }
spi::IncludedVersions getIncludedVersions() const { return _includedVersions; }
const std::string& getFields() const { return _fieldSet; }
@@ -118,7 +118,7 @@ public:
class CreateIteratorReply : public api::InternalReply
{
- document::BucketId _bucketId;
+ document::Bucket _bucket;
spi::IteratorId _iteratorId;
public:
static const uint32_t ID = 1004;
@@ -129,7 +129,7 @@ public:
~CreateIteratorReply();
bool hasSingleBucketId() const override { return true; }
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
+ document::Bucket getBucket() const override { return _bucket; }
spi::IteratorId getIteratorId() const { return _iteratorId; }
@@ -170,7 +170,7 @@ public:
class RecheckBucketInfoCommand : public api::InternalCommand
{
- document::BucketId _bucketId;
+ document::Bucket _bucket;
public:
static const uint32_t ID = 1007;
typedef std::shared_ptr<RecheckBucketInfoCommand> SP;
@@ -179,7 +179,7 @@ public:
RecheckBucketInfoCommand(const document::BucketId& bucketId);
~RecheckBucketInfoCommand();
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
+ document::Bucket getBucket() const override { return _bucket; }
std::unique_ptr<api::StorageReply> makeReply() override;
@@ -188,7 +188,7 @@ public:
class RecheckBucketInfoReply : public api::InternalReply
{
- document::BucketId _bucketId;
+ document::Bucket _bucket;
public:
static const uint32_t ID = 1008;
typedef std::shared_ptr<RecheckBucketInfoReply> SP;
@@ -197,7 +197,7 @@ public:
RecheckBucketInfoReply(const RecheckBucketInfoCommand& cmd);
~RecheckBucketInfoReply();
- document::Bucket getBucket() const override { return getPlaceHolderBucket(_bucketId); }
+ document::Bucket getBucket() const override { return _bucket; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};