/** * Get the node instance of a host if defined * @param hostname hostname to look up * @return a node instance or null * @throws RuntimeException if the container has no hostname */ public synchronized NodeInstance getExistingNodeInstance(String hostname) { return nodemap.get(hostname); }
/** * Update the node state. Return true if the node state changed: either by * being created, or by changing its internal state as defined * by {@link NodeInstance#updateNode(NodeReport)}. * * @param hostname host name * @param report latest node report * @return true if the node state changed enough for a request evaluation. */ public boolean updateNode(String hostname, NodeReport report) { boolean nodeExisted = get(hostname) != null; boolean updated = getOrCreate(hostname).updateNode(report); return updated || !nodeExisted; }
/** * Get the node instance of a host if defined * @param hostname hostname to look up * @return a node instance or null * @throws RuntimeException if the container has no hostname */ public synchronized NodeInstance getExistingNodeInstance(String hostname) { return nodemap.get(hostname); }
/** * Update the node state. Return true if the node state changed: either by * being created, or by changing its internal state as defined * by {@link NodeInstance#updateNode(NodeReport)}. * * @param hostname host name * @param report latest node report * @return true if the node state changed enough for a request evaluation. */ public boolean updateNode(String hostname, NodeReport report) { boolean nodeExisted = get(hostname) != null; boolean updated = getOrCreate(hostname).updateNode(report); return updated || !nodeExisted; }
/** * Get the node instance of a container <i>if there's an entry in the history</i> * @param container container to look up * @return a node instance or null * @throws RuntimeException if the container has no hostname */ public synchronized NodeInstance getExistingNodeInstance(Container container) { return nodemap.get(RoleHistoryUtils.hostnameOf(container)); }
/** * Get the information on a node * @param hostname hostname * @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. * @return the information about that host, or null if there is none */ public synchronized NodeInformation getNodeInformation(String hostname, Map<Integer, String> naming) { NodeInstance nodeInstance = nodemap.get(hostname); return nodeInstance != null ? nodeInstance.serialize(naming) : null; }
/** * Get the information on a node * @param hostname hostname * @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. * @return the information about that host, or null if there is none */ public synchronized NodeInformation getNodeInformation(String hostname, Map<Integer, String> naming) { NodeInstance nodeInstance = nodemap.get(hostname); return nodeInstance != null ? nodeInstance.serialize(naming) : null; }
/** * Get the node instance of a container <i>if there's an entry in the history</i> * @param container container to look up * @return a node instance or null * @throws RuntimeException if the container has no hostname */ public synchronized NodeInstance getExistingNodeInstance(Container container) { return nodemap.get(RoleHistoryUtils.hostnameOf(container)); }
@Override public synchronized String toString() { final StringBuilder sb = new StringBuilder("NodeMap{"); List<String> keys = new ArrayList<>(keySet()); Collections.sort(keys); for (String key : keys) { sb.append(key).append(": "); sb.append(get(key).toFullString()).append("\n"); } sb.append('}'); return sb.toString(); } }
@Override public synchronized String toString() { final StringBuilder sb = new StringBuilder("NodeMap{"); List<String> keys = new ArrayList<>(keySet()); Collections.sort(keys); for (String key : keys) { sb.append(key).append(": "); sb.append(get(key).toFullString()).append("\n"); } sb.append('}'); return sb.toString(); } }
/** * Get the node instance for the specific node -creating it if needed * @param hostname node * @return the instance */ public NodeInstance getOrCreate(String hostname) { NodeInstance node = get(hostname); if (node == null) { node = new NodeInstance(hostname, roleSize); put(hostname, node); } return node; }
/** * Get the node instance for the specific node -creating it if needed * @param hostname node * @return the instance */ public NodeInstance getOrCreate(String hostname) { NodeInstance node = get(hostname); if (node == null) { node = new NodeInstance(hostname, roleSize); put(hostname, node); } return node; }