aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/document_subdb_collection_explorer.cpp
blob: 91764d5dceb91cf2c15c6fb746be59bf3d32ca62 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "document_subdb_collection_explorer.h"
#include "document_subdb_explorer.h"

using vespalib::slime::Inserter;

namespace proton {

const vespalib::string READY = "ready";
const vespalib::string REMOVED = "removed";
const vespalib::string NOT_READY = "notready";

namespace {

std::unique_ptr<vespalib::StateExplorer>
createExplorer(const IDocumentSubDB &subDb)
{
    return std::unique_ptr<vespalib::StateExplorer>(new DocumentSubDBExplorer(subDb));
}

}

DocumentSubDBCollectionExplorer::DocumentSubDBCollectionExplorer(const DocumentSubDBCollection &subDbs)
    : _subDbs(subDbs)
{
}

void
DocumentSubDBCollectionExplorer::get_state(const Inserter &inserter, bool full) const
{
    // This is a transparent state where the short state of all children is rendered instead.
    (void) inserter;
    (void) full;
}

std::vector<vespalib::string>
DocumentSubDBCollectionExplorer::get_children_names() const
{
    return {READY, REMOVED, NOT_READY};
}

std::unique_ptr<vespalib::StateExplorer>
DocumentSubDBCollectionExplorer::get_child(vespalib::stringref name) const
{
    if (name == READY) {
        return createExplorer(*_subDbs.getReadySubDB());
    } else if (name == REMOVED) {
        return createExplorer(*_subDbs.getRemSubDB());
    } else if (name == NOT_READY) {
        return createExplorer(*_subDbs.getNotReadySubDB());
    }
    return std::unique_ptr<vespalib::StateExplorer>();
}

} // namespace proton