blob: 24d38b96524b270bbdb35ca266de933803c37a1b (
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
71
72
73
74
75
76
77
78
79
80
81
|
// 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/searchlib/common/indexmetainfo.h>
#include <vespa/searchlib/common/serialnum.h>
#include <vespa/vespalib/objects/nbostream.h>
class FNET_Transport;
namespace proton {
class FileConfigManager : public ConfigStore {
private:
FNET_Transport & _transport;
vespalib::string _baseDir;
vespalib::string _configId;
vespalib::string _docTypeName;
search::IndexMetaInfo _info;
ProtonConfigSP _protonConfig;
public:
/**
* Creates a new file config manager.
*
* @param baseDir the directory in which config snapshots are saved and loaded.
* @param configId the configId that was used to subscribe to config that is later handled by this manager.
*/
FileConfigManager(FNET_Transport & transport, const vespalib::string &baseDir,
const vespalib::string &configId, const vespalib::string &docTypeName);
~FileConfigManager() override;
SerialNum getBestSerialNum() const override;
SerialNum getOldestSerialNum() const override;
void saveConfig(const DocumentDBConfig &snapshot, SerialNum serialNum) override;
/**
* Load a config snapshot from disk corresponding to the given
* serial number. The config id of this manager is set on the
* loaded config snapshot.
*
* @param currentSnapshot the current snapshot, for reusing
* unchanged parts .
* @param serialNum the serial number of the config snapshot to load.
* @param loadedSnapshot the shared pointer in which to store the
* resulting config snapshot.
*/
void loadConfig(const DocumentDBConfig ¤tSnapshot, SerialNum serialNum,
std::shared_ptr<DocumentDBConfig> &loadedSnapshot) override;
void removeInvalid() override;
void prune(SerialNum serialNum) override;
bool hasValidSerial(SerialNum serialNum) const override;
SerialNum getPrevValidSerial(SerialNum serialNum) const override;
/**
* Serialize config files.
*
* Used for serializing config into transaction log.
*/
void serializeConfig(SerialNum serialNum, vespalib::nbostream &stream) override;
/**
* Deserialize config files.
*
* Used for deserializing config from transaction log when it is
* not already present on disk. Config files on disk
* takes precedence over the serialized config files in the
* transaction log.
*/
void deserializeConfig(SerialNum serialNum, vespalib::nbostream &stream) override;
void setProtonConfig(const ProtonConfigSP &protonConfig) override;
};
} // namespace proton
|