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

#include "document_meta_store_explorer.h"
#include "documentmetastore.h"
#include <vespa/searchlib/util/state_explorer_utils.h>
#include <vespa/vespalib/data/slime/cursor.h>

using search::StateExplorerUtils;
using search::attribute::Status;
using vespalib::slime::Cursor;
using vespalib::slime::Inserter;

namespace proton {

DocumentMetaStoreExplorer::DocumentMetaStoreExplorer(IDocumentMetaStoreContext::IReadGuard::SP metaStore)
    : _metaStore(std::move(metaStore))
{
}

void
DocumentMetaStoreExplorer::get_state(const Inserter &inserter, bool full) const
{
    Cursor &object = inserter.insertObject();
    if (full) {
        auto dms = dynamic_cast<const DocumentMetaStore*>(&_metaStore->get());
        if (dms != nullptr) {
            const Status &status = dms->getStatus();
            StateExplorerUtils::status_to_slime(status, object.setObject("status"));
        }
        search::LidUsageStats stats = _metaStore->get().getLidUsageStats();
        object.setLong("usedLids", stats.getUsedLids());
        object.setLong("activeLids", _metaStore->get().getNumActiveLids());
        object.setLong("lidLimit", stats.getLidLimit());
        object.setLong("lowestFreeLid", stats.getLowestFreeLid());
        object.setLong("highestUsedLid", stats.getHighestUsedLid());
        object.setLong("lidBloat", stats.getLidBloat());
        object.setDouble("lidBloatFactor", stats.getLidBloatFactor());
    } else {
        object.setLong("usedLids", _metaStore->get().getNumUsedLids());
        object.setLong("activeLids", _metaStore->get().getNumActiveLids());
    }
}

} // namespace proton