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 Classes
Modifier and Type
Class
Description
`static class`
`NettyOcientWireV1Transport.Factory`

## Nested classes/interfaces inherited from interface com.ocient.transport.SimplexTransport

`SimplexTransport.StreamCtx<T>`

## Constructor Summary

Constructors
Constructor
Description
`NettyOcientWireV1Transport(io.netty.channel.ChannelFuture channelFuture, Supplier<CompletionStage<Void>> onClose)`

## 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`
`hasData()`
`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 queueDepth)`
Accepts a stream of requests and returns the result response stream.
`String`
`toString()`

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

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

## Constructor Details

### NettyOcientWireV1Transport

public NettyOcientWireV1Transport(io.netty.channel.ChannelFuture channelFuture, Supplier<CompletionStage<Void>> onClose)

## Method Details

### 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>`

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

### 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.

### 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>`

### toString

public String toString()

Overrides:
  `toString` in class `Object`