Package com.ocient.util
Class MockOcientCluster.Transport
java.lang.Object
com.ocient.util.MockOcientCluster.Transport
- All Implemented Interfaces:
com.ibm.asyncutil.util.AsyncCloseable,SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>
- Enclosing class:
MockOcientCluster
public class MockOcientCluster.Transport
extends Object
implements SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>
Represents a TCP connection to the backing server instance.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.ocient.transport.SimplexTransport
SimplexTransport.Ctx, SimplexTransport.StreamCtx<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.netty.buffer.ByteBufallocate(int capacity) Allocates an I/O capableByteBufwith the specified capacity.close()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 maxQueueDepth) Accepts a stream of requests and returns the result response stream.
-
Constructor Details
-
Transport
-
-
Method Details
-
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.
-
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
-
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 maxQueueDepth) Description copied from interface:SimplexTransportAccepts a stream of requests and returns the result response stream. Backpressure may be applied by the request producer via theinterface.invalid reference
AsynciteratorImplementations 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.maxQueueDepth- the maximum queue depth of the recipient's recv queue.- Returns:
- the stream of responses; one per request.
-
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>
-
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>
-