diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-05-04 18:07:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-04 18:07:53 +0200 |
commit | cfadef5ba3314067dfc31d39031c6b2ab38ee36d (patch) | |
tree | 973df8d73c96f199622459ecc4835744a23bc4f9 | |
parent | 6e28cee26fd30b13572646575f46f9d81c7c0d1e (diff) | |
parent | c3ca3db96ee29df4b3ba5d4285a4be3187198e41 (diff) |
Merge pull request #2388 from yahoo/balder/ensure-config-is-available-before-trying-to-create-components
Balder/ensure config is available before trying to create components
6 files changed, 24 insertions, 24 deletions
diff --git a/config/src/vespa/config/helper/configfetcher.cpp b/config/src/vespa/config/helper/configfetcher.cpp index f6e39523900..0a4b95e9153 100644 --- a/config/src/vespa/config/helper/configfetcher.cpp +++ b/config/src/vespa/config/helper/configfetcher.cpp @@ -1,8 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include "configfetcher.h" + #include <vespa/log/log.h> LOG_SETUP(".config.helper.configfetcher"); -#include "configfetcher.h" namespace config { diff --git a/config/src/vespa/config/helper/configfetcher.h b/config/src/vespa/config/helper/configfetcher.h index ad7c2a8b549..ed04dc62f50 100644 --- a/config/src/vespa/config/helper/configfetcher.h +++ b/config/src/vespa/config/helper/configfetcher.h @@ -1,11 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include "configpoller.h" #include <vespa/config/config.h> #include <vespa/config/common/timingvalues.h> #include <vespa/vespalib/util/thread.h> -#include "configpoller.h" - #include <atomic> namespace config { diff --git a/filedistribution/src/apps/filedistributor/filedistributor.cpp b/filedistribution/src/apps/filedistributor/filedistributor.cpp index 452b951bf6b..222f157b8e4 100644 --- a/filedistribution/src/apps/filedistributor/filedistributor.cpp +++ b/filedistribution/src/apps/filedistributor/filedistributor.cpp @@ -1,25 +1,20 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root -#include <boost/program_options.hpp> - -#include <vespa/fastos/app.h> -#include <vespa/config-zookeepers.h> - -#include <vespa/fileacquirer/config-filedistributorrpc.h> #include <vespa/filedistribution/distributor/config-filedistributor.h> #include <vespa/filedistribution/model/config-filereferences.h> #include <vespa/filedistribution/distributor/filedistributortrackerimpl.h> #include <vespa/filedistribution/distributor/filedownloadermanager.h> -#include <vespa/filedistribution/distributor/filedownloader.h> #include <vespa/filedistribution/distributor/signalhandling.h> #include <vespa/filedistribution/distributor/state_server_impl.h> #include <vespa/filedistribution/model/filedistributionmodelimpl.h> #include <vespa/filedistribution/rpc/filedistributorrpc.h> -#include <vespa/filedistribution/common/exception.h> #include <vespa/filedistribution/common/componentsdeleter.h> -#include <iostream> +#include <vespa/fileacquirer/config-filedistributorrpc.h> +#include <vespa/config-zookeepers.h> +#include <vespa/fastos/app.h> +#include <boost/program_options.hpp> namespace { const char* programName = "filedistributor"; @@ -182,6 +177,10 @@ public: } } + bool isConfigComplete() { + LockGuard guard(_configMutex); + return (_zooKeepersConfig && _fileDistributorConfig && _rpcConfig); + } void createComponents(const config::ConfigUri & configUri) { LockGuard guard(_configMutex); _components.reset( @@ -219,8 +218,8 @@ public: (postPoneAskedToReinitializedSecs > 0 || !askedToReinitialize()) && !completeReconfigurationNeeded()) { - postPoneAskedToReinitializedSecs--; - std::this_thread::sleep_for(1s); + postPoneAskedToReinitializedSecs--; + std::this_thread::sleep_for(1s); } _components.reset(); } @@ -257,8 +256,7 @@ bool exists(const std::string& optionName, const boost::program_options::variabl return map.find(optionName) != map.end(); } -void ensureExists(const std::string& optionName, const boost::program_options::variables_map& map \ - ) { +void ensureExists(const std::string& optionName, const boost::program_options::variables_map& map ) { if (!exists(optionName, map)) { throw ProgramOptionException("Error: Missing option " + optionName); } @@ -282,6 +280,9 @@ FileDistributorApplication::Main() { configFetcher.subscribeGenerationChanges(&distributor); configFetcher.start(); + while (! distributor.isConfigComplete() ) { + std::this_thread::sleep_for(10ms); + } distributor.run(_configUri); EV_STOPPING(programName, "Clean exit"); diff --git a/filedistribution/src/vespa/filedistribution/distributor/signalhandling.cpp b/filedistribution/src/vespa/filedistribution/distributor/signalhandling.cpp index 0465f8d7b29..9ac658ba619 100644 --- a/filedistribution/src/vespa/filedistribution/distributor/signalhandling.cpp +++ b/filedistribution/src/vespa/filedistribution/distributor/signalhandling.cpp @@ -1,5 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> + #include "signalhandling.h" #include <vespa/vespalib/util/signalhandler.h> diff --git a/vespalib/src/vespa/vespalib/util/signalhandler.cpp b/vespalib/src/vespa/vespalib/util/signalhandler.cpp index f16ef55fc30..c0456ca9cef 100644 --- a/vespalib/src/vespa/vespalib/util/signalhandler.cpp +++ b/vespalib/src/vespa/vespalib/util/signalhandler.cpp @@ -12,8 +12,7 @@ namespace { class Shutdown { public: - ~Shutdown(void) - { + ~Shutdown() { SignalHandler::shutdown(); } }; @@ -106,7 +105,7 @@ SignalHandler::unhook() void -SignalHandler::shutdown(void) +SignalHandler::shutdown() { for (std::vector<SignalHandler*>::iterator it = _handlers.begin(), ite = _handlers.end(); diff --git a/vespalib/src/vespa/vespalib/util/signalhandler.h b/vespalib/src/vespa/vespalib/util/signalhandler.h index 3ac7926531f..a5a474bb471 100644 --- a/vespalib/src/vespa/vespalib/util/signalhandler.h +++ b/vespalib/src/vespa/vespalib/util/signalhandler.h @@ -59,8 +59,9 @@ private: * initialization. **/ SignalHandler(int signal); - SignalHandler(const SignalHandler &); // not defined - SignalHandler &operator=(const SignalHandler &); // not defined + + SignalHandler(const SignalHandler &) = delete; + SignalHandler &operator=(const SignalHandler &) = delete; public: static SignalHandler HUP; @@ -103,8 +104,7 @@ public: **/ void unhook(); - static void - shutdown(void); + static void shutdown(); }; } // vespalib |