@Override public int compare(NodeInstance left, NodeInstance right) { int activeLeft = left.getActiveRoleInstances(role); int activeRight = right.getActiveRoleInstances(role); return activeRight - activeLeft; } }
@Override public int compare(NodeInstance left, NodeInstance right) { int activeLeft = left.getActiveRoleInstances(role); int activeRight = right.getActiveRoleInstances(role); return activeRight - activeLeft; } }
/** * List the active nodes * @param role role * @return a possibly empty sorted list of all nodes that are active * in that role */ public List<NodeInstance> listActiveNodes(int role) { List<NodeInstance> nodes = new ArrayList<>(); for (NodeInstance instance : values()) { if (instance.getActiveRoleInstances(role) > 0) { nodes.add(instance); } } Collections.sort(nodes, new NodeInstance.MoreActiveThan(role)); return nodes; }
/** * List the active nodes * @param role role * @return a possibly empty sorted list of all nodes that are active * in that role */ public List<NodeInstance> listActiveNodes(int role) { List<NodeInstance> nodes = new ArrayList<>(); for (NodeInstance instance : values()) { if (instance.getActiveRoleInstances(role) > 0) { nodes.add(instance); } } Collections.sort(nodes, new NodeInstance.MoreActiveThan(role)); return nodes; }
for (int i = 0; i < cnt && nodeInstance == null; i++) { NodeInstance candidate = targets.get(i); if (candidate.getActiveRoleInstances(roleId) == 0) {
for (int i = 0; i < cnt && nodeInstance == null; i++) { NodeInstance candidate = targets.get(i); if (candidate.getActiveRoleInstances(roleId) == 0) {