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
Constructor
Description
`Transport(int id, String host, int port)`

## Method Summary

Modifier and Type
Method
Description
`io.netty.buffer.ByteBuf`
`allocate(int capacity)`
Allocates an I/O capable `ByteBuf` with the specified capacity.
`CompletionStage<Void>`
`close()`
`Optional<SocketAddress>`
`getLocalAddress()`
`Optional<SocketAddress>`
`getRemoteAddress()`
`boolean`
`isValid()`
`CompletionStage<TransportResult<io.netty.buffer.ByteBuf>>`
`sendAndReceive(io.netty.buffer.ByteBuf request, SimplexTransport.Ctx ctx)`
Sends a `SimplexTransport` to the server and returns a `CompletionStage` that completes with the `SimplexTransport` from the server.
`CompletionStage<TransportResult<Void>>`
`sendNoReceive(io.netty.buffer.ByteBuf request, SimplexTransport.Ctx ctx)`
Sends `SimplexTransport` to 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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Transport

public Transport(int id, String host, int port)

## Method Details

### allocate

public io.netty.buffer.ByteBuf allocate(int capacity)
Description copied from interface: `SimplexTransport`
Allocates an I/O capable `ByteBuf` with the specified capacity.

Specified by:
  `allocate` in interface `SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>`
Parameters:
  `capacity` - the desired capacity of the new buffer.
Returns:
  a new I/O capable `ByteBuf` with the specified capacity.

### sendAndReceive

public CompletionStage<TransportResult<io.netty.buffer.ByteBuf>> sendAndReceive(io.netty.buffer.ByteBuf request, SimplexTransport.Ctx ctx)
Description copied from interface: `SimplexTransport`
Sends a `SimplexTransport` to the server and returns a `CompletionStage` that completes with the `SimplexTransport` from the server.

Specified by:
  `sendAndReceive` in interface `SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>`
Parameters:
  `request` - the `SimplexTransport`
Returns:
  a `CompletionStage` that completes with a `SimplexTransport` from the server.

### sendNoReceive

public CompletionStage<TransportResult<Void>> sendNoReceive(io.netty.buffer.ByteBuf request, SimplexTransport.Ctx ctx)
Description copied from interface: `SimplexTransport`
Sends `SimplexTransport` to the server. notably, a response is NOT expected from the server.

Specified by:
  `sendNoReceive` in interface `SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>`
Parameters:
  `request` - the `SimplexTransport`

### 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: `SimplexTransport`
Accepts a stream of requests and returns the result response stream. Backpressure may be applied by the request producer via the
invalid reference

    Asynciterator

interface.

Implementations may enqueue up to `maxQueueDepth` requests 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:
  `stream` in interface `SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>`
Parameters:
  `requests` - the stream of `SimplexTransport`s. 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

public CompletionStage<Void> close()

Specified by:
  `close` in interface `com.ibm.asyncutil.util.AsyncCloseable`
Specified by:
  `close` in interface `SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>`

### isValid

public boolean isValid()

Specified by:
  `isValid` in interface `SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>`

### getLocalAddress

public Optional<SocketAddress> getLocalAddress()

Specified by:
  `getLocalAddress` in interface `SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>`

### getRemoteAddress

public Optional<SocketAddress> getRemoteAddress()

Specified by:
  `getRemoteAddress` in interface `SimplexTransport<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>`