summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-parser.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2015-02-27 16:01:31 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-09 15:36:31 -0700
commita70231c78aaea436575d427a1386a64d1471b776 (patch)
tree458c971ecd520163e2406b91f8d26ac26e86cf2c /cli/src/cli-cmd-parser.c
parent72dc1025dc17a650f3838223c78e3205132deba9 (diff)
cluster/ec: Add self-heal-daemon command handlers
This patch introduces the changes required in ec xlator to handle index/full heal. Index healer threads: Ec xlator start an index healer thread per local brick. This thread keeps waking up every minute to check if there are any files to be healed based on the indices kept in index directory. Whenever child_up event comes, then also this index healer thread wakes up and crawls the indices and triggers heal. When self-heal-daemon is disabled on this particular volume then the healer thread keeps waiting until it is enabled again to perform heals. Full healer threads: Ec xlator starts a full healer thread for the local subvolume provided by glusterd to perform full crawl on the directory hierarchy to perform heals. Once the crawl completes the thread exits if no more full heals are issued. Changed xl-op prefix GF_AFR_OP to GF_SHD_OP to make it more generic. Change-Id: Idf9b2735d779a6253717be064173dfde6f8f824b BUG: 1177601 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/9787 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Ravishankar N <ravishankar@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r--cli/src/cli-cmd-parser.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 9c887fa78a5..bbec6aa5f8d 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -2984,7 +2984,7 @@ set_hostname_path_in_dict (const char *token, dict_t *dict, int heal_op)
goto out;
switch (heal_op) {
- case GF_AFR_OP_SBRAIN_HEAL_FROM_BRICK:
+ case GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK:
ret = dict_set_dynstr (dict, "heal-source-hostname",
hostname);
if (ret)
@@ -2992,7 +2992,7 @@ set_hostname_path_in_dict (const char *token, dict_t *dict, int heal_op)
ret = dict_set_dynstr (dict, "heal-source-brickpath",
path);
break;
- case GF_AFR_OP_STATISTICS_HEAL_COUNT_PER_REPLICA:
+ case GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA:
ret = dict_set_dynstr (dict, "per-replica-cmd-hostname",
hostname);
if (ret)
@@ -3014,29 +3014,29 @@ heal_command_type_get (const char *command)
{
int i = 0;
/* subcommands are set as NULL */
- char *heal_cmds[GF_AFR_OP_HEAL_DISABLE + 1] = {
- [GF_AFR_OP_INVALID] = NULL,
- [GF_AFR_OP_HEAL_INDEX] = NULL,
- [GF_AFR_OP_HEAL_FULL] = "full",
- [GF_AFR_OP_INDEX_SUMMARY] = "info",
- [GF_AFR_OP_HEALED_FILES] = NULL,
- [GF_AFR_OP_HEAL_FAILED_FILES] = NULL,
- [GF_AFR_OP_SPLIT_BRAIN_FILES] = NULL,
- [GF_AFR_OP_STATISTICS] = "statistics",
- [GF_AFR_OP_STATISTICS_HEAL_COUNT] = NULL,
- [GF_AFR_OP_STATISTICS_HEAL_COUNT_PER_REPLICA] = NULL,
- [GF_AFR_OP_SBRAIN_HEAL_FROM_BIGGER_FILE] = "split-brain",
- [GF_AFR_OP_SBRAIN_HEAL_FROM_BRICK] = "split-brain",
- [GF_AFR_OP_HEAL_ENABLE] = "enable",
- [GF_AFR_OP_HEAL_DISABLE] = "disable",
+ char *heal_cmds[GF_SHD_OP_HEAL_DISABLE + 1] = {
+ [GF_SHD_OP_INVALID] = NULL,
+ [GF_SHD_OP_HEAL_INDEX] = NULL,
+ [GF_SHD_OP_HEAL_FULL] = "full",
+ [GF_SHD_OP_INDEX_SUMMARY] = "info",
+ [GF_SHD_OP_HEALED_FILES] = NULL,
+ [GF_SHD_OP_HEAL_FAILED_FILES] = NULL,
+ [GF_SHD_OP_SPLIT_BRAIN_FILES] = NULL,
+ [GF_SHD_OP_STATISTICS] = "statistics",
+ [GF_SHD_OP_STATISTICS_HEAL_COUNT] = NULL,
+ [GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA] = NULL,
+ [GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE] = "split-brain",
+ [GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK] = "split-brain",
+ [GF_SHD_OP_HEAL_ENABLE] = "enable",
+ [GF_SHD_OP_HEAL_DISABLE] = "disable",
};
- for (i = 0; i <= GF_AFR_OP_HEAL_DISABLE; i++) {
+ for (i = 0; i <= GF_SHD_OP_HEAL_DISABLE; i++) {
if (heal_cmds[i] && (strcmp (heal_cmds[i], command) == 0))
return i;
}
- return GF_AFR_OP_INVALID;
+ return GF_SHD_OP_INVALID;
}
int
@@ -3047,7 +3047,7 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount,
dict_t *dict = NULL;
char *hostname = NULL;
char *path = NULL;
- gf_xl_afr_op_t op = GF_AFR_OP_INVALID;
+ gf_xl_afr_op_t op = GF_SHD_OP_INVALID;
dict = dict_new ();
if (!dict)
@@ -3060,13 +3060,13 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount,
}
if (wordcount == 3) {
- ret = dict_set_int32 (dict, "heal-op", GF_AFR_OP_HEAL_INDEX);
+ ret = dict_set_int32 (dict, "heal-op", GF_SHD_OP_HEAL_INDEX);
goto done;
}
if (wordcount == 4) {
op = heal_command_type_get (words[3]);
- if (op == GF_AFR_OP_INVALID) {
+ if (op == GF_SHD_OP_INVALID) {
ret = -1;
goto out;
}
@@ -3085,17 +3085,17 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount,
if (!strcmp (words[3], "info")) {
if (!strcmp (words[4], "healed")) {
ret = dict_set_int32 (dict, "heal-op",
- GF_AFR_OP_HEALED_FILES);
+ GF_SHD_OP_HEALED_FILES);
goto done;
}
if (!strcmp (words[4], "heal-failed")) {
ret = dict_set_int32 (dict, "heal-op",
- GF_AFR_OP_HEAL_FAILED_FILES);
+ GF_SHD_OP_HEAL_FAILED_FILES);
goto done;
}
if (!strcmp (words[4], "split-brain")) {
ret = dict_set_int32 (dict, "heal-op",
- GF_AFR_OP_SPLIT_BRAIN_FILES);
+ GF_SHD_OP_SPLIT_BRAIN_FILES);
goto done;
}
}
@@ -3103,7 +3103,7 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount,
if (!strcmp (words[3], "statistics")) {
if (!strcmp (words[4], "heal-count")) {
ret = dict_set_int32 (dict, "heal-op",
- GF_AFR_OP_STATISTICS_HEAL_COUNT);
+ GF_SHD_OP_STATISTICS_HEAL_COUNT);
goto done;
}
}
@@ -3117,7 +3117,7 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount,
}
if (!strcmp (words[4], "bigger-file")) {
ret = dict_set_int32 (dict, "heal-op",
- GF_AFR_OP_SBRAIN_HEAL_FROM_BIGGER_FILE);
+ GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE);
if (ret)
goto out;
ret = dict_set_str (dict, "file", (char *)words[5]);
@@ -3127,11 +3127,11 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount,
}
if (!strcmp (words[4], "source-brick")) {
ret = dict_set_int32 (dict, "heal-op",
- GF_AFR_OP_SBRAIN_HEAL_FROM_BRICK);
+ GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK);
if (ret)
goto out;
ret = set_hostname_path_in_dict (words[5], dict,
- GF_AFR_OP_SBRAIN_HEAL_FROM_BRICK);
+ GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK);
if (ret)
goto out;
goto done;
@@ -3145,11 +3145,11 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount,
&& !strcmp (words[5], "replica")) {
ret = dict_set_int32 (dict, "heal-op",
- GF_AFR_OP_STATISTICS_HEAL_COUNT_PER_REPLICA);
+ GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA);
if (ret)
goto out;
ret = set_hostname_path_in_dict (words[6], dict,
- GF_AFR_OP_STATISTICS_HEAL_COUNT_PER_REPLICA);
+ GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA);
if (ret)
goto out;
goto done;
@@ -3158,9 +3158,9 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount,
if (!strcmp (words[3], "split-brain") &&
!strcmp (words[4], "source-brick")) {
ret = dict_set_int32 (dict, "heal-op",
- GF_AFR_OP_SBRAIN_HEAL_FROM_BRICK);
+ GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK);
ret = set_hostname_path_in_dict (words[5], dict,
- GF_AFR_OP_SBRAIN_HEAL_FROM_BRICK);
+ GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK);
if (ret)
goto out;
ret = dict_set_str (dict, "file",