mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 15:21:03 +00:00
Cluster Manager: fixed expected slots calculation (rebalance)
Cluster Manager: fixed argument parsing after --cluster-weight
This commit is contained in:
parent
2f31545beb
commit
be94e89031
@ -1318,6 +1318,7 @@ static int parseOptions(int argc, char **argv) {
|
|||||||
if (wargc > 0) {
|
if (wargc > 0) {
|
||||||
config.cluster_manager_command.weight = weight;
|
config.cluster_manager_command.weight = weight;
|
||||||
config.cluster_manager_command.weight_argc = wargc;
|
config.cluster_manager_command.weight_argc = wargc;
|
||||||
|
i += wargc;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(argv[i],"--cluster-slots") && !lastarg) {
|
} else if (!strcmp(argv[i],"--cluster-slots") && !lastarg) {
|
||||||
config.cluster_manager_command.slots = atoi(argv[++i]);
|
config.cluster_manager_command.slots = atoi(argv[++i]);
|
||||||
@ -4724,7 +4725,6 @@ static int clusterManagerCommandRebalance(int argc, char **argv) {
|
|||||||
int nodes_involved = 0;
|
int nodes_involved = 0;
|
||||||
int use_empty = config.cluster_manager_command.flags &
|
int use_empty = config.cluster_manager_command.flags &
|
||||||
CLUSTER_MANAGER_CMD_FLAG_EMPTYMASTER;
|
CLUSTER_MANAGER_CMD_FLAG_EMPTYMASTER;
|
||||||
|
|
||||||
involved = listCreate();
|
involved = listCreate();
|
||||||
listIter li;
|
listIter li;
|
||||||
listNode *ln;
|
listNode *ln;
|
||||||
@ -4762,15 +4762,15 @@ static int clusterManagerCommandRebalance(int argc, char **argv) {
|
|||||||
while ((ln = listNext(&li)) != NULL) {
|
while ((ln = listNext(&li)) != NULL) {
|
||||||
clusterManagerNode *n = ln->value;
|
clusterManagerNode *n = ln->value;
|
||||||
weightedNodes[i++] = n;
|
weightedNodes[i++] = n;
|
||||||
int expected = (((float)CLUSTER_MANAGER_SLOTS / total_weight) *
|
int expected = (int) (((float)CLUSTER_MANAGER_SLOTS / total_weight) *
|
||||||
(int) n->weight);
|
n->weight);
|
||||||
n->balance = n->slots_count - expected;
|
n->balance = n->slots_count - expected;
|
||||||
total_balance += n->balance;
|
total_balance += n->balance;
|
||||||
/* Compute the percentage of difference between the
|
/* Compute the percentage of difference between the
|
||||||
* expected number of slots and the real one, to see
|
* expected number of slots and the real one, to see
|
||||||
* if it's over the threshold specified by the user. */
|
* if it's over the threshold specified by the user. */
|
||||||
int over_threshold = 0;
|
int over_threshold = 0;
|
||||||
if (config.cluster_manager_command.threshold > 0) {
|
if (threshold > 0) {
|
||||||
if (n->slots_count > 0) {
|
if (n->slots_count > 0) {
|
||||||
float err_perc = fabs((100-(100.0*expected/n->slots_count)));
|
float err_perc = fabs((100-(100.0*expected/n->slots_count)));
|
||||||
if (err_perc > threshold) over_threshold = 1;
|
if (err_perc > threshold) over_threshold = 1;
|
||||||
@ -4784,7 +4784,6 @@ static int clusterManagerCommandRebalance(int argc, char **argv) {
|
|||||||
clusterManagerLogWarn("*** No rebalancing needed! "
|
clusterManagerLogWarn("*** No rebalancing needed! "
|
||||||
"All nodes are within the %.2f%% threshold.\n",
|
"All nodes are within the %.2f%% threshold.\n",
|
||||||
config.cluster_manager_command.threshold);
|
config.cluster_manager_command.threshold);
|
||||||
result = 0;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
/* Because of rounding, it is possible that the balance of all nodes
|
/* Because of rounding, it is possible that the balance of all nodes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user