// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "process.h" #include #include #include #include #include #include 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(_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