/** * Get the node instance for the specific node -creating it if needed * @param hostname node address * @return the instance */ public synchronized NodeInstance getOrCreateNodeInstance(String hostname) { //convert to a string return nodemap.getOrCreate(hostname); }
/** * Get the node instance for the specific node -creating it if needed * @param hostname node address * @return the instance */ public synchronized NodeInstance getOrCreateNodeInstance(String hostname) { //convert to a string return nodemap.getOrCreate(hostname); }
/** * Get the node instance of a container -always returns something * @param container container to look up * @return a (possibly new) node instance * @throws RuntimeException if the container has no hostname */ public synchronized NodeInstance getOrCreateNodeInstance(Container container) { return nodemap.getOrCreate(RoleHistoryUtils.hostnameOf(container)); }
/** * Get the node instance of a container -always returns something * @param container container to look up * @return a (possibly new) node instance * @throws RuntimeException if the container has no hostname */ public synchronized NodeInstance getOrCreateNodeInstance(Container container) { return nodemap.getOrCreate(RoleHistoryUtils.hostnameOf(container)); }
/** * Test helper: build or update a cluster from a list of node reports * @param reports the list of reports * @return true if this has been considered to have changed the cluster */ @VisibleForTesting public boolean buildOrUpdate(List<NodeReport> reports) { boolean updated = false; for (NodeReport report : reports) { updated |= getOrCreate(report.getNodeId().getHost()).updateNode(report); } return updated; }
/** * 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; }
/** * 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; }
/** * Test helper: build or update a cluster from a list of node reports * @param reports the list of reports * @return true if this has been considered to have changed the cluster */ @VisibleForTesting public boolean buildOrUpdate(List<NodeReport> reports) { boolean updated = false; for (NodeReport report : reports) { updated |= getOrCreate(report.getNodeId().getHost()).updateNode(report); } return updated; }