aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/bmcluster/storage_api_bm_feed_handler_base.h
blob: 150b19ccb10c96b85c5ead2e797977face742af9 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "i_bm_feed_handler.h"

namespace storage::api { class StorageCommand; }

namespace search::bmcluster {

class IBmDistribution;

/*
 * Base class for benchmark feed handlers that feed to service layer
 * or distributor using storage api protocol.
 */
class StorageApiBmFeedHandlerBase : public IBmFeedHandler
{
protected:
    vespalib::string       _name;
    const IBmDistribution& _distribution;
    bool                   _distributor;

    virtual void send_cmd(std::shared_ptr<storage::api::StorageCommand> cmd, PendingTracker& tracker) = 0;
    uint32_t route_cmd(storage::api::StorageCommand& cmd);
public:
    StorageApiBmFeedHandlerBase(const vespalib::string& base_name, const IBmDistribution &distribution, bool distributor);
    ~StorageApiBmFeedHandlerBase();
    void put(const document::Bucket& bucket, std::unique_ptr<document::Document> document, uint64_t timestamp, PendingTracker& tracker) override;
    void update(const document::Bucket& bucket, std::unique_ptr<document::DocumentUpdate> document_update, uint64_t timestamp, PendingTracker& tracker) override;
    void remove(const document::Bucket& bucket, const document::DocumentId& document_id,  uint64_t timestamp, PendingTracker& tracker) override;
    void get(const document::Bucket& bucket, vespalib::stringref field_set_string, const document::DocumentId& document_id, PendingTracker& tracker) override;
    const vespalib::string &get_name() const override;
    bool manages_timestamp() const override;
};

}