mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Simplier config
This commit is contained in:
parent
ef34c95c7e
commit
338ff1615c
@ -26,6 +26,7 @@ KeeperStateManager::KeeperStateManager(
|
|||||||
const Poco::Util::AbstractConfiguration & config,
|
const Poco::Util::AbstractConfiguration & config,
|
||||||
const CoordinationSettingsPtr & coordination_settings)
|
const CoordinationSettingsPtr & coordination_settings)
|
||||||
: my_server_id(my_server_id_)
|
: my_server_id(my_server_id_)
|
||||||
|
, secure(config.getBool(config_prefix + ".raft_configuration.secure", false))
|
||||||
, log_store(nuraft::cs_new<KeeperLogStore>(
|
, log_store(nuraft::cs_new<KeeperLogStore>(
|
||||||
config.getString(config_prefix + ".log_storage_path", config.getString("path", DBMS_DEFAULT_PATH) + "coordination/logs"),
|
config.getString(config_prefix + ".log_storage_path", config.getString("path", DBMS_DEFAULT_PATH) + "coordination/logs"),
|
||||||
coordination_settings->rotate_log_storage_interval, coordination_settings->force_sync))
|
coordination_settings->rotate_log_storage_interval, coordination_settings->force_sync))
|
||||||
@ -35,11 +36,12 @@ KeeperStateManager::KeeperStateManager(
|
|||||||
Poco::Util::AbstractConfiguration::Keys keys;
|
Poco::Util::AbstractConfiguration::Keys keys;
|
||||||
config.keys(config_prefix + ".raft_configuration", keys);
|
config.keys(config_prefix + ".raft_configuration", keys);
|
||||||
total_servers = keys.size();
|
total_servers = keys.size();
|
||||||
bool has_secure = false;
|
|
||||||
bool has_unsecure = false;
|
|
||||||
|
|
||||||
for (const auto & server_key : keys)
|
for (const auto & server_key : keys)
|
||||||
{
|
{
|
||||||
|
if (!startsWith(server_key, "server"))
|
||||||
|
continue;
|
||||||
|
|
||||||
std::string full_prefix = config_prefix + ".raft_configuration." + server_key;
|
std::string full_prefix = config_prefix + ".raft_configuration." + server_key;
|
||||||
int server_id = config.getInt(full_prefix + ".id");
|
int server_id = config.getInt(full_prefix + ".id");
|
||||||
std::string hostname = config.getString(full_prefix + ".hostname");
|
std::string hostname = config.getString(full_prefix + ".hostname");
|
||||||
@ -47,10 +49,6 @@ KeeperStateManager::KeeperStateManager(
|
|||||||
bool can_become_leader = config.getBool(full_prefix + ".can_become_leader", true);
|
bool can_become_leader = config.getBool(full_prefix + ".can_become_leader", true);
|
||||||
int32_t priority = config.getInt(full_prefix + ".priority", 1);
|
int32_t priority = config.getInt(full_prefix + ".priority", 1);
|
||||||
bool start_as_follower = config.getBool(full_prefix + ".start_as_follower", false);
|
bool start_as_follower = config.getBool(full_prefix + ".start_as_follower", false);
|
||||||
bool is_secure = config.getBool(full_prefix + ".secure", false);
|
|
||||||
|
|
||||||
has_secure |= is_secure;
|
|
||||||
has_unsecure |= !is_secure;
|
|
||||||
|
|
||||||
if (start_as_follower)
|
if (start_as_follower)
|
||||||
start_as_follower_servers.insert(server_id);
|
start_as_follower_servers.insert(server_id);
|
||||||
@ -61,15 +59,11 @@ KeeperStateManager::KeeperStateManager(
|
|||||||
{
|
{
|
||||||
my_server_config = peer_config;
|
my_server_config = peer_config;
|
||||||
my_port = port;
|
my_port = port;
|
||||||
secure = is_secure;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster_config->get_servers().push_back(peer_config);
|
cluster_config->get_servers().push_back(peer_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_secure && has_unsecure)
|
|
||||||
throw Exception(ErrorCodes::RAFT_ERROR, "Cluster must have all secure or all non-secure nodes. Mixing secure and unsecure nodes is not allowed");
|
|
||||||
|
|
||||||
if (!my_server_config)
|
if (!my_server_config)
|
||||||
throw Exception(ErrorCodes::RAFT_ERROR, "Our server id {} not found in raft_configuration section", my_server_id);
|
throw Exception(ErrorCodes::RAFT_ERROR, "Our server id {} not found in raft_configuration section", my_server_id);
|
||||||
|
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
</coordination_settings>
|
</coordination_settings>
|
||||||
|
|
||||||
<raft_configuration>
|
<raft_configuration>
|
||||||
|
<secure>true</secure>
|
||||||
<server>
|
<server>
|
||||||
<id>1</id>
|
<id>1</id>
|
||||||
<hostname>node1</hostname>
|
<hostname>node1</hostname>
|
||||||
<port>44444</port>
|
<port>44444</port>
|
||||||
<can_become_leader>true</can_become_leader>
|
<can_become_leader>true</can_become_leader>
|
||||||
<priority>3</priority>
|
<priority>3</priority>
|
||||||
<secure>true</secure>
|
|
||||||
</server>
|
</server>
|
||||||
<server>
|
<server>
|
||||||
<id>2</id>
|
<id>2</id>
|
||||||
@ -28,7 +28,6 @@
|
|||||||
<can_become_leader>true</can_become_leader>
|
<can_become_leader>true</can_become_leader>
|
||||||
<start_as_follower>true</start_as_follower>
|
<start_as_follower>true</start_as_follower>
|
||||||
<priority>2</priority>
|
<priority>2</priority>
|
||||||
<secure>true</secure>
|
|
||||||
</server>
|
</server>
|
||||||
<server>
|
<server>
|
||||||
<id>3</id>
|
<id>3</id>
|
||||||
@ -37,7 +36,6 @@
|
|||||||
<can_become_leader>true</can_become_leader>
|
<can_become_leader>true</can_become_leader>
|
||||||
<start_as_follower>true</start_as_follower>
|
<start_as_follower>true</start_as_follower>
|
||||||
<priority>1</priority>
|
<priority>1</priority>
|
||||||
<secure>true</secure>
|
|
||||||
</server>
|
</server>
|
||||||
</raft_configuration>
|
</raft_configuration>
|
||||||
</keeper_server>
|
</keeper_server>
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
</coordination_settings>
|
</coordination_settings>
|
||||||
|
|
||||||
<raft_configuration>
|
<raft_configuration>
|
||||||
|
<secure>true</secure>
|
||||||
<server>
|
<server>
|
||||||
<id>1</id>
|
<id>1</id>
|
||||||
<hostname>node1</hostname>
|
<hostname>node1</hostname>
|
||||||
<port>44444</port>
|
<port>44444</port>
|
||||||
<can_become_leader>true</can_become_leader>
|
<can_become_leader>true</can_become_leader>
|
||||||
<priority>3</priority>
|
<priority>3</priority>
|
||||||
<secure>true</secure>
|
|
||||||
</server>
|
</server>
|
||||||
<server>
|
<server>
|
||||||
<id>2</id>
|
<id>2</id>
|
||||||
@ -28,7 +28,6 @@
|
|||||||
<can_become_leader>true</can_become_leader>
|
<can_become_leader>true</can_become_leader>
|
||||||
<start_as_follower>true</start_as_follower>
|
<start_as_follower>true</start_as_follower>
|
||||||
<priority>2</priority>
|
<priority>2</priority>
|
||||||
<secure>true</secure>
|
|
||||||
</server>
|
</server>
|
||||||
<server>
|
<server>
|
||||||
<id>3</id>
|
<id>3</id>
|
||||||
@ -37,7 +36,6 @@
|
|||||||
<can_become_leader>true</can_become_leader>
|
<can_become_leader>true</can_become_leader>
|
||||||
<start_as_follower>true</start_as_follower>
|
<start_as_follower>true</start_as_follower>
|
||||||
<priority>1</priority>
|
<priority>1</priority>
|
||||||
<secure>true</secure>
|
|
||||||
</server>
|
</server>
|
||||||
</raft_configuration>
|
</raft_configuration>
|
||||||
</keeper_server>
|
</keeper_server>
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
</coordination_settings>
|
</coordination_settings>
|
||||||
|
|
||||||
<raft_configuration>
|
<raft_configuration>
|
||||||
|
<secure>true</secure>
|
||||||
<server>
|
<server>
|
||||||
<id>1</id>
|
<id>1</id>
|
||||||
<hostname>node1</hostname>
|
<hostname>node1</hostname>
|
||||||
<port>44444</port>
|
<port>44444</port>
|
||||||
<can_become_leader>true</can_become_leader>
|
<can_become_leader>true</can_become_leader>
|
||||||
<priority>3</priority>
|
<priority>3</priority>
|
||||||
<secure>true</secure>
|
|
||||||
</server>
|
</server>
|
||||||
<server>
|
<server>
|
||||||
<id>2</id>
|
<id>2</id>
|
||||||
@ -28,7 +28,6 @@
|
|||||||
<can_become_leader>true</can_become_leader>
|
<can_become_leader>true</can_become_leader>
|
||||||
<start_as_follower>true</start_as_follower>
|
<start_as_follower>true</start_as_follower>
|
||||||
<priority>2</priority>
|
<priority>2</priority>
|
||||||
<secure>true</secure>
|
|
||||||
</server>
|
</server>
|
||||||
<server>
|
<server>
|
||||||
<id>3</id>
|
<id>3</id>
|
||||||
@ -37,7 +36,6 @@
|
|||||||
<can_become_leader>true</can_become_leader>
|
<can_become_leader>true</can_become_leader>
|
||||||
<start_as_follower>true</start_as_follower>
|
<start_as_follower>true</start_as_follower>
|
||||||
<priority>1</priority>
|
<priority>1</priority>
|
||||||
<secure>true</secure>
|
|
||||||
</server>
|
</server>
|
||||||
</raft_configuration>
|
</raft_configuration>
|
||||||
</keeper_server>
|
</keeper_server>
|
||||||
|
Loading…
Reference in New Issue
Block a user