diff options
author | Dan Lambright <dlambrig@redhat.com> | 2015-02-25 16:11:23 -0500 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-03-19 06:32:28 -0700 |
commit | 6f71bc02df5bd177c2f5dbf4e54b2af1525ab979 (patch) | |
tree | a676a70da909dedebc21dca408fafc9dee9d5810 /cli/src/cli-cmd-volume.c | |
parent | 99586305f66d6b5e81542139d84fbf111ace2554 (diff) |
glusterd: CLI commands to create and manage tiered volumes.
A tiered volume is a normal volume with some number of new bricks
representing "hot" storage. The "hot" bricks can be attached or
detached dynamically to a normal volume. When this happens, a new graph
is constructed. The root of the new graph is an instance of the tier
translator. One subvolume of the tier translator leads to the old volume,
and another leads to the new hot bricks.
attach-tier <VOLNAME> [<replica> <COUNT>] <NEW-BRICK> ... [force]
volume detach-tier <VOLNAME> [replica <COUNT>] <BRICK>
... <start|stop|status|commit|force>
gluster volume rebalance <volume> tier start
gluster volume rebalance <volume> tier stop
gluster volume rebalance <volume> tier status
The "tier start" CLI command starts a server side daemon. The daemon
initiates file level migration based on caching policies. The daemon's
status can be monitored and stopped.
Note development on the "tier status" command is incomplete. It will be
added in a subsequent patch.
When the "hot" storage is detached, the tier translator is removed
from the graph and the tiered volume reverts to its original state as
described in the volume's info file.
For more background and design see the feature page [1].
[1]
http://www.gluster.org/community/documentation/index.php/Features/data-classification
Change-Id: Ic8042ce37327b850b9e199236e5be3dae95d2472
BUG: 1194753
Signed-off-by: Dan Lambright <dlambrig@redhat.com>
Reviewed-on: http://review.gluster.org/9753
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
-rw-r--r-- | cli/src/cli-cmd-volume.c | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 6c950da4e97..3098d74491c 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -840,6 +840,142 @@ out: return ret; } +int +cli_cmd_volume_attach_tier_cbk (struct cli_state *state, + struct cli_cmd_word *word, const char **words, + int wordcount) +{ + int ret = -1; + rpc_clnt_procedure_t *proc = NULL; + call_frame_t *frame = NULL; + dict_t *options = NULL; + int sent = 0; + int parse_error = 0; + gf_answer_t answer = GF_ANSWER_NO; + cli_local_t *local = NULL; + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) + goto out; + + ret = cli_cmd_volume_add_brick_parse (words, wordcount, &options); + if (ret) { + cli_usage_out (word->pattern); + parse_error = 1; + goto out; + } + + if (state->mode & GLUSTER_MODE_WIGNORE) { + ret = dict_set_int32 (options, "force", _gf_true); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to set force " + "option"); + goto out; + } + } + + ret = dict_set_int32 (options, "attach-tier", 1); + if (ret) + goto out; + + ret = dict_set_int32 (options, "type", GF_CLUSTER_TYPE_TIER); + if (ret) + goto out; + + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_ATTACH_TIER]; + + CLI_LOCAL_INIT (local, words, frame, options); + + if (proc->fn) { + ret = proc->fn (frame, THIS, options); + } + +out: + if (ret) { + cli_cmd_sent_status_get (&sent); + if ((sent == 0) && (parse_error == 0)) + cli_out ("attach-tier failed"); + } + + CLI_STACK_DESTROY (frame); + + return ret; +} + +int +cli_cmd_volume_detach_tier_cbk (struct cli_state *state, + struct cli_cmd_word *word, const char **words, + int wordcount) +{ + int ret = -1; + rpc_clnt_procedure_t *proc = NULL; + call_frame_t *frame = NULL; + dict_t *options = NULL; + int sent = 0; + int parse_error = 0; + gf_answer_t answer = GF_ANSWER_NO; + cli_local_t *local = NULL; + int need_question = 0; + + const char *question = "Removing tier can result in data loss. " + "Do you want to Continue?"; + + if (wordcount != 3) + goto out; + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) + goto out; + + options = dict_new (); + if (!options) + goto out; + + ret = dict_set_int32 (options, "force", 1); + if (ret) + goto out; + + ret = dict_set_int32 (options, "command", GF_OP_CMD_DETACH); + if (ret) + goto out; + + ret = dict_set_str (options, "volname", (char *)words[2]); + if (ret) + goto out; + + ret = dict_set_int32 (options, "count", 1); + if (ret) + goto out; + + if (!(state->mode & GLUSTER_MODE_SCRIPT) && need_question) { + /* we need to ask question only in case of 'commit or force' */ + answer = cli_cmd_get_confirmation (state, question); + if (GF_ANSWER_NO == answer) { + ret = 0; + goto out; + } + } + + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DETACH_TIER]; + + CLI_LOCAL_INIT (local, words, frame, options); + + if (proc->fn) { + ret = proc->fn (frame, THIS, options); + } + +out: + if (ret) { + cli_cmd_sent_status_get (&sent); + if ((sent == 0) && (parse_error == 0)) + cli_out ("Volume detach-tier failed"); + } + + CLI_STACK_DESTROY (frame); + + return ret; +} + static int gf_cli_create_auxiliary_mount (char *volname) { @@ -2435,6 +2571,14 @@ struct cli_cmd volume_cmds[] = { cli_cmd_volume_rename_cbk, "rename volume <VOLNAME> to <NEW-VOLNAME>"},*/ + { "volume attach-tier <VOLNAME> [<replica COUNT>] <NEW-BRICK>...", + cli_cmd_volume_attach_tier_cbk, + "attach tier to volume <VOLNAME>"}, + + { "volume detach-tier <VOLNAME>", + cli_cmd_volume_detach_tier_cbk, + "detach tier from volume <VOLNAME>"}, + { "volume add-brick <VOLNAME> [<stripe|replica> <COUNT>] <NEW-BRICK> ... [force]", cli_cmd_volume_add_brick_cbk, "add brick to volume <VOLNAME>"}, |