Repository: incubator-slider Updated Branches: refs/heads/feature/SLIDER-799-AM-managed-relax [created] b952b6401
SLIDER-799 clarify in javadocs that an RTE is raised if a container with no hostname is looked up. Add a new method getExistingNodeInstance() to find the node instance hosting a container, if it exists Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/55815c22 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/55815c22 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/55815c22 Branch: refs/heads/feature/SLIDER-799-AM-managed-relax Commit: 55815c227912602d80230971cbcd2fda3742cd79 Parents: 2037ac4 Author: Steve Loughran <[email protected]> Authored: Tue Mar 3 15:25:17 2015 -0800 Committer: Steve Loughran <[email protected]> Committed: Tue Mar 3 15:25:17 2015 -0800 ---------------------------------------------------------------------- .../server/appmaster/state/RoleHistory.java | 21 ++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/55815c22/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java index e94457a..5509cac 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleHistory.java @@ -47,13 +47,13 @@ import com.google.common.annotations.VisibleForTesting; /** * The Role History. - * + * <p> * Synchronization policy: all public operations are synchronized. * Protected methods are in place for testing -no guarantees are made. - * + * <p> * Inner classes have no synchronization guarantees; they should be manipulated * in these classes and not externally. - * + * <p> * Note that as well as some methods marked visible for testing, there * is the option for the time generator method, {@link #now()} to * be overridden so that a repeatable time series can be used. @@ -573,6 +573,7 @@ public class RoleHistory { * Get the node entry of a container * @param container container to look up * @return the entry + * @throws RuntimeException if the container has no hostname */ public NodeEntry getOrCreateNodeEntry(Container container) { NodeInstance node = getOrCreateNodeInstance(container); @@ -583,6 +584,7 @@ public class RoleHistory { * 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) { String hostname = RoleHistoryUtils.hostnameOf(container); @@ -593,12 +595,23 @@ public class RoleHistory { * 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); } /** + * 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)); + } + + /** * Perform any pre-allocation operations on the list of allocated containers * based on knowledge of system state. * Currently this places requested hosts ahead of unrequested ones. @@ -670,7 +683,7 @@ public class RoleHistory { /** * Container start event - * @param container + * @param container container that just started */ public void onContainerStarted(Container container) { NodeEntry nodeEntry = getOrCreateNodeEntry(container);
