2020-11-03 13:47:26 +00:00
|
|
|
#pragma once
|
2021-04-10 23:33:54 +00:00
|
|
|
|
2020-11-03 13:47:26 +00:00
|
|
|
#include <DataStreams/BlockIO.h>
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
2020-11-03 13:47:26 +00:00
|
|
|
#include <Parsers/IAST_fwd.h>
|
|
|
|
|
|
|
|
namespace zkutil
|
|
|
|
{
|
|
|
|
class ZooKeeper;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class AccessRightsElements;
|
|
|
|
struct DDLLogEntry;
|
|
|
|
|
|
|
|
|
2020-11-05 09:52:23 +00:00
|
|
|
/// Returns true if provided ALTER type can be executed ON CLUSTER
|
|
|
|
bool isSupportedAlterType(int type);
|
|
|
|
|
2020-11-03 13:47:26 +00:00
|
|
|
/// Pushes distributed DDL query to the queue.
|
|
|
|
/// Returns DDLQueryStatusInputStream, which reads results of query execution on each host in the cluster.
|
2021-04-10 23:33:54 +00:00
|
|
|
BlockIO executeDDLQueryOnCluster(const ASTPtr & query_ptr, ContextPtr context);
|
|
|
|
BlockIO executeDDLQueryOnCluster(const ASTPtr & query_ptr, ContextPtr context, const AccessRightsElements & query_requires_access);
|
|
|
|
BlockIO executeDDLQueryOnCluster(const ASTPtr & query_ptr, ContextPtr context, AccessRightsElements && query_requires_access);
|
2020-11-03 13:47:26 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
BlockIO getDistributedDDLStatus(const String & node_path, const DDLLogEntry & entry, ContextPtr context, const std::optional<Strings> & hosts_to_wait = {});
|
2020-11-03 13:47:26 +00:00
|
|
|
|
2021-02-15 22:07:23 +00:00
|
|
|
class DDLQueryStatusInputStream final : public IBlockInputStream
|
2020-11-03 13:47:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-04-10 23:33:54 +00:00
|
|
|
DDLQueryStatusInputStream(const String & zk_node_path, const DDLLogEntry & entry, ContextPtr context_, const std::optional<Strings> & hosts_to_wait = {});
|
2020-11-03 13:47:26 +00:00
|
|
|
|
|
|
|
String getName() const override { return "DDLQueryStatusInputStream"; }
|
|
|
|
|
|
|
|
Block getHeader() const override { return sample; }
|
|
|
|
|
|
|
|
Block getSampleBlock() const { return sample.cloneEmpty(); }
|
|
|
|
|
|
|
|
Block readImpl() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static Strings getChildrenAllowNoNode(const std::shared_ptr<zkutil::ZooKeeper> & zookeeper, const String & node_path);
|
|
|
|
|
|
|
|
Strings getNewAndUpdate(const Strings & current_list_of_finished_hosts);
|
|
|
|
|
2021-03-08 20:35:09 +00:00
|
|
|
std::pair<String, UInt16> parseHostAndPort(const String & host_id) const;
|
|
|
|
|
2020-11-03 13:47:26 +00:00
|
|
|
String node_path;
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr context;
|
2020-11-03 13:47:26 +00:00
|
|
|
Stopwatch watch;
|
|
|
|
Poco::Logger * log;
|
|
|
|
|
|
|
|
Block sample;
|
|
|
|
|
|
|
|
NameSet waiting_hosts; /// hosts from task host list
|
|
|
|
NameSet finished_hosts; /// finished hosts from host list
|
|
|
|
NameSet ignoring_hosts; /// appeared hosts that are not in hosts list
|
|
|
|
Strings current_active_hosts; /// Hosts that were in active state at the last check
|
|
|
|
size_t num_hosts_finished = 0;
|
|
|
|
|
|
|
|
/// Save the first detected error and throw it at the end of execution
|
|
|
|
std::unique_ptr<Exception> first_exception;
|
|
|
|
|
|
|
|
Int64 timeout_seconds = 120;
|
2020-11-29 11:45:32 +00:00
|
|
|
bool by_hostname = true;
|
2021-03-08 20:35:09 +00:00
|
|
|
bool throw_on_timeout = true;
|
|
|
|
bool timeout_exceeded = false;
|
2020-11-03 13:47:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|