mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Return getUpdateTime method to interface
This commit is contained in:
parent
709783a1bc
commit
8429f46f3c
@ -84,6 +84,7 @@ public:
|
||||
private:
|
||||
struct LoadablesInfos
|
||||
{
|
||||
Poco::Timestamp last_update_time = 0;
|
||||
std::vector<std::pair<String, ObjectConfig>> configs; // Parsed file's contents.
|
||||
bool in_use = true; // Whether the ` LoadablesInfos` should be destroyed because the correspondent file is deleted.
|
||||
};
|
||||
@ -150,7 +151,10 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!repository.isUpdated(path))
|
||||
auto update_time_from_repository = repository.getUpdateTime(path);
|
||||
|
||||
/// Actually it can't be less, but for sure we check less or equal
|
||||
if (update_time_from_repository <= loadable_info.last_update_time)
|
||||
{
|
||||
loadable_info.in_use = true;
|
||||
return false;
|
||||
@ -184,6 +188,7 @@ private:
|
||||
}
|
||||
|
||||
loadable_info.configs = std::move(configs_from_file);
|
||||
loadable_info.last_update_time = update_time_from_repository;
|
||||
loadable_info.in_use = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -12,18 +12,9 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
bool ExternalLoaderXMLConfigRepository::isUpdated(const std::string & definition_entity_name)
|
||||
Poco::Timestamp ExternalLoaderXMLConfigRepository::getUpdateTime(const std::string & definition_entity_name)
|
||||
{
|
||||
Poco::Timestamp last_modified = Poco::File(definition_entity_name).getLastModified();
|
||||
|
||||
auto itr = update_time_mapping.find(definition_entity_name);
|
||||
if (itr == update_time_mapping.end() || last_modified > itr->second)
|
||||
{
|
||||
update_time_mapping[definition_entity_name] = last_modified;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Poco::File(definition_entity_name).getLastModified();
|
||||
}
|
||||
|
||||
std::set<std::string> ExternalLoaderXMLConfigRepository::getAllLoadablesDefinitionNames() const
|
||||
|
@ -26,18 +26,13 @@ public:
|
||||
/// Checks that file with name exists on filesystem
|
||||
bool exists(const std::string & definition_entity_name) const override;
|
||||
|
||||
/// Checks that file was updated since last check
|
||||
bool isUpdated(const std::string & definition_entity_name) override;
|
||||
/// Return xml-file modification time via stat call
|
||||
Poco::Timestamp getUpdateTime(const std::string & definition_entity_name) override;
|
||||
|
||||
/// May contain definition about several entities (several dictionaries in one .xml file)
|
||||
LoadablesConfigurationPtr load(const std::string & definition_entity_name) const override;
|
||||
|
||||
private:
|
||||
|
||||
/// Simple map with last modification time with path -> timestamp,
|
||||
/// modification time received by stat.
|
||||
std::unordered_map<std::string, Poco::Timestamp> update_time_mapping;
|
||||
|
||||
/// Main server config (config.xml).
|
||||
const Poco::Util::AbstractConfiguration & main_config;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <Poco/AutoPtr.h>
|
||||
#include <Poco/Util/AbstractConfiguration.h>
|
||||
#include <Poco/Timestamp.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -28,9 +29,8 @@ public:
|
||||
/// Checks that source of loadables configuration exist.
|
||||
virtual bool exists(const std::string & loadable_definition_name) const = 0;
|
||||
|
||||
/// Checks that entity was updated since last call of this method.
|
||||
/// Assumes usage of some state and probably some mutex.
|
||||
virtual bool isUpdated(const std::string & loadable_definition_name) = 0;
|
||||
/// Returns entity last update time
|
||||
virtual Poco::Timestamp getUpdateTime(const std::string & loadable_definition_name) = 0;
|
||||
|
||||
/// Load configuration from some concrete source to AbstractConfiguration
|
||||
virtual LoadablesConfigurationPtr load(const std::string & loadable_definition_name) const = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user