| 183 | */ |
| 184 | |
| 185 | gint |
| 186 | sort_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 */ |
nothing calls this directly
no test coverage detected