blob: 7ca1a21d2f042bea01f75e5018b172f705cdfaf4 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "executor_thread_service.h"
#include "i_proton_configurer.h"
#include <vespa/document/bucket/bucketspace.h>
#include <vespa/searchcore/proton/common/doctypename.h>
#include <vespa/vespalib/net/http/simple_component_config_producer.h>
#include <vespa/vespalib/util/monitored_refcount.h>
#include <map>
#include <mutex>
namespace proton {
class DocumentDBDirectoryHolder;
class IDocumentDBConfigOwner;
class IProtonConfigurerOwner;
class BootstrapConfig;
class IProtonDiskLayout;
/*
* Class to handle config changes to proton using config snapshots spanning
* all document types.
*/
class ProtonConfigurer : public IProtonConfigurer
{
using DocumentDBs = std::map<DocTypeName, std::pair<std::weak_ptr<IDocumentDBConfigOwner>, std::weak_ptr<DocumentDBDirectoryHolder>>>;
using InitializeThreads = std::shared_ptr<vespalib::ThreadExecutor>;
class ReconfigureTask;
ExecutorThreadService _executor;
IProtonConfigurerOwner &_owner;
DocumentDBs _documentDBs;
std::shared_ptr<ProtonConfigSnapshot> _pendingConfigSnapshot;
std::shared_ptr<ProtonConfigSnapshot> _activeConfigSnapshot;
mutable std::mutex _mutex;
bool _allowReconfig;
vespalib::SimpleComponentConfigProducer _componentConfig;
const std::unique_ptr<IProtonDiskLayout> &_diskLayout;
vespalib::MonitoredRefCount _pendingReconfigureTasks;
void performReconfigure();
bool skipConfig(const ProtonConfigSnapshot *configSnapshot, bool initialConfig);
void applyConfig(std::shared_ptr<ProtonConfigSnapshot> configSnapshot,
InitializeThreads initializeThreads, bool initialConfig);
void configureDocumentDB(const ProtonConfigSnapshot &configSnapshot,
const DocTypeName &docTypeName, document::BucketSpace bucketSpace,
const vespalib::string &configId, InitializeThreads initializeThreads);
void pruneDocumentDBs(const ProtonConfigSnapshot &configSnapshot);
void pruneInitialDocumentDBDirs(const ProtonConfigSnapshot &configSnapshot);
public:
ProtonConfigurer(vespalib::ThreadExecutor &executor,
IProtonConfigurerOwner &owner,
const std::unique_ptr<IProtonDiskLayout> &diskLayout);
~ProtonConfigurer() override;
void setAllowReconfig(bool allowReconfig);
std::shared_ptr<ProtonConfigSnapshot> getPendingConfigSnapshot();
std::shared_ptr<ProtonConfigSnapshot> getActiveConfigSnapshot() const;
void reconfigure(std::shared_ptr<ProtonConfigSnapshot> configSnapshot) override;
void applyInitialConfig(InitializeThreads initializeThreads);
vespalib::SimpleComponentConfigProducer &getComponentConfig() { return _componentConfig; }
};
} // namespace proton
|