47 GHashTable *new_table = NULL;
55 g_hash_table_iter_init(&iter, nodes);
56 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) {
59 g_hash_table_insert(new_table, (gpointer) new_node->
details->
id,
79 for (
const GList *gIter = list; gIter != NULL; gIter = gIter->next) {
92 struct node_weight_s {
112 compare_nodes(gconstpointer a, gconstpointer b, gpointer
data)
116 struct node_weight_s *nw =
data;
118 int node1_weight = 0;
119 int node2_weight = 0;
135 if (node1_weight > node2_weight) {
142 if (node1_weight < node2_weight) {
155 if (pcmk__str_eq(nw->data_set->placement_strategy,
"minimal",
160 if (pcmk__str_eq(nw->data_set->placement_strategy,
"balanced",
177 crm_trace(
"%s (%d) > %s (%d) : resources",
183 crm_trace(
"%s (%d) < %s (%d) : resources",
191 if (nw->active != NULL) {
192 if (nw->active->details == node1->
details) {
197 }
else if (nw->active->details == node2->
details) {
225 struct node_weight_s nw = { active_node,
data_set };
227 return g_list_sort_with_data(nodes, compare_nodes, &nw);
248 g_hash_table_iter_init(&iter, nodes);
249 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
275 crm_info(
"Applying node health strategy '%s'", strategy_str);
282 for (GList *iter =
data_set->
nodes; iter != NULL; iter = iter->next) {
290 crm_info(
"Node %s overall system health is %d",
297 bool constrain =
true;
pe_node_t * pe__copy_node(const pe_node_t *this_node)
const char * pe_pref(GHashTable *options, const char *name)
void pcmk__apply_node_health(pe_working_set_t *data_set)
enum pcmk__health_strategy pcmk__parse_health_strategy(const char *value)
bool pcmk__any_node_available(GHashTable *nodes)
#define PCMK__OPT_NODE_HEALTH_BASE
GList * pcmk__sort_nodes(GList *nodes, pe_node_t *active_node, pe_working_set_t *data_set)
#define crm_trace(fmt, args...)
GList * pcmk__copy_node_list(const GList *list, bool reset)
struct pe_node_shared_s * details
pe_working_set_t * data_set
#define PCMK__OPT_NODE_HEALTH_STRATEGY
#define PCMK__META_ALLOW_UNHEALTHY_NODES
G_GNUC_INTERNAL pe__location_t * pcmk__new_location(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)
GHashTable * pcmk__copy_node_table(GHashTable *nodes)
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
bool pcmk__node_available(const pe_node_t *node)
pcmk__action_result_t result
G_GNUC_INTERNAL int pcmk__compare_node_capacities(const pe_node_t *node1, const pe_node_t *node2)
gboolean crm_is_true(const char *s)
#define pe_rsc_trace(rsc, fmt, args...)
int pe__sum_node_health_scores(const pe_node_t *node, int base_health)
#define crm_info(fmt, args...)