glusterd/cli changes for distributed geo-rep

Commands:
gluster system:: execute gsec_create
gluster volume geo-rep <master> <slave-url> create [push-pem] [force]
gluster volume geo-rep <master> <slave-url> start [force]
gluster volume geo-rep <master> <slave-url> stop [force]
gluster volume geo-rep <master> <slave-url> delete
gluster volume geo-rep <master> <slave-url> config
gluster volume geo-rep <master> <slave-url> status

The geo-replication is distributed. The session will be created, and
gsyncd will be spawned on all relevant nodes, instead of only one
node.

geo-rep: Collecting status detail related data

Added persistent store for saving information about
TotalFilesSynced, TotalSyncTime, TotalBytesSynced

Changes in the status information in socket:
Existing(Ex):
FilesSynced=2;BytesSynced=2507;Uptime=00:26:01;

New(Ex):
FilesSynced=2;BytesSynced=2507;Uptime=00:26:01;SyncTime=0.69978;
TotalSyncTime=2.890044;TotalFilesSynced=6;TotalBytesSynced=143640;

Persistent details stored in
/var/lib/glusterd/geo-replication/${mastervol}/${eSlave}-detail.status

Change-Id: I1db7fc13ffca2e415c05200b0109b1254067f111
BUG: 847839
Original Author: Avra Sengupta <asengupt@redhat.com>
Original Author: Venky Shankar <vshankar@redhat.com>
Original Author: Aravinda VK <avishwan@redhat.com>
Original Author: Amar Tumballi <amarts@redhat.com>
Original Author: Csaba Henk <csaba@redhat.com>
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/5132
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
Avra Sengupta 2013-07-10 17:32:41 +05:30 committed by Vijay Bellur
parent b13c483dca
commit 5757ed2727
31 changed files with 3668 additions and 756 deletions

1
.gitignore vendored
View File

@ -41,3 +41,4 @@ glusterfsd/src/glusterfsd
libglusterfs/src/spec.lex.c
libglusterfs/src/y.tab.c
libglusterfs/src/y.tab.h
libgfchangelog.pc

View File

@ -1595,22 +1595,161 @@ gsyncd_glob_check (const char *w)
return !!strpbrk (w, "*?[");
}
static int
config_parse (const char **words, int wordcount, dict_t *dict,
unsigned cmdi, unsigned glob)
{
int32_t ret = -1;
int32_t i = -1;
char *append_str = NULL;
size_t append_len = 0;
char *subop = NULL;
switch ((wordcount - 1) - cmdi) {
case 0:
subop = gf_strdup ("get-all");
break;
case 1:
if (words[cmdi + 1][0] == '!') {
(words[cmdi + 1])++;
if (gf_asprintf (&subop, "del%s",
glob ? "-glob" : "") == -1)
subop = NULL;
} else
subop = gf_strdup ("get");
ret = dict_set_str (dict, "op_name", ((char *)words[cmdi + 1]));
if (ret < 0)
goto out;
break;
default:
if (gf_asprintf (&subop, "set%s", glob ? "-glob" : "") == -1)
subop = NULL;
ret = dict_set_str (dict, "op_name", ((char *)words[cmdi + 1]));
if (ret < 0)
goto out;
/* join the varargs by spaces to get the op_value */
for (i = cmdi + 2; i < wordcount; i++)
append_len += (strlen (words[i]) + 1);
/* trailing strcat will add two bytes, make space for that */
append_len++;
append_str = GF_CALLOC (1, append_len, cli_mt_append_str);
if (!append_str) {
ret = -1;
goto out;
}
for (i = cmdi + 2; i < wordcount; i++) {
strcat (append_str, words[i]);
strcat (append_str, " ");
}
append_str[append_len - 2] = '\0';
/* "checkpoint now" is special: we resolve that "now" */
if (strcmp (words[cmdi + 1], "checkpoint") == 0 &&
strcmp (append_str, "now") == 0) {
struct timeval tv = {0,};
ret = gettimeofday (&tv, NULL);
if (ret == -1)
goto out; /* FIXME: free append_str? */
GF_FREE (append_str);
append_str = GF_CALLOC (1, 300, cli_mt_append_str);
if (!append_str) {
ret = -1;
goto out;
}
strcpy (append_str, "as of ");
gf_time_fmt (append_str + strlen ("as of "),
300 - strlen ("as of "),
tv.tv_sec, gf_timefmt_FT);
}
ret = dict_set_dynstr (dict, "op_value", append_str);
}
ret = -1;
if (subop) {
ret = dict_set_dynstr (dict, "subop", subop);
if (!ret)
subop = NULL;
}
out:
if (ret && append_str)
GF_FREE (append_str);
GF_FREE (subop);
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
static int32_t
force_push_pem_parse (const char **words, int wordcount,
dict_t *dict, unsigned *cmdi)
{
int32_t ret = 0;
if (!strcmp ((char *)words[wordcount-1], "force")) {
if ((strcmp ((char *)words[wordcount-2], "start")) &&
(strcmp ((char *)words[wordcount-2], "stop")) &&
(strcmp ((char *)words[wordcount-2], "create")) &&
(strcmp ((char *)words[wordcount-2], "push-pem"))) {
ret = -1;
goto out;
}
ret = dict_set_uint32 (dict, "force",
_gf_true);
if (ret)
goto out;
(*cmdi)++;
if (!strcmp ((char *)words[wordcount-2], "push-pem")) {
if (strcmp ((char *)words[wordcount-3], "create")) {
ret = -1;
goto out;
}
ret = dict_set_int32 (dict, "push_pem", 1);
if (ret)
goto out;
(*cmdi)++;
}
} else if (!strcmp ((char *)words[wordcount-1], "push-pem")) {
if (strcmp ((char *)words[wordcount-2], "create")) {
ret = -1;
goto out;
}
ret = dict_set_int32 (dict, "push_pem", 1);
if (ret)
goto out;
(*cmdi)++;
}
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
int32_t
cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
{
int32_t ret = -1;
dict_t *dict = NULL;
gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE;
char *append_str = NULL;
size_t append_len = 0;
char *subop = NULL;
int i = 0;
unsigned masteri = 0;
unsigned slavei = 0;
unsigned glob = 0;
unsigned cmdi = 0;
char *opwords[] = { "status", "start", "stop", "config",
"log-rotate", NULL };
char *opwords[] = { "create", "status", "start", "stop",
"config", "force", "delete",
"push-pem", NULL };
char *w = NULL;
GF_ASSERT (words);
@ -1622,10 +1761,11 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
/* new syntax:
*
* volume geo-replication $m $s create [push-pem] [force]
* volume geo-replication [$m [$s]] status
* volume geo-replication [$m] $s config [[!]$opt [$val]]
* volume geo-replication $m $s start|stop
* volume geo-replication $m [$s] log-rotate
* volume geo-replication $m $s start|stop [force]
* volume geo-replication $m $s delete
*/
if (wordcount < 3)
@ -1682,7 +1822,12 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
if (!w)
goto out;
if (strcmp (w, "status") == 0) {
if (strcmp (w, "create") == 0) {
type = GF_GSYNC_OPTION_TYPE_CREATE;
if (!masteri || !slavei)
goto out;
} else if (strcmp (w, "status") == 0) {
type = GF_GSYNC_OPTION_TYPE_STATUS;
if (slavei && !masteri)
@ -1702,14 +1847,18 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
if (!masteri || !slavei)
goto out;
} else if (strcmp(w, "log-rotate") == 0) {
type = GF_GSYNC_OPTION_TYPE_ROTATE;
} else if (strcmp (w, "delete") == 0) {
type = GF_GSYNC_OPTION_TYPE_DELETE;
if (slavei && !masteri)
if (!masteri || !slavei)
goto out;
} else
GF_ASSERT (!"opword mismatch");
ret = force_push_pem_parse (words, wordcount, dict, &cmdi);
if (ret)
goto out;
if (type != GF_GSYNC_OPTION_TYPE_CONFIG &&
(cmdi < wordcount - 1 || glob))
goto out;
@ -1718,97 +1867,26 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
ret = 0;
if (masteri)
if (masteri) {
ret = dict_set_str (dict, "master", (char *)words[masteri]);
if (!ret)
ret = dict_set_str (dict, "volname",
(char *)words[masteri]);
}
if (!ret && slavei)
ret = dict_set_str (dict, "slave", (char *)words[slavei]);
if (!ret)
ret = dict_set_int32 (dict, "type", type);
if (!ret && type == GF_GSYNC_OPTION_TYPE_CONFIG) {
switch ((wordcount - 1) - cmdi) {
case 0:
subop = gf_strdup ("get-all");
break;
case 1:
if (words[cmdi + 1][0] == '!') {
(words[cmdi + 1])++;
if (gf_asprintf (&subop, "del%s", glob ? "-glob" : "") == -1)
subop = NULL;
} else
subop = gf_strdup ("get");
ret = dict_set_str (dict, "op_name", ((char *)words[cmdi + 1]));
if (ret < 0)
goto out;
break;
default:
if (gf_asprintf (&subop, "set%s", glob ? "-glob" : "") == -1)
subop = NULL;
ret = dict_set_str (dict, "op_name", ((char *)words[cmdi + 1]));
if (ret < 0)
goto out;
/* join the varargs by spaces to get the op_value */
for (i = cmdi + 2; i < wordcount; i++)
append_len += (strlen (words[i]) + 1);
/* trailing strcat will add two bytes, make space for that */
append_len++;
append_str = GF_CALLOC (1, append_len, cli_mt_append_str);
if (!append_str) {
ret = -1;
goto out;
}
for (i = cmdi + 2; i < wordcount; i++) {
strcat (append_str, words[i]);
strcat (append_str, " ");
}
append_str[append_len - 2] = '\0';
/* "checkpoint now" is special: we resolve that "now" */
if (strcmp (words[cmdi + 1], "checkpoint") == 0 &&
strcmp (append_str, "now") == 0) {
struct timeval tv = {0,};
ret = gettimeofday (&tv, NULL);
if (ret == -1)
goto out; /* FIXME: free append_str? */
GF_FREE (append_str);
append_str = GF_CALLOC (1, 300, cli_mt_append_str);
if (!append_str) {
ret = -1;
goto out;
}
strcpy (append_str, "as of ");
gf_time_fmt (append_str + strlen ("as of "),
300 - strlen ("as of "),
tv.tv_sec, gf_timefmt_FT);
}
ret = dict_set_dynstr (dict, "op_value", append_str);
}
ret = -1;
if (subop) {
ret = dict_set_dynstr (dict, "subop", subop);
if (!ret)
subop = NULL;
}
}
if (!ret && type == GF_GSYNC_OPTION_TYPE_CONFIG)
ret = config_parse (words, wordcount, dict, cmdi, glob);
out:
if (ret) {
if (dict)
dict_destroy (dict);
GF_FREE (append_str);
} else
*options = dict;
GF_FREE (subop);
return ret;
}

View File

@ -31,6 +31,12 @@ extern rpc_clnt_prog_t *cli_rpc_prog;
int cli_cmd_system_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
const char **words, int wordcount);
int cli_cmd_copy_file_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount);
int cli_cmd_sys_exec_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount);
int
cli_cmd_getspec_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
@ -423,9 +429,150 @@ struct cli_cmd cli_system_cmds[] = {
cli_cmd_system_help_cbk,
"display help for system commands"},
{ "system:: copy file [<filename>]",
cli_cmd_copy_file_cbk,
"Copy file from current node's $working_dir to "
"$working_dir of all cluster nodes"},
{ "system:: execute <command> <args>",
cli_cmd_sys_exec_cbk,
"Execute the command on all the nodes "
"in the cluster and display their output."},
{ NULL, NULL, NULL }
};
int
cli_cmd_sys_exec_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
{
char cmd_arg_name[PATH_MAX] = "";
char *command = NULL;
char *saveptr = NULL;
char *tmp = NULL;
int ret = -1;
int i = -1;
int cmd_args_count = 0;
int in_cmd_args_count = 0;
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *dict = NULL;
cli_local_t *local = NULL;
if (wordcount < 3) {
cli_usage_out (word->pattern);
goto out;
}
dict = dict_new ();
if (!dict)
goto out;
command = strtok_r ((char *)words[2], " ", &saveptr);
do {
tmp = strtok_r (NULL, " ", &saveptr);
if (tmp) {
in_cmd_args_count++;
memset (cmd_arg_name, '\0', sizeof(cmd_arg_name));
snprintf (cmd_arg_name, sizeof(cmd_arg_name),
"cmd_arg_%d", in_cmd_args_count);
ret = dict_set_str (dict, cmd_arg_name, tmp);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to set "
"%s in dict", cmd_arg_name);
goto out;
}
}
} while (tmp);
cmd_args_count = wordcount - 3;
ret = dict_set_str (dict, "command", command);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to set command in dict");
goto out;
}
for (i=1; i <= cmd_args_count; i++) {
in_cmd_args_count++;
memset (cmd_arg_name, '\0', sizeof(cmd_arg_name));
snprintf (cmd_arg_name, sizeof(cmd_arg_name),
"cmd_arg_%d", in_cmd_args_count);
ret = dict_set_str (dict, cmd_arg_name,
(char *)words[2+i]);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to set %s in dict",
cmd_arg_name);
goto out;
}
}
ret = dict_set_int32 (dict, "cmd_args_count", in_cmd_args_count);
if (ret) {
gf_log ("", GF_LOG_ERROR,
"Unable to set cmd_args_count in dict");
goto out;
}
ret = dict_set_str (dict, "volname", "N/A");
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to set volname in dict");
goto out;
}
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SYS_EXEC];
if (proc && proc->fn) {
frame = create_frame (THIS, THIS->ctx->pool);
if (!frame)
goto out;
CLI_LOCAL_INIT (local, words, frame, dict);
ret = proc->fn (frame, THIS, (void*)dict);
}
out:
return ret;
}
int
cli_cmd_copy_file_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;
char *filename = "";
dict_t *dict = NULL;
cli_local_t *local = NULL;
if (wordcount != 4) {
cli_usage_out (word->pattern);
goto out;
}
dict = dict_new ();
if (!dict)
goto out;
filename = (char*)words[3];
ret = dict_set_str (dict, "source", filename);
if (ret)
gf_log ("", GF_LOG_ERROR, "Unable to set filename in dict");
ret = dict_set_str (dict, "volname", "N/A");
if (ret)
gf_log ("", GF_LOG_ERROR, "Unable to set volname in dict");
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_COPY_FILE];
if (proc && proc->fn) {
frame = create_frame (THIS, THIS->ctx->pool);
if (!frame)
goto out;
CLI_LOCAL_INIT (local, words, frame, dict);
ret = proc->fn (frame, THIS, (void*)dict);
}
out:
return ret;
}
int
cli_cmd_system_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
const char **words, int wordcount)

View File

@ -1887,7 +1887,8 @@ struct cli_cmd volume_cmds[] = {
"reset all the reconfigured options"},
#if (SYNCDAEMON_COMPILE)
{"volume "GEOREP" [<VOLNAME>] [<SLAVE-URL>] {start|stop|config|status|log-rotate} [options...]",
{"volume "GEOREP" [<VOLNAME>] [<SLAVE-URL>] {create [push-pem] [force]"
"|start [force]|stop [force]|config|status|delete} [options...]",
cli_cmd_volume_gsync_set_cbk,
"Geo-sync operations",
cli_cmd_check_gsync_exists_cbk},

View File

@ -13,10 +13,6 @@
#include "config.h"
#endif
#ifndef GSYNC_CONF
#define GSYNC_CONF GEOREP"/gsyncd.conf"
#endif
/* Widths of various columns in top read/write-perf output
* Total width of top read/write-perf should be 80 chars
* including one space between column
@ -3745,6 +3741,54 @@ out:
return ret;
}
static int
gf_cli_get_slave_volname (char *slave, char **slave_vol)
{
char *tmp = NULL;
char *buf = NULL;
char *save_ptr = NULL;
char *slave_buf = NULL;
int32_t ret = -1;
GF_ASSERT (slave);
slave_buf = gf_strdup(slave);
if (!slave_buf) {
gf_log ("", GF_LOG_ERROR,
"Failed to gf_strdup");
ret = -1;
goto out;
}
tmp = strtok_r (slave_buf, ":", &save_ptr);
while (tmp) {
buf = tmp;
tmp = strtok_r (NULL, ":", &save_ptr);
}
if (buf) {
*slave_vol = gf_strdup (buf);
if (!*slave_vol) {
gf_log ("", GF_LOG_ERROR,
"Failed to gf_strdup");
ret = -1;
goto out;
}
gf_log ("", GF_LOG_DEBUG, "Slave Vol : %s", *slave_vol);
ret = 0;
} else {
gf_log ("", GF_LOG_ERROR, "Invalid slave name");
goto out;
}
out:
if (slave_buf)
GF_FREE(slave_buf);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
int
gf_cli_gsync_config_command (dict_t *dict)
{
@ -3752,8 +3796,11 @@ gf_cli_gsync_config_command (dict_t *dict)
char *subop = NULL;
char *gwd = NULL;
char *slave = NULL;
char *slave_vol = NULL;
char *master = NULL;
char *op_name = NULL;
int ret = -1;
char conf_path[PATH_MAX] = "";
if (dict_get_str (dict, "subop", &subop) != 0)
return -1;
@ -3772,9 +3819,21 @@ gf_cli_gsync_config_command (dict_t *dict)
if (dict_get_str (dict, "op_name", &op_name) != 0)
op_name = NULL;
ret = gf_cli_get_slave_volname (slave, &slave_vol);
if (ret) {
gf_log ("", GF_LOG_ERROR,
"Unable to fetch slave volume name.");
return -1;
}
ret = snprintf (conf_path, sizeof(conf_path) - 1,
"%s/"GEOREP"/%s-%s/gsyncd.conf",
gwd, master, slave_vol);
conf_path[ret] = '\0';
runinit (&runner);
runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "-c", NULL);
runner_argprintf (&runner, "%s/"GSYNC_CONF, gwd);
runner_argprintf (&runner, "%s", conf_path);
if (master)
runner_argprintf (&runner, ":%s", master);
runner_add_arg (&runner, slave);
@ -3785,68 +3844,450 @@ gf_cli_gsync_config_command (dict_t *dict)
return runner_run (&runner);
}
static int
gf_cli_fetch_gsyncd_health_uptime (char *status, char **health, char **uptime)
{
char *tmp = NULL;
char *save_ptr = NULL;
int32_t ret = -1;
char *key = NULL;
char *value = NULL;
if (!health || !uptime || !status) {
gf_log ("", GF_LOG_ERROR, "health or uptime or status is null");
goto out;
}
tmp = strtok_r (status, "\n", &save_ptr);
if (tmp)
*health = gf_strdup (tmp);
while (tmp) {
key = strtok_r (tmp, "=", &value);
if ((key) && (!strcmp(key, "Uptime"))) {
*uptime = gf_strdup (value);
break;
}
tmp = strtok_r (NULL, ";", &save_ptr);
}
if (*health)
ret = 0;
if (!*uptime)
*uptime = gf_strdup ("N/A");
out:
gf_log ("", GF_LOG_DEBUG, "Returning %d.", ret);
return ret;
}
int
gf_cli_gsync_out_status (dict_t *dict)
{
int gsync_count = 0;
int i = 0;
int ret = 0;
char mst[PATH_MAX] = {0, };
char slv[PATH_MAX] = {0, };
char sts[PATH_MAX] = {0, };
char nds[PATH_MAX] = {0, };
char hyphens[100] = {0, };
char *mst_val = NULL;
char *slv_val = NULL;
char *sts_val = NULL;
char *nds_val = NULL;
cli_out ("%-20s %-20s %-50s %-10s", "NODE", "MASTER", "SLAVE", "STATUS");
for (i=0; i<sizeof(hyphens)-1; i++)
hyphens[i] = '-';
cli_out ("%s", hyphens);
char mst[PATH_MAX] = {0, };
char slv[PATH_MAX] = {0, };
char sts[PATH_MAX] = {0, };
char nds[PATH_MAX] = {0, };
char errmsg[1024] = "";
char *sts_val = NULL;
char *master = NULL;
char *slave = NULL;
char **output_values = NULL;
char **dict_values = NULL;
char *hyphens = NULL;
char *title_values[] = {"NODE", "MASTER", "SLAVE",
"HEALTH", "UPTIME"};
int gsync_count = 0;
int i = 0;
int j = 0;
int dict_val_count = 0;
int ret = 0;
int spacing[5] = {0, 0, 0, 0, 10};
int total_spacing = 0;
/* Checks if any session is active or not */
ret = dict_get_int32 (dict, "gsync-count", &gsync_count);
if (ret) {
gf_log ("cli", GF_LOG_INFO, "No active geo-replication sessions"
"present for the selected");
ret = dict_get_str (dict, "master", &master);
ret = dict_get_str (dict, "slave", &slave);
if (master) {
if (slave)
snprintf (errmsg, sizeof(errmsg), "No active "
"geo-replication sessions between %s"
" and %s", master, slave);
else
snprintf (errmsg, sizeof(errmsg), "No active "
"geo-replication sessions for %s",
master);
} else
snprintf (errmsg, sizeof(errmsg), "No active "
"geo-replication sessions");
gf_log ("cli", GF_LOG_INFO, "%s", errmsg);
cli_out ("%s", errmsg);
ret = 0;
goto out;
}
for (i = 1; i <= gsync_count; i++) {
/* (gsync_count = number of nodes reporting output *
5 = number of fields) = total number of values to
be fetched from dict */
dict_values = GF_CALLOC (gsync_count * 5, sizeof (char *),
gf_common_mt_char);
if (!dict_values) {
gf_log ("cli", GF_LOG_ERROR, "Out Of Memory");
ret = -1;
goto out;
}
for (i = 1, j = 0; i <= gsync_count; i++) {
snprintf (nds, sizeof(nds), "node%d", i);
snprintf (mst, sizeof(mst), "master%d", i);
snprintf (slv, sizeof(slv), "slave%d", i);
snprintf (sts, sizeof(sts), "status%d", i);
ret = dict_get_str (dict, nds, &nds_val);
/* Fetching the values from dict, and calculating
the max length for each field */
ret = dict_get_str (dict, nds, &dict_values[j]);
if (ret)
goto out;
if (strlen (dict_values[j]) > spacing [0])
spacing[0] = strlen (dict_values[j]);
j++;
ret = dict_get_str (dict, mst, &mst_val);
ret = dict_get_str (dict, mst, &dict_values[j]);
if (ret)
goto out;
if (strlen (dict_values[j]) > spacing [1])
spacing[1] = strlen (dict_values[j]);
j++;
ret = dict_get_str (dict, slv, &slv_val);
ret = dict_get_str (dict, slv, &dict_values[j]);
if (ret)
goto out;
if (strlen (dict_values[j]) > spacing [2])
spacing[2] = strlen (dict_values[j]);
j++;
ret = dict_get_str (dict, sts, &sts_val);
if (ret)
goto out;
cli_out ("%-20s %-20s %-50s %-10s", nds_val, mst_val,
slv_val, sts_val);
/* Fetching health and uptime from sts_val */
ret = gf_cli_fetch_gsyncd_health_uptime (sts_val,
&dict_values[j],
&dict_values[j+1]);
if (ret)
goto out;
if (strlen (dict_values[j]) > spacing [3])
spacing[3] = strlen (dict_values[j]);
j++;
if (strlen (dict_values[j]) > spacing [4])
spacing[4] = strlen (dict_values[j]);
j++;
}
out:
return ret;
/* calculating spacing for hyphens */
for (i = 0; i < 5; i++) {
spacing[i] += 3; /* Adding extra space to
distinguish between fields */
total_spacing += spacing[i];
}
total_spacing += 4; /* For the spacing between the fields */
/* char pointers for each field */
output_values = GF_CALLOC (5, sizeof (char *), gf_common_mt_char);
if (!output_values)
ret = -1;
for (i = 0; i < 5; i++) {
output_values[i] = GF_CALLOC (spacing[i] + 1, sizeof (char),
gf_common_mt_char);
if (!output_values[i])
ret = -1;
}
hyphens = GF_CALLOC (total_spacing + 1, sizeof (char),
gf_common_mt_char);
if (!hyphens)
ret = -1;
if (ret) {
gf_log ("cli", GF_LOG_ERROR, "Out Of Memory");
ret = -1;
goto out;
}
/* setting the title "NODE", "MASTER", etc. from title_values[]
and printing the same */
for (j = 0; j < 5; j++) {
memset (output_values[j], ' ', spacing[j]);
memcpy (output_values[j], title_values[j],
strlen(title_values[j]));
output_values[j][spacing[j]] = '\0';
}
cli_out ("%s %s %s %s %s", output_values[0], output_values[1],
output_values[2], output_values[3], output_values[4]);
/* setting and printing the hyphens */
memset (hyphens, '-', total_spacing);
hyphens[total_spacing] = '\0';
cli_out ("%s", hyphens);
for (i = 1, dict_val_count = 0; i <= gsync_count; i++) {
/* Setting the field values for each row */
for (j = 0; j < 5; j++) {
memset (output_values[j], ' ', spacing[j]);
memcpy (output_values[j], dict_values[dict_val_count],
strlen(dict_values[dict_val_count]));
output_values[j][spacing[j]] = '\0';
dict_val_count++;
}
cli_out ("%s %s %s %s %s", output_values[0], output_values[1],
output_values[2], output_values[3], output_values[4]);
}
out:
if (output_values) {
for (i = 0; i < 5; i++) {
if (output_values[i])
GF_FREE (output_values[i]);
}
GF_FREE (output_values);
}
if (dict_values)
GF_FREE (dict_values);
if (hyphens)
GF_FREE (hyphens);
return ret;
}
static int32_t
write_contents_to_common_pem_file (dict_t *dict, int output_count)
{
char *workdir = NULL;
char common_pem_file[PATH_MAX] = "";
char *output = NULL;
char output_name[PATH_MAX] = "";
int bytes_writen = 0;
int fd = -1;
int ret = -1;
int i = -1;
ret = dict_get_str (dict, "glusterd_workdir", &workdir);
if (ret || !workdir) {
gf_log ("", GF_LOG_ERROR, "Unable to fetch workdir");
ret = -1;
goto out;
}
snprintf (common_pem_file, sizeof(common_pem_file),
"%s/geo-replication/common_secret.pem.pub",
workdir);
unlink (common_pem_file);
fd = open (common_pem_file, O_WRONLY | O_CREAT, 0600);
if (fd == -1) {
gf_log ("", GF_LOG_ERROR, "Failed to open %s"
" Error : %s", common_pem_file,
strerror (errno));
ret = -1;
goto out;
}
for (i = 1; i <= output_count; i++) {
memset (output_name, '\0', sizeof (output_name));
snprintf (output_name, sizeof (output_name),
"output_%d", i);
ret = dict_get_str (dict, output_name, &output);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Failed to get %s.",
output_name);
cli_out ("Unable to fetch output.");
}
if (output) {
bytes_writen = write (fd, output, strlen(output));
if (bytes_writen != strlen(output)) {
gf_log ("", GF_LOG_ERROR, "Failed to write "
"to %s", common_pem_file);
ret = -1;
goto out;
}
/* Adding the new line character */
bytes_writen = write (fd, "\n", strlen("\n"));
if (bytes_writen != strlen("\n")) {
gf_log ("", GF_LOG_ERROR,
"Failed to add new line char");
ret = -1;
goto out;
}
output = NULL;
}
}
cli_out ("Common secret pub file present at %s", common_pem_file);
ret = 0;
out:
if (fd)
close (fd);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
int
gf_cli_sys_exec_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
int ret = -1;
int output_count = -1;
int i = -1;
char *output = NULL;
char *command = NULL;
char output_name[PATH_MAX] = "";
gf_cli_rsp rsp = {0, };
dict_t *dict = NULL;
call_frame_t *frame = NULL;
if (req->rpc_status == -1) {
ret = -1;
goto out;
}
frame = myframe;
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log (frame->this->name, GF_LOG_ERROR,
"Failed to decode xdr response");
goto out;
}
dict = dict_new ();
if (!dict) {
ret = -1;
goto out;
}
ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict);
if (ret)
goto out;
if (rsp.op_ret) {
cli_err ("%s", rsp.op_errstr ? rsp.op_errstr :
"Command failed.");
ret = rsp.op_ret;
goto out;
}
ret = dict_get_int32 (dict, "output_count", &output_count);
if (ret) {
cli_out ("Command executed successfully.");
ret = 0;
goto out;
}
ret = dict_get_str (dict, "command", &command);
if (ret) {
gf_log ("", GF_LOG_ERROR,
"Unable to get command from dict");
goto out;
}
if (!strcmp (command, "gsec_create")) {
ret = write_contents_to_common_pem_file (dict, output_count);
if (!ret)
goto out;
}
for (i = 1; i <= output_count; i++) {
memset (output_name, '\0', sizeof (output_name));
snprintf (output_name, sizeof (output_name),
"output_%d", i);
ret = dict_get_str (dict, output_name, &output);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Failed to get %s.",
output_name);
cli_out ("Unable to fetch output.");
}
if (output) {
cli_out ("%s", output);
output = NULL;
}
}
ret = 0;
out:
if (dict)
dict_unref (dict);
cli_cmd_broadcast_response (ret);
free (rsp.dict.dict_val);
return ret;
}
int
gf_cli_copy_file_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
int ret = -1;
gf_cli_rsp rsp = {0, };
dict_t *dict = NULL;
call_frame_t *frame = NULL;
if (req->rpc_status == -1) {
ret = -1;
goto out;
}
frame = myframe;
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log (frame->this->name, GF_LOG_ERROR,
"Failed to decode xdr response");
goto out;
}
dict = dict_new ();
if (!dict) {
ret = -1;
goto out;
}
ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict);
if (ret)
goto out;
if (rsp.op_ret) {
cli_err ("%s", rsp.op_errstr ? rsp.op_errstr :
"Copy unsuccessful");
ret = rsp.op_ret;
goto out;
}
cli_out ("Successfully copied file.");
out:
if (dict)
dict_unref (dict);
cli_cmd_broadcast_response (ret);
free (rsp.dict.dict_val);
return ret;
}
int
@ -3861,6 +4302,8 @@ gf_cli_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
char *slave = NULL;
int32_t type = 0;
call_frame_t *frame = NULL;
gf_boolean_t is_force = _gf_false;
if (req->rpc_status == -1) {
ret = -1;
@ -3897,7 +4340,9 @@ gf_cli_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
if (rsp.op_ret) {
is_force = dict_get_str_boolean (dict, "force", _gf_false);
if (rsp.op_ret && !is_force) {
cli_err ("%s", rsp.op_errstr ? rsp.op_errstr :
GEOREP" command unsuccessful");
ret = rsp.op_ret;
@ -3937,7 +4382,26 @@ gf_cli_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
case GF_GSYNC_OPTION_TYPE_STATUS:
ret = gf_cli_gsync_out_status (dict);
goto out;
break;
case GF_GSYNC_OPTION_TYPE_DELETE:
if (dict_get_str (dict, "master", &master) != 0)
master = "???";
if (dict_get_str (dict, "slave", &slave) != 0)
slave = "???";
cli_out ("Deleting " GEOREP " session between %s & %s"
" has been successful", master, slave);
break;
case GF_GSYNC_OPTION_TYPE_CREATE:
if (dict_get_str (dict, "master", &master) != 0)
master = "???";
if (dict_get_str (dict, "slave", &slave) != 0)
slave = "???";
cli_out ("Creating " GEOREP " session between %s & %s"
" has been successful", master, slave);
break;
default:
cli_out (GEOREP" command executed successfully");
}
@ -3952,6 +4416,54 @@ out:
return ret;
}
int32_t
gf_cli_sys_exec (call_frame_t *frame, xlator_t *this, void *data)
{
int ret = 0;
dict_t *dict = NULL;
gf_cli_req req = {{0,}};
if (!frame || !this || !data) {
ret = -1;
gf_log ("cli", GF_LOG_ERROR, "Invalid data");
goto out;
}
dict = data;
ret = cli_to_glusterd (&req, frame, gf_cli_sys_exec_cbk,
(xdrproc_t) xdr_gf_cli_req, dict,
GLUSTER_CLI_SYS_EXEC, this, cli_rpc_prog,
NULL);
out:
GF_FREE (req.dict.dict_val);
return ret;
}
int32_t
gf_cli_copy_file (call_frame_t *frame, xlator_t *this, void *data)
{
int ret = 0;
dict_t *dict = NULL;
gf_cli_req req = {{0,}};
if (!frame || !this || !data) {
ret = -1;
gf_log ("cli", GF_LOG_ERROR, "Invalid data");
goto out;
}
dict = data;
ret = cli_to_glusterd (&req, frame, gf_cli_copy_file_cbk,
(xdrproc_t) xdr_gf_cli_req, dict,
GLUSTER_CLI_COPY_FILE, this, cli_rpc_prog,
NULL);
out:
GF_FREE (req.dict.dict_val);
return ret;
}
int32_t
gf_cli_gsync_set (call_frame_t *frame, xlator_t *this,
void *data)
@ -6822,6 +7334,8 @@ struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = {
[GLUSTER_CLI_STATEDUMP_VOLUME] = {"STATEDUMP_VOLUME", gf_cli_statedump_volume},
[GLUSTER_CLI_LIST_VOLUME] = {"LIST_VOLUME", gf_cli_list_volume},
[GLUSTER_CLI_CLRLOCKS_VOLUME] = {"CLEARLOCKS_VOLUME", gf_cli_clearlocks_volume},
[GLUSTER_CLI_COPY_FILE] = {"COPY_FILE", gf_cli_copy_file},
[GLUSTER_CLI_SYS_EXEC] = {"SYS_EXEC", gf_cli_sys_exec},
#ifdef HAVE_BD_XLATOR
[GLUSTER_CLI_BD_OP] = {"BD_OP", gf_cli_bd_op},
#endif

View File

@ -30,6 +30,7 @@ AC_CONFIG_FILES([Makefile
libglusterfs/Makefile
libglusterfs/src/Makefile
geo-replication/src/peer_gsec_create
geo-replication/src/peer_add_secret_pub
glusterfsd/Makefile
glusterfsd/src/Makefile
rpc/Makefile

View File

@ -1 +1 @@
EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh S30samba-stop.sh S30samba-set.sh Sglusterd-geo-rep-create-post.sh
EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh S30samba-stop.sh S30samba-set.sh S56glusterd-geo-rep-create-post.sh

View File

@ -0,0 +1,41 @@
#!/bin/bash
key_val_pair1=`echo $2 | cut -d ' ' -f 1`
key_val_pair2=`echo $2 | cut -d ' ' -f 2`
key_val_pair3=`echo $2 | cut -d ' ' -f 3`
key=`echo $key_val_pair1 | cut -d '=' -f 1`
val=`echo $key_val_pair1 | cut -d '=' -f 2`
if [ "$key" != "is_push_pem" ]; then
exit;
fi
if [ "$val" != '1' ]; then
exit;
fi
key=`echo $key_val_pair2 | cut -d '=' -f 1`
val=`echo $key_val_pair2 | cut -d '=' -f 2`
if [ "$key" != "pub_file" ]; then
exit;
fi
if [ "$val" == "" ]; then
exit;
fi
pub_file=`echo $val`
key=`echo $key_val_pair3 | cut -d '=' -f 1`
val=`echo $key_val_pair3 | cut -d '=' -f 2`
if [ "$key" != "slave_ip" ]; then
exit;
fi
if [ "$val" == "" ]; then
exit;
fi
slave_ip=`echo $val`
if [ -f $pub_file ]; then
ssh $slave_ip "\rm -rf $pub_file"
scp $pub_file $slave_ip:$pub_file &> /dev/null
ssh $slave_ip "gluster system:: copy file /geo-replication/common_secret.pem.pub > /dev/null"
ssh $slave_ip "gluster system:: execute add_secret_pub > /dev/null"
fi

View File

@ -3,9 +3,9 @@ gsyncddir = $(libexecdir)/glusterfs
gsyncd_SCRIPTS = gverify.sh peer_add_secret_pub peer_gsec_create
# peer_gsec_create is not added to EXTRA_DIST as it's derived
# from a .in file
EXTRA_DIST = gverify.sh peer_add_secret_pub
# peer_gsec_create and peer_add_secret_pub are not added to
# EXTRA_DIST as it's derived from a .in file
EXTRA_DIST = gverify.sh
gsyncd_PROGRAMS = gsyncd

View File

@ -37,7 +37,7 @@
#define _GLUSTERD_CALLED_ "_GLUSTERD_CALLED_"
#define _GSYNCD_DISPATCHED_ "_GSYNCD_DISPATCHED_"
#define GSYNCD_CONF "geo-replication/gsyncd.conf"
#define GSYNCD_CONF_TEMPLATE "geo-replication/gsyncd_template.conf"
#define GSYNCD_PY "gsyncd.py"
#define RSYNC "rsync"
@ -127,11 +127,11 @@ invoke_gsyncd (int argc, char **argv)
gluster_workdir_len = len - 1;
if (gluster_workdir_len) {
if (gluster_workdir_len + 1 + strlen (GSYNCD_CONF) + 1 >
if (gluster_workdir_len + 1 + strlen (GSYNCD_CONF_TEMPLATE) + 1 >
PATH_MAX)
goto error;
config_file[gluster_workdir_len] = '/';
strcat (config_file, GSYNCD_CONF);
strcat (config_file, GSYNCD_CONF_TEMPLATE);
} else
goto error;

View File

@ -1,3 +0,0 @@
#!/bin/bash
cat $1 >> ~/.ssh/authorized_keys

View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ ! -d ~/.ssh ]; then
mkdir ~/.ssh;
chmod 700 ~/.ssh
chown root:root ~/.ssh
fi
cat "$GLUSTERD_WORKING_DIR"/geo-replication/common_secret.pem.pub >> ~/.ssh/authorized_keys

View File

@ -39,7 +39,7 @@ The config file format matches the following syntax:
<option2>: <value2>
# comment
By default (unless specified by the option `-c`), gsyncd looks for config file at _conf/gsyncd.conf_
By default (unless specified by the option `-c`), gsyncd looks for config file at _conf/gsyncd_template.conf_
in the source tree.
USAGE

View File

@ -346,10 +346,9 @@ def main_i():
for name in rmap[x]:
for j in range(3):
namedict[mods[j](name)] = pa[j][i]
if x.scheme == 'gluster':
namedict[name + 'vol'] = x.volume
namedict[name + 'vol'] = x.volume
if not 'config_file' in rconf:
rconf['config_file'] = os.path.join(os.path.dirname(sys.argv[0]), "conf/gsyncd.conf")
rconf['config_file'] = os.path.join(os.path.dirname(sys.argv[0]), "conf/gsyncd_template.conf")
gcnf = GConffile(rconf['config_file'], canon_peers, defaults.__dict__, opts.__dict__, namedict)
checkpoint_change = False
@ -399,6 +398,8 @@ def main_i():
if getattr(gconf, 'state_socket_unencoded', None):
cleanup_paths.append(gconf.state_socket_unencoded)
cleanup_paths.append(rconf['config_file'][:-11] + "*");
# Cleanup changelog working dirs
if getattr(gconf, 'working_dir', None):
try:

View File

@ -1056,6 +1056,7 @@ class SSH(AbstractUrl, SlaveRemote):
self.remote_addr, inner_url = sup(self, path,
'^((?:%s@)?%s):(.+)' % tuple([ r.pattern for r in (UserRX, HostRX) ]))
self.inner_rsc = parse_url(inner_url)
self.volume = inner_url[1:]
@staticmethod
def parse_ssh_address(addr):

View File

@ -431,7 +431,7 @@ sed -i 's|option working-directory /etc/glusterd|option working-directory %{_sha
%if ( 0%{!?_without_georeplication:1} )
# geo-rep ghosts
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/geo-replication
touch %{buildroot}%{_sharedstatedir}/glusterd/geo-replication/gsyncd.conf
touch %{buildroot}%{_sharedstatedir}/glusterd/geo-replication/gsyncd_template.conf
%endif
# the rest of the ghosts
@ -460,6 +460,12 @@ touch %{buildroot}%{_sharedstatedir}/glusterd/options
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/delete
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/delete/post
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/delete/pre
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/copy-file
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/copy-file/post
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/copy-file/pre
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/gsync-create
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/gsync-create/post
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/hooks/1/gsync-create/pre
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/glustershd
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/peers
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd/vols
@ -521,8 +527,10 @@ fi
%{_libexecdir}/glusterfs/gsyncd
%{_libexecdir}/glusterfs/python/syncdaemon/*
%{_libexecdir}/glusterfs/gverify.sh
%{_libexecdir}/glusterfs/peer_add_secret_pub
%{_libexecdir}/glusterfs/peer_gsec_create
%ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/geo-replication
%ghost %attr(0644,-,-) %{_sharedstatedir}/glusterd/geo-replication/gsyncd.conf
%ghost %attr(0644,-,-) %{_sharedstatedir}/glusterd/geo-replication/gsyncd_template.conf
%endif
%files fuse
@ -697,6 +705,9 @@ if [ $1 -ge 1 ]; then
fi
%changelog
* Thu Jul 25 2013 Csaba Henk <csaba@redhat.com>
- Added peer_add_secret_pub and peer_gsec_create to %{_libexecdir}/glusterfs
* Thu Jul 25 2013 Aravinda VK <avishwan@redhat.com>
- Added gverify.sh to %{_libexecdir}/glusterfs directory.

View File

@ -158,6 +158,8 @@ enum gluster_cli_procnum {
GLUSTER_CLI_UUID_RESET,
GLUSTER_CLI_BD_OP,
GLUSTER_CLI_UUID_GET,
GLUSTER_CLI_COPY_FILE,
GLUSTER_CLI_SYS_EXEC,
GLUSTER_CLI_MAXVALUE,
};

View File

@ -121,6 +121,8 @@ enum gf1_cli_gsync_set {
GF_GSYNC_OPTION_TYPE_CONFIG = 3,
GF_GSYNC_OPTION_TYPE_STATUS = 4,
GF_GSYNC_OPTION_TYPE_ROTATE = 5,
GF_GSYNC_OPTION_TYPE_CREATE = 6,
GF_GSYNC_OPTION_TYPE_DELETE = 7,
};
typedef enum gf1_cli_gsync_set gf1_cli_gsync_set;

View File

@ -51,7 +51,8 @@ enum gf_quota_type {
};
enum gf1_cli_friends_list {
GF_CLI_LIST_ALL = 1
GF_CLI_LIST_PEERS = 1,
GF_CLI_LIST_POOL_NODES = 2
} ;
enum gf1_cli_get_volume {
@ -74,7 +75,9 @@ enum gf1_cli_gsync_set {
GF_GSYNC_OPTION_TYPE_STOP,
GF_GSYNC_OPTION_TYPE_CONFIG,
GF_GSYNC_OPTION_TYPE_STATUS,
GF_GSYNC_OPTION_TYPE_ROTATE
GF_GSYNC_OPTION_TYPE_ROTATE,
GF_GSYNC_OPTION_TYPE_DELETE,
GF_GSYNC_OPTION_TYPE_CREATE
};
enum gf1_cli_stats_op {

File diff suppressed because it is too large Load Diff

View File

@ -3922,6 +3922,8 @@ rpcsvc_actor_t gd_svc_cli_actors[] = {
#ifdef HAVE_BD_XLATOR
[GLUSTER_CLI_BD_OP] = {"BD_OP", GLUSTER_CLI_BD_OP, glusterd_handle_cli_bd_op, NULL, 0, DRC_NA},
#endif
[GLUSTER_CLI_COPY_FILE] = {"COPY_FILE", GLUSTER_CLI_COPY_FILE, glusterd_handle_copy_file, NULL, 0, DRC_NA},
[GLUSTER_CLI_SYS_EXEC] = {"SYS_EXEC", GLUSTER_CLI_SYS_EXEC, glusterd_handle_sys_exec, NULL, 0, DRC_NA},
};
struct rpcsvc_program gd_svc_cli_prog = {

View File

@ -49,6 +49,7 @@ char glusterd_hook_dirnames[GD_OP_MAX][256] =
[GD_OP_RESET_VOLUME] = EMPTY,
[GD_OP_SYNC_VOLUME] = EMPTY,
[GD_OP_LOG_ROTATE] = EMPTY,
[GD_OP_GSYNC_CREATE] = "gsync-create",
[GD_OP_GSYNC_SET] = EMPTY,
[GD_OP_PROFILE_VOLUME] = EMPTY,
[GD_OP_QUOTA] = EMPTY,
@ -185,6 +186,7 @@ static int
glusterd_hooks_add_op_args (runner_t *runner, glusterd_op_t op,
dict_t *op_ctx, glusterd_commit_hook_type_t type)
{
char *hooks_args = NULL;
int vol_count = 0;
gf_boolean_t truth = _gf_false;
glusterd_volinfo_t *voliter = NULL;
@ -236,6 +238,18 @@ glusterd_hooks_add_op_args (runner_t *runner, glusterd_op_t op,
ret = glusterd_hooks_set_volume_args (op_ctx, runner);
break;
case GD_OP_GSYNC_CREATE:
ret = dict_get_str (op_ctx, "hooks_args", &hooks_args);
if (ret)
gf_log ("", GF_LOG_DEBUG,
"No Hooks Arguments.");
else
gf_log ("", GF_LOG_DEBUG,
"Hooks Args = %s", hooks_args);
if (hooks_args)
runner_argprintf (runner, "%s", hooks_args);
break;
default:
break;

View File

@ -2504,12 +2504,13 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx)
}
break;
case GD_OP_GSYNC_CREATE:
case GD_OP_GSYNC_SET:
{
ret = glusterd_op_gsync_args_get (dict,
&errstr,
&volname,
NULL);
NULL, NULL);
if (ret == 0) {
ret = glusterd_dict_set_volid
(dict, volname, op_errstr);
@ -2622,6 +2623,18 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx)
}
break;
case GD_OP_COPY_FILE:
{
dict_copy (dict, req_dict);
break;
}
case GD_OP_SYS_EXEC:
{
dict_copy (dict, req_dict);
break;
}
default:
break;
}
@ -3755,6 +3768,10 @@ glusterd_op_stage_validate (glusterd_op_t op, dict_t *dict, char **op_errstr,
ret = glusterd_op_stage_sync_volume (dict, op_errstr);
break;
case GD_OP_GSYNC_CREATE:
ret = glusterd_op_stage_gsync_create (dict, op_errstr);
break;
case GD_OP_GSYNC_SET:
ret = glusterd_op_stage_gsync_set (dict, op_errstr);
break;
@ -3793,13 +3810,21 @@ glusterd_op_stage_validate (glusterd_op_t op, dict_t *dict, char **op_errstr,
ret = glusterd_op_stage_bd (dict, op_errstr);
break;
#endif
case GD_OP_COPY_FILE:
ret = glusterd_op_stage_copy_file (dict, op_errstr);
break;
case GD_OP_SYS_EXEC:
ret = glusterd_op_stage_sys_exec (dict, op_errstr);
break;
default:
gf_log (this->name, GF_LOG_ERROR, "Unknown op %s",
gd_op_list[op]);
}
gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
gf_log (this->name, GF_LOG_DEBUG, "OP = %d. Returning %d", op, ret);
return ret;
}
@ -3857,6 +3882,11 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr,
ret = glusterd_op_sync_volume (dict, op_errstr, rsp_dict);
break;
case GD_OP_GSYNC_CREATE:
ret = glusterd_op_gsync_create (dict, op_errstr,
rsp_dict);
break;
case GD_OP_GSYNC_SET:
ret = glusterd_op_gsync_set (dict, op_errstr, rsp_dict);
break;
@ -3896,6 +3926,15 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr,
ret = 0;
break;
#endif
case GD_OP_COPY_FILE:
ret = glusterd_op_copy_file (dict, op_errstr);
break;
case GD_OP_SYS_EXEC:
ret = glusterd_op_sys_exec (dict, op_errstr, rsp_dict);
break;
default:
gf_log (this->name, GF_LOG_ERROR, "Unknown op %s",
gd_op_list[op]);
@ -3904,8 +3943,8 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr,
if (ret == 0)
glusterd_op_commit_hook (op, dict, GD_COMMIT_HOOK_POST);
gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}

View File

@ -15,8 +15,8 @@
#include "config.h"
#endif
#ifndef GSYNC_CONF
#define GSYNC_CONF GEOREP"/gsyncd.conf"
#ifndef GSYNC_CONF_TEMPLATE
#define GSYNC_CONF_TEMPLATE GEOREP"/gsyncd_template.conf"
#endif
#include <pthread.h>
@ -270,7 +270,7 @@ glusterd_are_all_volumes_stopped ();
int
glusterd_stop_bricks (glusterd_volinfo_t *volinfo);
int
gsync_status (char *master, char *slave, int *status);
gsync_status (char *master, char *slave, char *conf_path, int *status);
int
glusterd_check_gsync_running (glusterd_volinfo_t *volinfo, gf_boolean_t *flag);

View File

@ -84,6 +84,7 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
}
break;
}
case GD_OP_GSYNC_CREATE:
case GD_OP_GSYNC_SET:
{
if (ctx) {
@ -146,6 +147,21 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
/*nothing specific to be done*/
break;
}
case GD_OP_COPY_FILE:
{
if (ctx)
ret = dict_get_str (ctx, "errstr", &errstr);
break;
}
case GD_OP_SYS_EXEC:
{
if (ctx) {
ret = dict_get_str (ctx, "errstr", &errstr);
ret = dict_set_str (ctx, "glusterd_workdir",
conf->workdir);
}
break;
}
}
rsp.op_ret = op_ret;

View File

@ -32,14 +32,77 @@ gd_synctask_barrier_wait (struct syncargs *args, int count)
static void
gd_collate_errors (struct syncargs *args, int op_ret, int op_errno,
char *op_errstr)
char *op_errstr, int op_code,
glusterd_peerinfo_t *peerinfo, u_char *uuid)
{
if (args->op_ret)
return;
args->op_ret = op_ret;
args->op_errno = op_errno;
if (op_ret && op_errstr && strcmp (op_errstr, ""))
args->errstr = gf_strdup (op_errstr);
char err_str[PATH_MAX] = "Please check log file for details.";
char op_err[PATH_MAX] = "";
int len = -1;
char *peer_str = NULL;
if (op_ret) {
args->op_ret = op_ret;
args->op_errno = op_errno;
if (peerinfo)
peer_str = peerinfo->hostname;
else
peer_str = uuid_utoa (uuid);
if (op_errstr && strcmp (op_errstr, "")) {
len = snprintf (err_str, sizeof(err_str) - 1,
"Error: %s", op_errstr);
err_str[len] = '\0';
}
switch (op_code){
case GLUSTERD_MGMT_CLUSTER_LOCK :
{
len = snprintf (op_err, sizeof(op_err) - 1,
"Locking failed on %s. %s",
peer_str, err_str);
break;
}
case GLUSTERD_MGMT_CLUSTER_UNLOCK :
{
len = snprintf (op_err, sizeof(op_err) - 1,
"Unlocking failed on %s. %s",
peer_str, err_str);
break;
}
case GLUSTERD_MGMT_STAGE_OP :
{
len = snprintf (op_err, sizeof(op_err) - 1,
"Staging failed on %s. %s",
peer_str, err_str);
break;
}
case GLUSTERD_MGMT_COMMIT_OP :
{
len = snprintf (op_err, sizeof(op_err) - 1,
"Commit failed on %s. %s",
peer_str, err_str);
break;
}
}
op_err[len] = '\0';
if (args->errstr) {
len = snprintf (err_str, sizeof(err_str) - 1,
"%s\n%s", args->errstr,
op_err);
GF_FREE (args->errstr);
args->errstr = NULL;
} else
len = snprintf (err_str, sizeof(err_str) - 1,
"%s", op_err);
err_str[len] = '\0';
gf_log ("", GF_LOG_ERROR, "%s", op_err);
args->errstr = gf_strdup (err_str);
}
return;
}
static void
@ -169,6 +232,9 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp)
goto out;
break;
case GD_OP_GSYNC_CREATE:
break;
case GD_OP_GSYNC_SET:
ret = glusterd_gsync_use_rsp_dict (aggr, rsp, NULL);
if (ret)
@ -203,6 +269,12 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp)
break;
case GD_OP_SYS_EXEC:
ret = glusterd_sys_exec_output_rsp_dict (aggr, rsp);
if (ret)
goto out;
break;
default:
break;
}
@ -246,7 +318,8 @@ _gd_syncop_mgmt_lock_cbk (struct rpc_req *req, struct iovec *iov,
op_ret = rsp.op_ret;
op_errno = rsp.op_errno;
out:
gd_collate_errors (args, op_ret, op_errno, NULL);
gd_collate_errors (args, op_ret, op_errno, NULL,
GLUSTERD_MGMT_CLUSTER_LOCK, peerinfo, rsp.uuid);
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@ -312,7 +385,8 @@ _gd_syncop_mgmt_unlock_cbk (struct rpc_req *req, struct iovec *iov,
op_ret = rsp.op_ret;
op_errno = rsp.op_errno;
out:
gd_collate_errors (args, op_ret, op_errno, NULL);
gd_collate_errors (args, op_ret, op_errno, NULL,
GLUSTERD_MGMT_CLUSTER_UNLOCK, peerinfo, rsp.uuid);
STACK_DESTROY (frame->root);
synctask_barrier_wake(args);
return 0;
@ -356,6 +430,7 @@ _gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
xlator_t *this = NULL;
dict_t *rsp_dict = NULL;
call_frame_t *frame = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
int op_ret = -1;
int op_errno = -1;
@ -389,6 +464,15 @@ _gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
}
}
ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo);
if (ret) {
gf_log (this->name, GF_LOG_CRITICAL, "Staging response "
"for 'Volume %s' received from unknown "
"peer: %s", gd_op_list[rsp.op],
uuid_utoa (rsp.uuid));
goto out;
}
uuid_copy (args->uuid, rsp.uuid);
if (rsp.op == GD_OP_REPLACE_BRICK) {
pthread_mutex_lock (&args->lock_dict);
@ -407,7 +491,9 @@ _gd_syncop_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
op_errno = rsp.op_errno;
out:
gd_collate_errors (args, op_ret, op_errno, rsp.op_errstr);
gd_collate_errors (args, op_ret, op_errno, rsp.op_errstr,
GLUSTERD_MGMT_STAGE_OP, peerinfo, rsp.uuid);
if (rsp_dict)
dict_unref (rsp_dict);
@ -588,14 +674,15 @@ int32_t
_gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
int ret = -1;
gd1_mgmt_commit_op_rsp rsp = {{0},};
struct syncargs *args = NULL;
xlator_t *this = NULL;
dict_t *rsp_dict = NULL;
call_frame_t *frame = NULL;
int op_ret = -1;
int op_errno = -1;
int ret = -1;
gd1_mgmt_commit_op_rsp rsp = {{0},};
struct syncargs *args = NULL;
xlator_t *this = NULL;
dict_t *rsp_dict = NULL;
call_frame_t *frame = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
int op_ret = -1;
int op_errno = -1;
this = THIS;
frame = myframe;
@ -628,6 +715,15 @@ _gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
}
}
ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo);
if (ret) {
gf_log (this->name, GF_LOG_CRITICAL, "Commit response "
"for 'Volume %s' received from unknown "
"peer: %s", gd_op_list[rsp.op],
uuid_utoa (rsp.uuid));
goto out;
}
uuid_copy (args->uuid, rsp.uuid);
pthread_mutex_lock (&args->lock_dict);
{
@ -642,8 +738,10 @@ _gd_syncop_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
op_ret = rsp.op_ret;
op_errno = rsp.op_errno;
out:
gd_collate_errors (args, op_ret, op_errno, rsp.op_errstr);
gd_collate_errors (args, op_ret, op_errno, rsp.op_errstr,
GLUSTERD_MGMT_COMMIT_OP, peerinfo, rsp.uuid);
if (rsp_dict)
dict_unref (rsp_dict);
@ -816,12 +914,16 @@ stage_done:
peer_cnt++;
}
gd_synctask_barrier_wait((&args), peer_cnt);
ret = args.op_ret;
if (dict_get_str (op_ctx, "errstr", &errstr) == 0)
*op_errstr = gf_strdup (errstr);
else if (args.errstr)
*op_errstr = gf_strdup (args.errstr);
if (args.errstr)
*op_errstr = gf_strdup (args.errstr);
else if (dict_get_str (op_ctx, "errstr", &errstr) == 0)
*op_errstr = gf_strdup (errstr);
ret = args.op_ret;
gf_log (this->name, GF_LOG_DEBUG, "Sent stage op req for 'Volume %s' "
"to %d peers", gd_op_list[op], peer_cnt);
out:
if (rsp_dict)
dict_unref (rsp_dict);
@ -881,6 +983,7 @@ commit_done:
ret = 0;
goto out;
}
gd_syncargs_init (&args, op_ctx);
synctask_barrier_init((&args));
peer_cnt = 0;
@ -892,17 +995,23 @@ commit_done:
}
gd_synctask_barrier_wait((&args), peer_cnt);
ret = args.op_ret;
if (dict_get_str (op_ctx, "errstr", &errstr) == 0)
if (args.errstr)
*op_errstr = gf_strdup (args.errstr);
else if (dict_get_str (op_ctx, "errstr", &errstr) == 0)
*op_errstr = gf_strdup (errstr);
else if (args.errstr)
*op_errstr = gf_strdup (args.errstr);
gf_log (this->name, GF_LOG_DEBUG, "Sent commit op req for 'Volume %s' "
"to %d peers", gd_op_list[op], peer_cnt);
out:
if (!ret)
glusterd_op_modify_op_ctx (op, op_ctx);
if (rsp_dict)
dict_unref (rsp_dict);
GF_FREE (args.errstr);
args.errstr = NULL;
return ret;
}
@ -1108,8 +1217,10 @@ out:
if (req_dict)
dict_unref (req_dict);
if (op_errstr)
if (op_errstr) {
GF_FREE (op_errstr);
op_errstr = NULL;
}
return;
}

View File

@ -3969,10 +3969,13 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
int
_local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
{
char *path_list = NULL;
char *slave = NULL;
int uuid_len = 0;
int ret = 0;
char uuid_str[64] = {0};
glusterd_volinfo_t *volinfo = NULL;
char *conf_path = NULL;
volinfo = data;
GF_ASSERT (volinfo);
@ -3984,9 +3987,24 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
uuid_len = (slave - value->data - 1);
strncpy (uuid_str, (char*)value->data, uuid_len);
glusterd_start_gsync (volinfo, slave, uuid_str, NULL);
return 0;
ret = glusterd_get_local_brickpaths (volinfo, &path_list);
ret = dict_get_str (this, "conf_path", &conf_path);
if (ret) {
gf_log ("", GF_LOG_ERROR,
"Unable to fetch conf file path.");
goto out;
}
glusterd_start_gsync (volinfo, slave, path_list, conf_path,
uuid_str, NULL);
GF_FREE (path_list);
path_list = NULL;
out:
return ret;
}
int
@ -5424,13 +5442,93 @@ glusterd_delete_all_bricks (glusterd_volinfo_t* volinfo)
return ret;
}
int
glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo, char **pathlist)
{
char **path_tokens = NULL;
char *tmp_path_list = NULL;
char path[PATH_MAX] = "";
int32_t count = 0;
int32_t pathlen = 0;
int32_t total_len = 0;
int32_t ret = 0;
int i = 0;
glusterd_brickinfo_t *brickinfo = NULL;
if ((!volinfo) || (!pathlist))
goto out;
path_tokens = GF_CALLOC (sizeof(char*), volinfo->brick_count,
gf_gld_mt_charptr);
if (!path_tokens) {
gf_log ("", GF_LOG_DEBUG, "Could not allocate memory.");
ret = -1;
goto out;
}
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
if (uuid_compare (brickinfo->uuid, MY_UUID))
continue;
pathlen = snprintf (path, sizeof(path),
"--path=%s ", brickinfo->path);
if (pathlen < sizeof(path))
path[pathlen] = '\0';
else
path[sizeof(path)-1] = '\0';
path_tokens[count] = gf_strdup (path);
if (!path_tokens[count]) {
gf_log ("", GF_LOG_DEBUG,
"Could not allocate memory.");
ret = -1;
goto out;
}
count++;
total_len += pathlen;
}
tmp_path_list = GF_CALLOC (sizeof(char), total_len + 1,
gf_gld_mt_char);
if (!tmp_path_list) {
gf_log ("", GF_LOG_DEBUG, "Could not allocate memory.");
ret = -1;
goto out;
}
for (i = 0; i < count; i++)
strcat (tmp_path_list, path_tokens[i]);
if (count)
*pathlist = tmp_path_list;
ret = count;
out:
for (i = 0; i < count; i++) {
GF_FREE (path_tokens[i]);
path_tokens[i] = NULL;
}
GF_FREE (path_tokens);
path_tokens = NULL;
if (ret == 0) {
gf_log ("", GF_LOG_DEBUG, "No Local Bricks Present.");
GF_FREE (tmp_path_list);
tmp_path_list = NULL;
}
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
int
glusterd_start_gsync (glusterd_volinfo_t *master_vol, char *slave,
char *glusterd_uuid_str, char **op_errstr)
char *path_list, char *conf_path,
char *glusterd_uuid_str,
char **op_errstr)
{
int32_t ret = 0;
int32_t status = 0;
char buf[PATH_MAX] = {0,};
char uuid_str [64] = {0};
runner_t runner = {0,};
xlator_t *this = NULL;
@ -5443,32 +5541,23 @@ glusterd_start_gsync (glusterd_volinfo_t *master_vol, char *slave,
GF_ASSERT (priv);
uuid_utoa_r (MY_UUID, uuid_str);
if (strcmp (uuid_str, glusterd_uuid_str))
goto out;
ret = gsync_status (master_vol->volname, slave, &status);
if (!path_list) {
ret = 0;
gf_log ("", GF_LOG_DEBUG, "No Bricks in this node."
" Not starting gsyncd.");
goto out;
}
ret = gsync_status (master_vol->volname, slave, conf_path, &status);
if (status == 0)
goto out;
snprintf (buf, PATH_MAX, "%s/"GEOREP"/%s", priv->workdir, master_vol->volname);
ret = mkdir_p (buf, 0777, _gf_true);
if (ret) {
errcode = -1;
goto out;
}
snprintf (buf, PATH_MAX, DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"/%s",
master_vol->volname);
ret = mkdir_p (buf, 0777, _gf_true);
if (ret) {
errcode = -1;
goto out;
}
uuid_utoa_r (master_vol->volume_id, uuid_str);
runinit (&runner);
runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "-c", NULL);
runner_argprintf (&runner, "%s/"GSYNC_CONF, priv->workdir);
runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd",
path_list, "-c", NULL);
runner_argprintf (&runner, "%s", conf_path);
runner_argprintf (&runner, ":%s", master_vol->volname);
runner_add_args (&runner, slave, "--config-set", "session-owner",
uuid_str, NULL);
@ -5481,9 +5570,12 @@ glusterd_start_gsync (glusterd_volinfo_t *master_vol, char *slave,
}
runinit (&runner);
runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "--monitor", "-c", NULL);
runner_argprintf (&runner, "%s/"GSYNC_CONF, priv->workdir);
runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd",
path_list, "--monitor", "-c", NULL);
runner_argprintf (&runner, "%s", conf_path);
runner_argprintf (&runner, ":%s", master_vol->volname);
runner_argprintf (&runner, "--glusterd-uuid=%s",
uuid_utoa (priv->uuid));
runner_add_arg (&runner, slave);
synclock_unlock (&priv->big_lock);
ret = runner_run (&runner);
@ -5499,7 +5591,7 @@ glusterd_start_gsync (glusterd_volinfo_t *master_vol, char *slave,
out:
if ((ret != 0) && errcode == -1) {
if (op_errstr)
*op_errstr = gf_strdup ("internal error, cannot start"
*op_errstr = gf_strdup ("internal error, cannot start "
"the " GEOREP " session");
}
@ -6852,6 +6944,61 @@ out:
return ret;
}
int
glusterd_sys_exec_output_rsp_dict (dict_t *dst, dict_t *src)
{
char output_name[PATH_MAX] = "";
char *output = NULL;
int ret = 0;
int i = 0;
int len = 0;
int src_output_count = 0;
int dst_output_count = 0;
if (!dst || !src) {
gf_log ("", GF_LOG_ERROR, "Source or Destination "
"dict is empty.");
goto out;
}
ret = dict_get_int32 (dst, "output_count", &dst_output_count);
ret = dict_get_int32 (src, "output_count", &src_output_count);
if (ret) {
gf_log ("", GF_LOG_DEBUG, "No output from source");
ret = 0;
goto out;
}
for (i = 1; i <= src_output_count; i++) {
len = snprintf (output_name, sizeof(output_name) - 1,
"output_%d", i);
output_name[len] = '\0';
ret = dict_get_str (src, output_name, &output);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to fetch %s",
output_name);
goto out;
}
len = snprintf (output_name, sizeof(output_name) - 1,
"output_%d", i+dst_output_count);
output_name[len] = '\0';
ret = dict_set_dynstr (dst, output_name, gf_strdup (output));
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to set %s",
output_name);
goto out;
}
}
ret = dict_set_int32 (dst, "output_count",
dst_output_count+src_output_count);
out:
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
int
glusterd_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
{
@ -7404,3 +7551,39 @@ gd_is_remove_brick_committed (glusterd_volinfo_t *volinfo)
return _gf_true;
}
gf_boolean_t
glusterd_are_vol_all_peers_up (glusterd_volinfo_t *volinfo,
struct list_head *peers,
char **down_peerstr)
{
glusterd_peerinfo_t *peerinfo = NULL;
glusterd_brickinfo_t *brickinfo = NULL;
gf_boolean_t ret = _gf_false;
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
if (!uuid_compare (brickinfo->uuid, MY_UUID))
continue;
list_for_each_entry (peerinfo, peers, uuid_list) {
if (uuid_compare (peerinfo->uuid, brickinfo->uuid))
continue;
/*Found peer who owns the brick, return false
* if peer is not connected or not friend */
if (!(peerinfo->connected) ||
(peerinfo->state.state !=
GD_FRIEND_STATE_BEFRIENDED)) {
*down_peerstr = gf_strdup (peerinfo->hostname);
gf_log ("", GF_LOG_DEBUG, "Peer %s is down. ",
peerinfo->hostname);
goto out;
}
}
}
ret = _gf_true;
out:
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}

View File

@ -367,7 +367,13 @@ int
glusterd_restart_gsyncds (glusterd_conf_t *conf);
int
glusterd_start_gsync (glusterd_volinfo_t *master_vol, char *slave,
char *glusterd_uuid_str, char **op_errstr);
char *path_list, char *conf_path,
char *glusterd_uuid_str,
char **op_errstr);
int
glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo,
char **pathlist);
int32_t
glusterd_recreate_bricks (glusterd_conf_t *conf);
int32_t
@ -471,6 +477,8 @@ int
glusterd_volume_heal_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict);
int
glusterd_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict);
int
glusterd_sys_exec_output_rsp_dict (dict_t *aggr, dict_t *rsp_dict);
int32_t
glusterd_handle_node_rsp (dict_t *req_ctx, void *pending_entry,
glusterd_op_t op, dict_t *rsp_dict, dict_t *op_ctx,
@ -487,6 +495,11 @@ glusterd_profile_volume_brick_rsp (void *pending_entry,
dict_t *rsp_dict, dict_t *op_ctx,
char **op_errstr, gd_node_type type);
gf_boolean_t
glusterd_are_vol_all_peers_up (glusterd_volinfo_t *volinfo,
struct list_head *peers,
char **down_peerstr);
/* Should be used only when an operation is in progress, as that is the only
* time a lock_owner is set
*/
@ -531,4 +544,9 @@ gd_peer_uuid_str (glusterd_peerinfo_t *peerinfo);
gf_boolean_t
gd_is_remove_brick_committed (glusterd_volinfo_t *volinfo);
gf_boolean_t
glusterd_are_vol_all_peers_up (glusterd_volinfo_t *volinfo,
struct list_head *peers,
char **down_peerstr);
#endif

View File

@ -23,6 +23,7 @@
#define VKEY_DIAG_LAT_MEASUREMENT "diagnostics.latency-measurement"
#define VKEY_FEATURES_LIMIT_USAGE "features.limit-usage"
#define VKEY_MARKER_XTIME GEOREP".indexing"
#define VKEY_CHANGELOG "changelog.changelog"
#define VKEY_FEATURES_QUOTA "features.quota"
#define AUTH_ALLOW_MAP_KEY "auth.allow"

View File

@ -94,6 +94,9 @@ const char *gd_op_list[GD_OP_MAX + 1] = {
[GD_OP_LIST_VOLUME] = "Lists",
[GD_OP_CLEARLOCKS_VOLUME] = "Clear locks",
[GD_OP_DEFRAG_BRICK_VOLUME] = "Rebalance",
[GD_OP_COPY_FILE] = "Copy File",
[GD_OP_SYS_EXEC] = "Execute system commands",
[GD_OP_GSYNC_CREATE] = "Geo-replication Create",
[GD_OP_MAX] = "Invalid op"
};
@ -519,7 +522,7 @@ runinit_gsyncd_setrx (runner_t *runner, glusterd_conf_t *conf)
{
runinit (runner);
runner_add_args (runner, GSYNCD_PREFIX"/gsyncd", "-c", NULL);
runner_argprintf (runner, "%s/"GSYNC_CONF,conf->workdir);
runner_argprintf (runner, "%s/"GSYNC_CONF_TEMPLATE, conf->workdir);
runner_add_arg (runner, "--config-set-rx");
}
@ -581,7 +584,7 @@ configure_syncdaemon (glusterd_conf_t *conf)
/* gluster-params */
runinit_gsyncd_setrx (&runner, conf);
runner_add_args (&runner, "gluster-params",
"xlator-option=*-dht.assert-no-child-down=true",
"aux-gfid-mount xlator-option=*-dht.assert-no-child-down=true",
".", ".", NULL);
RUN_GSYNCD_CMD;
@ -598,14 +601,30 @@ configure_syncdaemon (glusterd_conf_t *conf)
/* pid-file */
runinit_gsyncd_setrx (&runner, conf);
runner_add_arg (&runner, "pid-file");
runner_argprintf (&runner, "%s/${mastervol}/${eSlave}.pid", georepdir);
runner_argprintf (&runner, "%s/${mastervol}-${slavevol}/${eSlave}.pid", georepdir);
runner_add_args (&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* state-file */
runinit_gsyncd_setrx (&runner, conf);
runner_add_arg (&runner, "state-file");
runner_argprintf (&runner, "%s/${mastervol}/${eSlave}.status", georepdir);
runner_argprintf (&runner, "%s/${mastervol}-${slavevol}/${eSlave}.status", georepdir);
runner_add_args (&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* state-detail-file */
runinit_gsyncd_setrx (&runner, conf);
runner_add_arg (&runner, "state-detail-file");
runner_argprintf (&runner, "%s/${mastervol}-${slavevol}/${eSlave}-detail.status",
georepdir);
runner_add_args (&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* state-detail-file */
runinit_gsyncd_setrx (&runner, conf);
runner_add_arg (&runner, "state-detail-file");
runner_argprintf (&runner, "%s/${mastervol}-${slavevol}/${eSlave}-detail.status",
georepdir);
runner_add_args (&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
@ -647,6 +666,18 @@ configure_syncdaemon (glusterd_conf_t *conf)
runner_add_args (&runner, "special-sync-mode", "partial", ".", ".", NULL);
RUN_GSYNCD_CMD;
/* change-detector == changelog */
runinit_gsyncd_setrx (&runner, conf);
runner_add_args(&runner, "change-detector", "changelog", ".", ".", NULL);
RUN_GSYNCD_CMD;
runinit_gsyncd_setrx (&runner, conf);
runner_add_arg(&runner, "working-dir");
runner_argprintf(&runner, "%s/${mastervol}/${eSlave}",
DEFAULT_VAR_RUN_DIRECTORY);
runner_add_args (&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/************
* slave pre-configuration
************/
@ -660,7 +691,7 @@ configure_syncdaemon (glusterd_conf_t *conf)
/* gluster-params */
runinit_gsyncd_setrx (&runner, conf);
runner_add_args (&runner, "gluster-params",
"xlator-option=*-dht.assert-no-child-down=true",
"aux-gfid-mount xlator-option=*-dht.assert-no-child-down=true",
".", NULL);
RUN_GSYNCD_CMD;
@ -967,6 +998,7 @@ init (xlator_t *this)
first_time = 1;
}
setenv ("GLUSTERD_WORKING_DIR", workdir, 1);
gf_log (this->name, GF_LOG_INFO, "Using %s as working directory",
workdir);

View File

@ -47,6 +47,7 @@
#define GLUSTERD_QUORUM_TYPE_KEY "cluster.server-quorum-type"
#define GLUSTERD_QUORUM_RATIO_KEY "cluster.server-quorum-ratio"
#define GLUSTERD_GLOBAL_OPT_VERSION "global-option-version"
#define GLUSTERD_COMMON_PEM_PUB_FILE "/geo-replication/common_secret.pem.pub"
#define GLUSTERD_SERVER_QUORUM "server"
@ -95,6 +96,9 @@ typedef enum glusterd_op_ {
GD_OP_CLEARLOCKS_VOLUME,
GD_OP_DEFRAG_BRICK_VOLUME,
GD_OP_BD_OP,
GD_OP_COPY_FILE,
GD_OP_SYS_EXEC,
GD_OP_GSYNC_CREATE,
GD_OP_MAX,
} glusterd_op_t;
@ -601,6 +605,12 @@ glusterd_handle_set_volume (rpcsvc_request_t *req);
int
glusterd_handle_reset_volume (rpcsvc_request_t *req);
int
glusterd_handle_copy_file (rpcsvc_request_t *req);
int
glusterd_handle_sys_exec (rpcsvc_request_t *req);
int
glusterd_handle_gsync_set (rpcsvc_request_t *req);
@ -685,6 +695,12 @@ int glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr);
int glusterd_op_heal_volume (dict_t *dict, char **op_errstr);
int glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr);
int glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict);
int glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr);
int glusterd_op_copy_file (dict_t *dict, char **op_errstr);
int glusterd_op_stage_sys_exec (dict_t *dict, char **op_errstr);
int glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict);
int glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr);
int glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict);
int glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict);
int glusterd_op_stage_quota (dict_t *dict, char **op_errstr);
int glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
@ -726,7 +742,7 @@ int glusterd_op_statedump_volume_args_get (dict_t *dict, char **volname,
char **options, int *option_cnt);
int glusterd_op_gsync_args_get (dict_t *dict, char **op_errstr,
char **master, char **slave);
char **master, char **slave, char **host_uuid);
/* Synctask part */
int32_t glusterd_op_begin_synctask (rpcsvc_request_t *req, glusterd_op_t op,
void *dict);