32 utilization_value(
const char *s)
38 "invalid value '%s'", s);
69 compare_utilization_value(gpointer key, gpointer value, gpointer user_data)
71 int node1_capacity = 0;
72 int node2_capacity = 0;
73 struct compare_data *
data = user_data;
74 const char *node2_value = NULL;
76 if (
data->node2_only) {
77 if (g_hash_table_lookup(
data->node1->priv->utilization, key)) {
81 node1_capacity = utilization_value((
const char *) value);
84 node2_value = g_hash_table_lookup(
data->node2->priv->utilization, key);
85 node2_capacity = utilization_value(node2_value);
87 if (node1_capacity > node2_capacity) {
89 }
else if (node1_capacity < node2_capacity) {
109 struct compare_data
data = {
121 data.node2_only =
true;
133 struct calculate_data {
134 GHashTable *current_utilization;
147 update_utilization_value(gpointer key, gpointer value, gpointer user_data)
149 struct calculate_data *
data = user_data;
150 const char *current = g_hash_table_lookup(
data->current_utilization, key);
151 long long result = utilization_value(current)
152 + (
data->plus? 1LL : -1LL) * utilization_value(value);
156 }
else if (
result > INT_MAX) {
159 g_hash_table_replace(
data->current_utilization,
160 strdup(key), pcmk__itoa((
int)
result));
174 struct calculate_data
data = {
175 .current_utilization = current_utilization,
194 struct calculate_data
data = {
195 .current_utilization = current_utilization,
208 struct capacity_data {
223 check_capacity(gpointer key, gpointer value, gpointer user_data)
227 const char *node_value_s = NULL;
228 struct capacity_data *
data = user_data;
230 node_value_s = g_hash_table_lookup(
data->node->priv->utilization, key);
232 required = utilization_value(value);
233 remaining = utilization_value(node_value_s);
235 if (required > remaining) {
236 crm_debug(
"Remaining capacity for %s on %s (%d) is insufficient " 237 "for resource %s usage (%d)",
238 (
const char *) key, pcmk__node_name(
data->node), remaining,
239 data->rsc_id, required);
240 data->is_enough =
false;
255 have_enough_capacity(
const pcmk_node_t *node,
const char *rsc_id,
256 GHashTable *utilization)
258 struct capacity_data
data = {
264 g_hash_table_foreach(utilization, check_capacity, &
data);
265 return data.is_enough;
284 for (GList *iter = rscs; iter != NULL; iter = iter->next) {
304 bool any_capable =
false;
305 char *rscs_id = NULL;
308 GList *colocated_rscs = NULL;
309 GHashTable *unassigned_utilization = NULL;
322 if (colocated_rscs == NULL) {
329 if (g_list_find(colocated_rscs, rsc) == NULL) {
330 colocated_rscs = g_list_append(colocated_rscs, rsc);
334 unassigned_utilization = sum_resource_utilization(rsc, colocated_rscs);
338 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
343 if (have_enough_capacity(node, rscs_id, unassigned_utilization)) {
348 if ((most_capable_node == NULL)
350 most_capable_node = node;
357 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
359 && !have_enough_capacity(node, rscs_id,
360 unassigned_utilization)) {
362 pcmk__node_name(node), rscs_id);
364 "__limit_utilization__",
368 most_capable_node = NULL;
373 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
375 && !have_enough_capacity(node, rsc->
id,
378 pcmk__node_name(node), rsc->
id);
380 "__limit_utilization__",
386 g_hash_table_destroy(unassigned_utilization);
387 g_list_free(colocated_rscs);
392 return most_capable_node;
411 if (load_stopped->
node == NULL) {
415 free(load_stopped_task);
428 const GList *allowed_nodes)
430 const GList *iter = NULL;
434 "Creating utilization constraints for %s - strategy: %s",
439 load_stopped = new_load_stopped_op(iter->data);
446 for (iter = allowed_nodes; iter; iter = iter->next) {
447 load_stopped = new_load_stopped_op(iter->data);
474 iter != NULL; iter = iter->next) {
478 out->
message(out,
"node-capacity", node, desc);
#define CRM_CHECK(expr, failure_action)
pcmk_node_t * pe__copy_node(const pcmk_node_t *this_node)
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)
int(* message)(pcmk__output_t *out, const char *message_id,...)
#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
pcmk__scheduler_private_t * priv
#define PCMK_ACTION_MIGRATE_TO
void(* add_utilization)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *all_rscs, GHashTable *utilization)
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...)
pcmk__node_private_t * priv
void pcmk__create_utilization_constraints(pcmk_resource_t *rsc, const GList *allowed_nodes)
#define crm_debug(fmt, args...)
pcmk_scheduler_t * scheduler
#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)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
pcmk__resource_private_t * priv
Wrappers for and extensions to libxml2.
pcmk_scheduler_t * scheduler
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
GHashTable * allowed_nodes
#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
const char * placement_strategy
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)
GList *(* colocated_resources)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *colocated_rscs)
const pcmk__assignment_methods_t * cmds
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1