blob: ad4d9ffa7f65a84a282b93f813c5fac71db9a5c5 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "process.h"
#include <vespa/document/repo/document_type_repo_factory.h>
#include <vespa/storage/storageserver/storagenode.h>
#include <vespa/storage/storageserver/storagenodecontext.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/log/log.h>
LOG_SETUP(".process");
using document::DocumentTypeRepoFactory;
namespace storage {
Process::Process(const config::ConfigUri & configUri)
: _configUri(configUri),
_configSubscriber(_configUri.getContext())
{ }
Process::~Process() = default;
void
Process::setupConfig(vespalib::duration subscribeTimeout)
{
_documentHandler = _configSubscriber.subscribe<document::config::DocumenttypesConfig>(_configUri.getConfigId(), subscribeTimeout);
if (!_configSubscriber.nextConfig()) {
throw vespalib::TimeoutException("Could not subscribe to document config within timeout");
}
_repos.push_back(DocumentTypeRepoFactory::make(*_documentHandler->getConfig()));
getContext().getComponentRegister().setDocumentTypeRepo(_repos.back());
}
bool
Process::configUpdated()
{
_configSubscriber.nextGenerationNow();
if (_documentHandler->isChanged()) {
LOG(info, "Document config detected changed");
return true;
}
return false;
}
void
Process::updateConfig()
{
if (_documentHandler->isChanged()) {
_repos.push_back(DocumentTypeRepoFactory::make(*_documentHandler->getConfig()));
getNode().setNewDocumentRepo(_repos.back());
}
}
void
Process::shutdown()
{
removeConfigSubscriptions();
}
int64_t
Process::getGeneration() const
{
return _configSubscriber.getGeneration();
}
} // storage
|