29 utilization_value(
const char *s)
34 pe_warn(
"Using 0 for utilization instead of invalid value '%s'", value);
65 compare_utilization_value(gpointer key, gpointer value, gpointer user_data)
67 int node1_capacity = 0;
68 int node2_capacity = 0;
69 struct compare_data *
data = user_data;
70 const char *node2_value = NULL;
72 if (
data->node2_only) {
73 if (g_hash_table_lookup(
data->node1->details->utilization, key)) {
77 node1_capacity = utilization_value((
const char *) value);
80 node2_value = g_hash_table_lookup(
data->node2->details->utilization, key);
81 node2_capacity = utilization_value(node2_value);
83 if (node1_capacity > node2_capacity) {
85 }
else if (node1_capacity < node2_capacity) {
105 struct compare_data
data = {
117 data.node2_only =
true;
129 struct calculate_data {
130 GHashTable *current_utilization;
143 update_utilization_value(gpointer key, gpointer value, gpointer user_data)
146 const char *current = NULL;
147 struct calculate_data *
data = user_data;
149 current = g_hash_table_lookup(
data->current_utilization, key);
151 result = utilization_value(current) + utilization_value(value);
152 }
else if (current) {
153 result = utilization_value(current) - utilization_value(value);
155 g_hash_table_replace(
data->current_utilization,
156 strdup(key), pcmk__itoa(
result));
170 struct calculate_data
data = {
171 .current_utilization = current_utilization,
175 g_hash_table_foreach(rsc->
utilization, update_utilization_value, &
data);
189 struct calculate_data
data = {
190 .current_utilization = current_utilization,
194 g_hash_table_foreach(rsc->
utilization, update_utilization_value, &
data);
202 struct capacity_data {
217 check_capacity(gpointer key, gpointer value, gpointer user_data)
221 const char *node_value_s = NULL;
222 struct capacity_data *
data = user_data;
224 node_value_s = g_hash_table_lookup(
data->node->details->utilization, key);
226 required = utilization_value(value);
227 remaining = utilization_value(node_value_s);
229 if (required > remaining) {
230 crm_debug(
"Remaining capacity for %s on %s (%d) is insufficient " 231 "for resource %s usage (%d)",
232 (
const char *) key, pe__node_name(
data->node), remaining,
233 data->rsc_id, required);
234 data->is_enough =
false;
249 have_enough_capacity(
const pcmk_node_t *node,
const char *rsc_id,
250 GHashTable *utilization)
252 struct capacity_data
data = {
258 g_hash_table_foreach(utilization, check_capacity, &
data);
259 return data.is_enough;
278 for (GList *iter = rscs; iter != NULL; iter = iter->next) {
298 bool any_capable =
false;
299 char *rscs_id = NULL;
302 GList *colocated_rscs = NULL;
303 GHashTable *unassigned_utilization = NULL;
316 if (colocated_rscs == NULL) {
323 if (g_list_find(colocated_rscs, rsc) == NULL) {
324 colocated_rscs = g_list_append(colocated_rscs, rsc);
328 unassigned_utilization = sum_resource_utilization(rsc, colocated_rscs);
332 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
337 if (have_enough_capacity(node, rscs_id, unassigned_utilization)) {
342 if ((most_capable_node == NULL)
344 most_capable_node = node;
351 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
353 && !have_enough_capacity(node, rscs_id,
354 unassigned_utilization)) {
355 pe_rsc_debug(rsc,
"%s does not have enough capacity for %s",
356 pe__node_name(node), rscs_id);
361 most_capable_node = NULL;
366 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
369 pe_rsc_debug(rsc,
"%s does not have enough capacity for %s",
370 pe__node_name(node), rsc->
id);
377 g_hash_table_destroy(unassigned_utilization);
378 g_list_free(colocated_rscs);
383 return most_capable_node;
402 if (load_stopped->
node == NULL) {
406 free(load_stopped_task);
419 const GList *allowed_nodes)
421 const GList *iter = NULL;
424 pe_rsc_trace(rsc,
"Creating utilization constraints for %s - strategy: %s",
428 for (iter = rsc->
running_on; iter != NULL; iter = iter->next) {
429 load_stopped = new_load_stopped_op(iter->data);
435 for (iter = allowed_nodes; iter; iter = iter->next) {
436 load_stopped = new_load_stopped_op(iter->data);
461 iter != NULL; iter = iter->next) {
465 out->message(out,
"node-capacity", node, desc);
pcmk_assignment_methods_t * cmds
Resource assignment methods.
#define CRM_CHECK(expr, failure_action)
pcmk_node_t * pe__copy_node(const pcmk_node_t *this_node)
pcmk_scheduler_t * cluster
Cluster that resource is part of.
Actions are ordered if on same node (or migration target for migrate_to)
#define pe_rsc_debug(rsc, fmt, args...)
pcmk_action_t * get_pseudo_op(const char *name, pcmk_scheduler_t *scheduler)
Whether action should not be executed.
int pcmk__scan_min_int(const char *text, int *result, int minimum)
G_GNUC_INTERNAL void pcmk__new_ordering(pcmk_resource_t *first_rsc, char *first_task, pcmk_action_t *first_action, pcmk_resource_t *then_rsc, char *then_task, pcmk_action_t *then_action, uint32_t flags, pcmk_scheduler_t *sched)
void pcmk__consume_node_capacity(GHashTable *current_utilization, const pcmk_resource_t *rsc)
void pcmk__show_node_capacities(const char *desc, pcmk_scheduler_t *scheduler)
Implementation of pcmk_action_t.
const pcmk_node_t * pcmk__ban_insufficient_capacity(pcmk_resource_t *rsc)
#define PCMK_ACTION_MIGRATE_TO
pcmk_scheduler_t * data_set
Cluster that node is part of.
Implementation of pcmk_scheduler_t.
G_GNUC_INTERNAL bool pcmk__node_available(const pcmk_node_t *node, bool consider_score, bool consider_guest)
GList * nodes
Nodes in cluster.
Whether to show node and resource utilization (in log or output)
void pcmk__create_utilization_constraints(pcmk_resource_t *rsc, const GList *allowed_nodes)
pcmk_node_t * node
Node to execute action on, if any.
Implementation of pcmk_resource_t.
#define crm_debug(fmt, args...)
void resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score, const char *tag, pcmk_scheduler_t *scheduler)
#define pe__clear_action_flags(action, flags_to_clear)
void * priv
For Pacemaker use only.
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
Basic node information.
const char * uname
Node name in cluster.
GHashTable * utilization
Resource's utilization attributes.
GList *(* colocated_resources)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *colocated_rscs)
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
Implementation of pcmk_node_t.
const char * placement_strategy
Value of placement-strategy property.
#define PCMK_ACTION_LOAD_STOPPED
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
pcmk__action_result_t result
int pcmk__compare_node_capacities(const pcmk_node_t *node1, const pcmk_node_t *node2)
pcmk_scheduler_t * scheduler
void pcmk__release_node_capacity(GHashTable *current_utilization, const pcmk_resource_t *rsc)
This structure contains everything that makes up a single output formatter.
GHashTable * utilization
Node utilization attributes.
#define pe__show_node_scores(level, rsc, text, nodes, scheduler)
GList * running_on
Nodes where resource may be active.
#define pe_rsc_trace(rsc, fmt, args...)
unsigned long long flags
Group of enum pcmk_scheduler_flags.
void(* add_utilization)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *all_rscs, GHashTable *utilization)
char * id
Resource ID in configuration.
GHashTable * allowed_nodes
Nodes where resource may run (key is node ID, not name)