qnetd-log-debug.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (c) 2015-2016 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Jan Friesse (jfriesse@redhat.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the Red Hat, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include "qnetd-log.h"
  35. #include "qnetd-log-debug.h"
  36. #include "utils.h"
  37. void
  38. qnetd_log_debug_dump_cluster(struct qnetd_cluster *cluster)
  39. {
  40. struct qnetd_client *client;
  41. qnetd_log(LOG_DEBUG, " cluster dump:");
  42. TAILQ_FOREACH(client, &cluster->client_list, cluster_entries) {
  43. qnetd_log(LOG_DEBUG, " client = %s, node_id = "UTILS_PRI_NODE_ID,
  44. client->addr_str, client->node_id);
  45. }
  46. }
  47. void
  48. qnetd_log_debug_new_client_connected(struct qnetd_client *client)
  49. {
  50. qnetd_log(LOG_DEBUG, "New client connected");
  51. qnetd_log(LOG_DEBUG, " cluster name = %s", client->cluster_name);
  52. qnetd_log(LOG_DEBUG, " tls started = %u", client->tls_started);
  53. qnetd_log(LOG_DEBUG, " tls peer certificate verified = %u",
  54. client->tls_peer_certificate_verified);
  55. qnetd_log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID, client->node_id);
  56. qnetd_log(LOG_DEBUG, " pointer = %p", client);
  57. qnetd_log(LOG_DEBUG, " addr_str = %s", client->addr_str);
  58. qnetd_log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", client->last_ring_id.node_id,
  59. client->last_ring_id.seq);
  60. qnetd_log_debug_dump_cluster(client->cluster);
  61. }
  62. void
  63. qnetd_log_debug_dump_node_list(struct qnetd_client *client, const struct node_list *nodes)
  64. {
  65. struct node_list_entry *node_info;
  66. qnetd_log(LOG_DEBUG, " node list:");
  67. TAILQ_FOREACH(node_info, nodes, entries) {
  68. qnetd_log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID", "
  69. "data_center_id = "UTILS_PRI_DATACENTER_ID", "
  70. "node_state = %s", node_info->node_id, node_info->data_center_id,
  71. tlv_node_state_to_str(node_info->node_state));
  72. }
  73. }
  74. void
  75. qnetd_log_debug_config_node_list_received(struct qnetd_client *client,
  76. uint32_t msg_seq_num, int config_version_set, uint64_t config_version,
  77. const struct node_list *nodes, int initial)
  78. {
  79. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  80. "sent %s node list.", client->addr_str, client->cluster_name, client->node_id,
  81. (initial ? "initial" : "changed"));
  82. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  83. if (config_version_set) {
  84. qnetd_log(LOG_DEBUG, " config version " UTILS_PRI_CONFIG_VERSION, config_version);
  85. }
  86. qnetd_log_debug_dump_node_list(client, nodes);
  87. }
  88. void
  89. qnetd_log_debug_membership_node_list_received(struct qnetd_client *client,
  90. uint32_t msg_seq_num, const struct tlv_ring_id *ring_id,
  91. const struct node_list *nodes)
  92. {
  93. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  94. "sent membership node list.", client->addr_str, client->cluster_name, client->node_id);
  95. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  96. qnetd_log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", ring_id->node_id, ring_id->seq);
  97. qnetd_log_debug_dump_node_list(client, nodes);
  98. }
  99. void
  100. qnetd_log_debug_quorum_node_list_received(struct qnetd_client *client,
  101. uint32_t msg_seq_num, enum tlv_quorate quorate, const struct node_list *nodes)
  102. {
  103. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  104. "sent quorum node list.", client->addr_str, client->cluster_name, client->node_id);
  105. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  106. qnetd_log(LOG_DEBUG, " quorate = %u", quorate);
  107. qnetd_log_debug_dump_node_list(client, nodes);
  108. }
  109. void
  110. qnetd_log_debug_client_disconnect(struct qnetd_client *client, int server_going_down)
  111. {
  112. qnetd_log(LOG_DEBUG, "Client %s (init_received %u, cluster %s, node_id "
  113. UTILS_PRI_NODE_ID") disconnect%s", client->addr_str, client->init_received,
  114. client->cluster_name, client->node_id,
  115. (server_going_down ? " (server is going down)" : ""));
  116. }
  117. void
  118. qnetd_log_debug_ask_for_vote_received(struct qnetd_client *client, uint32_t msg_seq_num)
  119. {
  120. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  121. "asked for a vote", client->addr_str, client->cluster_name, client->node_id);
  122. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  123. }
  124. void
  125. qnetd_log_debug_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
  126. {
  127. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  128. "replied back to vote info message", client->addr_str, client->cluster_name,
  129. client->node_id);
  130. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  131. }
  132. void
  133. qnetd_log_debug_send_vote_info(struct qnetd_client *client, uint32_t msg_seq_num, enum tlv_vote vote)
  134. {
  135. qnetd_log(LOG_DEBUG, "Sending vote info to client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") ",
  136. client->addr_str, client->cluster_name, client->node_id);
  137. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  138. qnetd_log(LOG_DEBUG, " vote %s", tlv_vote_to_str(vote));
  139. }