blob: b86863890a1b7f021778ea582367c405edd05af8 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/storage/distributor/distributormessagesender.h>
#include <cassert>
#include <vector>
namespace storage {
struct MessageSenderStub : distributor::DistributorMessageSender
{
std::vector<std::shared_ptr<api::StorageCommand> > commands;
std::vector<std::shared_ptr<api::StorageReply> > replies;
MessageSenderStub();
~MessageSenderStub();
void clear() {
commands.clear();
replies.clear();
}
void sendCommand(const std::shared_ptr<api::StorageCommand>& cmd) override {
commands.push_back(cmd);
}
void sendReply(const std::shared_ptr<api::StorageReply>& reply) override {
replies.push_back(reply);
}
std::string getLastCommand(bool verbose = true) const;
std::string getCommands(bool includeAddress = false,
bool verbose = false,
uint32_t fromIndex = 0) const;
std::string getLastReply(bool verbose = true) const;
std::string getReplies(bool includeAddress = false,
bool verbose = false) const;
std::string dumpMessage(const api::StorageMessage& msg,
bool includeAddress,
bool verbose) const;
int getDistributorIndex() const override {
return 0;
}
const std::string& getClusterName() const override {
return _clusterName;
}
const distributor::PendingMessageTracker& getPendingMessageTracker() const override {
assert(_pendingMessageTracker);
return *_pendingMessageTracker;
}
void setPendingMessageTracker(distributor::PendingMessageTracker& tracker) {
_pendingMessageTracker = &tracker;
}
private:
std::string _clusterName;
distributor::PendingMessageTracker* _pendingMessageTracker;
};
}
|