From ad0dc580c5407fdf9306073db213952ff2c17e8b Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Tue, 29 May 2018 13:14:23 -0600 Subject: [PATCH] Fix location of AbstractHttpServerTransport (#30888) Currently AbstractHttpServerTransport is in a netty4 module. This is the incorrect location. This commit moves it out of netty4 module. Additionally, it moves unit tests that test AbstractHttpServerTransport logic to server. --- .../http/netty4/Netty4HttpServerTransport.java | 1 + .../http/netty4/Netty4HttpServerTransportTests.java | 4 ++-- .../elasticsearch/http/nio/NioHttpServerTransport.java | 2 +- .../http/{netty4 => }/AbstractHttpServerTransport.java | 4 +--- .../http/AbstractHttpServerTransportTests.java | 9 +++------ 5 files changed, 8 insertions(+), 12 deletions(-) rename server/src/main/java/org/elasticsearch/http/{netty4 => }/AbstractHttpServerTransport.java (98%) rename modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpPublishPortTests.java => server/src/test/java/org/elasticsearch/http/AbstractHttpServerTransportTests.java (93%) diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java index 45e889797bde4..31c1214f03428 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java @@ -56,6 +56,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.http.AbstractHttpServerTransport; import org.elasticsearch.http.BindHttpException; import org.elasticsearch.http.HttpHandlingSettings; import org.elasticsearch.http.HttpStats; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerTransportTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerTransportTests.java index 96b436ce7de43..5b22409b92da0 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerTransportTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerTransportTests.java @@ -273,7 +273,7 @@ public void dispatchBadRequest(final RestRequest request, try (Netty4HttpServerTransport transport = new Netty4HttpServerTransport(settings, networkService, bigArrays, threadPool, xContentRegistry(), dispatcher)) { transport.start(); - final TransportAddress remoteAddress = randomFrom(transport.boundAddress.boundAddresses()); + final TransportAddress remoteAddress = randomFrom(transport.boundAddress().boundAddresses()); try (Netty4HttpClient client = new Netty4HttpClient()) { final String url = "/" + new String(new byte[maxInitialLineLength], Charset.forName("UTF-8")); @@ -352,7 +352,7 @@ public void dispatchBadRequest(final RestRequest request, try (Netty4HttpServerTransport transport = new Netty4HttpServerTransport(settings, networkService, bigArrays, threadPool, xContentRegistry(), dispatcher)) { transport.start(); - final TransportAddress remoteAddress = randomFrom(transport.boundAddress.boundAddresses()); + final TransportAddress remoteAddress = randomFrom(transport.boundAddress().boundAddresses()); AtomicBoolean channelClosed = new AtomicBoolean(false); diff --git a/plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/NioHttpServerTransport.java b/plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/NioHttpServerTransport.java index 825a023bd51bc..de5c166de3f5b 100644 --- a/plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/NioHttpServerTransport.java +++ b/plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/NioHttpServerTransport.java @@ -42,7 +42,7 @@ import org.elasticsearch.http.HttpHandlingSettings; import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.http.HttpStats; -import org.elasticsearch.http.netty4.AbstractHttpServerTransport; +import org.elasticsearch.http.AbstractHttpServerTransport; import org.elasticsearch.nio.AcceptingSelector; import org.elasticsearch.nio.AcceptorEventHandler; import org.elasticsearch.nio.BytesChannelContext; diff --git a/server/src/main/java/org/elasticsearch/http/netty4/AbstractHttpServerTransport.java b/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java similarity index 98% rename from server/src/main/java/org/elasticsearch/http/netty4/AbstractHttpServerTransport.java rename to server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java index a0b3632310b24..c75754bde5855 100644 --- a/server/src/main/java/org/elasticsearch/http/netty4/AbstractHttpServerTransport.java +++ b/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.http.netty4; +package org.elasticsearch.http; import com.carrotsearch.hppc.IntHashSet; import com.carrotsearch.hppc.IntSet; @@ -30,8 +30,6 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; -import org.elasticsearch.http.BindHttpException; -import org.elasticsearch.http.HttpInfo; import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.threadpool.ThreadPool; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpPublishPortTests.java b/server/src/test/java/org/elasticsearch/http/AbstractHttpServerTransportTests.java similarity index 93% rename from modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpPublishPortTests.java rename to server/src/test/java/org/elasticsearch/http/AbstractHttpServerTransportTests.java index afa513275eabc..ee74d98002faa 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpPublishPortTests.java +++ b/server/src/test/java/org/elasticsearch/http/AbstractHttpServerTransportTests.java @@ -17,13 +17,11 @@ * under the License. */ -package org.elasticsearch.http.netty4; +package org.elasticsearch.http; import org.elasticsearch.common.network.NetworkUtils; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; -import org.elasticsearch.http.BindHttpException; -import org.elasticsearch.http.HttpTransportSettings; import org.elasticsearch.test.ESTestCase; import java.net.UnknownHostException; @@ -32,11 +30,11 @@ import static java.net.InetAddress.getByName; import static java.util.Arrays.asList; -import static org.elasticsearch.http.netty4.Netty4HttpServerTransport.resolvePublishPort; +import static org.elasticsearch.http.AbstractHttpServerTransport.resolvePublishPort; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -public class Netty4HttpPublishPortTests extends ESTestCase { +public class AbstractHttpServerTransportTests extends ESTestCase { public void testHttpPublishPort() throws Exception { int boundPort = randomIntBetween(9000, 9100); @@ -88,5 +86,4 @@ private List randomAddresses() throws UnknownHostException { } return addresses; } - }