qnetd-log-debug.c 5.8 KB

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