1 /*
2 * Copyright 2004-2024 the Pacemaker project contributors
3 *
4 * The version control history for this file may have further details.
5 *
6 * This source code is licensed under the GNU Lesser General Public License
7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8 */
9
10 #ifndef PCMK__CRM_COMMON_SCHEDULER__H
11 #define PCMK__CRM_COMMON_SCHEDULER__H
12
13 #include <sys/types.h> // time_t
14 #include <libxml/tree.h> // xmlNode
15 #include <glib.h> // guint, GList, GHashTable
16
17 #include <crm/common/iso8601.h> // crm_time_t
18
19 #include <crm/common/actions.h>
20 #include <crm/common/nodes.h>
21 #include <crm/common/resources.h>
22 #include <crm/common/roles.h>
23 #include <crm/common/rules.h>
24 #include <crm/common/scheduler_types.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /*!
31 * \file
32 * \brief Scheduler API
33 * \ingroup core
34 */
35
36 // NOTE: sbd (as of at least 1.5.2) uses this enum
37 //! Possible responses to loss of quorum
38 enum pe_quorum_policy {
39 pcmk_no_quorum_freeze, //!< Do not recover resources from outside partition
40 pcmk_no_quorum_stop, //!< Stop all resources in partition
41 pcmk_no_quorum_ignore, //!< Act as if partition still holds quorum
42 pcmk_no_quorum_fence, //!< Fence all nodes in partition
43 pcmk_no_quorum_demote, //!< Demote promotable resources and stop all others
44
45 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
46 // NOTE: sbd (as of at least 1.5.2) uses this value
47 //! \deprecated Use pcmk_no_quorum_freeze instead
48 no_quorum_freeze = pcmk_no_quorum_freeze,
49
50 // NOTE: sbd (as of at least 1.5.2) uses this value
51 //! \deprecated Use pcmk_no_quorum_stop instead
52 no_quorum_stop = pcmk_no_quorum_stop,
53
54 // NOTE: sbd (as of at least 1.5.2) uses this value
55 //! \deprecated Use pcmk_no_quorum_ignore instead
56 no_quorum_ignore = pcmk_no_quorum_ignore,
57
58 //! \deprecated Use pcmk_no_quorum_fence instead
59 no_quorum_suicide = pcmk_no_quorum_fence,
60
61 // NOTE: sbd (as of at least 1.5.2) uses this value
62 //! \deprecated Use pcmk_no_quorum_demote instead
63 no_quorum_demote = pcmk_no_quorum_demote,
64 #endif
65 };
66
67 //! \internal Do not use
68 typedef struct pcmk__scheduler_private pcmk__scheduler_private_t;
69
70 /* Implementation of pcmk_scheduler_t
71 *
72 * @COMPAT Drop this struct once all members are moved to
73 * pcmk__scheduler_private_t, and repoint pcmk_scheduler_t to that
74 */
75 //! \deprecated Do not use (public access will be removed in a future release)
76 struct pcmk__scheduler {
77 // Be careful about when each piece of information is available and final
78
79 // NOTE: sbd (as of at least 1.5.2) uses this
80 //! \deprecated Set scheduler input with pcmk_set_scheduler_cib() instead
81 xmlNode *input; // CIB XML
82
83 // NOTE: sbd (as of at least 1.5.2) uses this
84 //! \deprecated Call pcmk_get_dc() instead
85 pcmk_node_t *dc_node; // Node object for DC
86
87 // NOTE: sbd (as of at least 1.5.2) uses this
88 //! \deprecated Call pcmk_has_quorum() to check quorum
89 uint64_t flags; // Group of enum pcmk__scheduler_flags
90
91 // NOTE: sbd (as of at least 1.5.2) uses this
92 //! \deprecated Call pcmk_get_no_quorum_policy() to get no-quorum policy
93 enum pe_quorum_policy no_quorum_policy; // Response to loss of quorum
94
95 // NOTE: sbd (as of at least 1.5.2) uses this
96 //! \deprecated Call pcmk_find_node() to find a node instead
97 GList *nodes; // Nodes in cluster
98
99 pcmk__scheduler_private_t *priv; //!< \internal For Pacemaker use only
100 };
101
102 pcmk_node_t *pcmk_get_dc(const pcmk_scheduler_t *scheduler);
103 enum pe_quorum_policy pcmk_get_no_quorum_policy(const pcmk_scheduler_t
104 *scheduler);
105
106 int pcmk_set_scheduler_cib(pcmk_scheduler_t *scheduler, xmlNode *cib);
107
108 bool pcmk_has_quorum(const pcmk_scheduler_t *scheduler);
109 pcmk_node_t *pcmk_find_node(const pcmk_scheduler_t *scheduler,
110 const char *node_name);
111
112 #ifdef __cplusplus
113 }
114 #endif
115
116 #endif // PCMK__CRM_COMMON_SCHEDULER__H