4
0

qnetd-log-debug.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (c) 2015-2019 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 "log.h"
  35. #include "log-common.h"
  36. #include "qnetd-log-debug.h"
  37. #include "utils.h"
  38. void
  39. qnetd_log_debug_dump_cluster(struct qnetd_cluster *cluster)
  40. {
  41. struct qnetd_client *client;
  42. log(LOG_DEBUG, " cluster dump:");
  43. TAILQ_FOREACH(client, &cluster->client_list, cluster_entries) {
  44. log(LOG_DEBUG, " client = %s, node_id = "UTILS_PRI_NODE_ID,
  45. client->addr_str, client->node_id);
  46. }
  47. }
  48. void
  49. qnetd_log_debug_new_client_connected(struct qnetd_client *client)
  50. {
  51. log(LOG_DEBUG, "New client connected");
  52. log(LOG_DEBUG, " cluster name = %s", client->cluster_name);
  53. log(LOG_DEBUG, " tls started = %u", client->tls_started);
  54. log(LOG_DEBUG, " tls peer certificate verified = %u",
  55. client->tls_peer_certificate_verified);
  56. log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID, client->node_id);
  57. log(LOG_DEBUG, " pointer = %p", client);
  58. log(LOG_DEBUG, " addr_str = %s", client->addr_str);
  59. log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", client->last_ring_id.node_id,
  60. client->last_ring_id.seq);
  61. qnetd_log_debug_dump_cluster(client->cluster);
  62. }
  63. void
  64. qnetd_log_debug_config_node_list_received(struct qnetd_client *client,
  65. uint32_t msg_seq_num, int config_version_set, uint64_t config_version,
  66. const struct node_list *nodes, int initial)
  67. {
  68. log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  69. "sent %s node list.", client->addr_str, client->cluster_name, client->node_id,
  70. (initial ? "initial" : "changed"));
  71. log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
  72. if (config_version_set) {
  73. log(LOG_DEBUG, " config version = " UTILS_PRI_CONFIG_VERSION, config_version);
  74. }
  75. log_common_debug_dump_node_list(nodes);
  76. }
  77. void
  78. qnetd_log_debug_membership_node_list_received(struct qnetd_client *client,
  79. uint32_t msg_seq_num, const struct tlv_ring_id *ring_id,
  80. enum tlv_heuristics heuristics, const struct node_list *nodes)
  81. {
  82. log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  83. "sent membership node list.", client->addr_str, client->cluster_name, client->node_id);
  84. log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
  85. log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", ring_id->node_id, ring_id->seq);
  86. log(LOG_DEBUG, " heuristics = %s ", tlv_heuristics_to_str(heuristics));
  87. log_common_debug_dump_node_list(nodes);
  88. }
  89. void
  90. qnetd_log_debug_quorum_node_list_received(struct qnetd_client *client,
  91. uint32_t msg_seq_num, enum tlv_quorate quorate, const struct node_list *nodes)
  92. {
  93. log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  94. "sent quorum node list.", client->addr_str, client->cluster_name, client->node_id);
  95. log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
  96. log(LOG_DEBUG, " quorate = %u", quorate);
  97. log_common_debug_dump_node_list(nodes);
  98. }
  99. void
  100. qnetd_log_debug_client_disconnect(struct qnetd_client *client, int server_going_down)
  101. {
  102. log(LOG_DEBUG, "Client %s (init_received %u, cluster %s, node_id "
  103. UTILS_PRI_NODE_ID") disconnect%s", client->addr_str, client->init_received,
  104. client->cluster_name, client->node_id,
  105. (server_going_down ? " (server is going down)" : ""));
  106. }
  107. void
  108. qnetd_log_debug_ask_for_vote_received(struct qnetd_client *client, uint32_t msg_seq_num)
  109. {
  110. log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  111. "asked for a vote", client->addr_str, client->cluster_name, client->node_id);
  112. log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
  113. }
  114. void
  115. qnetd_log_debug_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
  116. {
  117. log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  118. "replied back to vote info message", client->addr_str, client->cluster_name,
  119. client->node_id);
  120. log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
  121. }
  122. void
  123. qnetd_log_debug_send_vote_info(struct qnetd_client *client, uint32_t msg_seq_num, enum tlv_vote vote)
  124. {
  125. log(LOG_DEBUG, "Sending vote info to client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") ",
  126. client->addr_str, client->cluster_name, client->node_id);
  127. log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
  128. log(LOG_DEBUG, " vote = %s", tlv_vote_to_str(vote));
  129. }
  130. void
  131. qnetd_log_debug_heuristics_change_received(struct qnetd_client *client, uint32_t msg_seq_num,
  132. enum tlv_heuristics heuristics)
  133. {
  134. log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
  135. "sent heuristics change", client->addr_str, client->cluster_name, client->node_id);
  136. log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
  137. log(LOG_DEBUG, " heuristics = %s", tlv_heuristics_to_str(heuristics));
  138. }