aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/common/statusmessages.h
blob: 12432bfe095570e9fe4a60461f9e579a9f6bfab1 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
 * Internal command used by visitor and filestor framework to gather partial
 * status from message processing threads.
 */

#pragma once

#include <vespa/storageapi/message/internal.h>
#include <vespa/storageframework/generic/status/httpurlpath.h>

namespace storage {

/**
 * @class RequestStatusPage
 * @ingroup visiting
 *
 * @brief Used to retrieve status page from threads.
 */
class RequestStatusPage : public api::InternalCommand {
    framework::HttpUrlPath _path;
    std::string _sortToken; // Used if sending multiple messages, to set order
                            // in which results should be sorted on status page.
                            // (Used by filestor threads)
public:
    static constexpr uint32_t ID = 2100;

    RequestStatusPage(const framework::HttpUrlPath& path);
    ~RequestStatusPage();

    const std::string& getSortToken() const { return _sortToken; }
    void setSortToken(const std::string& token) { _sortToken = token; }

    std::unique_ptr<api::StorageReply> makeReply() override;

    const framework::HttpUrlPath& getPath() const { return _path; }

    void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};

/**
 * @class RequestStatusPageReply
 * @ingroup visiting
 */
class RequestStatusPageReply : public api::InternalReply {
    std::string _status;
    std::string _sortToken;
public:
    static constexpr uint32_t ID = 2101;

    RequestStatusPageReply(const RequestStatusPage& cmd, const std::string& status);
    ~RequestStatusPageReply();

    const std::string& getStatus() const { return _status; }
    const std::string& getSortToken() const { return _sortToken; }

    void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};

struct StatusReqSorter {
    bool operator()(const std::shared_ptr<RequestStatusPageReply>& a,
                    const std::shared_ptr<RequestStatusPageReply>& b)
    {
        return (a->getSortToken() < b->getSortToken());
    }
};

} // storage