blob: 838bdeb6f2eccca9881f3943c52ed9aa402c598f (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "trans_log_server_explorer.h"
#include "translogserver.h"
#include "domain.h"
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/util/time.h>
#include <filesystem>
using vespalib::slime::Inserter;
using vespalib::slime::Cursor;
namespace fs = std::filesystem;
namespace search::transactionlog {
namespace {
struct DomainExplorer : vespalib::StateExplorer {
Domain::SP domain;
DomainExplorer(Domain::SP domain_in) : domain(std::move(domain_in)) {}
void get_state(const Inserter &inserter, bool full) const override {
Cursor &state = inserter.insertObject();
DomainInfo info = domain->getDomainInfo();
state.setLong("from", info.range.from());
state.setLong("to", info.range.to());
state.setLong("numEntries", info.numEntries);
state.setLong("byteSize", info.byteSize);
if (full) {
Cursor &array = state.setArray("parts");
for (const PartInfo &part_in: info.parts) {
Cursor &part = array.addObject();
part.setLong("from", part_in.range.from());
part.setLong("to", part_in.range.to());
part.setLong("numEntries", part_in.numEntries);
part.setLong("byteSize", part_in.byteSize);
part.setString("file", part_in.file);
part.setString("lastModified", vespalib::to_string(fs::last_write_time(fs::path(part_in.file))));
}
}
}
};
} // namespace search::transactionlog::<unnamed>
TransLogServerExplorer::~TransLogServerExplorer() = default;
void
TransLogServerExplorer::get_state(const Inserter &inserter, bool full) const
{
(void) full;
inserter.insertObject();
}
std::vector<vespalib::string>
TransLogServerExplorer::get_children_names() const
{
return _server->getDomainNames();
}
std::unique_ptr<vespalib::StateExplorer>
TransLogServerExplorer::get_child(vespalib::stringref name) const
{
Domain::SP domain = _server->findDomain(name);
if (!domain) {
return std::unique_ptr<vespalib::StateExplorer>(nullptr);
}
return std::unique_ptr<vespalib::StateExplorer>(new DomainExplorer(std::move(domain)));
}
}
|