Skip to content

Commit d202d90

Browse files
authored
Adding support for handling multiple transport protocols (opensearch-project#12967)
* Adding support for more than one protocol for transport Signed-off-by: Vacha Shah <vachshah@amazon.com> * Adding CHANGELOG entry Signed-off-by: Vacha Shah <vachshah@amazon.com> * Addressing comments Signed-off-by: Vacha Shah <vachshah@amazon.com> * Addressing comments Signed-off-by: Vacha Shah <vachshah@amazon.com> * Removing determineTransportProtocol Signed-off-by: Vacha Shah <vachshah@amazon.com> * Determine transport protocol only on first byte reference Signed-off-by: Vacha Shah <vachshah@amazon.com> * Making InboundBytesHandler closeable Signed-off-by: Vacha Shah <vachshah@amazon.com> * Fixing close() for InboundPipeline Signed-off-by: Vacha Shah <vachshah@amazon.com> * Adding DeprecatedAPI annotation to japicmp task Signed-off-by: Vacha Shah <vachshah@amazon.com> * Fixing for detect breaking changes workflow Signed-off-by: Vacha Shah <vachshah@amazon.com> * Fixing recursion Signed-off-by: Vacha Shah <vachshah@amazon.com> --------- Signed-off-by: Vacha Shah <vachshah@amazon.com>
1 parent 9b0f578 commit d202d90

18 files changed

+1010
-570
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
114114
- Add cluster primary balance contraint for rebalancing with buffer ([#12656](https://github.com/opensearch-project/OpenSearch/pull/12656))
115115
- [Remote Store] Make translog transfer timeout configurable ([#12704](https://github.com/opensearch-project/OpenSearch/pull/12704))
116116
- Reject Resize index requests (i.e, split, shrink and clone), While DocRep to SegRep migration is in progress.([#12686](https://github.com/opensearch-project/OpenSearch/pull/12686))
117+
- Add support for more than one protocol for transport ([#12967](https://github.com/opensearch-project/OpenSearch/pull/12967))
117118

118119
### Dependencies
119120
- Bump `org.apache.commons:commons-configuration2` from 2.10.0 to 2.10.1 ([#12896](https://github.com/opensearch-project/OpenSearch/pull/12896))

server/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ tasks.register("japicmp", me.champeau.gradle.japicmp.JapicmpTask) {
387387
onlyModified = true
388388
failOnModification = true
389389
ignoreMissingClasses = true
390-
annotationIncludes = ['@org.opensearch.common.annotation.PublicApi']
390+
annotationIncludes = ['@org.opensearch.common.annotation.PublicApi', '@org.opensearch.common.annotation.DeprecatedApi']
391391
txtOutputFile = layout.buildDirectory.file("reports/java-compatibility/report.txt")
392392
htmlOutputFile = layout.buildDirectory.file("reports/java-compatibility/report.html")
393393
dependsOn downloadSnapshot

server/src/main/java/org/opensearch/transport/Header.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,19 @@ public int getNetworkMessageSize() {
7575
return networkMessageSize;
7676
}
7777

78-
Version getVersion() {
78+
public Version getVersion() {
7979
return version;
8080
}
8181

82-
long getRequestId() {
82+
public long getRequestId() {
8383
return requestId;
8484
}
8585

8686
byte getStatus() {
8787
return status;
8888
}
8989

90-
boolean isRequest() {
90+
public boolean isRequest() {
9191
return TransportStatus.isRequest(status);
9292
}
9393

@@ -99,7 +99,7 @@ boolean isError() {
9999
return TransportStatus.isError(status);
100100
}
101101

102-
boolean isHandshake() {
102+
public boolean isHandshake() {
103103
return TransportStatus.isHandshake(status);
104104
}
105105

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.transport;
10+
11+
import org.opensearch.common.bytes.ReleasableBytesReference;
12+
13+
import java.io.Closeable;
14+
import java.io.IOException;
15+
import java.util.function.BiConsumer;
16+
17+
/**
18+
* Interface for handling inbound bytes. Can be implemented by different transport protocols.
19+
*/
20+
public interface InboundBytesHandler extends Closeable {
21+
22+
public void doHandleBytes(
23+
TcpChannel channel,
24+
ReleasableBytesReference reference,
25+
BiConsumer<TcpChannel, ProtocolInboundMessage> messageHandler
26+
) throws IOException;
27+
28+
public boolean canHandleBytes(ReleasableBytesReference reference);
29+
30+
@Override
31+
void close();
32+
}

server/src/main/java/org/opensearch/transport/InboundDecoder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
*/
5151
public class InboundDecoder implements Releasable {
5252

53-
static final Object PING = new Object();
54-
static final Object END_CONTENT = new Object();
53+
public static final Object PING = new Object();
54+
public static final Object END_CONTENT = new Object();
5555

5656
private final Version version;
5757
private final PageCacheRecycler recycler;

0 commit comments

Comments
 (0)