root/daemons/attrd/pacemaker-attrd.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright 2013-2021 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 General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #ifndef PACEMAKER_ATTRD__H
  11 #  define PACEMAKER_ATTRD__H
  12 
  13 #include <regex.h>
  14 #include <glib.h>
  15 #include <crm/crm.h>
  16 #include <crm/cluster.h>
  17 #include <crm/cluster/election_internal.h>
  18 #include <crm/cib/internal.h>
  19 
  20 void attrd_init_mainloop(void);
  21 void attrd_run_mainloop(void);
  22 
  23 void attrd_set_requesting_shutdown(void);
  24 void attrd_clear_requesting_shutdown(void);
  25 gboolean attrd_requesting_shutdown(void);
  26 gboolean attrd_shutting_down(void);
  27 void attrd_shutdown(int nsig);
  28 void attrd_init_ipc(qb_ipcs_service_t **ipcs,
  29                     qb_ipcs_msg_process_fn dispatch_fn);
  30 void attrd_ipc_fini(void);
  31 
  32 void attrd_cib_disconnect(void);
  33 
  34 gboolean attrd_value_needs_expansion(const char *value);
  35 int attrd_expand_value(const char *value, const char *old_value);
  36 
  37 /* regular expression to clear failures of all resources */
  38 #define ATTRD_RE_CLEAR_ALL \
  39     "^(" PCMK__FAIL_COUNT_PREFIX "|" PCMK__LAST_FAILURE_PREFIX ")-"
  40 
  41 /* regular expression to clear failure of all operations for one resource
  42  * (format takes resource name)
  43  *
  44  * @COMPAT attributes set < 1.1.17:
  45  * also match older attributes that do not have the operation part
  46  */
  47 #define ATTRD_RE_CLEAR_ONE ATTRD_RE_CLEAR_ALL "%s(#.+_[0-9]+)?$"
  48 
  49 /* regular expression to clear failure of one operation for one resource
  50  * (format takes resource name, operation name, and interval)
  51  *
  52  * @COMPAT attributes set < 1.1.17:
  53  * also match older attributes that do not have the operation part
  54  */
  55 #define ATTRD_RE_CLEAR_OP ATTRD_RE_CLEAR_ALL "%s(#%s_%u)?$"
  56 
  57 int attrd_failure_regex(regex_t *regex, const char *rsc, const char *op,
  58                         guint interval_ms);
  59 
  60 extern cib_t *the_cib;
  61 
  62 /* Alerts */
  63 
  64 extern lrmd_t *the_lrmd;
  65 extern crm_trigger_t *attrd_config_read;
  66 
  67 void attrd_lrmd_disconnect(void);
  68 gboolean attrd_read_options(gpointer user_data);
  69 void attrd_cib_replaced_cb(const char *event, xmlNode * msg);
  70 void attrd_cib_updated_cb(const char *event, xmlNode *msg);
  71 int attrd_send_attribute_alert(const char *node, int nodeid,
  72                                const char *attr, const char *value);
  73 
  74 // Elections
  75 void attrd_election_init(void);
  76 void attrd_election_fini(void);
  77 void attrd_start_election_if_needed(void);
  78 bool attrd_election_won(void);
  79 void attrd_handle_election_op(const crm_node_t *peer, xmlNode *xml);
  80 bool attrd_check_for_new_writer(const crm_node_t *peer, const xmlNode *xml);
  81 void attrd_declare_winner(void);
  82 void attrd_remove_voter(const crm_node_t *peer);
  83 void attrd_xml_add_writer(xmlNode *xml);
  84 
  85 typedef struct attribute_s {
  86     char *uuid; /* TODO: Remove if at all possible */
  87     char *id;
  88     char *set;
  89     GHashTable *values;
  90     int update;
  91     int timeout_ms;
  92 
  93     /* TODO: refactor these three as a bitmask */
  94     bool changed; /* whether attribute value has changed since last write */
  95     bool unknown_peer_uuids; /* whether we know we're missing a peer uuid */
  96     gboolean is_private; /* whether to keep this attribute out of the CIB */
  97 
  98     mainloop_timer_t *timer;
  99 
 100     char *user;
 101 
 102     gboolean force_write; /* Flag for updating attribute by ignoring delay */
 103 
 104 } attribute_t;
 105 
 106 typedef struct attribute_value_s {
 107         uint32_t nodeid;
 108         gboolean is_remote;
 109         char *nodename;
 110         char *current;
 111         char *requested;
 112         gboolean seen;
 113 } attribute_value_t;
 114 
 115 extern crm_cluster_t *attrd_cluster;
 116 extern GHashTable *attributes;
 117 
 118 #define attrd_send_ack(client, id, flags) \
 119     pcmk__ipc_send_ack((client), (id), (flags), "ack", CRM_EX_INDETERMINATE)
 120 
 121 #define CIB_OP_TIMEOUT_S 120
 122 
 123 void write_attributes(bool all, bool ignore_delay);
 124 void attrd_broadcast_protocol(void);
 125 void attrd_peer_message(crm_node_t *client, xmlNode *msg);
 126 void attrd_client_peer_remove(pcmk__client_t *client, xmlNode *xml);
 127 void attrd_client_clear_failure(xmlNode *xml);
 128 void attrd_client_update(xmlNode *xml);
 129 void attrd_client_refresh(void);
 130 void attrd_client_query(pcmk__client_t *client, uint32_t id, uint32_t flags,
 131                         xmlNode *query);
 132 
 133 void free_attribute(gpointer data);
 134 
 135 gboolean attrd_election_cb(gpointer user_data);
 136 void attrd_peer_change_cb(enum crm_status_type type, crm_node_t *peer, const void *data);
 137 
 138 #endif /* PACEMAKER_ATTRD__H */

/* [previous][next][first][last][top][bottom][index][help] */