aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.h
blob: 6199186e2c898935e957fac70a9f33aaf07a9b43 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "configstore.h"
#include <vespa/searchcommon/common/schema.h>
#include <map>
#include <set>

namespace proton {

struct ConfigMaps {
    using SP = std::shared_ptr<ConfigMaps>;
    std::map<search::SerialNum, std::shared_ptr<DocumentDBConfig>> configs;
    std::set<search::SerialNum> _valid;
    ~ConfigMaps();
};

class MemoryConfigStore : public ConfigStore {
    using Schema = search::index::Schema;
    ConfigMaps::SP _maps;

public:
    MemoryConfigStore(const MemoryConfigStore &) = delete;
    MemoryConfigStore & operator = (const MemoryConfigStore &) = delete;
    MemoryConfigStore();
    MemoryConfigStore(ConfigMaps::SP maps);
    ~MemoryConfigStore();

    SerialNum getBestSerialNum() const override;
    SerialNum getOldestSerialNum() const override;
    bool hasValidSerial(SerialNum serial) const override;
    SerialNum getPrevValidSerial(SerialNum serial) const override;
    void saveConfig(const DocumentDBConfig &config, SerialNum serial) override;
    void loadConfig(const DocumentDBConfig &, SerialNum serial, std::shared_ptr<DocumentDBConfig> &loaded_config) override;
    void removeInvalid() override;
    void prune(SerialNum serial) override;
    void serializeConfig(SerialNum, vespalib::nbostream &) override;
    void deserializeConfig(SerialNum, vespalib::nbostream &) override;
    void setProtonConfig(const ProtonConfigSP &) override;
};

// Holds the state of a set of MemoryConfigStore objects, making stored
// state available between different instantiations.
class MemoryConfigStores {
    std::map<std::string, ConfigMaps::SP> _config_maps;

public:
    MemoryConfigStores(const MemoryConfigStores &) = delete;
    MemoryConfigStores & operator = (const MemoryConfigStores &) = delete;
    MemoryConfigStores();
    ~MemoryConfigStores();
    ConfigStore::UP getConfigStore(const std::string &type);
};

}  // namespace proton