29 utilization_value(
const char *s)
35 "invalid value '%s'", s);
66 compare_utilization_value(gpointer key, gpointer value, gpointer user_data)
68 int node1_capacity = 0;
69 int node2_capacity = 0;
70 struct compare_data *
data = user_data;
71 const char *node2_value = NULL;
73 if (
data->node2_only) {
74 if (g_hash_table_lookup(
data->node1->details->utilization, key)) {
78 node1_capacity = utilization_value((
const char *) value);
81 node2_value = g_hash_table_lookup(
data->node2->details->utilization, key);
82 node2_capacity = utilization_value(node2_value);
84 if (node1_capacity > node2_capacity) {
86 }
else if (node1_capacity < node2_capacity) {
106 struct compare_data
data = {
118 data.node2_only =
true;
130 struct calculate_data {
131 GHashTable *current_utilization;
144 update_utilization_value(gpointer key, gpointer value, gpointer user_data)
147 const char *current = NULL;
148 struct calculate_data *
data = user_data;
150 current = g_hash_table_lookup(
data->current_utilization, key);
152 result = utilization_value(current) + utilization_value(value);
153 }
else if (current) {
154 result = utilization_value(current) - utilization_value(value);
156 g_hash_table_replace(
data->current_utilization,
157 strdup(key), pcmk__itoa(
result));
171 struct calculate_data
data = {
172 .current_utilization = current_utilization,
176 g_hash_table_foreach(rsc->
utilization, update_utilization_value, &
data);
190 struct calculate_data
data = {
191 .current_utilization = current_utilization,
195 g_hash_table_foreach(rsc->
utilization, update_utilization_value, &
data);
203 struct capacity_data {
218 check_capacity(gpointer key, gpointer value, gpointer user_data)
222 const char *node_value_s = NULL;
223 struct capacity_data *
data = user_data;
225 node_value_s = g_hash_table_lookup(
data->node->details->utilization, key);
227 required = utilization_value(value);
228 remaining = utilization_value(node_value_s);
230 if (required > remaining) {
231 crm_debug(
"Remaining capacity for %s on %s (%d) is insufficient " 232 "for resource %s usage (%d)",
233 (
const char *) key, pcmk__node_name(
data->node), remaining,
234 data->rsc_id, required);
235 data->is_enough =
false;
250 have_enough_capacity(
const pcmk_node_t *node,
const char *rsc_id,
251 GHashTable *utilization)
253 struct capacity_data
data = {
259 g_hash_table_foreach(utilization, check_capacity, &
data);
260 return data.is_enough;
279 for (GList *iter = rscs; iter != NULL; iter = iter->next) {
299 bool any_capable =
false;
300 char *rscs_id = NULL;
303 GList *colocated_rscs = NULL;
304 GHashTable *unassigned_utilization = NULL;
317 if (colocated_rscs == NULL) {
324 if (g_list_find(colocated_rscs, rsc) == NULL) {
325 colocated_rscs = g_list_append(colocated_rscs, rsc);
329 unassigned_utilization = sum_resource_utilization(rsc, colocated_rscs);
333 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
338 if (have_enough_capacity(node, rscs_id, unassigned_utilization)) {
343 if ((most_capable_node == NULL)
345 most_capable_node = node;
352 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
354 && !have_enough_capacity(node, rscs_id,
355 unassigned_utilization)) {
357 pcmk__node_name(node), rscs_id);
359 "__limit_utilization__", rsc->
cluster);
362 most_capable_node = NULL;
367 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
371 pcmk__node_name(node), rsc->
id);
373 "__limit_utilization__", rsc->
cluster);
378 g_hash_table_destroy(unassigned_utilization);
379 g_list_free(colocated_rscs);
384 return most_capable_node;
403 if (load_stopped->
node == NULL) {
407 free(load_stopped_task);
420 const GList *allowed_nodes)
422 const GList *iter = NULL;
426 "Creating utilization constraints for %s - strategy: %s",
430 for (iter = rsc->
running_on; iter != NULL; iter = iter->next) {
431 load_stopped = new_load_stopped_op(iter->data);
437 for (iter = allowed_nodes; iter; iter = iter->next) {
438 load_stopped = new_load_stopped_op(iter->data);
463 iter != NULL; iter = iter->next) {
467 out->message(out,
"node-capacity", node, desc);
pcmk_assignment_methods_t * cmds
#define CRM_CHECK(expr, failure_action)
pcmk_node_t * pe__copy_node(const pcmk_node_t *this_node)
pcmk_scheduler_t * cluster
Actions are ordered if on same node (or migration target for migrate_to)
pcmk_action_t * get_pseudo_op(const char *name, pcmk_scheduler_t *scheduler)
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)
#define pcmk__config_warn(fmt...)
#define pcmk__rsc_trace(rsc, fmt, args...)
void pcmk__show_node_capacities(const char *desc, pcmk_scheduler_t *scheduler)
const pcmk_node_t * pcmk__ban_insufficient_capacity(pcmk_resource_t *rsc)
#define PCMK_VALUE_DEFAULT
#define PCMK_ACTION_MIGRATE_TO
pcmk_scheduler_t * data_set
G_GNUC_INTERNAL bool pcmk__node_available(const pcmk_node_t *node, bool consider_score, bool consider_guest)
#define pcmk__rsc_debug(rsc, fmt, args...)
void pcmk__create_utilization_constraints(pcmk_resource_t *rsc, const GList *allowed_nodes)
#define crm_debug(fmt, args...)
#define pcmk__clear_action_flags(action, flags_to_clear)
void resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score, const char *tag, pcmk_scheduler_t *scheduler)
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
Wrappers for and extensions to libxml2.
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)
const char * placement_strategy
#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.
#define pe__show_node_scores(level, rsc, text, nodes, scheduler)
void(* add_utilization)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *all_rscs, GHashTable *utilization)
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
GHashTable * allowed_nodes