Package org.apache.qpid.proton.engine.impl

# Class TransportImpl

java.lang.Object
org.apache.qpid.proton.engine.impl.EndpointImpl
org.apache.qpid.proton.engine.impl.TransportImpl

All Implemented Interfaces:
  `FrameBody.FrameBodyHandler<Integer>`, `Endpoint`, `Extendable`, `FrameHandler`, `TransportInternal`, `ProtonJEndpoint`, `ProtonJTransport`, `Transport`

public class TransportImpl extends EndpointImpl implements ProtonJTransport, FrameBody.FrameBodyHandler<Integer>, FrameHandler, TransportInternal

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.apache.qpid.proton.engine.Transport

`Transport.Factory`

## Field Summary

### Fields inherited from interface org.apache.qpid.proton.engine.Transport

`DEFAULT_MAX_FRAME_SIZE, END_OF_STREAM, MIN_MAX_FRAME_SIZE, SESSION_WINDOW, TRACE_DRV, TRACE_FRM, TRACE_OFF, TRACE_RAW`

## Constructor Summary

Constructors
Constructor
Description
`TransportImpl()`
Application code should use `Transport.Factory.create()` instead

## Method Summary

Modifier and Type
Method
Description
`void`
`addTransportLayer(TransportLayer layer)`
Add a `TransportLayer` to the transport, wrapping the input and output process handlers in the state they currently exist.
`void`
`bind(Connection conn)`
`int`
`capacity()`
`void`
`close_head()`
`void`
`close_tail()`
`void`
`closed(TransportException error)`
`int`
`getChannelMax()`
Gets the local channel-max value to be advertised to the remote peer
`ErrorCondition`
`getCondition()`
`protected ConnectionImpl`
`getConnectionImpl()`
`long`
`getFramesInput()`
`long`
`getFramesOutput()`
`int`
`getIdleTimeout()`
`ByteBuffer`
`getInputBuffer()`
Get a buffer that can be used to write input data into the transport.
`int`
`getMaxFrameSize()`
Get the maximum frame size for the transport
`int`
`getOutboundFrameSizeLimit()`
`ByteBuffer`
`getOutputBuffer()`
Get a read-only byte buffer containing the transport's pending output.
`ProtocolTracer`
`getProtocolTracer()`
`Reactor`
`getReactor()`
`int`
`getRemoteChannelMax()`
Gets the remote value of channel-max, as advertised by the peer on its Open frame.
`int`
`getRemoteIdleTimeout()`
`int`
`getRemoteMaxFrameSize()`
`Selectable`
`getSelectable()`
`void`
`handleAttach(Attach attach, Binary payload, Integer channel)`
`void`
`handleBegin(Begin begin, Binary payload, Integer channel)`
`void`
`handleClose(Close close, Binary payload, Integer channel)`
`void`
`handleDetach(Detach detach, Binary payload, Integer channel)`
`void`
`handleDisposition(Disposition disposition, Binary payload, Integer channel)`
`void`
`handleEnd(End end, Binary payload, Integer channel)`
`void`
`handleFlow(Flow flow, Binary payload, Integer channel)`
`boolean`
`handleFrame(TransportFrame frame)`
`void`
`handleOpen(Open open, Binary payload, Integer channel)`
`void`
`handleTransfer(Transfer transfer, Binary payload, Integer channel)`
`ByteBuffer`
`head()`
`int`
`input(byte[] bytes, int offset, int length)`
Processes the provided input.
`boolean`
`isClosed()`
`boolean`
`isEmitFlowEventOnSend()`
`boolean`
`isHandlingFrames()`
Returns whether I am currently able to handle frames.
`boolean`
`isUseReadOnlyOutputBuffer()`
`TransportResult`
`oldApiCheckStateBeforeInput(int inputLength)`
This method is public as it is used by Python layer.
`int`
`output(byte[] bytes, int offset, int size)`
Has the transport produce up to size bytes placing the result into dest beginning at position offset.
`void`
`outputConsumed()`
Informs the transport that the output buffer returned by `Transport.getOutputBuffer()` is finished with, allowing implementation-dependent steps to be performed such as reclaiming buffer space.
`int`
`pending()`
`void`
`pop(int bytes)`
`void`
`process()`
`TransportResult`
`processInput()`
Tell the transport to process the data written to the input buffer.
`Sasl`
`sasl()`
Signal the transport to expect SASL frames used to establish a SASL layer prior to performing the AMQP protocol version negotiation.
`void`
`setChannelMax(int channelMax)`
Set the local value of channel-max, to be advertised to the peer on the Open frame emitted by the transport.
`void`
`setCondition(ErrorCondition error)`
Set the local error condition
`void`
`setEmitFlowEventOnSend(boolean emitFlowEventOnSend)`
Configure whether a synthetic Flow event should be emitted when messages are sent, reflecting a change in the credit level on the link that may prompt other action.
`void`
`setFrameHandler(FrameHandler frameHandler)`
Override the default frame handler.
`void`
`setIdleTimeout(int timeout)`
`void`
`setInitialRemoteMaxFrameSize(int remoteMaxFrameSize)`
Allows overriding the initial remote-max-frame-size to a value greater than the default 512bytes.
`void`
`setMaxFrameSize(int maxFrameSize)`
`void`
`setOutboundFrameSizeLimit(int limit)`
Set an upper limit on the size of outgoing frames that will be sent to the peer.
`void`
`setProtocolTracer(ProtocolTracer protocolTracer)`
`void`
`setReactor(Reactor reactor)`
`void`
`setSelectable(Selectable selectable)`
`void`
`setUseReadOnlyOutputBuffer(boolean value)`
`Ssl`
`ssl(SslDomain sslDomain)`
Equivalent to `Transport.ssl(SslDomain, SslPeerDetails)` but passing null for SslPeerDetails, meaning no SNI detail is sent, hostname verification isn't supported etc when connecting.
`Ssl`
`ssl(SslDomain sslDomain, SslPeerDetails sslPeerDetails)`
Wrap this transport's output and input to apply SSL encryption and decryption respectively.
`ByteBuffer`
`tail()`
`long`
`tick(long now)`
Prompt the transport to perform work such as idle-timeout/heartbeat handling, and return an absolute deadline in milliseconds that tick must again be called by/at, based on the provided current time in milliseconds, to ensure the periodic work is carried out as necessary.
`String`
`toString()`
`void`
`trace(int levels)`
`void`
`unbind()`
`protected void`
`writeFrame(int channel, FrameBody frameBody, ReadableBuffer payload, Runnable onPayloadTooLarge)`
`boolean`
`writeInto(ByteBuffer outputBuffer)`

### Methods inherited from class org.apache.qpid.proton.engine.impl.EndpointImpl

`attachments, close, free, getContext, getLocalState, getRemoteCondition, getRemoteState, open, setContext`

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

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

### Methods inherited from interface org.apache.qpid.proton.engine.Endpoint

`close, free, getContext, getLocalState, getRemoteCondition, getRemoteState, open, setContext`

### Methods inherited from interface org.apache.qpid.proton.engine.Extendable

`attachments`

## Constructor Details

### TransportImpl

public TransportImpl()
Application code should use `Transport.Factory.create()` instead

## Method Details

### trace

public void trace(int levels)

Specified by:
  `trace` in interface `Transport`

### getMaxFrameSize

public int getMaxFrameSize()
Description copied from interface: `Transport`
Get the maximum frame size for the transport

Specified by:
  `getMaxFrameSize` in interface `Transport`
Returns:
  the maximum frame size

### getRemoteMaxFrameSize

public int getRemoteMaxFrameSize()

Specified by:
  `getRemoteMaxFrameSize` in interface `Transport`

### setInitialRemoteMaxFrameSize

public void setInitialRemoteMaxFrameSize(int remoteMaxFrameSize)
Description copied from interface: `Transport`
Allows overriding the initial remote-max-frame-size to a value greater than the default 512bytes. The value set will be used until such time as the Open frame arrives from the peer and populates the remote max frame size. This method must be called before before `Transport.sasl()` in order to influence SASL behaviour.

Specified by:
  `setInitialRemoteMaxFrameSize` in interface `Transport`
Parameters:
  `remoteMaxFrameSize` - the remote frame size to use

### setMaxFrameSize

public void setMaxFrameSize(int maxFrameSize)

Specified by:
  `setMaxFrameSize` in interface `Transport`

### getChannelMax

public int getChannelMax()
Description copied from interface: `Transport`
Gets the local channel-max value to be advertised to the remote peer

Specified by:
  `getChannelMax` in interface `Transport`
Returns:
  the local channel-max value
See Also:
  - `Transport.setChannelMax(int)`

### setChannelMax

public void setChannelMax(int channelMax)
Description copied from interface: `Transport`
Set the local value of channel-max, to be advertised to the peer on the Open frame emitted by the transport. The remote peers advertised channel-max can be observed using `Transport.getRemoteChannelMax()`.

Specified by:
  `setChannelMax` in interface `Transport`
Parameters:
  `channelMax` - the local channel-max to advertise to the peer, in range [0 - 2^16).

### getRemoteChannelMax

public int getRemoteChannelMax()
Description copied from interface: `Transport`
Gets the remote value of channel-max, as advertised by the peer on its Open frame. The local peers advertised channel-max can be observed using `Transport.getChannelMax()`.

Specified by:
  `getRemoteChannelMax` in interface `Transport`
Returns:
  the remote channel-max value

### getCondition

public ErrorCondition getCondition()

Specified by:
  `getCondition` in interface `Endpoint`
Specified by:
  `getCondition` in interface `Transport`
Overrides:
  `getCondition` in class `EndpointImpl`
Returns:
  the local endpoint error, or null if there is none

### setCondition

public void setCondition(ErrorCondition error)
Description copied from interface: `Endpoint`
Set the local error condition

Specified by:
  `setCondition` in interface `Endpoint`
Overrides:
  `setCondition` in class `EndpointImpl`

### bind

public void bind(Connection conn)

Specified by:
  `bind` in interface `Transport`

### unbind

public void unbind()

Specified by:
  `unbind` in interface `Transport`

### input

public int input(byte[] bytes, int offset, int length)
Description copied from interface: `Transport`
Processes the provided input.

Specified by:
  `input` in interface `Transport`
Parameters:
  `bytes` - input bytes for consumption
  `offset` - the offset within bytes where input begins
  `length` - the number of bytes available for input
Returns:
  the number of bytes consumed

### oldApiCheckStateBeforeInput

public TransportResult oldApiCheckStateBeforeInput(int inputLength)
This method is public as it is used by Python layer.

See Also:
  - `Transport.input(byte[], int, int)`

### output

public int output(byte[] bytes, int offset, int size)
Description copied from interface: `Transport`
Has the transport produce up to size bytes placing the result into dest beginning at position offset.

Specified by:
  `output` in interface `Transport`
Parameters:
  `bytes` - array for output bytes
  `offset` - the offset within bytes where output begins
  `size` - the maximum number of bytes to be output
Returns:
  the number of bytes written

### writeInto

public boolean writeInto(ByteBuffer outputBuffer)

### sasl

public Sasl sasl()
Description copied from interface: `Transport`
Signal the transport to expect SASL frames used to establish a SASL layer prior to performing the AMQP protocol version negotiation. This must first be performed before the transport is used for processing. Subsequent invocations will return the same `Sasl` object.

Specified by:
  `sasl` in interface `Transport`

### ssl

public Ssl ssl(SslDomain sslDomain, SslPeerDetails sslPeerDetails)
Wrap this transport's output and input to apply SSL encryption and decryption respectively. This method is expected to be called at most once. A subsequent invocation will return the same `Ssl` object, regardless of the parameters supplied.

Note that sslDomain must implement `ProtonSslEngineProvider`. This is not possible enforce at the API level because `ProtonSslEngineProvider` is not part of the public Proton API.

Specified by:
  `ssl` in interface `Transport`
Parameters:
  `sslDomain` - the SSL settings to use
  `sslPeerDetails` - peer details, used for SNI, hostname verification, etc when connecting. May be null.
Returns:
  an `Ssl` object representing the SSL session.

### ssl

public Ssl ssl(SslDomain sslDomain)
Description copied from interface: `Transport`
Equivalent to `Transport.ssl(SslDomain, SslPeerDetails)` but passing null for SslPeerDetails, meaning no SNI detail is sent, hostname verification isn't supported etc when connecting.

Specified by:
  `ssl` in interface `Transport`

### writeFrame

protected void writeFrame(int channel, FrameBody frameBody, ReadableBuffer payload, Runnable onPayloadTooLarge)

### getConnectionImpl

protected ConnectionImpl getConnectionImpl()

Specified by:
  `getConnectionImpl` in class `EndpointImpl`

### handleOpen

public void handleOpen(Open open, Binary payload, Integer channel)

Specified by:
  `handleOpen` in interface `FrameBody.FrameBodyHandler<Integer>`

### handleBegin

public void handleBegin(Begin begin, Binary payload, Integer channel)

Specified by:
  `handleBegin` in interface `FrameBody.FrameBodyHandler<Integer>`

### handleAttach

public void handleAttach(Attach attach, Binary payload, Integer channel)

Specified by:
  `handleAttach` in interface `FrameBody.FrameBodyHandler<Integer>`

### handleFlow

public void handleFlow(Flow flow, Binary payload, Integer channel)

Specified by:
  `handleFlow` in interface `FrameBody.FrameBodyHandler<Integer>`

### handleTransfer

public void handleTransfer(Transfer transfer, Binary payload, Integer channel)

Specified by:
  `handleTransfer` in interface `FrameBody.FrameBodyHandler<Integer>`

### handleDisposition

public void handleDisposition(Disposition disposition, Binary payload, Integer channel)

Specified by:
  `handleDisposition` in interface `FrameBody.FrameBodyHandler<Integer>`

### handleDetach

public void handleDetach(Detach detach, Binary payload, Integer channel)

Specified by:
  `handleDetach` in interface `FrameBody.FrameBodyHandler<Integer>`

### handleEnd

public void handleEnd(End end, Binary payload, Integer channel)

Specified by:
  `handleEnd` in interface `FrameBody.FrameBodyHandler<Integer>`

### handleClose

public void handleClose(Close close, Binary payload, Integer channel)

Specified by:
  `handleClose` in interface `FrameBody.FrameBodyHandler<Integer>`

### handleFrame

public boolean handleFrame(TransportFrame frame)

Specified by:
  `handleFrame` in interface `FrameHandler`
Returns:
  false on end of stream
See Also:
  - `FrameHandler.isHandlingFrames()`

### closed

public void closed(TransportException error)

Specified by:
  `closed` in interface `FrameHandler`

### isHandlingFrames

public boolean isHandlingFrames()
Description copied from interface: `FrameHandler`
Returns whether I am currently able to handle frames. MUST be checked before calling `FrameHandler.handleFrame(TransportFrame)`.

Specified by:
  `isHandlingFrames` in interface `FrameHandler`

### getProtocolTracer

public ProtocolTracer getProtocolTracer()

Specified by:
  `getProtocolTracer` in interface `ProtonJTransport`

### setProtocolTracer

public void setProtocolTracer(ProtocolTracer protocolTracer)

Specified by:
  `setProtocolTracer` in interface `ProtonJTransport`

### getInputBuffer

public ByteBuffer getInputBuffer()
Description copied from interface: `Transport`
Get a buffer that can be used to write input data into the transport. Once the client has finished putting into the input buffer, `Transport.processInput()` must be called. Successive calls to this method are not guaranteed to return the same object. Once `Transport.processInput()` is called the buffer must not be used.

Specified by:
  `getInputBuffer` in interface `Transport`

### processInput

public TransportResult processInput()
Description copied from interface: `Transport`
Tell the transport to process the data written to the input buffer. If the returned result indicates failure, the transport will not accept any more input. Specifically, any subsequent `Transport.processInput()` calls on this object will throw an exception.

Specified by:
  `processInput` in interface `Transport`
Returns:
  the result of processing the data, which indicates success or failure.
See Also:
  - `Transport.getInputBuffer()`

### getOutputBuffer

public ByteBuffer getOutputBuffer()
Description copied from interface: `Transport`
Get a read-only byte buffer containing the transport's pending output. Once the client has finished getting from the output buffer, `Transport.outputConsumed()` must be called. Successive calls to this method are not guaranteed to return the same object. Once `Transport.outputConsumed()` is called the buffer must not be used. If the transport's state changes AFTER calling this method, this will not be reflected in the output buffer.

Specified by:
  `getOutputBuffer` in interface `Transport`

### outputConsumed

public void outputConsumed()
Description copied from interface: `Transport`
Informs the transport that the output buffer returned by `Transport.getOutputBuffer()` is finished with, allowing implementation-dependent steps to be performed such as reclaiming buffer space.

Specified by:
  `outputConsumed` in interface `Transport`

### capacity

public int capacity()

Specified by:
  `capacity` in interface `Transport`

### tail

public ByteBuffer tail()

Specified by:
  `tail` in interface `Transport`

### process

public void process() throws TransportException

Specified by:
  `process` in interface `Transport`
Throws:
  `TransportException`

### close_tail

public void close_tail()

Specified by:
  `close_tail` in interface `Transport`

### pending

public int pending()

Specified by:
  `pending` in interface `Transport`

### head

public ByteBuffer head()

Specified by:
  `head` in interface `Transport`

### pop

public void pop(int bytes)

Specified by:
  `pop` in interface `Transport`

### setIdleTimeout

public void setIdleTimeout(int timeout)

Specified by:
  `setIdleTimeout` in interface `Transport`
Parameters:
  `timeout` - local idle timeout in milliseconds

### getIdleTimeout

public int getIdleTimeout()

Specified by:
  `getIdleTimeout` in interface `Transport`
Returns:
  local idle timeout in milliseconds

### getRemoteIdleTimeout

public int getRemoteIdleTimeout()

Specified by:
  `getRemoteIdleTimeout` in interface `Transport`
Returns:
  remote idle timeout in milliseconds

### tick

public long tick(long now)
Description copied from interface: `Transport`
Prompt the transport to perform work such as idle-timeout/heartbeat handling, and return an absolute deadline in milliseconds that tick must again be called by/at, based on the provided current time in milliseconds, to ensure the periodic work is carried out as necessary. A returned deadline of 0 indicates there is no periodic work necessitating tick be called, e.g. because neither peer has defined an idle-timeout value. The provided milliseconds time values can be from `System.currentTimeMillis()` or derived from `System.nanoTime()`, noting that for the later in particular that the returned deadline could be a different sign than the given time, and (if non-zero) the returned deadline should have the current time originally provided subtracted from it in order to establish a relative time delay to the next deadline.

Specified by:
  `tick` in interface `Transport`
Parameters:
  `now` - the current time in milliseconds
Returns:
  the absolute deadline in milliseconds to next call tick by/at, or 0 if there is none.

### getFramesOutput

public long getFramesOutput()

Specified by:
  `getFramesOutput` in interface `Transport`

### getFramesInput

public long getFramesInput()

Specified by:
  `getFramesInput` in interface `Transport`

### close_head

public void close_head()

Specified by:
  `close_head` in interface `Transport`

### isClosed

public boolean isClosed()

Specified by:
  `isClosed` in interface `Transport`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### setFrameHandler

public void setFrameHandler(FrameHandler frameHandler)
Override the default frame handler. Must be called before the transport starts being used (e.g. `getInputBuffer()`, `getOutputBuffer()`, `ssl(SslDomain)` etc).

### setSelectable

public void setSelectable(Selectable selectable)

### getSelectable

public Selectable getSelectable()

### setReactor

public void setReactor(Reactor reactor)

### getReactor

public Reactor getReactor()

### setEmitFlowEventOnSend

public void setEmitFlowEventOnSend(boolean emitFlowEventOnSend)
Description copied from interface: `Transport`
Configure whether a synthetic Flow event should be emitted when messages are sent, reflecting a change in the credit level on the link that may prompt other action. Defaults to true.

Specified by:
  `setEmitFlowEventOnSend` in interface `Transport`
Parameters:
  `emitFlowEventOnSend` - true if a flow event should be emitted, false otherwise

### isEmitFlowEventOnSend

public boolean isEmitFlowEventOnSend()

Specified by:
  `isEmitFlowEventOnSend` in interface `Transport`

### setUseReadOnlyOutputBuffer

public void setUseReadOnlyOutputBuffer(boolean value)

Specified by:
  `setUseReadOnlyOutputBuffer` in interface `TransportInternal`

### isUseReadOnlyOutputBuffer

public boolean isUseReadOnlyOutputBuffer()

Specified by:
  `isUseReadOnlyOutputBuffer` in interface `TransportInternal`

### addTransportLayer

public void addTransportLayer(TransportLayer layer)
Description copied from interface: `TransportInternal`
Add a `TransportLayer` to the transport, wrapping the input and output process handlers in the state they currently exist. No effect if the given layer was previously added.

Specified by:
  `addTransportLayer` in interface `TransportInternal`
Parameters:
  `layer` - the layer to add (if it was not previously added)

### setOutboundFrameSizeLimit

public void setOutboundFrameSizeLimit(int limit)
Description copied from interface: `Transport`
Set an upper limit on the size of outgoing frames that will be sent to the peer. Allows constraining the transport not to emit Transfer frames over a given size even when the peers max frame size allows it. Must be set before receiving the peers Open frame to have effect.

Specified by:
  `setOutboundFrameSizeLimit` in interface `Transport`
Parameters:
  `limit` - the size limit to apply

### getOutboundFrameSizeLimit

public int getOutboundFrameSizeLimit()

Specified by:
  `getOutboundFrameSizeLimit` in interface `Transport`