aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storageapi/messageapi/bucketcommand.h
blob: bcff166094e654fa8cd225c4b21d6acffee2fdab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
 * @class storage::api::BucketCommand
 * @ingroup messageapi
 *
 * @brief Superclass for storage commands that operate towards a single bucket.
 */

#pragma once

#include "storagecommand.h"
#include <vespa/document/bucket/bucket.h>

namespace storage::api {

class BucketCommand : public StorageCommand {
    document::Bucket   _bucket;
    document::BucketId _originalBucket;

protected:
    BucketCommand(const MessageType& type, const document::Bucket &bucket) noexcept;

public:
    DECLARE_POINTER_TYPEDEFS(BucketCommand);

    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;
};

}