17 #define LOAD_STOPPED "load_stopped"    32 utilization_value(
const char *s)
    37         pe_warn(
"Using 0 for utilization instead of invalid value '%s'", value);
    68 compare_utilization_value(gpointer key, gpointer value, gpointer user_data)
    70     int node1_capacity = 0;
    71     int node2_capacity = 0;
    72     struct compare_data *
data = user_data;
    73     const char *node2_value = NULL;
    75     if (
data->node2_only) {
    76         if (g_hash_table_lookup(
data->node1->details->utilization, key)) {
    80         node1_capacity = utilization_value((
const char *) value);
    83     node2_value = g_hash_table_lookup(
data->node2->details->utilization, key);
    84     node2_capacity = utilization_value(node2_value);
    86     if (node1_capacity > node2_capacity) {
    88     } 
else if (node1_capacity < node2_capacity) {
   107     struct compare_data 
data = {
   119     data.node2_only = 
true;
   131 struct calculate_data {
   132     GHashTable *current_utilization;
   145 update_utilization_value(gpointer key, gpointer value, gpointer user_data)
   148     const char *current = NULL;
   149     struct calculate_data *
data = user_data;
   151     current = g_hash_table_lookup(
data->current_utilization, key);
   153         result = utilization_value(current) + utilization_value(value);
   154     } 
else if (current) {
   155         result = utilization_value(current) - utilization_value(value);
   157     g_hash_table_replace(
data->current_utilization,
   158                          strdup(key), pcmk__itoa(
result));
   172     struct calculate_data 
data = {
   173         .current_utilization = current_utilization,
   177     g_hash_table_foreach(rsc->
utilization, update_utilization_value, &
data);
   191     struct calculate_data 
data = {
   192         .current_utilization = current_utilization,
   196     g_hash_table_foreach(rsc->
utilization, update_utilization_value, &
data);
   204 struct capacity_data {
   219 check_capacity(gpointer key, gpointer value, gpointer user_data)
   223     const char *node_value_s = NULL;
   224     struct capacity_data *
data = user_data;
   226     node_value_s = g_hash_table_lookup(
data->node->details->utilization, key);
   228     required = utilization_value(value);
   229     remaining = utilization_value(node_value_s);
   231     if (required > remaining) {
   232         crm_debug(
"Remaining capacity for %s on %s (%d) is insufficient "   233                   "for resource %s usage (%d)",
   234                   (
const char *) key, pe__node_name(
data->node), remaining,
   235                   data->rsc_id, required);
   236         data->is_enough = 
false;
   251 have_enough_capacity(
const pe_node_t *node, 
const char *rsc_id,
   252                      GHashTable *utilization)
   254     struct capacity_data 
data = {
   260     g_hash_table_foreach(utilization, check_capacity, &
data);
   261     return data.is_enough;
   276 sum_resource_utilization(
const pe_resource_t *orig_rsc, GList *rscs)
   280     for (GList *iter = rscs; iter != NULL; iter = iter->next) {
   300     bool any_capable = 
false;
   301     char *rscs_id = NULL;
   303     const pe_node_t *most_capable_node = NULL;
   304     GList *colocated_rscs = NULL;
   305     GHashTable *unallocated_utilization = NULL;
   318     if (colocated_rscs == NULL) {
   325     if (g_list_find(colocated_rscs, rsc) == NULL) {
   326         colocated_rscs = g_list_append(colocated_rscs, rsc);
   330     unallocated_utilization = sum_resource_utilization(rsc, colocated_rscs);
   334     while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
   339         if (have_enough_capacity(node, rscs_id, unallocated_utilization)) {
   344         if ((most_capable_node == NULL)
   346             most_capable_node = node;
   353         while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
   355                 && !have_enough_capacity(node, rscs_id,
   356                                          unallocated_utilization)) {
   357                 pe_rsc_debug(rsc, 
"%s does not have enough capacity for %s",
   358                              pe__node_name(node), rscs_id);
   363         most_capable_node = NULL;
   368         while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
   371                 pe_rsc_debug(rsc, 
"%s does not have enough capacity for %s",
   372                              pe__node_name(node), rsc->
id);
   379     g_hash_table_destroy(unallocated_utilization);
   380     g_list_free(colocated_rscs);
   385     return most_capable_node;
   404     if (load_stopped->
node == NULL) {
   408     free(load_stopped_task);
   421                                      const GList *allowed_nodes)
   423     const GList *iter = NULL;
   427     pe_rsc_trace(rsc, 
"Creating utilization constraints for %s - strategy: %s",
   431     for (iter = rsc->
running_on; iter != NULL; iter = iter->next) {
   433         load_stopped = new_load_stopped_op(node, rsc->
cluster);
   439     for (iter = allowed_nodes; iter; iter = iter->next) {
   441         load_stopped = new_load_stopped_op(node, rsc->
cluster);
   463     for (
const GList *iter = 
data_set->
nodes; iter != NULL; iter = iter->next) {
   467         out->message(out, 
"node-capacity", node, desc);
 #define CRM_CHECK(expr, failure_action)
#define pe_rsc_debug(rsc, fmt, args...)
const pe_node_t * pcmk__ban_insufficient_capacity(pe_resource_t *rsc)
#define pe__show_node_weights(level, rsc, text, nodes, data_set)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
resource_alloc_functions_t * cmds
pe_node_t * pe__copy_node(const pe_node_t *this_node)
void resource_location(pe_resource_t *rsc, const pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
void pcmk__release_node_capacity(GHashTable *current_utilization, const pe_resource_t *rsc)
void pcmk__create_utilization_constraints(pe_resource_t *rsc, const GList *allowed_nodes)
GList *(* colocated_resources)(const pe_resource_t *rsc, const pe_resource_t *orig_rsc, GList *colocated_rscs)
pe_action_t * get_pseudo_op(const char *name, pe_working_set_t *data_set)
#define crm_debug(fmt, args...)
G_GNUC_INTERNAL bool pcmk__node_available(const pe_node_t *node, bool consider_score, bool consider_guest)
#define pe__clear_action_flags(action, flags_to_clear)
void pcmk__show_node_capacities(const char *desc, pe_working_set_t *data_set)
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
pe_working_set_t * data_set
G_GNUC_INTERNAL void pcmk__new_ordering(pe_resource_t *first_rsc, char *first_task, pe_action_t *first_action, pe_resource_t *then_rsc, char *then_task, pe_action_t *then_action, uint32_t flags, pe_working_set_t *data_set)
void pcmk__consume_node_capacity(GHashTable *current_utilization, const pe_resource_t *rsc)
void(* add_utilization)(const pe_resource_t *rsc, const pe_resource_t *orig_rsc, GList *all_rscs, GHashTable *utilization)
const char * placement_strategy
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL) 
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
pcmk__action_result_t result
#define pe_flag_show_utilization
This structure contains everything that makes up a single output formatter. 
pe_working_set_t * cluster
#define pe_rsc_trace(rsc, fmt, args...)
int pcmk__compare_node_capacities(const pe_node_t *node1, const pe_node_t *node2)
GHashTable * allowed_nodes