glusterd: Add geo-replication session details to get-state output
This commit adds support to the get-state CLI to capture details on geo-replication session as obtained in `gluster volume geo-replication status detail` in its output. Fixes: #291 Change-Id: I2fbcba70bfdaf439522637234805545194777ed4 Signed-off-by: Samikshan Bairagya <samikshan@gmail.com> Reviewed-on: https://review.gluster.org/17941 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Shubhendu Tripathi <shtripat@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
This commit is contained in:
parent
590ae48c65
commit
2e7daeffef
1
.gitignore
vendored
1
.gitignore
vendored
@ -92,6 +92,7 @@ libglusterfs/src/y.tab.h
|
||||
libglusterfs/src/defaults.c
|
||||
libglusterfs/src/glusterfs-fops.h
|
||||
libglusterfs/src/cli1-xdr.h
|
||||
libglusterfs/src/protocol-common.h
|
||||
libtool
|
||||
# copied XDR for cyclic libglusterfs <-> rpc-header dependency
|
||||
rpc/xdr/gen/*.x
|
||||
|
@ -5622,39 +5622,6 @@ gf_cli_gsync_config_command (dict_t *dict)
|
||||
return runner_run (&runner);
|
||||
}
|
||||
|
||||
char*
|
||||
get_struct_variable (int mem_num, gf_gsync_status_t *sts_val)
|
||||
{
|
||||
switch (mem_num) {
|
||||
case 0: return (sts_val->node);
|
||||
case 1: return (sts_val->master);
|
||||
case 2: return (sts_val->brick);
|
||||
case 3: return (sts_val->slave_user);
|
||||
case 4: return (sts_val->slave);
|
||||
case 5: return (sts_val->slave_node);
|
||||
case 6: return (sts_val->worker_status);
|
||||
case 7: return (sts_val->crawl_status);
|
||||
case 8: return (sts_val->last_synced);
|
||||
case 9: return (sts_val->entry);
|
||||
case 10: return (sts_val->data);
|
||||
case 11: return (sts_val->meta);
|
||||
case 12: return (sts_val->failures);
|
||||
case 13: return (sts_val->checkpoint_time);
|
||||
case 14: return (sts_val->checkpoint_completed);
|
||||
case 15: return (sts_val->checkpoint_completion_time);
|
||||
case 16: return (sts_val->brick_host_uuid);
|
||||
case 17: return (sts_val->last_synced_utc);
|
||||
case 18: return (sts_val->checkpoint_time_utc);
|
||||
case 19: return (sts_val->checkpoint_completion_time_utc);
|
||||
case 20: return (sts_val->slavekey);
|
||||
case 21: return (sts_val->session_slave);
|
||||
default:
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
gf_cli_print_status (char **title_values,
|
||||
|
@ -38,9 +38,12 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
|
||||
compound-fop-utils.c throttle-tbf.c
|
||||
|
||||
nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c defaults.c
|
||||
nodist_libglusterfs_la_HEADERS = y.tab.h
|
||||
nodist_libglusterfs_la_HEADERS = y.tab.h protocol-common.h
|
||||
|
||||
BUILT_SOURCES = graph.lex.c defaults.c eventtypes.h
|
||||
BUILT_SOURCES = graph.lex.c defaults.c eventtypes.h protocol-common.h
|
||||
|
||||
protocol-common.h: $(top_srcdir)/rpc/rpc-lib/src/protocol-common.h
|
||||
cp $(top_srcdir)/rpc/rpc-lib/src/protocol-common.h .
|
||||
|
||||
libglusterfs_la_HEADERS = common-utils.h defaults.h default-args.h \
|
||||
dict.h glusterfs.h hashfn.h timespec.h logging.h xlator.h \
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "xxhash.h"
|
||||
#include <ifaddrs.h>
|
||||
#include "libglusterfs-messages.h"
|
||||
#include "protocol-common.h"
|
||||
|
||||
#ifndef AI_ADDRCONFIG
|
||||
#define AI_ADDRCONFIG 0
|
||||
@ -4930,3 +4931,38 @@ glusterfs_compute_sha256 (const unsigned char *content, size_t size,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char*
|
||||
get_struct_variable (int mem_num, gf_gsync_status_t *sts_val)
|
||||
{
|
||||
switch (mem_num) {
|
||||
case 0: return (sts_val->node);
|
||||
case 1: return (sts_val->master);
|
||||
case 2: return (sts_val->brick);
|
||||
case 3: return (sts_val->slave_user);
|
||||
case 4: return (sts_val->slave);
|
||||
case 5: return (sts_val->slave_node);
|
||||
case 6: return (sts_val->worker_status);
|
||||
case 7: return (sts_val->crawl_status);
|
||||
case 8: return (sts_val->last_synced);
|
||||
case 9: return (sts_val->entry);
|
||||
case 10: return (sts_val->data);
|
||||
case 11: return (sts_val->meta);
|
||||
case 12: return (sts_val->failures);
|
||||
case 13: return (sts_val->checkpoint_time);
|
||||
case 14: return (sts_val->checkpoint_completed);
|
||||
case 15: return (sts_val->checkpoint_completion_time);
|
||||
case 16: return (sts_val->brick_host_uuid);
|
||||
case 17: return (sts_val->last_synced_utc);
|
||||
case 18: return (sts_val->checkpoint_time_utc);
|
||||
case 19: return (sts_val->checkpoint_completion_time_utc);
|
||||
case 20: return (sts_val->slavekey);
|
||||
case 21: return (sts_val->session_slave);
|
||||
default:
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ void trap (void);
|
||||
#include "iatt.h"
|
||||
#include "uuid.h"
|
||||
#include "libglusterfs-messages.h"
|
||||
#include "protocol-common.h"
|
||||
|
||||
#define STRINGIFY(val) #val
|
||||
#define TOSTRING(val) STRINGIFY(val)
|
||||
@ -939,5 +940,7 @@ gf_getgrouplist (const char *user, gid_t group, gid_t **groups);
|
||||
int
|
||||
glusterfs_compute_sha256 (const unsigned char *content, size_t size,
|
||||
char *sha256_hash);
|
||||
char*
|
||||
get_struct_variable (int mem_num, gf_gsync_status_t *sts_val);
|
||||
|
||||
#endif /* _COMMON_UTILS_H */
|
||||
|
@ -4882,7 +4882,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
glusterd_get_gsync_status_mst (glusterd_volinfo_t *volinfo, dict_t *rsp_dict,
|
||||
char *node)
|
||||
{
|
||||
|
@ -45,5 +45,9 @@ int
|
||||
_get_slave_status (dict_t *dict, char *key, data_t *value, void *data);
|
||||
int
|
||||
glusterd_check_geo_rep_running (gsync_status_param_t *param, char **op_errstr);
|
||||
|
||||
int
|
||||
glusterd_get_gsync_status_mst (glusterd_volinfo_t *volinfo, dict_t *rsp_dict,
|
||||
char *node);
|
||||
#endif
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "glusterd-store.h"
|
||||
#include "glusterd-locks.h"
|
||||
#include "glusterd-snapshot-utils.h"
|
||||
#include "glusterd-geo-rep.h"
|
||||
|
||||
#include "glusterd1-xdr.h"
|
||||
#include "cli1-xdr.h"
|
||||
@ -4984,6 +4985,128 @@ out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
glusterd_print_gsync_status (FILE *fp, dict_t *gsync_dict)
|
||||
{
|
||||
int ret = -1;
|
||||
int gsync_count = 0;
|
||||
int i = 0;
|
||||
gf_gsync_status_t **status_vals = NULL;
|
||||
char status_val_name[PATH_MAX] = {0,};
|
||||
|
||||
GF_VALIDATE_OR_GOTO (THIS->name, fp, out);
|
||||
GF_VALIDATE_OR_GOTO (THIS->name, gsync_dict, out);
|
||||
|
||||
ret = dict_get_int32 (gsync_dict, "gsync-count", &gsync_count);
|
||||
|
||||
fprintf (fp, "Volume%d.gsync_count: %d\n", volcount, gsync_count);
|
||||
|
||||
if (gsync_count == 0) {
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
status_vals = GF_CALLOC (gsync_count, sizeof (gf_gsync_status_t *),
|
||||
gf_common_mt_char);
|
||||
if (!status_vals) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
for (i = 0; i < gsync_count; i++) {
|
||||
status_vals[i] = GF_CALLOC (1, sizeof (gf_gsync_status_t),
|
||||
gf_common_mt_char);
|
||||
if (!status_vals[i]) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < gsync_count; i++) {
|
||||
snprintf (status_val_name, sizeof(status_val_name), "status_value%d", i);
|
||||
|
||||
ret = dict_get_bin (gsync_dict, status_val_name, (void **)&(status_vals[i]));
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
fprintf (fp, "Volume%d.pair%d.session_slave: %s\n", volcount, i+1,
|
||||
get_struct_variable(21, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.master_node: %s\n", volcount, i+1,
|
||||
get_struct_variable(0, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.master_volume: %s\n", volcount, i+1,
|
||||
get_struct_variable(1, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.master_brick: %s\n", volcount, i+1,
|
||||
get_struct_variable(2, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.slave_user: %s\n", volcount, i+1,
|
||||
get_struct_variable(3, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.slave: %s\n", volcount, i+1,
|
||||
get_struct_variable(4, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.slave_node: %s\n", volcount, i+1,
|
||||
get_struct_variable(5, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.status: %s\n", volcount, i+1,
|
||||
get_struct_variable(6, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.crawl_status: %s\n", volcount, i+1,
|
||||
get_struct_variable(7, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.last_synced: %s\n", volcount, i+1,
|
||||
get_struct_variable(8, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.entry: %s\n", volcount, i+1,
|
||||
get_struct_variable(9, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.data: %s\n", volcount, i+1,
|
||||
get_struct_variable(10, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.meta: %s\n", volcount, i+1,
|
||||
get_struct_variable(11, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.failures: %s\n", volcount, i+1,
|
||||
get_struct_variable(12, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.checkpoint_time: %s\n", volcount,
|
||||
i+1, get_struct_variable(13, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.checkpoint_completed: %s\n",
|
||||
volcount, i+1, get_struct_variable(14, status_vals[i]));
|
||||
fprintf (fp, "Volume%d.pair%d.checkpoint_completion_time: %s\n",
|
||||
volcount, i+1, get_struct_variable(15, status_vals[i]));
|
||||
}
|
||||
out:
|
||||
for (i = 0; i < gsync_count; i++) {
|
||||
if (status_vals[i]) {
|
||||
GF_FREE (status_vals[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (status_vals)
|
||||
GF_FREE (status_vals);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
glusterd_print_gsync_status_by_vol (FILE *fp, glusterd_volinfo_t *volinfo)
|
||||
{
|
||||
int ret = -1;
|
||||
dict_t *gsync_rsp_dict = NULL;
|
||||
char my_hostname[256] = {0,};
|
||||
|
||||
GF_VALIDATE_OR_GOTO (THIS->name, volinfo, out);
|
||||
GF_VALIDATE_OR_GOTO (THIS->name, fp, out);
|
||||
|
||||
gsync_rsp_dict = dict_new();
|
||||
if (!gsync_rsp_dict)
|
||||
goto out;
|
||||
|
||||
ret = gethostname(my_hostname, 256);
|
||||
if (ret) {
|
||||
/* stick to N/A */
|
||||
(void) strcpy (my_hostname, "N/A");
|
||||
}
|
||||
|
||||
ret = glusterd_get_gsync_status_mst (volinfo, gsync_rsp_dict,
|
||||
my_hostname);
|
||||
/* Ignoring ret as above function always returns ret = 0 */
|
||||
|
||||
ret = glusterd_print_gsync_status (fp, gsync_rsp_dict);
|
||||
if (ret)
|
||||
goto out;
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
glusterd_print_snapinfo_by_vol (FILE *fp, glusterd_volinfo_t *volinfo, int volcount)
|
||||
{
|
||||
@ -5635,6 +5758,10 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
|
||||
}
|
||||
|
||||
volcount = count;
|
||||
ret = glusterd_print_gsync_status_by_vol (fp, volinfo);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (volinfo->dict)
|
||||
dict_foreach (volinfo->dict,
|
||||
glusterd_print_volume_options, fp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user