Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions java/src/org/openqa/selenium/grid/router/GridStatusHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.openqa.selenium.grid.router;

import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
import static org.openqa.selenium.grid.data.Availability.UP;
import static org.openqa.selenium.remote.http.Contents.asJson;
import static org.openqa.selenium.remote.tracing.HttpTracing.newSpanAsChildOf;
Expand All @@ -29,12 +28,15 @@
import static org.openqa.selenium.remote.tracing.Tags.HTTP_RESPONSE_EVENT;

import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import org.openqa.selenium.grid.data.DistributorStatus;
import org.openqa.selenium.grid.distributor.Distributor;
import org.openqa.selenium.internal.Require;
Expand Down Expand Up @@ -89,9 +91,9 @@ public HttpResponse execute(HttpRequest req) {
new HttpResponse()
.setContent(
asJson(
ImmutableMap.of(
Map.of(
"value",
ImmutableMap.of(
Map.of(
"ready", false, "message", "Unable to read distributor status."))));

HTTP_RESPONSE.accept(span, response);
Expand All @@ -111,9 +113,9 @@ public HttpResponse execute(HttpRequest req) {
new HttpResponse()
.setContent(
asJson(
ImmutableMap.of(
Map.of(
"value",
ImmutableMap.of(
Map.of(
"ready",
false,
"message",
Expand All @@ -136,19 +138,20 @@ public HttpResponse execute(HttpRequest req) {
List<Map<String, Object>> nodeResults =
status.getNodes().stream()
.map(
node ->
new ImmutableMap.Builder<String, Object>()
.put("id", node.getNodeId())
.put("uri", node.getExternalUri())
.put("maxSessions", node.getMaxSessionCount())
.put("sessionTimeout", node.getSessionTimeout().toMillis())
.put("osInfo", node.getOsInfo())
.put("heartbeatPeriod", node.getHeartbeatPeriod().toMillis())
.put("availability", node.getAvailability())
.put("version", node.getVersion())
.put("slots", node.getSlots())
.build())
.collect(toList());
node -> {
Map<String, Object> nodeMap = new HashMap<>();
nodeMap.put("id", node.getNodeId());
nodeMap.put("uri", node.getExternalUri());
nodeMap.put("maxSessions", node.getMaxSessionCount());
nodeMap.put("sessionTimeout", node.getSessionTimeout().toMillis());
nodeMap.put("osInfo", node.getOsInfo());
nodeMap.put("heartbeatPeriod", node.getHeartbeatPeriod().toMillis());
nodeMap.put("availability", node.getAvailability());
nodeMap.put("version", node.getVersion());
nodeMap.put("slots", node.getSlots());
return Collections.unmodifiableMap(nodeMap);
})
.collect(Collectors.toList());

ImmutableMap.Builder<String, Object> value = ImmutableMap.builder();
value.put("ready", ready);
Expand Down
4 changes: 2 additions & 2 deletions java/src/org/openqa/selenium/grid/router/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import static org.openqa.selenium.remote.http.Route.get;
import static org.openqa.selenium.remote.http.Route.matching;

import com.google.common.collect.ImmutableSet;
import java.io.Closeable;
import java.util.Set;
import org.openqa.selenium.grid.distributor.Distributor;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
Expand Down Expand Up @@ -71,7 +71,7 @@ public Router(
@Override
public boolean isReady() {
try {
return ImmutableSet.of(distributor, sessions, queue).parallelStream()
return Set.of(distributor, sessions, queue).parallelStream()
.map(HasReadyState::isReady)
.reduce(true, Boolean::logicalAnd);
} catch (RuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@
import static org.openqa.selenium.remote.http.Route.get;

import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.io.Closeable;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URL;
import java.time.Duration;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -94,8 +93,7 @@ public String getDescription() {

@Override
public Set<Role> getConfigurableRoles() {
return ImmutableSet.of(
DISTRIBUTOR_ROLE, HTTPD_ROLE, ROUTER_ROLE, SESSION_MAP_ROLE, SESSION_QUEUE_ROLE);
return Set.of(DISTRIBUTOR_ROLE, HTTPD_ROLE, ROUTER_ROLE, SESSION_MAP_ROLE, SESSION_QUEUE_ROLE);
}

@Override
Expand All @@ -110,7 +108,7 @@ protected String getSystemPropertiesConfigPrefix() {

@Override
protected Config getDefaultConfig() {
return new MapConfig(ImmutableMap.of("server", ImmutableMap.of("port", 4444)));
return new MapConfig(Map.of("server", Map.of("port", 4444)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import static org.openqa.selenium.grid.security.AddSecretFilter.HEADER_NAME;
import static org.openqa.selenium.json.Json.JSON_UTF_8;

import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.Map;
import java.util.logging.Logger;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.http.Contents;
Expand Down Expand Up @@ -53,7 +53,7 @@ public HttpHandler apply(HttpHandler httpHandler) {
Contents.asJson(
Collections.singletonMap(
"value",
ImmutableMap.of(
Map.of(
"error", "unknown error",
"message", "Unauthorized access attempted to ",
"stacktrace", ""))));
Expand Down
3 changes: 1 addition & 2 deletions java/src/org/openqa/selenium/grid/server/EventBusFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import com.beust.jcommander.Parameter;
import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
import org.openqa.selenium.grid.config.ConfigValue;
import org.openqa.selenium.grid.config.HasRoles;
Expand Down Expand Up @@ -67,6 +66,6 @@ public class EventBusFlags implements HasRoles {

@Override
public Set<Role> getRoles() {
return ImmutableSet.of(EVENT_BUS_ROLE);
return Set.of(EVENT_BUS_ROLE);
}
}
7 changes: 2 additions & 5 deletions java/src/org/openqa/selenium/grid/server/NetworkOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.openqa.selenium.grid.server;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand All @@ -38,7 +36,7 @@ public class NetworkOptions {

private final Config config;
// These are commonly used by process which can't set various headers.
private final Set<String> SKIP_CHECKS_ON = ImmutableSet.of("/status", "/readyz");
private final Set<String> SKIP_CHECKS_ON = Set.of("/status", "/readyz");

public NetworkOptions(Config config) {
this.config = Require.nonNull("Config", config);
Expand Down Expand Up @@ -67,8 +65,7 @@ public Filter getSpecComplianceChecks() {

if (checkOrigin || allowedOrigins.isPresent()) {
toReturn =
toReturn.andThen(
new CheckOriginHeader(allowedOrigins.orElse(ImmutableList.of()), SKIP_CHECKS_ON));
toReturn.andThen(new CheckOriginHeader(allowedOrigins.orElse(List.of()), SKIP_CHECKS_ON));
}

return toReturn;
Expand Down
Loading