aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storageapi/messageapi/bucketcommand.cpp
blob: f202ce9da7d19e93d7bf977f5769055c3c5fcd70 (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
34
35
36
37
38
39
40
41
42
43
44
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "bucketcommand.h"
#include <ostream>

using document::Bucket;
using document::BucketId;
using document::BucketSpace;

namespace storage::api {

BucketCommand::BucketCommand(const MessageType& type, const Bucket &bucket) noexcept
    : StorageCommand(type),
      _bucket(bucket),
      _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.getBucketId();
    if (hasBeenRemapped()) {
        out << " <- " << _originalBucket;
    }
    out << ")";
    if (verbose) {
        out << " : ";
        StorageCommand::print(out, verbose, indent);
    }
}

}