/** * Get the total size of the cluster -the number of NodeInstances * @return a count */ public synchronized int getClusterSize() { return nodemap.size(); }
/** * Get the total size of the cluster -the number of NodeInstances * @return a count */ public synchronized int getClusterSize() { return nodemap.size(); }
/** * Get snapshot of the node map * @return a snapshot of the current node state * @param naming naming map of priority to enty name; entries must be unique. * It's OK to be incomplete, for those the list falls back to numbers. */ public synchronized Map<String, NodeInformation> getNodeInformationSnapshot( Map<Integer, String> naming) { Map<String, NodeInformation> result = new HashMap<>(nodemap.size()); for (Map.Entry<String, NodeInstance> entry : nodemap.entrySet()) { result.put(entry.getKey(), entry.getValue().serialize(naming)); } return result; }
/** * Get snapshot of the node map * @return a snapshot of the current node state * @param naming naming map of priority to enty name; entries must be unique. * It's OK to be incomplete, for those the list falls back to numbers. */ public synchronized Map<String, NodeInformation> getNodeInformationSnapshot( Map<Integer, String> naming) { Map<String, NodeInformation> result = new HashMap<>(nodemap.size()); for (Map.Entry<String, NodeInstance> entry : nodemap.entrySet()) { result.put(entry.getKey(), entry.getValue().serialize(naming)); } return result; }
/** * Scan the current node map for all nodes capable of hosting an instance * @param role role ID * @param label label which must match, or "" for no label checks * @return a possibly empty list of node instances matching the criteria. */ public List<NodeInstance> findAllNodesForRole(int role, String label) { List<NodeInstance> nodes = new ArrayList<>(size()); for (NodeInstance instance : values()) { if (instance.canHost(role, label)) { nodes.add(instance); } } Collections.sort(nodes, new NodeInstance.CompareNames()); return nodes; }
/** * Scan the current node map for all nodes capable of hosting an instance * @param role role ID * @param label label which must match, or "" for no label checks * @return a possibly empty list of node instances matching the criteria. */ public List<NodeInstance> findAllNodesForRole(int role, String label) { List<NodeInstance> nodes = new ArrayList<>(size()); for (NodeInstance instance : values()) { if (instance.canHost(role, label)) { nodes.add(instance); } } Collections.sort(nodes, new NodeInstance.CompareNames()); return nodes; }