qdevice-instance.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) 2015-2017 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. #ifndef _QDEVICE_INSTANCE_H_
  35. #define _QDEVICE_INSTANCE_H_
  36. #include <sys/types.h>
  37. #include <stdlib.h>
  38. #include <stdint.h>
  39. #include <cmap.h>
  40. #include <votequorum.h>
  41. #include "qdevice-advanced-settings.h"
  42. #include "qdevice-heuristics.h"
  43. #include "qdevice-model-type.h"
  44. #include "node-list.h"
  45. #include "unix-socket-ipc.h"
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. struct qdevice_instance {
  50. cmap_handle_t cmap_handle;
  51. int cmap_poll_fd;
  52. int cmap_reload_in_progress;
  53. cmap_track_handle_t cmap_reload_track_handle;
  54. cmap_track_handle_t cmap_nodelist_track_handle;
  55. cmap_track_handle_t cmap_logging_track_handle;
  56. cmap_track_handle_t cmap_heuristics_track_handle;
  57. votequorum_handle_t votequorum_handle;
  58. int votequorum_poll_fd;
  59. struct unix_socket_ipc local_ipc;
  60. enum qdevice_model_type model_type;
  61. uint32_t node_id;
  62. uint32_t heartbeat_interval; /* Heartbeat interval during normal operation */
  63. uint32_t sync_heartbeat_interval; /* Heartbeat interval during corosync sync */
  64. struct node_list config_node_list;
  65. int config_node_list_version_set;
  66. uint64_t config_node_list_version;
  67. /*
  68. * Copy of votequorum_quorum_notify_fn callback paramters.
  69. * Set after model callback is called.
  70. */
  71. uint32_t vq_quorum_quorate;
  72. uint32_t vq_quorum_node_list_entries;
  73. votequorum_node_t *vq_quorum_node_list;
  74. /*
  75. * Copy of current votequorum_nodelist_notify_fn callback parameters.
  76. * Set after model callback qdevice_votequorum_node_list_notify_callback is called.
  77. */
  78. uint8_t vq_node_list_initial_ring_id_set;
  79. votequorum_ring_id_t vq_node_list_ring_id;
  80. uint32_t vq_node_list_entries;
  81. uint32_t *vq_node_list;
  82. uint8_t vq_node_list_initial_heuristics_finished;
  83. enum qdevice_heuristics_exec_result vq_node_list_heuristics_result;
  84. /*
  85. * Copy of current votequorum_nodelist_notify_fn callback ring id
  86. * It's set before any callback is called and used for qdevice_votequorum_poll
  87. */
  88. votequorum_ring_id_t vq_poll_ring_id;
  89. /*
  90. * Copy of votequorum_expectedvotes_notify_fn callback parameters.
  91. * Set after model callback is called.
  92. */
  93. uint32_t vq_expected_votes;
  94. time_t vq_last_poll;
  95. int vq_last_poll_cast_vote;
  96. void *model_data;
  97. const struct qdevice_advanced_settings *advanced_settings;
  98. int sync_in_progress;
  99. struct qdevice_heuristics_instance heuristics_instance;
  100. };
  101. extern int qdevice_instance_init(struct qdevice_instance *instance,
  102. const struct qdevice_advanced_settings *advanced_settings);
  103. extern int qdevice_instance_destroy(struct qdevice_instance *instance);
  104. extern int qdevice_instance_configure_from_cmap(struct qdevice_instance *instance);
  105. extern int qdevice_instance_configure_from_cmap_heuristics(struct qdevice_instance *instance);
  106. #ifdef __cplusplus
  107. }
  108. #endif
  109. #endif /* _QDEVICE_INSTANCE_H_ */