From 67b6c8d909d62afc1b9d83c7d0cc48407024c159 Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Tue, 10 Jul 2018 19:44:54 +0100 Subject: [PATCH] Reformatting code and organising imports. No logical change --- .../grid/web/servlet/HubStatusServlet.java | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/java/server/src/org/openqa/grid/web/servlet/HubStatusServlet.java b/java/server/src/org/openqa/grid/web/servlet/HubStatusServlet.java index 2d11733cf1dd0..2129d39aa2e19 100644 --- a/java/server/src/org/openqa/grid/web/servlet/HubStatusServlet.java +++ b/java/server/src/org/openqa/grid/web/servlet/HubStatusServlet.java @@ -17,6 +17,9 @@ package org.openqa.grid.web.servlet; +import static java.util.stream.Collectors.groupingBy; +import static java.util.stream.Collectors.reducing; +import static java.util.stream.Collectors.toList; import static org.openqa.selenium.json.Json.MAP_TYPE; import com.google.common.base.Splitter; @@ -42,9 +45,6 @@ import java.util.Map; import java.util.TreeMap; import java.util.stream.Collector; -import static java.util.stream.Collectors.groupingBy; -import static java.util.stream.Collectors.toList; -import static java.util.stream.Collectors.reducing; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -128,42 +128,41 @@ private Map getResponse( res.put(SUCCESS, true); try { - String configuration = request.getParameter(CONFIGURATION); - - if (Strings.isNullOrEmpty(configuration)) { - configuration = ""; - if (requestJSON.containsKey(CONFIGURATION)) { - //noinspection unchecked - configuration = requestJSON.get(CONFIGURATION).toString(); - } - } + String configuration = request.getParameter(CONFIGURATION); - List keysToReturn = Splitter.on(",").omitEmptyStrings().splitToList(configuration); - - GridRegistry registry = getRegistry(); - Map config = registry.getHub().getConfiguration().toJson(); - for (Map.Entry entry : config.entrySet()) { - if (isKeyPresentIn(keysToReturn, entry.getKey())) { - res.put(entry.getKey(), entry.getValue()); - } - } - if (isKeyPresentIn(keysToReturn, NEW_SESSION_REQUEST_COUNT)) { - res.put(NEW_SESSION_REQUEST_COUNT, registry.getNewSessionRequestCount()); + if (Strings.isNullOrEmpty(configuration)) { + configuration = ""; + if (requestJSON.containsKey(CONFIGURATION)) { + //noinspection unchecked + configuration = requestJSON.get(CONFIGURATION).toString(); } + } - if (isKeyPresentIn(keysToReturn, SLOT_COUNTS)) { - res.put(SLOT_COUNTS, getSlotCounts()); - } - if (keysToReturn != null && keysToReturn.contains(NODES)) { - res.put(NODES, getNodesInfo()); + List keysToReturn = Splitter.on(",").omitEmptyStrings().splitToList(configuration); + + GridRegistry registry = getRegistry(); + Map config = registry.getHub().getConfiguration().toJson(); + for (Map.Entry entry : config.entrySet()) { + if (isKeyPresentIn(keysToReturn, entry.getKey())) { + res.put(entry.getKey(), entry.getValue()); } + } + if (isKeyPresentIn(keysToReturn, NEW_SESSION_REQUEST_COUNT)) { + res.put(NEW_SESSION_REQUEST_COUNT, registry.getNewSessionRequestCount()); + } + + if (isKeyPresentIn(keysToReturn, SLOT_COUNTS)) { + res.put(SLOT_COUNTS, getSlotCounts()); + } + if (keysToReturn != null && keysToReturn.contains(NODES)) { + res.put(NODES, getNodesInfo()); + } } catch (Exception e) { res.remove(SUCCESS); res.put(SUCCESS, false); res.put("msg", e.getMessage()); } return res; - } private Map getSlotCounts() { @@ -208,8 +207,9 @@ private Map getNodeInfo(RemoteProxy remoteProxy) { private List> getInfoFromAllSlotsInNode(List slots) { List> browsers = Lists.newArrayList(); - Map> - slotsInfo = slots.stream().collect(groupingBy(HubStatusServlet::getBrowser)); + Map> slotsInfo = slots.stream() + .collect(groupingBy(HubStatusServlet::getBrowser)); + for (Map.Entry> each : slotsInfo.entrySet()) { String key = each.getKey(); Map value = getSlotInfoPerBrowserFlavor(each.getValue());