mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 19:42:00 +00:00
Remove holder from config
This commit is contained in:
parent
cca7da6664
commit
2e83d0f61f
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <Core/ServerSettings.h>
|
#include <Core/ServerSettings.h>
|
||||||
#include <Core/Settings.h>
|
#include <Core/Settings.h>
|
||||||
|
#include <Common/ShellCommandsHolder.h>
|
||||||
#include <IO/ConnectionTimeouts.h>
|
#include <IO/ConnectionTimeouts.h>
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
@ -29,7 +30,7 @@ LibraryBridgeHelper::LibraryBridgeHelper(ContextPtr context_)
|
|||||||
|
|
||||||
void LibraryBridgeHelper::startBridge(std::unique_ptr<ShellCommand> cmd) const
|
void LibraryBridgeHelper::startBridge(std::unique_ptr<ShellCommand> cmd) const
|
||||||
{
|
{
|
||||||
getContext()->addBackgroundShellCommand(std::move(cmd));
|
ShellCommandsHolder::instance().addCommand(std::move(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <Poco/Util/AbstractConfiguration.h>
|
#include <Poco/Util/AbstractConfiguration.h>
|
||||||
#include <Common/BridgeProtocolVersion.h>
|
#include <Common/BridgeProtocolVersion.h>
|
||||||
#include <Common/ShellCommand.h>
|
#include <Common/ShellCommand.h>
|
||||||
|
#include <Common/ShellCommandsHolder.h>
|
||||||
#include <IO/ConnectionTimeouts.h>
|
#include <IO/ConnectionTimeouts.h>
|
||||||
#include <base/range.h>
|
#include <base/range.h>
|
||||||
#include <BridgeHelper/IBridgeHelper.h>
|
#include <BridgeHelper/IBridgeHelper.h>
|
||||||
@ -144,7 +145,7 @@ protected:
|
|||||||
|
|
||||||
void startBridge(std::unique_ptr<ShellCommand> cmd) const override
|
void startBridge(std::unique_ptr<ShellCommand> cmd) const override
|
||||||
{
|
{
|
||||||
getContext()->addBackgroundShellCommand(std::move(cmd));
|
ShellCommandsHolder::instance().addCommand(std::move(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ struct ShellCommand::tryWaitResult
|
|||||||
|
|
||||||
int ShellCommand::tryWait()
|
int ShellCommand::tryWait()
|
||||||
{
|
{
|
||||||
return tryWaitImpl(false).retcode;
|
return tryWaitImpl(true).retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShellCommand::tryWaitResult ShellCommand::tryWaitImpl(bool blocking)
|
ShellCommand::tryWaitResult ShellCommand::tryWaitImpl(bool blocking)
|
||||||
@ -311,15 +311,18 @@ ShellCommand::tryWaitResult ShellCommand::tryWaitImpl(bool blocking)
|
|||||||
|
|
||||||
ShellCommand::tryWaitResult result;
|
ShellCommand::tryWaitResult result;
|
||||||
|
|
||||||
int options = ((blocking) ? WNOHANG : 0);
|
int options = ((!blocking) ? WNOHANG : 0);
|
||||||
int status = 0;
|
int status = 0;
|
||||||
int waitpid_retcode = -1;
|
int waitpid_retcode = -1;
|
||||||
|
|
||||||
while (waitpid_retcode < 0)
|
while (waitpid_retcode < 0)
|
||||||
{
|
{
|
||||||
waitpid_retcode = waitpid(pid, &status, options);
|
waitpid_retcode = waitpid(pid, &status, options);
|
||||||
|
if (waitpid_retcode > 0)
|
||||||
if (blocking && !waitpid_retcode)
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!blocking && !waitpid_retcode)
|
||||||
{
|
{
|
||||||
result.is_process_terminated = false;
|
result.is_process_terminated = false;
|
||||||
return result;
|
return result;
|
||||||
@ -385,7 +388,7 @@ void ShellCommand::handleProcessRetcode(int retcode) const
|
|||||||
|
|
||||||
bool ShellCommand::waitIfProccesTerminated()
|
bool ShellCommand::waitIfProccesTerminated()
|
||||||
{
|
{
|
||||||
auto proc_status = tryWaitImpl(true);
|
auto proc_status = tryWaitImpl(false);
|
||||||
if (proc_status.is_process_terminated)
|
if (proc_status.is_process_terminated)
|
||||||
{
|
{
|
||||||
handleProcessRetcode(proc_status.retcode);
|
handleProcessRetcode(proc_status.retcode);
|
||||||
@ -396,7 +399,7 @@ bool ShellCommand::waitIfProccesTerminated()
|
|||||||
|
|
||||||
void ShellCommand::wait()
|
void ShellCommand::wait()
|
||||||
{
|
{
|
||||||
int retcode = tryWaitImpl(false).retcode;
|
int retcode = tryWaitImpl(true).retcode;
|
||||||
handleProcessRetcode(retcode);
|
handleProcessRetcode(retcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,12 @@
|
|||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ShellCommandsHolder & ShellCommandsHolder::instance()
|
||||||
|
{
|
||||||
|
static ShellCommandsHolder instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
LoggerPtr ShellCommandsHolder::getLogger()
|
LoggerPtr ShellCommandsHolder::getLogger()
|
||||||
{
|
{
|
||||||
return ::getLogger("ShellCommandsHolder");
|
return ::getLogger("ShellCommandsHolder");
|
||||||
|
@ -15,6 +15,8 @@ namespace DB
|
|||||||
class ShellCommandsHolder final : public boost::noncopyable
|
class ShellCommandsHolder final : public boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static ShellCommandsHolder & instance();
|
||||||
|
|
||||||
void removeCommand(pid_t pid);
|
void removeCommand(pid_t pid);
|
||||||
void addCommand(std::unique_ptr<ShellCommand> command);
|
void addCommand(std::unique_ptr<ShellCommand> command);
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <Common/SignalHandlers.h>
|
#include <Common/SignalHandlers.h>
|
||||||
#include <Common/config_version.h>
|
#include <Common/config_version.h>
|
||||||
#include <Common/getHashOfLoadedBinary.h>
|
#include <Common/getHashOfLoadedBinary.h>
|
||||||
|
#include <Common/ShellCommandsHolder.h>
|
||||||
#include <Common/CurrentThread.h>
|
#include <Common/CurrentThread.h>
|
||||||
#include <Daemon/BaseDaemon.h>
|
#include <Daemon/BaseDaemon.h>
|
||||||
#include <Daemon/SentryWriter.h>
|
#include <Daemon/SentryWriter.h>
|
||||||
@ -312,7 +313,7 @@ void SignalListener::run()
|
|||||||
{
|
{
|
||||||
pid_t child_pid = 0;
|
pid_t child_pid = 0;
|
||||||
readBinary(child_pid, in);
|
readBinary(child_pid, in);
|
||||||
Context::getGlobalContextInstance()->removeBackgroundShellCommand(child_pid);
|
ShellCommandsHolder::instance().removeCommand(child_pid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,6 @@
|
|||||||
#include <Common/Config/AbstractConfigurationComparison.h>
|
#include <Common/Config/AbstractConfigurationComparison.h>
|
||||||
#include <Common/ZooKeeper/ZooKeeper.h>
|
#include <Common/ZooKeeper/ZooKeeper.h>
|
||||||
#include <Common/ShellCommand.h>
|
#include <Common/ShellCommand.h>
|
||||||
#include <Common/ShellCommandsHolder.h>
|
|
||||||
#include <Common/logger_useful.h>
|
#include <Common/logger_useful.h>
|
||||||
#include <Common/RemoteHostFilter.h>
|
#include <Common/RemoteHostFilter.h>
|
||||||
#include <Common/HTTPHeaderFilter.h>
|
#include <Common/HTTPHeaderFilter.h>
|
||||||
@ -541,10 +540,6 @@ struct ContextSharedPart : boost::noncopyable
|
|||||||
/// No lock required for application_type modified only during initialization
|
/// No lock required for application_type modified only during initialization
|
||||||
Context::ApplicationType application_type = Context::ApplicationType::SERVER;
|
Context::ApplicationType application_type = Context::ApplicationType::SERVER;
|
||||||
|
|
||||||
/// Manager of running background shell commands.
|
|
||||||
/// They will be killed when Context will be destroyed or with SIGCHLD signal.
|
|
||||||
ShellCommandsHolder background_active_shell_commands;
|
|
||||||
|
|
||||||
/// No lock required for config_reload_callback, start_servers_callback, stop_servers_callback modified only during initialization
|
/// No lock required for config_reload_callback, start_servers_callback, stop_servers_callback modified only during initialization
|
||||||
Context::ConfigReloadCallback config_reload_callback;
|
Context::ConfigReloadCallback config_reload_callback;
|
||||||
Context::StartStopServersCallback start_servers_callback;
|
Context::StartStopServersCallback start_servers_callback;
|
||||||
@ -5069,16 +5064,6 @@ void Context::addQueryParameters(const NameToNameMap & parameters)
|
|||||||
query_parameters.insert_or_assign(name, value);
|
query_parameters.insert_or_assign(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::addBackgroundShellCommand(std::unique_ptr<ShellCommand> cmd) const
|
|
||||||
{
|
|
||||||
shared->background_active_shell_commands.addCommand(std::move(cmd));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Context::removeBackgroundShellCommand(pid_t pid) const
|
|
||||||
{
|
|
||||||
shared->background_active_shell_commands.removeCommand(pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
IHostContextPtr & Context::getHostContext()
|
IHostContextPtr & Context::getHostContext()
|
||||||
{
|
{
|
||||||
|
@ -1288,11 +1288,6 @@ public:
|
|||||||
/// Overrides values of existing parameters.
|
/// Overrides values of existing parameters.
|
||||||
void addQueryParameters(const NameToNameMap & parameters);
|
void addQueryParameters(const NameToNameMap & parameters);
|
||||||
|
|
||||||
/// Add background shell command. It will be killed after context destruction or with SIGCHLD.
|
|
||||||
void addBackgroundShellCommand(std::unique_ptr<ShellCommand> cmd) const;
|
|
||||||
|
|
||||||
/// Terminate background shell command.
|
|
||||||
void removeBackgroundShellCommand(pid_t pid) const;
|
|
||||||
|
|
||||||
IHostContextPtr & getHostContext();
|
IHostContextPtr & getHostContext();
|
||||||
const IHostContextPtr & getHostContext() const;
|
const IHostContextPtr & getHostContext() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user