blob: 6ef391fa56ac555e1bbcc3ad0abd6919cec48ae4 (
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
82
83
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "distributorprocess.h"
#include <vespa/storage/common/storagelink.h>
#include <vespa/config/helper/configgetter.hpp>
#include <vespa/log/log.h>
LOG_SETUP(".process.distributor");
namespace storage {
DistributorProcess::DistributorProcess(const config::ConfigUri & configUri)
: Process(configUri),
_activeFlag(DistributorNode::NO_NEED_FOR_ACTIVE_STATES)
{
}
DistributorProcess::~DistributorProcess() {
shutdown();
}
void
DistributorProcess::shutdown()
{
Process::shutdown();
_node.reset();
}
void
DistributorProcess::setupConfig(uint64_t subscribeTimeout)
{
std::unique_ptr<vespa::config::content::core::StorServerConfig> config =
config::ConfigGetter<vespa::config::content::core::StorServerConfig>::getConfig(_configUri.getConfigId(), _configUri.getContext(), subscribeTimeout);
if (config->persistenceProvider.type
!= vespa::config::content::core::StorServerConfig::PersistenceProvider::STORAGE)
{
_activeFlag = DistributorNode::NEED_ACTIVE_BUCKET_STATES_SET;
}
_distributorConfigHandler
= _configSubscriber.subscribe<vespa::config::content::core::StorDistributormanagerConfig>(
_configUri.getConfigId(), subscribeTimeout);
_visitDispatcherConfigHandler
= _configSubscriber.subscribe<vespa::config::content::core::StorVisitordispatcherConfig>(
_configUri.getConfigId(), subscribeTimeout);
Process::setupConfig(subscribeTimeout);
}
void
DistributorProcess::updateConfig()
{
Process::updateConfig();
if (_distributorConfigHandler->isChanged()) {
_node->handleConfigChange(*_distributorConfigHandler->getConfig());
}
if (_visitDispatcherConfigHandler->isChanged()) {
_node->handleConfigChange(*_visitDispatcherConfigHandler->getConfig());
}
}
bool
DistributorProcess::configUpdated()
{
bool changed = Process::configUpdated();
if (_distributorConfigHandler->isChanged()) {
LOG(info, "Distributor manager config detected changed");
changed = true;
}
if (_visitDispatcherConfigHandler->isChanged()) {
LOG(info, "Visitor dispatcher config detected changed");
changed = true;
}
return changed;
}
void
DistributorProcess::createNode()
{
_node.reset(new DistributorNode(_configUri, _context, *this, _activeFlag, StorageLink::UP()));
_node->handleConfigChange(*_distributorConfigHandler->getConfig());
_node->handleConfigChange(*_visitDispatcherConfigHandler->getConfig());
}
} // storage
|