changed ExternalLoaderUpdateSettings [#CLICKHOUSE-3305]

This commit is contained in:
Nikolai Kochetov 2017-10-26 21:39:55 +03:00
parent 10bbf0871b
commit b66577e38a
3 changed files with 21 additions and 40 deletions

View File

@ -7,20 +7,7 @@ namespace DB
namespace
{
const ExternalLoaderUpdateSettings & getExternalDictionariesUpdateSettings()
{
static ExternalLoaderUpdateSettings settings;
static std::once_flag flag;
std::call_once(flag, [] {
settings.check_period_sec = 5;
settings.backoff_initial_sec = 5;
/// 10 minutes
settings.backoff_max_sec = 10 * 60;
});
return settings;
}
const ExternalLoaderUpdateSettings externalDictionariesUpdateSettings;
const ExternalLoaderConfigSettings & getExternalDictionariesConfigSettings()
{
@ -41,7 +28,7 @@ namespace
ExternalDictionaries::ExternalDictionaries(Context & context, bool throw_on_error)
: ExternalLoader(context.getConfigRef(),
getExternalDictionariesUpdateSettings(),
externalDictionariesUpdateSettings,
getExternalDictionariesConfigSettings(),
&Logger::get("ExternalDictionaries"),
"external dictionary"),

View File

@ -24,6 +24,12 @@ struct ExternalLoaderUpdateSettings
UInt64 backoff_initial_sec = 5;
/// 10 minutes
UInt64 backoff_max_sec = 10 * 60;
ExternalLoaderUpdateSettings() = default;
ExternalLoaderUpdateSettings(UInt64 check_period_sec, UInt64 backoff_initial_sec, UInt64 backoff_max_sec)
: check_period_sec(check_period_sec),
backoff_initial_sec(backoff_initial_sec),
backoff_max_sec(backoff_max_sec) {}
};

View File

@ -11,41 +11,29 @@ namespace ErrorCodes
namespace
{
const ExternalLoaderUpdateSettings & getExternalModelsUpdateSettings()
{
static ExternalLoaderUpdateSettings settings;
static std::once_flag flag;
std::call_once(flag, [] {
settings.check_period_sec = 5;
settings.backoff_initial_sec = 5;
/// 10 minutes
settings.backoff_max_sec = 10 * 60;
});
const ExternalLoaderUpdateSettings externalModelsUpdateSettings;
return settings;
}
const ExternalLoaderConfigSettings & getExternalModelsConfigSettings()
{
static ExternalLoaderConfigSettings settings;
static std::once_flag flag;
const ExternalLoaderConfigSettings & getExternalModelsConfigSettings()
{
static ExternalLoaderConfigSettings settings;
static std::once_flag flag;
std::call_once(flag, [] {
settings.external_config = "model";
settings.external_name = "name";
std::call_once(flag, [] {
settings.external_config = "model";
settings.external_name = "name";
settings.path_setting_name = "models_config";
});
settings.path_setting_name = "models_config";
});
return settings;
}
return settings;
}
}
ExternalModels::ExternalModels(Context & context, bool throw_on_error)
: ExternalLoader(context.getConfigRef(),
getExternalModelsUpdateSettings(),
externalModelsUpdateSettings,
getExternalModelsConfigSettings(),
&Logger::get("ExternalModels"),
"external model"),