Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

feat: support single replica #932

Merged
merged 1 commit into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ dsn::error_code replication_ddl_client::create_app(const std::string &app_name,
return ERR_INVALID_PARAMETERS;
}

if (replica_count < 2) {
std::cout << "create app " << app_name << " failed: replica_count should >= 2" << std::endl;
if (replica_count < 1) {
std::cout << "create app " << app_name << " failed: replica_count should >= 1" << std::endl;
return ERR_INVALID_PARAMETERS;
}

Expand Down
8 changes: 6 additions & 2 deletions src/meta/greedy_load_balancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ DSN_DEFINE_uint32("meta_server",
"balance operation count per round for cluster balancer");
DSN_TAG_VARIABLE(balance_op_count_per_round, FT_MUTABLE);

DSN_DECLARE_uint64(min_live_node_count_for_unfreeze);

uint32_t get_partition_count(const node_state &ns, cluster_balance_type type, int32_t app_id)
{
unsigned count = 0;
Expand Down Expand Up @@ -795,7 +797,8 @@ void greedy_load_balancer::shortest_path(std::vector<bool> &visit,
bool greedy_load_balancer::primary_balancer_per_app(const std::shared_ptr<app_state> &app,
bool only_move_primary)
{
dassert(t_alive_nodes > 2, "too few alive nodes will lead to freeze");
dassert(t_alive_nodes >= FLAGS_min_live_node_count_for_unfreeze,
"too few alive nodes will lead to freeze");
ddebug("primary balancer for app(%s:%d)", app->app_name.c_str(), app->app_id);

const node_mapper &nodes = *(t_global_view->nodes);
Expand Down Expand Up @@ -888,7 +891,8 @@ bool greedy_load_balancer::all_replica_infos_collected(const node_state &ns)

void greedy_load_balancer::greedy_balancer(const bool balance_checker)
{
dassert(t_alive_nodes > 2, "too few nodes will be freezed");
dassert(t_alive_nodes >= FLAGS_min_live_node_count_for_unfreeze,
"too few nodes will be freezed");
number_nodes(*t_global_view->nodes);

for (auto &kv : *(t_global_view->nodes)) {
Expand Down
16 changes: 11 additions & 5 deletions src/meta/meta_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@
*/
#include "meta_options.h"

#include <dsn/utility/flags.h>

namespace dsn {
namespace replication {

DSN_DEFINE_uint64("meta_server",
min_live_node_count_for_unfreeze,
3,
"minimum live node count without which the state is freezed");
DSN_TAG_VARIABLE(min_live_node_count_for_unfreeze, FT_MUTABLE);
DSN_DEFINE_validator(min_live_node_count_for_unfreeze,
[](uint64_t min_live_node_count) -> bool { return min_live_node_count > 0; });

std::string meta_options::concat_path_unix_style(const std::string &prefix,
const std::string &postfix)
{
Expand Down Expand Up @@ -72,11 +82,7 @@ void meta_options::initialize()
"if live_node_count * 100 < total_node_count * node_live_percentage_threshold_for_update, "
"then freeze the cluster; default is 65");

min_live_node_count_for_unfreeze =
dsn_config_get_value_uint64("meta_server",
"min_live_node_count_for_unfreeze",
3,
"minimum live node count without which the state is freezed");
min_live_node_count_for_unfreeze = FLAGS_min_live_node_count_for_unfreeze;

meta_function_level_on_start = meta_function_level::fl_invalid;
const char *level_str = dsn_config_get_value_string(
Expand Down