From 921241db86c8a511bb4c77316916d5d6ee3aadab Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Mon, 26 Apr 2021 18:43:37 +0100 Subject: [PATCH] Remove unused method from the LocalNewSessionQueue --- .../grid/sessionqueue/NewSessionQueue.java | 4 -- .../sessionqueue/OfferLastToSessionQueue.java | 61 ------------------- .../local/LocalNewSessionQueue.java | 21 ------- .../remote/RemoteNewSessionQueue.java | 9 --- .../local/LocalNewSessionQueueTest.java | 2 +- 5 files changed, 1 insertion(+), 96 deletions(-) delete mode 100644 java/server/src/org/openqa/selenium/grid/sessionqueue/OfferLastToSessionQueue.java diff --git a/java/server/src/org/openqa/selenium/grid/sessionqueue/NewSessionQueue.java b/java/server/src/org/openqa/selenium/grid/sessionqueue/NewSessionQueue.java index d054e9c4a78ae..f9c42f5c31f28 100644 --- a/java/server/src/org/openqa/selenium/grid/sessionqueue/NewSessionQueue.java +++ b/java/server/src/org/openqa/selenium/grid/sessionqueue/NewSessionQueue.java @@ -76,8 +76,6 @@ protected NewSessionQueue(Tracer tracer, Secret registrationSecret) { throw new UncheckedIOException(e); } }), - post("/se/grid/newsessionqueue/session/last") - .to(() -> new OfferLastToSessionQueue(tracer, this)), post("/se/grid/newsessionqueue/session") .to(() -> new AddToSessionQueue(tracer, this)), post("/se/grid/newsessionqueue/session/{requestId}/retry") @@ -103,8 +101,6 @@ private RequestId requestIdFrom(Map params) { public abstract HttpResponse addToQueue(SessionRequest request); - public abstract boolean offerLast(SessionRequest request); - public abstract boolean retryAddToQueue(SessionRequest request); public abstract Optional remove(RequestId reqId); diff --git a/java/server/src/org/openqa/selenium/grid/sessionqueue/OfferLastToSessionQueue.java b/java/server/src/org/openqa/selenium/grid/sessionqueue/OfferLastToSessionQueue.java deleted file mode 100644 index 58a39cfd699b5..0000000000000 --- a/java/server/src/org/openqa/selenium/grid/sessionqueue/OfferLastToSessionQueue.java +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.grid.sessionqueue; - -import org.openqa.selenium.internal.Require; -import org.openqa.selenium.remote.http.Contents; -import org.openqa.selenium.remote.http.HttpHandler; -import org.openqa.selenium.remote.http.HttpRequest; -import org.openqa.selenium.remote.http.HttpResponse; -import org.openqa.selenium.remote.tracing.Span; -import org.openqa.selenium.remote.tracing.Tracer; - -import java.util.Collections; - -import static org.openqa.selenium.remote.http.Contents.asJson; -import static org.openqa.selenium.remote.tracing.HttpTracing.newSpanAsChildOf; -import static org.openqa.selenium.remote.tracing.Tags.HTTP_REQUEST; -import static org.openqa.selenium.remote.tracing.Tags.HTTP_RESPONSE; - -class OfferLastToSessionQueue implements HttpHandler { - - private final Tracer tracer; - private final NewSessionQueue newSessionQueue; - - OfferLastToSessionQueue(Tracer tracer, NewSessionQueue newSessionQueue) { - this.tracer = Require.nonNull("Tracer", tracer); - this.newSessionQueue = Require.nonNull("New Session Queue", newSessionQueue); - } - - @Override - public HttpResponse execute(HttpRequest req) { - try (Span span = newSpanAsChildOf(tracer, req, "sessionqueue.addLast")) { - HTTP_REQUEST.accept(span, req); - - boolean result = newSessionQueue.offerLast(Contents.fromJson(req, SessionRequest.class)); - - HttpResponse response = new HttpResponse() - .setContent(Contents.asJson(Collections.singletonMap("value", result))); - - HTTP_RESPONSE.accept(span, response); - - return response; - } - } -} - diff --git a/java/server/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java b/java/server/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java index c8e7f6dbda5ac..46f454b5d8b2f 100644 --- a/java/server/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java +++ b/java/server/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java @@ -211,27 +211,6 @@ Data injectIntoQueue(SessionRequest request) { return data; } - @Override - public boolean offerLast(SessionRequest request) { - Require.nonNull("New session request", request); - - Lock writeLock = lock.writeLock(); - writeLock.lock(); - try { - if (!requests.containsKey(request.getRequestId())) { - return false; - } - - if (queue.contains(request)) { - return true; - } - - return queue.offerLast(request); - } finally { - writeLock.unlock(); - } - } - @Override public boolean retryAddToQueue(SessionRequest request) { Require.nonNull("New session request", request); diff --git a/java/server/src/org/openqa/selenium/grid/sessionqueue/remote/RemoteNewSessionQueue.java b/java/server/src/org/openqa/selenium/grid/sessionqueue/remote/RemoteNewSessionQueue.java index 1c6f314f67e99..15ac48b722950 100644 --- a/java/server/src/org/openqa/selenium/grid/sessionqueue/remote/RemoteNewSessionQueue.java +++ b/java/server/src/org/openqa/selenium/grid/sessionqueue/remote/RemoteNewSessionQueue.java @@ -96,15 +96,6 @@ public HttpResponse addToQueue(SessionRequest request) { return client.execute(upstream); } - @Override - public boolean offerLast(SessionRequest request) { - HttpRequest upstream = new HttpRequest(POST, "/se/grid/newsessionqueue/session/last"); - HttpTracing.inject(tracer, tracer.getCurrentContext(), upstream); - upstream.setContent(Contents.asJson(request)); - HttpResponse response = client.execute(upstream); - return Values.get(response, Boolean.class); - } - @Override public boolean retryAddToQueue(SessionRequest request) { Require.nonNull("Session request", request); diff --git a/java/server/test/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueueTest.java b/java/server/test/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueueTest.java index e671a0c7ad9f8..4c3e5f5be1f37 100644 --- a/java/server/test/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueueTest.java +++ b/java/server/test/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueueTest.java @@ -257,7 +257,7 @@ public void shouldBeClearQueueAndFireRejectedEvent() throws InterruptedException localQueue.injectIntoQueue(sessionRequest); queue.remove(requestId); - queue.offerLast(sessionRequest); + queue.retryAddToQueue(sessionRequest); int count = queue.clearQueue();