qnetd-log-debug.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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_debug_dump_cluster(client->cluster);
  59. }
  60. void
  61. qnetd_log_debug_dump_node_list(struct qnetd_client *client, const struct node_list *nodes)
  62. {
  63. struct node_list_entry *node_info;
  64. qnetd_log(LOG_DEBUG, " node list:");
  65. TAILQ_FOREACH(node_info, nodes, entries) {
  66. qnetd_log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID", "
  67. "data_center_id = "UTILS_PRI_DATACENTER_ID", "
  68. "node_state = %s", node_info->node_id, node_info->data_center_id,
  69. tlv_node_state_to_str(node_info->node_state));
  70. }
  71. }
  72. void
  73. qnetd_log_debug_config_node_list_received(struct qnetd_client *client,
  74. uint32_t msg_seq_num, int config_version_set, uint64_t config_version,
  75. const struct node_list *nodes, int initial)
  76. {
  77. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  78. "sent %s node list.", client->addr_str, client->cluster_name, client->node_id,
  79. (initial ? "initial" : "changed"));
  80. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  81. if (config_version_set) {
  82. qnetd_log(LOG_DEBUG, " config version " UTILS_PRI_CONFIG_VERSION, config_version);
  83. }
  84. qnetd_log_debug_dump_node_list(client, nodes);
  85. }
  86. void
  87. qnetd_log_debug_membership_node_list_received(struct qnetd_client *client,
  88. uint32_t msg_seq_num, const struct tlv_ring_id *ring_id,
  89. const struct node_list *nodes)
  90. {
  91. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  92. "sent membership node list.", client->addr_str, client->cluster_name, client->node_id);
  93. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  94. qnetd_log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", ring_id->node_id, ring_id->seq);
  95. qnetd_log_debug_dump_node_list(client, nodes);
  96. }
  97. void
  98. qnetd_log_debug_quorum_node_list_received(struct qnetd_client *client,
  99. uint32_t msg_seq_num, enum tlv_quorate quorate, const struct node_list *nodes)
  100. {
  101. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  102. "sent quorum node list.", client->addr_str, client->cluster_name, client->node_id);
  103. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  104. qnetd_log(LOG_DEBUG, " quorate = %u", quorate);
  105. qnetd_log_debug_dump_node_list(client, nodes);
  106. }
  107. void
  108. qnetd_log_debug_client_disconnect(struct qnetd_client *client, int server_going_down)
  109. {
  110. qnetd_log(LOG_DEBUG, "Client %s (init_received %u, cluster %s, node_id "
  111. UTILS_PRI_NODE_ID") disconnect%s", client->addr_str, client->init_received,
  112. client->cluster_name, client->node_id,
  113. (server_going_down ? " (server is going down)" : ""));
  114. }
  115. void
  116. qnetd_log_debug_ask_for_vote_received(struct qnetd_client *client, uint32_t msg_seq_num)
  117. {
  118. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  119. "asked for a vote", client->addr_str, client->cluster_name, client->node_id);
  120. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  121. }
  122. void
  123. qnetd_log_debug_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
  124. {
  125. qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  126. "replied back to vote info message", client->addr_str, client->cluster_name,
  127. client->node_id);
  128. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  129. }
  130. void
  131. qnetd_log_debug_send_vote_info(struct qnetd_client *client, uint32_t msg_seq_num, enum tlv_vote vote)
  132. {
  133. qnetd_log(LOG_DEBUG, "Sending vote info to client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") ",
  134. client->addr_str, client->cluster_name, client->node_id);
  135. qnetd_log(LOG_DEBUG, " msg seq num "UTILS_PRI_MSG_SEQ, msg_seq_num);
  136. qnetd_log(LOG_DEBUG, " vote %s", tlv_vote_to_str(vote));
  137. }