diff options
author | Pranith K <pranithk@gluster.com> | 2010-10-08 00:19:17 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-10-08 04:28:51 -0700 |
commit | ce616c5fa08722044ee311f5f6c7c4e3ccb684c4 (patch) | |
tree | 6b20b2bf93b623d5355c0cd39e334faacb10c0c7 | |
parent | 99b04920189df06cfd8704a773c51cdb995b7ae0 (diff) |
mgmt/glusterd: print state, event names for numbers in friend sm
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1847 (print event names, state names instead of numbers for FSMs)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1847
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-sm.c | 49 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 4 |
2 files changed, 42 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c index 2e872bb8afa..051bdee91be 100644 --- a/xlators/mgmt/glusterd/src/glusterd-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-sm.c @@ -58,6 +58,22 @@ static char *glusterd_friend_sm_state_names[] = { "Invalid State" }; +static char *glusterd_friend_sm_event_names[] = { + "GD_FRIEND_EVENT_NONE", + "GD_FRIEND_EVENT_PROBE", + "GD_FRIEND_EVENT_INIT_FRIEND_REQ", + "GD_FRIEND_EVENT_RCVD_ACC", + "GD_FRIEND_EVENT_LOCAL_ACC", + "GD_FRIEND_EVENT_RCVD_RJT", + "GD_FRIEND_EVENT_LOCAL_RJT", + "GD_FRIEND_EVENT_RCVD_FRIEND_REQ", + "GD_FRIEND_EVENT_INIT_REMOVE_FRIEND", + "GD_FRIEND_EVENT_RCVD_REMOVE_FRIEND", + "GD_FRIEND_EVENT_REMOVE_FRIEND", + "GD_FRIEND_EVENT_CONNECTED", + "GD_FRIEND_EVENT_MAX" +}; + char* glusterd_friend_sm_state_name_get (glusterd_friend_sm_state_t state) { @@ -65,6 +81,15 @@ glusterd_friend_sm_state_name_get (glusterd_friend_sm_state_t state) return glusterd_friend_sm_state_names[GD_FRIEND_STATE_MAX]; return glusterd_friend_sm_state_names[state]; } + +char* +glusterd_friend_sm_event_name_get (glusterd_friend_sm_event_type_t event) +{ + if (event < 0 || event >= GD_FRIEND_EVENT_MAX) + return glusterd_friend_sm_event_names[GD_FRIEND_EVENT_MAX]; + return glusterd_friend_sm_event_names[event]; +} + void glusterd_destroy_probe_ctx (glusterd_probe_ctx_t *ctx) { @@ -530,8 +555,12 @@ glusterd_friend_sm_transition_state (glusterd_peerinfo_t *peerinfo, //peerinfo->state.state = state; - gf_log ("", GF_LOG_NORMAL, "Transitioning from %d to %d", - peerinfo->state.state, state[event_type].next_state); + gf_log ("", GF_LOG_NORMAL, "Transitioning from '%s' to '%s' due to " + "event '%s'", + glusterd_friend_sm_state_name_get (peerinfo->state.state), + glusterd_friend_sm_state_name_get (state[event_type].next_state), + glusterd_friend_sm_event_name_get (event_type)); + peerinfo->state.state = state[event_type].next_state; return 0; } @@ -703,8 +732,8 @@ int glusterd_friend_sm_inject_event (glusterd_friend_sm_event_t *event) { GF_ASSERT (event); - gf_log ("glusterd", GF_LOG_NORMAL, "Enqueuing event: %d", - event->event); + gf_log ("glusterd", GF_LOG_NORMAL, "Enqueuing event: '%s'", + glusterd_friend_sm_event_name_get (event->event)); list_add_tail (&event->list, &gd_friend_sm_queue); return 0; @@ -725,7 +754,7 @@ glusterd_destroy_friend_event_context (glusterd_friend_sm_event_t *event) case GD_FRIEND_EVENT_LOCAL_RJT: case GD_FRIEND_EVENT_RCVD_ACC: case GD_FRIEND_EVENT_RCVD_RJT: - glusterd_destroy_friend_update_ctx(event->ctx); + glusterd_destroy_friend_update_ctx (event->ctx); break; default: break; @@ -782,12 +811,15 @@ glusterd_friend_sm () continue; } - ret = glusterd_friend_sm_transition_state (peerinfo, state, event_type); + ret = glusterd_friend_sm_transition_state (peerinfo, + state, event_type); if (ret) { gf_log ("glusterd", GF_LOG_ERROR, "Unable to transition" - "state from %d to %d", peerinfo->state.state, - state[event_type].next_state); + " state from '%s' to '%s' for event '%s'", + glusterd_friend_sm_state_name_get(peerinfo->state.state), + glusterd_friend_sm_state_name_get(state[event_type].next_state), + glusterd_friend_sm_event_name_get(event_type)); goto out; } @@ -802,7 +834,6 @@ glusterd_friend_sm () break; } - ret = 0; out: return ret; diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 2e219a2618d..c7018cde86f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2080,8 +2080,8 @@ glusterd_friend_find_by_uuid (uuid_t uuid, if (!uuid_compare (entry->uuid, uuid)) { gf_log ("glusterd", GF_LOG_NORMAL, - "Friend found.. state: %d", - entry->state.state); + "Friend found.. state: %s", + glusterd_friend_sm_state_name_get (entry->state.state)); *peerinfo = entry; return 0; } |