diff options
Diffstat (limited to 'api/src/glfs-mgmt.c')
-rw-r--r-- | api/src/glfs-mgmt.c | 88 |
1 files changed, 68 insertions, 20 deletions
diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c index 6843e9cb3fe..5493e89db81 100644 --- a/api/src/glfs-mgmt.c +++ b/api/src/glfs-mgmt.c @@ -413,32 +413,81 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, void *data) { xlator_t *this = NULL; - cmd_args_t *cmd_args = NULL; glusterfs_ctx_t *ctx = NULL; struct glfs *fs = NULL; int ret = 0; + server_cmdline_t *server = NULL; + rpc_transport_t *rpc_trans = NULL; + + this = mydata; + rpc_trans = rpc->conn.trans; + + ctx = this->ctx; + fs = ((xlator_t *)ctx->master)->private; + + switch (event) { + case RPC_CLNT_DISCONNECT: + if (!ctx->active) { + gf_log ("glfs-mgmt", GF_LOG_ERROR, + "failed to connect with remote-host: %s (%s)", + ctx->cmd_args.volfile_server, + strerror (errno)); + server = ctx->cmd_args.curr_server; + if (server->list.next == &ctx->cmd_args.volfile_servers) { + errno = ENOTCONN; + gf_log("glfs-mgmt", GF_LOG_INFO, + "Exhausted all volfile servers"); + glfs_init_done (fs, -1); + break; + } + server = list_entry (server->list.next, typeof(*server), + list); + ctx->cmd_args.curr_server = server; + ctx->cmd_args.volfile_server_port = server->port; + ctx->cmd_args.volfile_server = server->volfile_server; + ctx->cmd_args.volfile_server_transport = server->transport; + ret = dict_set_int32 (rpc_trans->options, + "remote-port", + server->port); + if (ret != 0) { + gf_log ("glfs-mgmt", GF_LOG_ERROR, + "failed to set remote-port: %d", + server->port); + errno = ENOTCONN; + glfs_init_done (fs, -1); + break; + } - this = mydata; - ctx = this->ctx; - fs = ((xlator_t *)ctx->master)->private; - cmd_args = &ctx->cmd_args; + ret = dict_set_str (rpc_trans->options, + "remote-host", + server->volfile_server); + if (ret != 0) { + gf_log ("glfs-mgmt", GF_LOG_ERROR, + "failed to set remote-host: %s", + server->volfile_server); + errno = ENOTCONN; + glfs_init_done (fs, -1); + break; + } - switch (event) { - case RPC_CLNT_DISCONNECT: - if (!ctx->active) { - cmd_args->max_connect_attempts--; - gf_log ("glfs-mgmt", GF_LOG_ERROR, - "failed to connect with remote-host: %s", - strerror (errno)); - gf_log ("glfs-mgmt", GF_LOG_INFO, - "%d connect attempts left", - cmd_args->max_connect_attempts); - if (0 >= cmd_args->max_connect_attempts) { + ret = dict_set_str (rpc_trans->options, + "transport-type", + server->transport); + if (ret != 0) { + gf_log ("glfs-mgmt", GF_LOG_ERROR, + "failed to set transport-type: %s", + server->transport); errno = ENOTCONN; - glfs_init_done (fs, -1); + glfs_init_done (fs, -1); + break; } - } - break; + gf_log ("glfs-mgmt", GF_LOG_INFO, + "connecting to next volfile server %s" + " at port %d with transport: %s", + server->volfile_server, server->port, + server->transport); + } + break; case RPC_CLNT_CONNECT: rpc_clnt_set_connected (&((struct rpc_clnt*)ctx->mgmt)->conn); @@ -540,4 +589,3 @@ glfs_mgmt_init (struct glfs *fs) out: return ret; } - |