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

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

namespace storage::distributor {

class PendingMessageTracker;

class GarbageCollectionOperation : public IdealStateOperation
{
public:
    GarbageCollectionOperation(const ClusterContext& cluster_ctx,
                               const BucketAndNodes& nodes);
    ~GarbageCollectionOperation() override;

    void onStart(DistributorStripeMessageSender& sender) override;
    void onReceive(DistributorStripeMessageSender& sender, const std::shared_ptr<api::StorageReply> &) override;
    const char* getName() const override { return "garbagecollection"; };
    Type getType() const override { return GARBAGE_COLLECTION; }
    bool shouldBlockThisOperation(uint32_t, uint8_t) const override;

protected:
    MessageTracker _tracker;
private:
    std::vector<BucketCopy> _replica_info;
    uint32_t _max_documents_removed;

    void merge_received_bucket_info_into_db();
    void update_gc_metrics();
};

}