-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vacha Shah <[email protected]>
- Loading branch information
Showing
15 changed files
with
133 additions
and
111 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
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
37 changes: 0 additions & 37 deletions
37
server/src/main/java/org/opensearch/transport/BaseInboundMessage.java
This file was deleted.
Oops, something went wrong.
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
53 changes: 53 additions & 0 deletions
53
.../src/main/java/org/opensearch/transport/protobufprotocol/ProtobufInboundBytesHandler.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,53 @@ | ||
/* | ||
* 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.transport.protobufprotocol; | ||
|
||
import org.opensearch.common.bytes.ReleasableBytesReference; | ||
import org.opensearch.core.common.bytes.BytesReference; | ||
import org.opensearch.transport.InboundBytesHandler; | ||
import org.opensearch.transport.ProtocolInboundMessage; | ||
import org.opensearch.transport.TcpChannel; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.util.function.BiConsumer; | ||
|
||
/** | ||
* Handler for inbound bytes for the protobuf protocol. | ||
*/ | ||
public class ProtobufInboundBytesHandler implements InboundBytesHandler { | ||
|
||
public void ProtobufInboundBytesHandler() {} | ||
|
||
@Override | ||
public void doHandleBytes( | ||
TcpChannel channel, | ||
ReleasableBytesReference reference, | ||
BiConsumer<TcpChannel, ProtocolInboundMessage> messageHandler | ||
) throws IOException { | ||
// removing the first byte we added for protobuf message | ||
byte[] incomingBytes = BytesReference.toBytes(reference.slice(3, reference.length() - 3)); | ||
ProtobufInboundMessage protobufMessage = new ProtobufInboundMessage(new ByteArrayInputStream(incomingBytes)); | ||
messageHandler.accept(channel, protobufMessage); | ||
} | ||
|
||
@Override | ||
public boolean canHandleBytes(ReleasableBytesReference reference) { | ||
if (reference.get(0) == 'O' && reference.get(1) == 'S' && reference.get(2) == 'P') { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
// no-op | ||
} | ||
|
||
} |
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.