Package com.ocient.transport
Class NettyOcientWireV1Transport
java.lang.Object
com.ocient.transport.NettyOcientWireV1Transport
- All Implemented Interfaces:
com.ibm.asyncutil.util.AsyncCloseable,SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>
public class NettyOcientWireV1Transport
extends Object
implements SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>
Transport implementation that implements the Ocient Wire Protocol V1.
Notably, the implementation does not decode the message.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.ocient.transport.SimplexTransport
SimplexTransport.StreamCtx<T> -
Constructor Summary
ConstructorsConstructorDescriptionNettyOcientWireV1Transport(io.netty.channel.ChannelFuture channelFuture, Supplier<CompletionStage<Void>> onClose) -
Method Summary
Modifier and TypeMethodDescriptionio.netty.buffer.ByteBufallocate(int capacity) Allocates an I/O capableByteBufwith the specified capacity.close()booleanhasData()booleanisValid()CompletionStage<TransportResult<io.netty.buffer.ByteBuf>>sendAndReceive(io.netty.buffer.ByteBuf request, SimplexTransport.Ctx ctx) Sends aSimplexTransportto the server and returns aCompletionStagethat completes with theSimplexTransportfrom the server.sendNoReceive(io.netty.buffer.ByteBuf request, SimplexTransport.Ctx ctx) SendsSimplexTransportto the server.com.ibm.asyncutil.iteration.AsyncIterator<SimplexTransport.StreamCtx<TransportResult<io.netty.buffer.ByteBuf>>>stream(com.ibm.asyncutil.iteration.AsyncIterator<SimplexTransport.StreamCtx<TransportResult<io.netty.buffer.ByteBuf>>> requests, int queueDepth) Accepts a stream of requests and returns the result response stream.toString()
-
Constructor Details
-
NettyOcientWireV1Transport
public NettyOcientWireV1Transport(io.netty.channel.ChannelFuture channelFuture, Supplier<CompletionStage<Void>> onClose)
-
-
Method Details
-
getLocalAddress
- Specified by:
getLocalAddressin interfaceSimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>
-
getRemoteAddress
- Specified by:
getRemoteAddressin interfaceSimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>
-
hasData
public boolean hasData() -
stream
public com.ibm.asyncutil.iteration.AsyncIterator<SimplexTransport.StreamCtx<TransportResult<io.netty.buffer.ByteBuf>>> stream(com.ibm.asyncutil.iteration.AsyncIterator<SimplexTransport.StreamCtx<TransportResult<io.netty.buffer.ByteBuf>>> requests, int queueDepth) Description copied from interface:SimplexTransportAccepts a stream of requests and returns the result response stream. Backpressure may be applied by the request producer via theAsynciteratorinterface.Implementations may enqueue up to
maxQueueDepthrequests in the recepient's recv queue at any given time.Implementations must ensure that requests are sent in the sequence they are generated.
- Specified by:
streamin interfaceSimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> - Parameters:
requests- the stream ofSimplexTransports. Callers may apply backpressure by throttling the stream of requests.queueDepth- the maximum queue depth of the recipient's recv queue.- Returns:
- the stream of responses; one per request.
-
sendAndReceive
public CompletionStage<TransportResult<io.netty.buffer.ByteBuf>> sendAndReceive(io.netty.buffer.ByteBuf request, SimplexTransport.Ctx ctx) Description copied from interface:SimplexTransportSends aSimplexTransportto the server and returns aCompletionStagethat completes with theSimplexTransportfrom the server.- Specified by:
sendAndReceivein interfaceSimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> - Parameters:
request- theSimplexTransport- Returns:
- a
CompletionStagethat completes with aSimplexTransportfrom the server.
-
sendNoReceive
public CompletionStage<TransportResult<Void>> sendNoReceive(io.netty.buffer.ByteBuf request, SimplexTransport.Ctx ctx) Description copied from interface:SimplexTransportSendsSimplexTransportto the server. notably, a response is NOT expected from the server.- Specified by:
sendNoReceivein interfaceSimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> - Parameters:
request- theSimplexTransport
-
allocate
public io.netty.buffer.ByteBuf allocate(int capacity) Description copied from interface:SimplexTransportAllocates an I/O capableByteBufwith the specified capacity.- Specified by:
allocatein interfaceSimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> - Parameters:
capacity- the desired capacity of the new buffer.- Returns:
- a new I/O capable
ByteBufwith the specified capacity.
-
close
- Specified by:
closein interfacecom.ibm.asyncutil.util.AsyncCloseable- Specified by:
closein interfaceSimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceSimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>
-
toString
-