aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/visiting/messages.h
blob: 817cff9c006e85c35c59f9e985af484e6eb6426f (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
 * Messages used internally within visitor implementation. Sent from visitor
 * manager to visitor threads, to avoid any locking issues generated by calling
 * visitor threads directly.
 */

#pragma once

#include <vespa/storageapi/message/internal.h>
#include <vespa/storage/visiting/config-stor-visitor.h>

namespace storage {

/**
 * @class PropagateVisitorConfig
 * @ingroup visiting
 *
 * @brief Used to propagate visitor config to visitor threads.
 */
class PropagateVisitorConfig : public api::InternalCommand {
    vespa::config::content::core::StorVisitorConfig _config;
public:
    static const uint32_t ID = 3001;

    PropagateVisitorConfig(const vespa::config::content::core::StorVisitorConfig& config)
        : api::InternalCommand(ID),
          _config(config) {}

    std::unique_ptr<api::StorageReply> makeReply() override;
    const vespa::config::content::core::StorVisitorConfig& getConfig() const { return _config; }

    void print(std::ostream& out, bool verbose, const std::string& indent) const override {
        out << "PropagateVisitorConfig()";

        if (verbose) {
            out << " : ";
            api::InternalCommand::print(out, true, indent);
        }
    }
};

/**
 * @class PropagateVisitorConfigReply
 * @ingroup visiting
 */
class PropagateVisitorConfigReply : public api::InternalReply {
public:
    static const int ID = 3002;

    PropagateVisitorConfigReply(const PropagateVisitorConfig& cmd)
        : api::InternalReply(ID, cmd)
    {}
    void print(std::ostream& out, bool verbose, const std::string& indent) const override {
        out << "PropagateVisitorConfigReply()";

        if (verbose) {
            out << " : ";
            api::InternalReply::print(out, true, indent);
        }
    }
};

inline std::unique_ptr<api::StorageReply>
PropagateVisitorConfig::makeReply()
{
    return std::unique_ptr<api::StorageReply>(
            new PropagateVisitorConfigReply(*this));
}

} // storage