 |
pacemaker
2.0.3-4b1f869f0f
Scalable High-Availability cluster resource manager
|
Go to the documentation of this file.
15 int node_weight,
const char *discover_mode,
20 if (rsc == NULL ||
id == NULL) {
24 }
else if (foo_node == NULL) {
29 if (new_con != NULL) {
30 new_con->
id = strdup(
id);
36 if (discover_mode == NULL ||
safe_str_eq(discover_mode,
"always")) {
40 }
else if (
safe_str_eq(discover_mode,
"exclusive")) {
47 if (foo_node != NULL) {
50 copy->
weight = node_weight;
76 crm_trace(
"%s: online=%d, unclean=%d, standby=%d, maintenance=%d",
84 struct node_weight_s {
94 sort_node_weight(gconstpointer a, gconstpointer b, gpointer
data)
98 struct node_weight_s *nw =
data;
100 int node1_weight = 0;
101 int node2_weight = 0;
112 node1_weight = node1->
weight;
113 node2_weight = node2->
weight;
122 if (node1_weight > node2_weight) {
128 if (node1_weight < node2_weight) {
137 if (
safe_str_eq(nw->data_set->placement_strategy,
"minimal")) {
141 if (
safe_str_eq(nw->data_set->placement_strategy,
"balanced")) {
147 }
else if (result > 0) {
156 crm_trace(
"%s (%d) > %s (%d) : resources",
162 crm_trace(
"%s (%d) < %s (%d) : resources",
168 if (nw->active && nw->active->details == node1->
details) {
173 }
else if (nw->active && nw->active->details == node2->
details) {
188 struct node_weight_s nw = { active_node, data_set };
190 return g_list_sort_with_data(nodes, sort_node_weight, &nw);
216 if (force == FALSE && chosen != NULL) {
228 crm_debug(
"All nodes for resource %s are unavailable"
229 ", unclean or shutting down (%s: %d, %d)",
243 if (chosen == NULL) {
247 crm_debug(
"Could not allocate a node for %s", rsc->
id);
250 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
262 }
else if (interval_ms_s &&
safe_str_neq(interval_ms_s,
"0")) {
292 const char *node_uname = NULL;
293 const char *node_uuid = NULL;
295 if (action == NULL) {
296 crm_trace(
"%s%s: <NULL>", pre_text == NULL ?
"" : pre_text, pre_text == NULL ?
"" :
": ");
304 }
else if (action->
node != NULL) {
308 node_uname =
"<none>";
315 crm_trace(
"%s%s%sAction %d: %s%s%s%s%s%s",
316 pre_text == NULL ?
"" : pre_text,
317 pre_text == NULL ?
"" :
": ",
318 is_set(action->
flags,
321 "Optional " : is_set(action->
flags,
324 ?
"" :
"(Provisional) " :
"!!Non-Startable!! ", action->
id,
325 action->
uuid, node_uname ?
"\ton " :
"",
326 node_uname ? node_uname :
"", node_uuid ?
"\t\t(" :
"",
327 node_uuid ? node_uuid :
"", node_uuid ?
")" :
"");
330 crm_trace(
"%s%s%sAction %d: %s %s%s%s%s%s%s",
331 pre_text == NULL ?
"" : pre_text,
332 pre_text == NULL ?
"" :
": ",
333 is_set(action->
flags,
336 ?
"Pseudo " : is_set(action->
flags,
339 ?
"" :
"(Provisional) " :
"!!Non-Startable!! ", action->
id,
341 node_uname ?
"\ton " :
"", node_uname ? node_uname :
"",
342 node_uuid ?
"\t\t(" :
"", node_uuid ? node_uuid :
"", node_uuid ?
")" :
"");
350 crm_trace(
"\t\t====== Preceding Actions");
353 for (; gIter != NULL; gIter = gIter->next) {
359 crm_trace(
"\t\t====== Subsequent Actions");
362 for (; gIter != NULL; gIter = gIter->next) {
386 g_hash_table_iter_init(&iter, nodes);
387 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
433 free(cancel_op->
task);
462 node, FALSE, TRUE, data_set);
471 generate_transition_magic(
const char *transition_key,
int op_status,
int op_rc)
473 CRM_CHECK(transition_key != NULL,
return NULL);
479 const char *magic,
int level)
486 xmlNode *args_xml = NULL;
502 do_crm_log(level,
"Calculated digest %s for %s (%s). Source: %s\n",
503 digest,
ID(update), magic, digest_source);
513 #define FAKE_TE_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
531 const char *caller_version,
int target_rc,
532 const char *node,
const char *origin,
int level)
537 char *op_id_additional = NULL;
538 char *local_user_data = NULL;
539 const char *exit_reason = NULL;
541 xmlNode *xml_op = NULL;
542 const char *task = NULL;
545 do_crm_log(level,
"%s: Updating resource %s after %s op %s (interval=%u)",
549 crm_trace(
"DC version: %s", caller_version);
600 if (xml_op == NULL) {
639 (
long long) op->
t_run);
643 (
long long) op->
t_run);
653 (
long long) op->
t_run);
674 append_digest(op, xml_op, caller_version, magic, LOG_DEBUG);
676 if (op_id_additional) {
678 op_id = op_id_additional;
679 op_id_additional = NULL;
683 if (local_user_data) {
684 free(local_user_data);
const char * crm_xml_add_ll(xmlNode *node, const char *name, long long value)
Create an XML attribute with specified name and long long int value.
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
#define XML_LRM_ATTR_MIGRATE_SOURCE
#define XML_RSC_OP_T_EXEC
#define XML_LRM_ATTR_TASK_KEY
gboolean exclusive_discover
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
enum pe_obj_types variant
char * dump_xml_unformatted(xmlNode *msg)
#define XML_LRM_ATTR_OPSTATUS
gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc)
enum rsc_role_e next_role
#define XML_LOCATION_ATTR_DISCOVERY
int compare_capacity(const node_t *node1, const node_t *node2)
#define CRMD_ACTION_NOTIFY
#define XML_ATTR_TRANSITION_KEY
#define pe_rsc_provisional
xmlNode * create_xml_node(xmlNode *parent, const char *name)
gboolean native_assign_node(resource_t *rsc, GListPtr nodes, node_t *chosen, gboolean force)
#define CRM_CHECK(expr, failure_action)
#define clear_bit(word, bit)
struct pe_node_shared_s * details
action_t * custom_action(resource_t *rsc, char *key, const char *task, node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
#define crm_notice(fmt, args...)
xmlNode * pcmk__create_history_xml(xmlNode *parent, lrmd_event_data_t *op, const char *caller_version, int target_rc, const char *node, const char *origin, int level)
int compare_version(const char *version1, const char *version2)
#define crm_trace(fmt, args...)
#define safe_str_eq(a, b)
enum action_tasks text2task(const char *task)
pe_action_t * pe_cancel_op(pe_resource_t *rsc, const char *task, guint interval_ms, pe_node_t *node, pe_working_set_t *data_set)
void filter_action_parameters(xmlNode *param_set, const char *version)
enum pe_action_flags flags
void free_xml(xmlNode *child)
#define XML_ATTR_CRM_VERSION
void native_deallocate(resource_t *rsc)
#define set_bit(word, bit)
void calculate_utilization(GHashTable *current_utilization, GHashTable *utilization, gboolean plus)
#define XML_RSC_OP_T_QUEUE
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
#define crm_info(fmt, args...)
#define XML_RSC_OP_LAST_RUN
gboolean update_action_flags(action_t *action, enum pe_action_flags flags, const char *source, int line)
enum rsc_role_e role_filter
#define CRM_LOG_ASSERT(expr)
gboolean can_run_any(GHashTable *nodes)
#define CRMD_ACTION_MIGRATED
#define XML_ATTR_TE_TARGET_RC
#define XML_LRM_ATTR_TASK
unsigned int get_crm_log_level(void)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define CRMD_ACTION_START
#define crm_debug(fmt, args...)
#define CRMD_ACTION_MIGRATE
gboolean show_utilization
#define XML_RSC_OP_LAST_CHANGE
enum pe_discover_e discover_mode
#define do_crm_log(level, fmt, args...)
Log a message.
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define XML_ATTR_TE_NOWAIT
#define XML_LRM_TAG_RSC_OP
node_t * node_copy(const node_t *this_node)
GListPtr placement_constraints
int utilization_log_level
void add_hash_param(GHashTable *hash, const char *name, const char *value)
gboolean shutdown_constraints(node_t *node, action_t *shutdown_op, pe_working_set_t *data_set)
const char * crm_meta_value(GHashTable *hash, const char *field)
GList * sort_nodes_by_weight(GList *nodes, pe_node_t *active_node, pe_working_set_t *data_set)
#define XML_LRM_ATTR_EXIT_REASON
#define XML_LRM_ATTR_OP_DIGEST
gboolean safe_str_neq(const char *a, const char *b)
#define XML_LRM_ATTR_MIGRATE_TARGET
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
void dump_rsc_utilization(int level, const char *comment, resource_t *rsc, node_t *node)
#define XML_ATTR_TRANSITION_MAGIC
#define XML_LRM_ATTR_TARGET
#define CRMD_ACTION_STATUS
#define XML_LRM_ATTR_INTERVAL_MS
pe_action_t * create_pseudo_resource_op(resource_t *rsc, const char *task, bool optional, bool runnable, pe_working_set_t *data_set)
gboolean can_run_resources(const node_t *node)
gboolean pe__is_guest_node(pe_node_t *node)
char * generate_op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key.
pe__location_t * rsc2node_new(const char *id, pe_resource_t *rsc, int node_weight, const char *discover_mode, pe_node_t *foo_node, pe_working_set_t *data_set)
#define XML_LRM_ATTR_CALLID
void hash2field(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry.
char * generate_transition_key(int action, int transition_id, int target_rc, const char *node)
pe_action_t * sched_shutdown_op(pe_node_t *node, pe_working_set_t *data_set)
const char * crm_xml_add_ms(xmlNode *node, const char *name, guint ms)
Create an XML attribute with specified name and unsigned value.
char * generate_notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
void log_action(unsigned int log_level, const char *pre_text, action_t *action, gboolean details)