MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / node_list_attr_score

Function node_list_attr_score

pengine/native.c:223–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223static int
224node_list_attr_score(GHashTable * list, const char *attr, const char *value)
225{
226 GHashTableIter iter;
227 node_t *node = NULL;
228 int best_score = -INFINITY;
229 const char *best_node = NULL;
230
231 if (attr == NULL) {
232 attr = "#" XML_ATTR_UNAME;
233 }
234
235 g_hash_table_iter_init(&iter, list);
236 while (g_hash_table_iter_next(&iter, NULL, (void **)&node)) {
237 int weight = node->weight;
238
239 if (can_run_resources(node) == FALSE) {
240 weight = -INFINITY;
241 }
242 if (weight > best_score || best_node == NULL) {
243 const char *tmp = g_hash_table_lookup(node->details->attrs, attr);
244
245 if (safe_str_eq(value, tmp)) {
246 best_score = weight;
247 best_node = node->details->uname;
248 }
249 }
250 }
251
252 if (safe_str_neq(attr, "#" XML_ATTR_UNAME)) {
253 crm_info("Best score for %s=%s was %s with %d",
254 attr, value, best_node ? best_node : "<none>", best_score);
255 }
256
257 return best_score;
258}
259
260static void
261node_hash_update(GHashTable * list1, GHashTable * list2, const char *attr, float factor,

Callers 1

node_hash_updateFunction · 0.85

Calls 4

g_hash_table_iter_initFunction · 0.85
g_hash_table_iter_nextFunction · 0.85
can_run_resourcesFunction · 0.85
safe_str_neqFunction · 0.85

Tested by

no test coverage detected