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

Function sort_node_weight

pengine/utils.c:185–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183 */
184
185gint
186sort_node_weight(gconstpointer a, gconstpointer b, gpointer data)
187{
188 const node_t *node1 = (const node_t *)a;
189 const node_t *node2 = (const node_t *)b;
190 const node_t *active = (node_t *) data;
191
192 int node1_weight = 0;
193 int node2_weight = 0;
194
195 int result = 0;
196
197 if (a == NULL) {
198 return 1;
199 }
200 if (b == NULL) {
201 return -1;
202 }
203
204 node1_weight = node1->weight;
205 node2_weight = node2->weight;
206
207 if (can_run_resources(node1) == FALSE) {
208 node1_weight = -INFINITY;
209 }
210 if (can_run_resources(node2) == FALSE) {
211 node2_weight = -INFINITY;
212 }
213
214 if (node1_weight > node2_weight) {
215 crm_trace( "%s (%d) > %s (%d) : weight",
216 node1->details->uname, node1_weight,
217 node2->details->uname, node2_weight);
218 return -1;
219 }
220
221 if (node1_weight < node2_weight) {
222 crm_trace( "%s (%d) < %s (%d) : weight",
223 node1->details->uname, node1_weight,
224 node2->details->uname, node2_weight);
225 return 1;
226 }
227
228 crm_trace( "%s (%d) == %s (%d) : weight",
229 node1->details->uname, node1_weight, node2->details->uname, node2_weight);
230
231 if (safe_str_eq(pe_dataset->placement_strategy, "minimal")) {
232 goto equal;
233 }
234
235 if (safe_str_eq(pe_dataset->placement_strategy, "balanced")) {
236 result = compare_capacity(node1, node2);
237 if (result != 0) {
238 return result;
239 }
240 }
241
242 /* now try to balance resources across the cluster */

Callers

nothing calls this directly

Calls 2

can_run_resourcesFunction · 0.85
compare_capacityFunction · 0.85

Tested by

no test coverage detected