aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/operations/external/removeoperation.h
blob: 772047b96ca8e57326e75e521462cfb3df45796e (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
45
46
47
48
49
50
51
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "check_condition.h"
#include <vespa/storage/distributor/operations/sequenced_operation.h>
#include <vespa/storage/distributor/persistencemessagetracker.h>

namespace storage::api { class RemoveCommand; }

namespace storage::distributor {

class DistributorBucketSpace;

class RemoveOperation : public SequencedOperation
{
public:
    RemoveOperation(const DistributorNodeContext& node_ctx,
                    DistributorStripeOperationContext& op_ctx,
                    DistributorBucketSpace& bucketSpace,
                    std::shared_ptr<api::RemoveCommand> msg,
                    PersistenceOperationMetricSet& metric,
                    PersistenceOperationMetricSet& condition_probe_metrics,
                    SequencingHandle sequencingHandle = SequencingHandle());
    ~RemoveOperation() override;

    void onStart(DistributorStripeMessageSender& sender) override;
    const char* getName() const noexcept override { return "remove"; };
    std::string getStatus() const override { return ""; };

    void onReceive(DistributorStripeMessageSender& sender, const std::shared_ptr<api::StorageReply> &) override;
    void onClose(DistributorStripeMessageSender& sender) override;
    void on_cancel(DistributorStripeMessageSender& sender, const CancelScope& cancel_scope) override;

private:
    PersistenceMessageTracker           _tracker;
    std::shared_ptr<api::RemoveCommand> _msg;
    document::BucketId                  _doc_id_bucket_id;
    const DistributorNodeContext&       _node_ctx;
    DistributorStripeOperationContext&  _op_ctx;
    PersistenceOperationMetricSet&      _condition_probe_metrics;
    DistributorBucketSpace&             _bucket_space;
    std::shared_ptr<CheckCondition>     _check_condition;

    void start_direct_remove_dispatch(DistributorStripeMessageSender& sender);
    void start_conditional_remove(DistributorStripeMessageSender& sender);
    void on_completed_check_condition(CheckCondition::Outcome& outcome,
                                      DistributorStripeMessageSender& sender);
    [[nodiscard]] bool has_condition() const noexcept;
};

}