Skip to content

Commit

Permalink
Reformatting code and organising imports. No logical change
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jul 10, 2018
1 parent 5289e97 commit 67b6c8d
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions java/server/src/org/openqa/grid/web/servlet/HubStatusServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -128,42 +128,41 @@ private Map<String, Object> 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<String> keysToReturn = Splitter.on(",").omitEmptyStrings().splitToList(configuration);

GridRegistry registry = getRegistry();
Map<String, Object> config = registry.getHub().getConfiguration().toJson();
for (Map.Entry<String, Object> 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<String> keysToReturn = Splitter.on(",").omitEmptyStrings().splitToList(configuration);

GridRegistry registry = getRegistry();
Map<String, Object> config = registry.getHub().getConfiguration().toJson();
for (Map.Entry<String, Object> 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<String, Object> getSlotCounts() {
Expand Down Expand Up @@ -208,8 +207,9 @@ private Map<String, Object> getNodeInfo(RemoteProxy remoteProxy) {

private List<Map<String, Object>> getInfoFromAllSlotsInNode(List<TestSlot> slots) {
List<Map<String, Object>> browsers = Lists.newArrayList();
Map<String, List<TestSlot>>
slotsInfo = slots.stream().collect(groupingBy(HubStatusServlet::getBrowser));
Map<String, List<TestSlot>> slotsInfo = slots.stream()
.collect(groupingBy(HubStatusServlet::getBrowser));

for (Map.Entry<String, List<TestSlot>> each : slotsInfo.entrySet()) {
String key = each.getKey();
Map<String, Object> value = getSlotInfoPerBrowserFlavor(each.getValue());
Expand Down

0 comments on commit 67b6c8d

Please sign in to comment.