aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.h
blob: fe88ec507493772e5d8ba0cb7e9e128497073a7d (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.
#pragma once

#include <vespa/vespalib/util/hdr_abort.h>
#include <vespa/storage/distributor/operations/operation.h>
#include <vespa/storage/bucketdb/bucketdatabase.h>

namespace storage::api { class GetBucketListCommand; }

namespace storage::distributor {

class MaintenanceOperationGenerator;

class StatBucketListOperation : public Operation
{
public:
    StatBucketListOperation(
            const BucketDatabase& bucketDb,
            const MaintenanceOperationGenerator& generator,
            uint16_t distributorIndex,
            const std::shared_ptr<api::GetBucketListCommand>& cmd);
    ~StatBucketListOperation() override;

    const char* getName() const noexcept override { return "statBucketList"; }
    std::string getStatus() const override { return ""; }

    void onStart(DistributorStripeMessageSender& sender) override;
    void onReceive(DistributorStripeMessageSender&, const std::shared_ptr<api::StorageReply>&) override
    {
        // Never called.
        HDR_ABORT("should not be reached");
    }
    void onClose(DistributorStripeMessageSender&) override {}

private:
    void getBucketStatus(const BucketDatabase::Entry& entry, std::ostream& os) const;

    const BucketDatabase& _bucketDb;
    const MaintenanceOperationGenerator& _generator;
    uint16_t _distributorIndex;
    std::shared_ptr<api::GetBucketListCommand> _command;
};

} // storage::distributor