Skip to content

Commit

Permalink
Follow up PR to ensure that the session queue name is used consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Apr 19, 2021
1 parent 8322f0f commit b1bfdab
Show file tree
Hide file tree
Showing 41 changed files with 456 additions and 463 deletions.
2 changes: 1 addition & 1 deletion deploys/docker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ container_image(
container_image(
name = "session-queue-image",
base = ":grid-base",
entrypoint = ENTRY_POINT + ["sessionqueuer"],
entrypoint = ENTRY_POINT + ["sessionqueue"],
ports = [
"5559/tcp", # Web
"4442/tcp", # ZeroMQ
Expand Down
4 changes: 2 additions & 2 deletions deploys/k8s/distributor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ spec:
value: "session-map"
- name: SESSIONS_PORT
value: "5556"
- name: SESSIONQUEUER_HOSTNAME
- name: SESSIONQUEUE_HOSTNAME
value: "session-queue"
- name: SESSIONQUEUER_PORT
- name: SESSIONQUEUE_PORT
value: "5559"
resources:
limits:
Expand Down
4 changes: 2 additions & 2 deletions deploys/k8s/router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ spec:
value: "session-map"
- name: SESSIONS_PORT
value: "5556"
- name: SESSIONQUEUER_HOSTNAME
- name: SESSIONQUEUE_HOSTNAME
value: "session-queue"
- name: SESSIONQUEUER_PORT
- name: SESSIONQUEUE_PORT
value: "5559"
- name: DISTRIBUTOR_HOSTNAME
value: "distributor"
Expand Down
24 changes: 11 additions & 13 deletions java/server/src/org/openqa/selenium/grid/commands/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
import org.openqa.selenium.grid.sessionqueue.local.SessionRequests;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueuer;
import org.openqa.selenium.grid.sessionqueue.config.NewSessionQueueOptions;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.config.SessionRequestOptions;
import org.openqa.selenium.grid.sessionqueue.local.LocalSessionRequests;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueuer;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue;
import org.openqa.selenium.grid.web.CombinedHandler;
import org.openqa.selenium.grid.web.GridUiRoute;
import org.openqa.selenium.grid.web.RoutableHttpClientFactory;
Expand All @@ -70,7 +70,6 @@
import static org.openqa.selenium.grid.config.StandardGridRoles.EVENT_BUS_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.HTTPD_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.ROUTER_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.SESSION_QUEUER_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.SESSION_QUEUE_ROLE;
import static org.openqa.selenium.remote.http.Route.combine;

Expand All @@ -96,7 +95,6 @@ public Set<Role> getConfigurableRoles() {
EVENT_BUS_ROLE,
HTTPD_ROLE,
SESSION_QUEUE_ROLE,
SESSION_QUEUER_ROLE,
ROUTER_ROLE);
}

Expand Down Expand Up @@ -145,31 +143,31 @@ protected Handlers createHandlers(Config config) {
handler,
networkOptions.getHttpClientFactory(tracer));

NewSessionQueueOptions newSessionQueueOptions = new NewSessionQueueOptions(config);
SessionRequestOptions sessionRequestOptions = new SessionRequestOptions(config);
SessionRequests sessionRequests = new LocalSessionRequests(
tracer,
bus,
newSessionQueueOptions.getSessionRequestRetryInterval(),
newSessionQueueOptions.getSessionRequestTimeout());
NewSessionQueuer queuer = new LocalNewSessionQueuer(tracer, bus, sessionRequests, secret);
handler.addHandler(queuer);
sessionRequestOptions.getSessionRequestRetryInterval(),
sessionRequestOptions.getSessionRequestTimeout());
NewSessionQueue queue = new LocalNewSessionQueue(tracer, bus, sessionRequests, secret);
handler.addHandler(queue);

DistributorOptions distributorOptions = new DistributorOptions(config);
Distributor distributor = new LocalDistributor(
tracer,
bus,
clientFactory,
sessions,
queuer,
queue,
secret,
distributorOptions.getHealthCheckInterval());
handler.addHandler(distributor);

Router router = new Router(tracer, clientFactory, sessions, queuer, distributor);
Router router = new Router(tracer, clientFactory, sessions, queue, distributor);
GraphqlHandler graphqlHandler = new GraphqlHandler(
tracer,
distributor,
queuer,
queue,
serverOptions.getExternalUri(),
getServerVersion());
HttpHandler readinessCheck = req -> {
Expand Down
22 changes: 11 additions & 11 deletions java/server/src/org/openqa/selenium/grid/commands/Standalone.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
import org.openqa.selenium.grid.sessionqueue.local.SessionRequests;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueuer;
import org.openqa.selenium.grid.sessionqueue.config.NewSessionQueueOptions;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.config.SessionRequestOptions;
import org.openqa.selenium.grid.sessionqueue.local.LocalSessionRequests;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueuer;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue;
import org.openqa.selenium.grid.web.CombinedHandler;
import org.openqa.selenium.grid.web.GridUiRoute;
import org.openqa.selenium.grid.web.RoutableHttpClientFactory;
Expand Down Expand Up @@ -140,32 +140,32 @@ protected Handlers createHandlers(Config config) {
SessionMap sessions = new LocalSessionMap(tracer, bus);
combinedHandler.addHandler(sessions);

NewSessionQueueOptions newSessionQueueOptions = new NewSessionQueueOptions(config);
SessionRequestOptions sessionRequestOptions = new SessionRequestOptions(config);
SessionRequests sessionRequests = new LocalSessionRequests(
tracer,
bus,
newSessionQueueOptions.getSessionRequestRetryInterval(),
newSessionQueueOptions.getSessionRequestTimeout());
sessionRequestOptions.getSessionRequestRetryInterval(),
sessionRequestOptions.getSessionRequestTimeout());

NewSessionQueuer queuer = new LocalNewSessionQueuer(
NewSessionQueue queue = new LocalNewSessionQueue(
tracer,
bus,
sessionRequests,
registrationSecret);
combinedHandler.addHandler(queuer);
combinedHandler.addHandler(queue);

DistributorOptions distributorOptions = new DistributorOptions(config);
Distributor distributor = new LocalDistributor(
tracer,
bus,
clientFactory,
sessions,
queuer,
queue,
registrationSecret,
distributorOptions.getHealthCheckInterval());
combinedHandler.addHandler(distributor);

Routable router = new Router(tracer, clientFactory, sessions, queuer, distributor)
Routable router = new Router(tracer, clientFactory, sessions, queue, distributor)
.with(networkOptions.getSpecComplianceChecks());

HttpHandler readinessCheck = req -> {
Expand All @@ -178,7 +178,7 @@ protected Handlers createHandlers(Config config) {
GraphqlHandler graphqlHandler = new GraphqlHandler(
tracer,
distributor,
queuer,
queue,
serverOptions.getExternalUri(),
getFormattedVersion());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ private StandardGridRoles() {
public static final Role ROUTER_ROLE = Role.of("grid-router");
public static final Role SESSION_MAP_ROLE = Role.of("grid-session-map");
public static final Role SESSION_QUEUE_ROLE = Role.of("grid-new-session-queue");
public static final Role SESSION_QUEUER_ROLE = Role.of("grid-new-session-queuer");

public static final Set<Role> ALL_ROLES = Collections.unmodifiableSet(
new TreeSet<>(
Expand All @@ -44,6 +43,5 @@ private StandardGridRoles() {
NODE_ROLE,
ROUTER_ROLE,
SESSION_MAP_ROLE,
SESSION_QUEUER_ROLE,
SESSION_QUEUE_ROLE)));
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import static org.openqa.selenium.grid.config.StandardGridRoles.EVENT_BUS_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.HTTPD_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.SESSION_MAP_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.SESSION_QUEUER_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.SESSION_QUEUE_ROLE;
import static org.openqa.selenium.remote.http.HttpMethod.GET;
import static org.openqa.selenium.remote.http.Route.get;

Expand All @@ -66,7 +66,7 @@ public String getDescription() {

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
import org.openqa.selenium.grid.server.NetworkOptions;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.config.SessionMapOptions;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueuer;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.SessionRequest;
import org.openqa.selenium.grid.sessionqueue.config.NewSessionQueuerOptions;
import org.openqa.selenium.grid.sessionqueue.config.NewSessionQueueOptions;
import org.openqa.selenium.internal.Either;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.http.HttpClient;
Expand Down Expand Up @@ -113,14 +113,14 @@ public class LocalDistributor extends Distributor {
private final GridModel model;
private final Map<NodeId, Node> nodes;

private final NewSessionQueuer sessionRequests;
private final NewSessionQueue sessionRequests;

public LocalDistributor(
Tracer tracer,
EventBus bus,
HttpClient.Factory clientFactory,
SessionMap sessions,
NewSessionQueuer sessionRequests,
NewSessionQueue sessionRequests,
Secret registrationSecret,
Duration healthcheckInterval) {
super(tracer, clientFactory, new DefaultSlotSelector(), sessions, registrationSecret);
Expand Down Expand Up @@ -169,9 +169,9 @@ public static Distributor create(Config config) {
HttpClient.Factory clientFactory = new NetworkOptions(config).getHttpClientFactory(tracer);
SessionMap sessions = new SessionMapOptions(config).getSessionMap();
SecretOptions secretOptions = new SecretOptions(config);
NewSessionQueuer sessionRequests =
new NewSessionQueuerOptions(config).getSessionQueuer(
"org.openqa.selenium.grid.sessionqueue.remote.RemoteNewSessionQueuer");
NewSessionQueue sessionRequests =
new NewSessionQueueOptions(config).getSessionQueue(
"org.openqa.selenium.grid.sessionqueue.remote.RemoteNewSessionQueue");
return new LocalDistributor(
tracer,
bus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry;
import org.openqa.selenium.grid.distributor.Distributor;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueuer;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.remote.http.Contents;
Expand Down Expand Up @@ -67,16 +67,16 @@ public class GraphqlHandler implements HttpHandler {
public static final Json JSON = new Json();
private final Tracer tracer;
private final Distributor distributor;
private final NewSessionQueuer newSessionQueuer;
private final NewSessionQueue newSessionQueue;
private final URI publicUri;
private final String version;
private final GraphQL graphQl;


public GraphqlHandler(Tracer tracer, Distributor distributor, NewSessionQueuer newSessionQueuer,
public GraphqlHandler(Tracer tracer, Distributor distributor, NewSessionQueue newSessionQueue,
URI publicUri, String version) {
this.distributor = Require.nonNull("Distributor", distributor);
this.newSessionQueuer = Require.nonNull("NewSessionQueuer", newSessionQueuer);
this.newSessionQueue = Require.nonNull("New session queue", newSessionQueue);
this.publicUri = Require.nonNull("Uri", publicUri);
this.version = Require.nonNull("GridVersion", version);
this.tracer = Require.nonNull("Tracer", tracer);
Expand Down Expand Up @@ -173,7 +173,7 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
}

private RuntimeWiring buildRuntimeWiring() {
GridData gridData = new GridData(distributor, newSessionQueuer, publicUri, version);
GridData gridData = new GridData(distributor, newSessionQueue, publicUri, version);
return RuntimeWiring.newRuntimeWiring()
.scalar(Types.Uri)
.scalar(Types.Url)
Expand Down
8 changes: 4 additions & 4 deletions java/server/src/org/openqa/selenium/grid/graphql/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.openqa.selenium.grid.data.NodeStatus;
import org.openqa.selenium.grid.data.Slot;
import org.openqa.selenium.grid.distributor.Distributor;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueuer;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.json.Json;

Expand All @@ -47,12 +47,12 @@ public class Grid {
private final List<Set<Capabilities>> queueInfoList;
private final String version;

public Grid(Distributor distributor, NewSessionQueuer newSessionQueuer, URI uri,
public Grid(Distributor distributor, NewSessionQueue newSessionQueue, URI uri,
String version) {
Require.nonNull("Distributor", distributor);
this.uri = Require.nonNull("Grid's public URI", uri);
NewSessionQueuer sessionQueuer = Require.nonNull("NewSessionQueuer", newSessionQueuer);
this.queueInfoList = sessionQueuer.getQueueContents();
NewSessionQueue sessionQueue = Require.nonNull("New session queue", newSessionQueue);
this.queueInfoList = sessionQueue.getQueueContents();
this.distributorStatus = Suppliers.memoize(distributor::getStatus);
this.version = Require.nonNull("Grid's version", version);
}
Expand Down
15 changes: 9 additions & 6 deletions java/server/src/org/openqa/selenium/grid/graphql/GridData.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,30 @@
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.openqa.selenium.grid.distributor.Distributor;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueuer;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
import org.openqa.selenium.internal.Require;

import java.net.URI;

public class GridData implements DataFetcher {
private final Distributor distributor;
private final NewSessionQueuer newSessionQueuer;
private final NewSessionQueue newSessionQueue;
private final URI publicUri;
private final String version;

public GridData(Distributor distributor, NewSessionQueuer newSessionQueuer, URI publicUri,
String version) {
public GridData(
Distributor distributor,
NewSessionQueue newSessionQueue,
URI publicUri,
String version) {
this.distributor = Require.nonNull("Distributor", distributor);
this.publicUri = Require.nonNull("Grid's public URI", publicUri);
this.newSessionQueuer = Require.nonNull("NewSessionQueuer", newSessionQueuer);
this.newSessionQueue = Require.nonNull("New session queue", newSessionQueue);
this.version = Require.nonNull("Grid's version", version);
}

@Override
public Object get(DataFetchingEnvironment environment) {
return new Grid(distributor, newSessionQueuer, publicUri, version);
return new Grid(distributor, newSessionQueue, publicUri, version);
}
}
12 changes: 6 additions & 6 deletions java/server/src/org/openqa/selenium/grid/router/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.openqa.selenium.grid.distributor.Distributor;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueuer;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpRequest;
Expand All @@ -43,19 +43,19 @@ public class Router implements HasReadyState, Routable {
private final Routable routes;
private final SessionMap sessions;
private final Distributor distributor;
private final NewSessionQueuer queuer;
private final NewSessionQueue queue;

public Router(
Tracer tracer,
HttpClient.Factory clientFactory,
SessionMap sessions,
NewSessionQueuer queuer,
NewSessionQueue queue,
Distributor distributor) {
Require.nonNull("Tracer to use", tracer);
Require.nonNull("HTTP client factory", clientFactory);

this.sessions = Require.nonNull("Session map", sessions);
this.queuer = Require.nonNull("New Session Request Queuer", queuer);
this.queue = Require.nonNull("New Session Request Queue", queue);
this.distributor = Require.nonNull("Distributor", distributor);

HandleSession sessionHandler = new HandleSession(tracer, clientFactory, sessions);
Expand All @@ -64,7 +64,7 @@ public Router(
combine(
get("/status").to(() -> new GridStatusHandler(tracer, distributor)),
sessions.with(new SpanDecorator(tracer, req -> "session_map")),
queuer.with(new SpanDecorator(tracer, req -> "session_queuer")),
queue.with(new SpanDecorator(tracer, req -> "session_queue")),
distributor.with(new SpanDecorator(tracer, req -> "distributor")),
matching(req -> req.getUri().startsWith("/session/"))
.to(() -> sessionHandler));
Expand All @@ -73,7 +73,7 @@ public Router(
@Override
public boolean isReady() {
try {
return ImmutableSet.of(distributor, sessions, queuer).parallelStream()
return ImmutableSet.of(distributor, sessions, queue).parallelStream()
.map(HasReadyState::isReady)
.reduce(true, Boolean::logicalAnd);
} catch (RuntimeException e) {
Expand Down
Loading

0 comments on commit b1bfdab

Please sign in to comment.