Skip to content

Commit

Permalink
Rename "NewSessionQueue" to "SessionRequests"
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Apr 19, 2021
1 parent fe6c4c2 commit 8322f0f
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 83 deletions.
6 changes: 3 additions & 3 deletions java/server/src/org/openqa/selenium/grid/commands/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
import org.openqa.selenium.grid.sessionqueue.local.NewSessionQueue;
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.local.LocalNewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.local.LocalSessionRequests;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueuer;
import org.openqa.selenium.grid.web.CombinedHandler;
import org.openqa.selenium.grid.web.GridUiRoute;
Expand Down Expand Up @@ -146,7 +146,7 @@ protected Handlers createHandlers(Config config) {
networkOptions.getHttpClientFactory(tracer));

NewSessionQueueOptions newSessionQueueOptions = new NewSessionQueueOptions(config);
NewSessionQueue sessionRequests = new LocalNewSessionQueue(
SessionRequests sessionRequests = new LocalSessionRequests(
tracer,
bus,
newSessionQueueOptions.getSessionRequestRetryInterval(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
import org.openqa.selenium.grid.sessionqueue.local.NewSessionQueue;
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.local.LocalNewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.local.LocalSessionRequests;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueuer;
import org.openqa.selenium.grid.web.CombinedHandler;
import org.openqa.selenium.grid.web.GridUiRoute;
Expand Down Expand Up @@ -141,7 +141,7 @@ protected Handlers createHandlers(Config config) {
combinedHandler.addHandler(sessions);

NewSessionQueueOptions newSessionQueueOptions = new NewSessionQueueOptions(config);
NewSessionQueue sessionRequests = new LocalNewSessionQueue(
SessionRequests sessionRequests = new LocalSessionRequests(
tracer,
bus,
newSessionQueueOptions.getSessionRequestRetryInterval(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public class GetNewSessionResponse {
private static final Logger LOG = Logger.getLogger(GetNewSessionResponse.class.getName());
private static final Map<RequestId, NewSessionRequest> knownRequests = new ConcurrentHashMap<>();
private final EventBus bus;
private final org.openqa.selenium.grid.sessionqueue.local.NewSessionQueue sessionRequests;
private final SessionRequests sessionRequests;
private final ReadWriteLock lock = new ReentrantReadWriteLock(true);

public GetNewSessionResponse(
EventBus bus,
NewSessionQueue sessionRequests) {
SessionRequests sessionRequests) {
this.bus = Require.nonNull("Event bus", bus);
this.sessionRequests = Require.nonNull("New Session Request Queue", sessionRequests);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@

public class LocalNewSessionQueuer extends NewSessionQueuer {

public final NewSessionQueue sessionRequests;
public final SessionRequests sessionRequests;
private final EventBus bus;
private final GetNewSessionResponse getNewSessionResponse;

public LocalNewSessionQueuer(
Tracer tracer,
EventBus bus,
NewSessionQueue sessionRequests,
SessionRequests sessionRequests,
Secret registrationSecret) {
super(tracer, registrationSecret);
this.bus = Require.nonNull("Event bus", bus);
Expand All @@ -70,7 +70,7 @@ public static NewSessionQueuer create(Config config) {
EventBus bus = new EventBusOptions(config).getEventBus();
Duration retryInterval = new NewSessionQueueOptions(config).getSessionRequestRetryInterval();
Duration requestTimeout = new NewSessionQueueOptions(config).getSessionRequestTimeout();
NewSessionQueue sessionRequests = new LocalNewSessionQueue(
SessionRequests sessionRequests = new LocalSessionRequests(
tracer,
bus,
retryInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@

@ManagedService(objectName = "org.seleniumhq.grid:type=SessionQueue,name=LocalSessionQueue",
description = "New session queue")
public class LocalNewSessionQueue extends NewSessionQueue {
public class LocalSessionRequests extends SessionRequests {

private static final Logger LOG = Logger.getLogger(LocalNewSessionQueue.class.getName());
private static final Logger LOG = Logger.getLogger(LocalSessionRequests.class.getName());
private final EventBus bus;
private final Deque<SessionRequest> sessionRequests = new ConcurrentLinkedDeque<>();
private final ReadWriteLock lock = new ReentrantReadWriteLock(true);
Expand All @@ -73,7 +73,7 @@ public class LocalNewSessionQueue extends NewSessionQueue {
"New session request rejected after being in the queue for more than %s",
format(requestTimeout));

public LocalNewSessionQueue(
public LocalSessionRequests(
Tracer tracer,
EventBus bus,
Duration retryInterval,
Expand All @@ -89,12 +89,12 @@ public LocalNewSessionQueue(
new JMXHelper().register(this);
}

public static NewSessionQueue create(Config config) {
public static SessionRequests create(Config config) {
Tracer tracer = new LoggingOptions(config).getTracer();
EventBus bus = new EventBusOptions(config).getEventBus();
Duration retryInterval = new NewSessionQueueOptions(config).getSessionRequestRetryInterval();
Duration requestTimeout = new NewSessionQueueOptions(config).getSessionRequestTimeout();
return new LocalNewSessionQueue(tracer, bus, retryInterval, requestTimeout);
return new LocalSessionRequests(tracer, bus, retryInterval, requestTimeout);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import java.util.Optional;
import java.util.Set;

public abstract class NewSessionQueue implements HasReadyState {
public abstract class SessionRequests implements HasReadyState {

protected final Tracer tracer;
protected final Duration retryInterval;
protected final Duration requestTimeout;

protected NewSessionQueue(Tracer tracer, Duration retryInterval, Duration requestTimeout) {
protected SessionRequests(Tracer tracer, Duration retryInterval, Duration requestTimeout) {
this.tracer = Require.nonNull("Tracer", tracer);
this.retryInterval = Require.nonNull("Session request retry interval", retryInterval);
this.requestTimeout = Require.nonNull("Session request timeout", requestTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.openqa.selenium.grid.node.local.LocalNode;
import org.openqa.selenium.grid.security.Secret;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.local.LocalSessionRequests;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueuer;
import org.openqa.selenium.grid.testing.TestSessionFactory;
import org.openqa.selenium.grid.web.CombinedHandler;
Expand Down Expand Up @@ -106,7 +106,7 @@ public void setUpDistributor() throws MalformedURLException {
HttpClient.Factory.createDefault());

LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
import org.openqa.selenium.grid.sessionqueue.SessionRequest;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.local.LocalSessionRequests;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueuer;
import org.openqa.selenium.grid.testing.EitherAssert;
import org.openqa.selenium.grid.testing.PassthroughHttpClient;
Expand Down Expand Up @@ -124,7 +124,7 @@ public void setUp() throws URISyntaxException {
tracer = DefaultTestTracer.createTracer();
bus = new GuavaEventBus();
LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -156,7 +156,7 @@ public void creatingANewSessionWithoutANodeEndsInFailure() {
public void shouldStartHeartBeatOnNodeRegistration() {
EventBus bus = new GuavaEventBus();
LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -207,7 +207,7 @@ public void shouldStartHeartBeatOnNodeRegistration() {
@Test
public void shouldBeAbleToAddANodeAndCreateASession() {
LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -248,7 +248,7 @@ public void shouldBeAbleToAddANodeAndCreateASession() {
@Test
public void creatingASessionAddsItToTheSessionMap() {
LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -291,7 +291,7 @@ public void creatingASessionAddsItToTheSessionMap() {
@Test
public void shouldBeAbleToRemoveANode() throws MalformedURLException {
LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -332,7 +332,7 @@ public void shouldBeAbleToRemoveANode() throws MalformedURLException {
@Test
public void testDrainingNodeDoesNotAcceptNewSessions() {
SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -368,7 +368,7 @@ public void testDrainingNodeDoesNotAcceptNewSessions() {
@Test
public void testDrainedNodeShutsDownOnceEmpty() throws InterruptedException {
SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -414,7 +414,7 @@ public void testDrainedNodeShutsDownOnceEmpty() throws InterruptedException {
@Test
public void drainedNodeDoesNotShutDownIfNotEmpty() throws InterruptedException {
SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -460,7 +460,7 @@ public void drainedNodeDoesNotShutDownIfNotEmpty() throws InterruptedException {
@Test
public void drainedNodeShutsDownAfterSessionsFinish() throws InterruptedException {
SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -535,7 +535,7 @@ public void theMostLightlyLoadedNodeIsSelectedFirst() {
// * reverse insertion order
// * sorted with most heavily used first
SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -582,7 +582,7 @@ public void theMostLightlyLoadedNodeIsSelectedFirst() {
@Test
public void shouldUseLastSessionCreatedTimeAsTieBreaker() {
SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -661,7 +661,7 @@ public void shouldIncludeHostsThatAreUpInHostList() {
CombinedHandler handler = new CombinedHandler();

SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -717,7 +717,7 @@ public void shouldIncludeHostsThatAreUpInHostList() {
@Test
public void shouldNotScheduleAJobIfAllSlotsAreBeingUsed() {
SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -757,7 +757,7 @@ public void shouldNotScheduleAJobIfAllSlotsAreBeingUsed() {
@Test
public void shouldReleaseSlotOnceSessionEnds() {
SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -816,7 +816,7 @@ public void shouldNotStartASessionIfTheCapabilitiesAreNotSupported() {
CombinedHandler handler = new CombinedHandler();

LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -852,7 +852,7 @@ public void shouldNotStartASessionIfTheCapabilitiesAreNotSupported() {
@Test
public void attemptingToStartASessionWhichFailsMarksAsTheSlotAsAvailable() {
SessionMap sessions = new LocalSessionMap(tracer, bus);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -894,7 +894,7 @@ public void shouldReturnNodesThatWereDownToPoolOfNodesOnceTheyMarkTheirHealthChe
SessionMap sessions = new LocalSessionMap(tracer, bus);
handler.addHandler(sessions);
AtomicReference<Availability> isUp = new AtomicReference<>(DOWN);
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down Expand Up @@ -969,7 +969,7 @@ public void shouldPrioritizeHostsWithTheMostSlotsAvailableForASessionType() {
SessionMap sessions = new LocalSessionMap(tracer, bus);
handler.addHandler(sessions);

LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
bus,
Duration.ofSeconds(2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.openqa.selenium.grid.security.Secret;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.local.LocalSessionRequests;
import org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueuer;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.tracing.DefaultTestTracer;
Expand All @@ -39,7 +39,7 @@ public class GridModelTest {
private final HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
private final SessionMap sessions = new LocalSessionMap(tracer, events);
private final Secret secret = new Secret("cheese");
LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue(
LocalSessionRequests localNewSessionQueue = new LocalSessionRequests(
tracer,
events,
Duration.ofSeconds(2),
Expand Down
Loading

0 comments on commit 8322f0f

Please sign in to comment.