SLIDER-561 AM Web UI doesn't show statistics for dynamic roles
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/5d9a053b Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/5d9a053b Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/5d9a053b Branch: refs/heads/develop Commit: 5d9a053b29a53e1cdf5fc2ffc3f6c62d99097228 Parents: c87b082 Author: Steve Loughran <[email protected]> Authored: Thu Oct 23 11:40:30 2014 +0100 Committer: Steve Loughran <[email protected]> Committed: Thu Oct 23 11:40:30 2014 +0100 ---------------------------------------------------------------------- .../slider/server/appmaster/web/WebAppApi.java | 2 +- .../server/appmaster/web/WebAppApiImpl.java | 50 +++----------------- 2 files changed, 8 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/5d9a053b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java index b7e749e..c8c47c9 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java @@ -57,7 +57,7 @@ public interface WebAppApi { * Generate a mapping from role name to its {@link RoleStatus}. Be aware that this * is a computed value and not just a getter */ - public Map<String,RoleStatus> getRoleStatusByName(); + public Map<String, RoleStatus> getRoleStatusByName(); /** * Returns an interface that can support the agent-based REST operations. http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/5d9a053b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java index 4c0aa6a..cacdb3a 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java @@ -99,50 +99,14 @@ public class WebAppApiImpl implements WebAppApi { * @see org.apache.slider.server.appmaster.web.WebAppApi#getRoleStatusByName() */ @Override - public TreeMap<String,RoleStatus> getRoleStatusByName() { - Map<Integer,ProviderRole> rolesById = rolesById(provider.getRoles()); - Map<Integer,RoleStatus> status = appState.getRoleStatusMap(); - - return getRoleStatusesByName(rolesById, status); - } - - /** - * Get the ProviderRoles by their index - * @param roles - * @return - */ - private Map<Integer,ProviderRole> rolesById(List<ProviderRole> roles) { - Map<Integer,ProviderRole> rolesById = new HashMap<Integer,ProviderRole>(); - rolesById.put(SliderKeys.ROLE_AM_PRIORITY_INDEX, AM_ROLE_NAME); - - for (ProviderRole role : roles) { - rolesById.put(role.id, role); - } - - return rolesById; - } - - /** - * Join the ProviderRole by their ID with the RoleStatus by their ID, to get the RoleStatus by role name. - * @param rolesById - * @param statusById - * @return A Map of RoleStatus by the role name - */ - private TreeMap<String, RoleStatus> getRoleStatusesByName(Map<Integer, ProviderRole> rolesById, - Map<Integer, RoleStatus> statusById) { - TreeMap<String, RoleStatus> statusByName = new TreeMap<String, RoleStatus>(); - for (Entry<Integer, ProviderRole> role : rolesById.entrySet()) { - final RoleStatus status = statusById.get(role.getKey()); - - if (null == status) { - log.error("Found ID ({}) which has no known ProviderRole", - role.getKey()); - } else { - statusByName.put(role.getValue().name, status); - } + public Map<String,RoleStatus> getRoleStatusByName() { + List<RoleStatus> roleStatuses = appState.cloneRoleStatusList(); + TreeMap<String, RoleStatus> map = + new TreeMap<String, RoleStatus>(); + for (RoleStatus status : roleStatuses) { + map.put(status.getName(), status); } - - return statusByName; + return map; } @Override
