aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storageapi/message/datagram.h
blob: e0f5a9f7b3097f3beb93c09ade22dde1ef53472d (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
72
73
74
75
76
77
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "visitor.h"
#include <vespa/storageapi/messageapi/storagecommand.h>
#include <vespa/storageapi/messageapi/storagereply.h>
#include <vespa/storageapi/defs.h>

namespace storage::api {

/**
 * @class MapStorageCommand
 * @ingroup message
 *
 * @brief Sends a map of data to a visitor.
 *
 * This is a generic way to transfer data to the visitor data handler.
 * It is for instance used when doing a specialized visitor to gather statistics
 * on usage of document types and namespaces.
 */
class MapVisitorCommand : public StorageCommand {
    vdslib::Parameters _statistics;
public:
    MapVisitorCommand();
    vdslib::Parameters& getData() { return _statistics; };
    const vdslib::Parameters& getData() const { return _statistics; };
    void print(std::ostream& out, bool verbose, const std::string& indent) const override;
    DECLARE_STORAGECOMMAND(MapVisitorCommand, onMapVisitor)
};

/**
 * @class MapStorageReply
 * @ingroup message
 *
 * @brief Confirm that a given map visitor command has been received.
 */
class MapVisitorReply : public StorageReply {
public:
    explicit MapVisitorReply(const MapVisitorCommand&);
    void print(std::ostream& out, bool verbose, const std::string& indent) const override;
    DECLARE_STORAGEREPLY(MapVisitorReply, onMapVisitorReply)
};

/**
 * @class EmptyBucketsCommand
 * @ingroup message
 *
 * @brief Sends a vector of bucket ids to a visitor.
 *
 * This message is used in synchronization to tell the synchronization client
 * that a bucket contains no data at all. This is needed to let the follower be
 * able to delete documents from these buckets, as they would otherwise be
 * ignored by the synch agent.
 */
class EmptyBucketsCommand : public StorageCommand {
    std::vector<document::BucketId> _buckets;
public:
    EmptyBucketsCommand(const std::vector<document::BucketId>&);
    const std::vector<document::BucketId>& getBuckets() const { return _buckets; }
    void print(std::ostream& out, bool verbose, const std::string& indent) const override;
    DECLARE_STORAGECOMMAND(EmptyBucketsCommand, onEmptyBuckets)
};

/**
 * @class EmptyBucketsReply
 * @ingroup message
 *
 * @brief Confirm that a given emptybucketscommad has been received.
 */
class EmptyBucketsReply : public StorageReply {
public:
    explicit EmptyBucketsReply(const EmptyBucketsCommand&);
    void print(std::ostream& out, bool verbose, const std::string& indent) const override;
    DECLARE_STORAGEREPLY(EmptyBucketsReply, onEmptyBucketsReply)
};

}