aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h
blob: c907627e4c2428828c52b143b3a29ba05cd34efa (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "idealstateoperation.h"
#include <vespa/storage/distributor/messagetracker.h>

namespace storage::distributor {

class PendingMessageTracker;

class RemoveBucketOperation : public IdealStateOperation
{
public:
    RemoveBucketOperation(const ClusterContext &cluster_context, const BucketAndNodes& nodes)
        : IdealStateOperation(nodes), _tracker(cluster_context)
    {}
    ~RemoveBucketOperation() override;

    /**
       Sends messages, returns true if we are done (sent nothing).
    */
    bool onStartInternal(DistributorStripeMessageSender& sender);

    /**
       Sends messages, calls done() if we are done (sent nothing).
    */
    void onStart(DistributorStripeMessageSender& sender) override;

    bool onReceiveInternal(const std::shared_ptr<api::StorageReply> &);

    void onReceive(DistributorStripeMessageSender& sender, const std::shared_ptr<api::StorageReply> &) override;
    const char* getName() const noexcept override { return "remove"; };
    Type getType() const noexcept override { return DELETE_BUCKET; }
    bool shouldBlockThisOperation(uint32_t, uint16_t, uint8_t) const  override;
protected:
    MessageTracker _tracker;
};

}