mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
libmysqlxx: enabled empty password. refactoring [#METR-8598]
This commit is contained in:
parent
ff61e2cbc8
commit
2fab08ae10
@ -121,6 +121,13 @@ public:
|
|||||||
incrementRefCount();
|
incrementRefCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getDescription() const
|
||||||
|
{
|
||||||
|
if (pool)
|
||||||
|
return pool->getDescription();
|
||||||
|
else
|
||||||
|
return "pool is null";
|
||||||
|
}
|
||||||
friend class Pool;
|
friend class Pool;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -182,6 +189,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param config_name Имя параметра в конфигурационном файле
|
* @param config_name Имя параметра в конфигурационном файле
|
||||||
* @param default_connections_ Количество подключений по-умолчанию
|
* @param default_connections_ Количество подключений по-умолчанию
|
||||||
@ -190,8 +198,7 @@ public:
|
|||||||
Pool(const std::string & config_name,
|
Pool(const std::string & config_name,
|
||||||
unsigned default_connections_ = MYSQLXX_POOL_DEFAULT_START_CONNECTIONS,
|
unsigned default_connections_ = MYSQLXX_POOL_DEFAULT_START_CONNECTIONS,
|
||||||
unsigned max_connections_ = MYSQLXX_POOL_DEFAULT_MAX_CONNECTIONS,
|
unsigned max_connections_ = MYSQLXX_POOL_DEFAULT_MAX_CONNECTIONS,
|
||||||
const std::string & user_default = "", const std::string & password_default = "",
|
const char * parent_config_name_ = NULL)
|
||||||
const std::string & db_default = "", int port_default = 0)
|
|
||||||
: default_connections(default_connections_), max_connections(max_connections_),
|
: default_connections(default_connections_), max_connections(max_connections_),
|
||||||
initialized(false), was_successful(false)
|
initialized(false), was_successful(false)
|
||||||
{
|
{
|
||||||
@ -199,19 +206,24 @@ public:
|
|||||||
|
|
||||||
server = cfg.getString(config_name + ".host");
|
server = cfg.getString(config_name + ".host");
|
||||||
|
|
||||||
db = cfg.getString(config_name + ".db", db_default);
|
if (parent_config_name_)
|
||||||
if (!user_default.empty())
|
{
|
||||||
user = cfg.getString(config_name + ".user", user_default);
|
const std::string parent_config_name(parent_config_name_);
|
||||||
|
db = cfg.getString(config_name + ".db", cfg.getString(parent_config_name + ".db", ""));
|
||||||
|
user = cfg.has(config_name + ".user") ?
|
||||||
|
cfg.getString(config_name + ".user") : cfg.getString(parent_config_name + ".user");
|
||||||
|
password = cfg.has(config_name + ".password") ?
|
||||||
|
cfg.getString(config_name + ".password") : cfg.getString(parent_config_name + ".password");
|
||||||
|
port = cfg.has(config_name + ".port") ? cfg.getInt(config_name + ".port") :
|
||||||
|
cfg.getInt(parent_config_name + ".port");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
db = cfg.getString(config_name + ".db", "");
|
||||||
user = cfg.getString(config_name + ".user");
|
user = cfg.getString(config_name + ".user");
|
||||||
if (!password_default.empty())
|
|
||||||
password = cfg.getString(config_name + ".password", password_default);
|
|
||||||
else
|
|
||||||
password = cfg.getString(config_name + ".password");
|
password = cfg.getString(config_name + ".password");
|
||||||
if (port_default)
|
|
||||||
port = cfg.getInt(config_name + ".port", port_default);
|
|
||||||
else
|
|
||||||
port = cfg.getInt(config_name + ".port");
|
port = cfg.getInt(config_name + ".port");
|
||||||
|
}
|
||||||
|
|
||||||
connect_timeout = cfg.getInt(config_name + ".connect_timeout",
|
connect_timeout = cfg.getInt(config_name + ".connect_timeout",
|
||||||
cfg.getInt("mysql_connect_timeout",
|
cfg.getInt("mysql_connect_timeout",
|
||||||
|
@ -11,20 +11,6 @@ PoolWithFailover::PoolWithFailover(const std::string & config_name, unsigned def
|
|||||||
|
|
||||||
if (cfg.has(config_name + ".replica"))
|
if (cfg.has(config_name + ".replica"))
|
||||||
{
|
{
|
||||||
int port_g = 0;
|
|
||||||
std::string user_g;
|
|
||||||
std::string password_g;
|
|
||||||
std::string db_g;
|
|
||||||
|
|
||||||
if (cfg.has(config_name + ".user"))
|
|
||||||
user_g = cfg.getString(config_name + ".user");
|
|
||||||
if (cfg.has(config_name + ".password"))
|
|
||||||
password_g = cfg.getString(config_name + ".password");
|
|
||||||
if (cfg.has(config_name + ".db"))
|
|
||||||
db_g= cfg.getString(config_name + ".db");
|
|
||||||
if (cfg.has(config_name + ".port"))
|
|
||||||
port_g = cfg.getInt(config_name + ".port");
|
|
||||||
|
|
||||||
Poco::Util::AbstractConfiguration::Keys replica_keys;
|
Poco::Util::AbstractConfiguration::Keys replica_keys;
|
||||||
cfg.keys(config_name, replica_keys);
|
cfg.keys(config_name, replica_keys);
|
||||||
for (Poco::Util::AbstractConfiguration::Keys::const_iterator it = replica_keys.begin(); it != replica_keys.end(); ++it)
|
for (Poco::Util::AbstractConfiguration::Keys::const_iterator it = replica_keys.begin(); it != replica_keys.end(); ++it)
|
||||||
@ -34,7 +20,7 @@ PoolWithFailover::PoolWithFailover(const std::string & config_name, unsigned def
|
|||||||
if (it->size() < std::string("replica").size() || it->substr(0, std::string("replica").size()) != "replica")
|
if (it->size() < std::string("replica").size() || it->substr(0, std::string("replica").size()) != "replica")
|
||||||
throw Poco::Exception("Unknown element in config: " + *it + ", expected replica");
|
throw Poco::Exception("Unknown element in config: " + *it + ", expected replica");
|
||||||
std::string replica_name = config_name + "." + *it;
|
std::string replica_name = config_name + "." + *it;
|
||||||
Replica replica(new Pool(replica_name, default_connections, max_connections, user_g, password_g, db_g, port_g),
|
Replica replica(new Pool(replica_name, default_connections, max_connections, config_name.c_str()),
|
||||||
cfg.getInt(replica_name + ".priority", 0));
|
cfg.getInt(replica_name + ".priority", 0));
|
||||||
replicas_by_priority[replica.priority].push_back(replica);
|
replicas_by_priority[replica.priority].push_back(replica);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user