summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-sm.c
diff options
context:
space:
mode:
authorNandaja Varma <nandaja.varma@gmail.com>2015-03-18 15:17:45 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-06-12 02:05:29 -0700
commit72a7a6ea78289b2897f9846dc4e111f442dd2788 (patch)
tree884001e5ca17819b7c3aaccfe4c3c3a6db602a87 /xlators/mgmt/glusterd/src/glusterd-sm.c
parenteeccafc72c95da83abeb51966d7eeeab02190899 (diff)
sm/glusterd: Porting messages to new logging framework
Change-Id: I391d1ac6a7b312461187c2e8c6f14d09a0238950 BUG: 1194640 Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com> Reviewed-on: http://review.gluster.org/9927 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c107
1 files changed, 70 insertions, 37 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index a3de0c30ac4..10b3ff91882 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -166,7 +166,9 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid)
*/
ret = dict_set_static_ptr (friends, "peerinfo", peerinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "failed to set peerinfo");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "failed to set peerinfo");
goto unlock;
}
@@ -178,7 +180,7 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid)
unlock:
rcu_read_unlock ();
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
out:
if (friends)
@@ -193,7 +195,7 @@ glusterd_ac_none (glusterd_friend_sm_event_t *event, void *ctx)
{
int ret = 0;
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -203,7 +205,8 @@ glusterd_ac_error (glusterd_friend_sm_event_t *event, void *ctx)
{
int ret = 0;
- gf_log ("", GF_LOG_ERROR, "Received event %d ", event->event);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_AC_ERROR, "Received event %d ", event->event);
return ret;
}
@@ -223,7 +226,8 @@ glusterd_ac_reverse_probe_begin (glusterd_friend_sm_event_t *event, void *ctx)
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (THIS->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
ret = -1;
goto out;
@@ -233,7 +237,9 @@ glusterd_ac_reverse_probe_begin (glusterd_friend_sm_event_t *event, void *ctx)
(GD_FRIEND_EVENT_PROBE, &new_event);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to get new new_event");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_NEW_GET_FAIL,
+ "Unable to get new new_event");
ret = -1;
goto out;
}
@@ -256,8 +262,10 @@ glusterd_ac_reverse_probe_begin (glusterd_friend_sm_event_t *event, void *ctx)
ret = glusterd_friend_sm_inject_event (new_event);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to inject new_event %d, "
- "ret = %d", new_event->event, ret);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_INJECT_FAIL,
+ "Unable to inject new_event %d, "
+ "ret = %d", new_event->event, ret);
}
out:
@@ -271,7 +279,7 @@ out:
GF_FREE (new_ev_ctx->hostname);
GF_FREE (new_ev_ctx);
}
- gf_log ("", GF_LOG_DEBUG, "returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "returning with %d", ret);
return ret;
}
@@ -296,7 +304,9 @@ glusterd_ac_friend_add (glusterd_friend_sm_event_t *event, void *ctx)
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND,
+ "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
goto out;
}
@@ -316,7 +326,7 @@ glusterd_ac_friend_add (glusterd_friend_sm_event_t *event, void *ctx)
out:
rcu_read_unlock ();
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -378,7 +388,9 @@ glusterd_ac_friend_probe (glusterd_friend_sm_event_t *event, void *ctx)
*/
ret = dict_set_static_ptr (dict, "peerinfo", peerinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "failed to set peerinfo");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "failed to set peerinfo");
goto out;
}
@@ -393,7 +405,7 @@ out:
if (dict)
dict_unref (dict);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -423,7 +435,8 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event,
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
goto out;
}
@@ -439,8 +452,9 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event,
gf_uuid_copy (new_event->peerid, peerinfo->uuid);
ret = glusterd_friend_sm_inject_event (new_event);
} else {
- gf_log ("glusterd", GF_LOG_ERROR,
- "Unable to get event");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_NEW_GET_FAIL,
+ "Unable to get event");
}
if (ctx) {
@@ -469,7 +483,7 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event,
out:
rcu_read_unlock ();
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -512,7 +526,8 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
cur_peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!cur_peerinfo) {
- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
ret = -1;
goto out;
@@ -555,7 +570,9 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
ret = dict_set_static_ptr (friends, "peerinfo", peerinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "failed to set peerinfo");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "failed to set peerinfo");
goto out;
}
@@ -565,7 +582,7 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
}
}
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
out:
rcu_read_unlock ();
@@ -602,7 +619,8 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv)
"Deleting stale volume %s", volinfo->volname);
ret = glusterd_delete_volume (volinfo);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_STALE_VOL_REMOVE_FAIL,
"Error deleting stale volume");
goto out;
}
@@ -610,7 +628,7 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv)
}
ret = 0;
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -658,7 +676,8 @@ glusterd_ac_handle_friend_remove_req (glusterd_friend_sm_event_t *event,
ret = glusterd_peer_detach_cleanup (priv);
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ GD_MSG_PEER_DETACH_CLEANUP_FAIL,
"Peer detach cleanup was not successful");
ret = 0;
}
@@ -667,7 +686,7 @@ out:
GF_FREE (new_event->peername);
GF_FREE (new_event);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning with %d", ret);
return ret;
}
@@ -683,7 +702,9 @@ glusterd_ac_friend_remove (glusterd_friend_sm_event_t *event, void *ctx)
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (THIS->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND,
+ "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
rcu_read_unlock ();
goto out;
@@ -700,7 +721,9 @@ glusterd_ac_friend_remove (glusterd_friend_sm_event_t *event, void *ctx)
ret = glusterd_peerinfo_cleanup (peerinfo);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Cleanup returned: %d", ret);
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_DETACH_CLEANUP_FAIL,
+ "Cleanup returned: %d", ret);
}
out:
return 0;
@@ -743,7 +766,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
rcu_read_lock ();
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
ret = -1;
rcu_read_unlock ();
@@ -788,7 +812,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
(conf->op_version >= GD_OP_VERSION_3_6_0)) {
ret = glusterd_import_friend_missed_snap_list (ev_ctx->vols);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSED_SNAP_LIST_STORE_FAIL,
"Failed to import peer's "
"missed_snaps_list.");
event_type = GD_FRIEND_EVENT_LOCAL_RJT;
@@ -806,7 +831,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
event->peername,
event->peerid);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_COMPARE_CONFLICT,
"Conflict in comparing peer's snapshots");
event_type = GD_FRIEND_EVENT_LOCAL_RJT;
op_errno = GF_PROBE_SNAP_CONFLICT;
@@ -817,7 +843,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
ret = glusterd_friend_sm_new_event (event_type, &new_event);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Out of Memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out of Memory");
}
new_event->peername = gf_strdup (event->peername);
@@ -857,7 +884,7 @@ out:
GF_FREE (new_event->peername);
GF_FREE (new_event);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -1108,7 +1135,7 @@ int
glusterd_friend_sm_inject_event (glusterd_friend_sm_event_t *event)
{
GF_ASSERT (event);
- gf_log ("glusterd", GF_LOG_DEBUG, "Enqueue event: '%s'",
+ gf_msg_debug ("glusterd", 0, "Enqueue event: '%s'",
glusterd_friend_sm_event_name_get (event->event));
cds_list_add_tail (&event->list, &gd_friend_sm_queue);
@@ -1191,7 +1218,8 @@ glusterd_friend_sm ()
peerinfo = glusterd_peerinfo_find (event->peerid,
event->peername);
if (!peerinfo) {
- gf_log ("glusterd", GF_LOG_CRITICAL, "Received"
+ gf_msg ("glusterd", GF_LOG_CRITICAL, 0,
+ GD_MSG_PEER_NOT_FOUND, "Received"
" event %s with empty peer info",
glusterd_friend_sm_event_name_get (event_type));
@@ -1199,7 +1227,7 @@ glusterd_friend_sm ()
rcu_read_unlock ();
continue;
}
- gf_log ("", GF_LOG_DEBUG, "Dequeued event of type: '%s'",
+ gf_msg_debug ("glusterd", 0, "Dequeued event of type: '%s'",
glusterd_friend_sm_event_name_get (event_type));
@@ -1228,7 +1256,9 @@ glusterd_friend_sm ()
}
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "handler returned: "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_HANDLER_RETURNED,
+ "handler returned: "
"%d", ret);
glusterd_destroy_friend_event_context (event);
GF_FREE (event);
@@ -1247,7 +1277,9 @@ glusterd_friend_sm ()
event_type);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to transition"
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_STATE_TRANSITION_FAIL,
+ "Unable to transition"
" state from '%s' to '%s' for event '%s'",
glusterd_friend_sm_state_name_get(old_state),
glusterd_friend_sm_state_name_get(state[event_type].next_state),
@@ -1271,7 +1303,8 @@ glusterd_friend_sm ()
* something has gone terribly wrong.
*/
ret = -1;
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND,
"Cannot find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
goto out;