Skip to content

Commit

Permalink
Remove unused constants
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Apr 13, 2021
1 parent f052b7b commit e33ed59
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.openqa.selenium.grid.data.RequestId;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.tracing.Tracer;
import org.openqa.selenium.status.HasReadyState;

Expand All @@ -30,8 +29,6 @@

public abstract class NewSessionQueue implements HasReadyState {

public static final String SESSIONREQUEST_TIMESTAMP_HEADER = "new-session-request-timestamp";
public static final String SESSIONREQUEST_ID_HEADER = "request-id";
protected final Tracer tracer;
protected final Duration retryInterval;
protected final Duration requestTimeout;
Expand All @@ -54,12 +51,6 @@ protected NewSessionQueue(Tracer tracer, Duration retryInterval, Duration reques

public abstract List<Object> getQueuedRequests();

public void addRequestHeaders(HttpRequest request, RequestId reqId) {
long timestamp = Instant.now().getEpochSecond();
request.addHeader(SESSIONREQUEST_TIMESTAMP_HEADER, Long.toString(timestamp));
request.addHeader(SESSIONREQUEST_ID_HEADER, reqId.toString());
}

public boolean hasRequestTimedOut(SessionRequest request) {
Instant enque = request.getEnqueued();
Instant deque = Instant.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ public HttpResponse execute(HttpRequest req) {
HttpResponse response = new HttpResponse();

if (sessionRequest.isPresent()) {
SessionRequest request = sessionRequest.get();

return response
.setHeader(
NewSessionQueue.SESSIONREQUEST_TIMESTAMP_HEADER,
String.valueOf(request.getEnqueued().getEpochSecond()))
.setContent(Contents.asJson(sessionRequest));
return response.setContent(Contents.asJson(sessionRequest));
} else {
response.setStatus(HTTP_NO_CONTENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@
import java.util.List;
import java.util.Optional;

import static org.openqa.selenium.grid.sessionqueue.NewSessionQueue.SESSIONREQUEST_ID_HEADER;
import static org.openqa.selenium.grid.sessionqueue.NewSessionQueue.SESSIONREQUEST_TIMESTAMP_HEADER;
import static org.openqa.selenium.remote.http.HttpMethod.DELETE;
import static org.openqa.selenium.remote.http.HttpMethod.GET;
import static org.openqa.selenium.remote.http.HttpMethod.POST;

public class RemoteNewSessionQueuer extends NewSessionQueuer {

private static final String timestampHeader = SESSIONREQUEST_TIMESTAMP_HEADER;
private static final String reqIdHeader = SESSIONREQUEST_ID_HEADER;
private static final Json JSON = new Json();
private final HttpClient client;
private final Filter addSecret;
Expand Down Expand Up @@ -100,8 +96,6 @@ public boolean retryAddToQueue(SessionRequest request) {
new HttpRequest(POST, "/se/grid/newsessionqueuer/session/retry/" + request.getRequestId());
HttpTracing.inject(tracer, tracer.getCurrentContext(), upstream);
upstream.setContent(Contents.asJson(request));
upstream.setHeader(timestampHeader, String.valueOf(request.getEnqueued().getEpochSecond()));
upstream.setHeader(reqIdHeader, request.getRequestId().toString());
HttpResponse response = client.with(addSecret).execute(upstream);
return Values.get(response, Boolean.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@
import org.openqa.selenium.grid.data.NewSessionRejectedEvent;
import org.openqa.selenium.grid.data.NewSessionRequestEvent;
import org.openqa.selenium.grid.data.RequestId;
import org.openqa.selenium.grid.data.Session;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.SessionRequest;
import org.openqa.selenium.remote.NewSessionPayload;
import org.openqa.selenium.remote.http.HttpMethod;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.tracing.DefaultTestTracer;
import org.openqa.selenium.remote.tracing.Tracer;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
Expand All @@ -51,10 +45,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.openqa.selenium.grid.sessionqueue.NewSessionQueue.SESSIONREQUEST_TIMESTAMP_HEADER;
import static org.openqa.selenium.remote.Dialect.W3C;
import static org.openqa.selenium.remote.http.Contents.utf8String;
import static org.openqa.selenium.remote.http.HttpMethod.POST;

public class LocalNewSessionQueueTest {

Expand Down

0 comments on commit e33ed59

Please sign in to comment.