forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for HTTP/2 (server-side) (opensearch-project#3847)
* Support for HTTP/2 (server-side) Signed-off-by: Andriy Redko <andriy.redko@aiven.io> * Addressing code review comments Signed-off-by: Andriy Redko <andriy.redko@aiven.io> * Added HTTP/1.1 channel configuration Signed-off-by: Andriy Redko <andriy.redko@aiven.io> * Addressing code review comments Signed-off-by: Andriy Redko <andriy.redko@aiven.io> * Update pul request URL in CHANGELOG.md Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
- Loading branch information
Showing
12 changed files
with
428 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
modules/transport-netty4/licenses/netty-codec-http2-4.1.79.Final.jar.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0eeffab0cd5efb699d5e4ab9b694d32fef6694b3 |
62 changes: 62 additions & 0 deletions
62
...ansport-netty4/src/internalClusterTest/java/org/opensearch/http/netty4/Netty4Http2IT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.http.netty4; | ||
|
||
import io.netty.handler.codec.http.FullHttpResponse; | ||
import io.netty.util.ReferenceCounted; | ||
import org.opensearch.OpenSearchNetty4IntegTestCase; | ||
import org.opensearch.common.transport.TransportAddress; | ||
import org.opensearch.http.HttpServerTransport; | ||
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope; | ||
import org.opensearch.test.OpenSearchIntegTestCase.Scope; | ||
|
||
import java.util.Collection; | ||
import java.util.Locale; | ||
import java.util.stream.IntStream; | ||
|
||
import static org.hamcrest.Matchers.containsInAnyOrder; | ||
import static org.hamcrest.Matchers.hasSize; | ||
|
||
@ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1) | ||
public class Netty4Http2IT extends OpenSearchNetty4IntegTestCase { | ||
|
||
@Override | ||
protected boolean addMockHttpTransport() { | ||
return false; // enable http | ||
} | ||
|
||
public void testThatNettyHttpServerSupportsHttp2() throws Exception { | ||
String[] requests = new String[] { "/", "/_nodes/stats", "/", "/_cluster/state", "/" }; | ||
|
||
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class); | ||
TransportAddress[] boundAddresses = httpServerTransport.boundAddress().boundAddresses(); | ||
TransportAddress transportAddress = randomFrom(boundAddresses); | ||
|
||
try (Netty4HttpClient nettyHttpClient = Netty4HttpClient.http2()) { | ||
Collection<FullHttpResponse> responses = nettyHttpClient.get(transportAddress.address(), requests); | ||
try { | ||
assertThat(responses, hasSize(5)); | ||
|
||
Collection<String> opaqueIds = Netty4HttpClient.returnOpaqueIds(responses); | ||
assertOpaqueIdsInAnyOrder(opaqueIds); | ||
} finally { | ||
responses.forEach(ReferenceCounted::release); | ||
} | ||
} | ||
} | ||
|
||
private void assertOpaqueIdsInAnyOrder(Collection<String> opaqueIds) { | ||
// check if opaque ids are present in any order, since for HTTP/2 we use streaming (no head of line blocking) | ||
// and responses may come back at any order | ||
int i = 0; | ||
String msg = String.format(Locale.ROOT, "Expected list of opaque ids to be in any order, got [%s]", opaqueIds); | ||
assertThat(msg, opaqueIds, containsInAnyOrder(IntStream.range(0, 5).mapToObj(Integer::toString).toArray())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.