public class TransportImpl extends EndpointImpl implements ProtonJTransport, FrameBody.FrameBodyHandler<java.lang.Integer>, FrameHandler, TransportInternal
Transport.Factory
DEFAULT_MAX_FRAME_SIZE, END_OF_STREAM, MIN_MAX_FRAME_SIZE, SESSION_WINDOW, TRACE_DRV, TRACE_FRM, TRACE_OFF, TRACE_RAW
Constructor and Description |
---|
TransportImpl()
Application code should use
Transport.Factory.create() instead |
Modifier and Type | Method and 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() |
java.nio.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() |
java.nio.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,
java.lang.Integer channel) |
void |
handleBegin(Begin begin,
Binary payload,
java.lang.Integer channel) |
void |
handleClose(Close close,
Binary payload,
java.lang.Integer channel) |
void |
handleDetach(Detach detach,
Binary payload,
java.lang.Integer channel) |
void |
handleDisposition(Disposition disposition,
Binary payload,
java.lang.Integer channel) |
void |
handleEnd(End end,
Binary payload,
java.lang.Integer channel) |
void |
handleFlow(Flow flow,
Binary payload,
java.lang.Integer channel) |
boolean |
handleFrame(TransportFrame frame) |
void |
handleOpen(Open open,
Binary payload,
java.lang.Integer channel) |
void |
handleTransfer(Transfer transfer,
Binary payload,
java.lang.Integer channel) |
java.nio.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.
|
java.nio.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.
|
java.lang.String |
toString() |
void |
trace(int levels) |
void |
unbind() |
protected void |
writeFrame(int channel,
FrameBody frameBody,
ReadableBuffer payload,
java.lang.Runnable onPayloadTooLarge) |
boolean |
writeInto(java.nio.ByteBuffer outputBuffer)
Writes my pending output bytes into outputBuffer.
|
attachments, close, free, getContext, getLocalState, getRemoteCondition, getRemoteState, open, setContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close, free, getContext, getLocalState, getRemoteCondition, getRemoteState, open, setContext
attachments
public TransportImpl()
Transport.Factory.create()
insteadpublic int getMaxFrameSize()
Transport
getMaxFrameSize
in interface Transport
public int getRemoteMaxFrameSize()
getRemoteMaxFrameSize
in interface Transport
public void setInitialRemoteMaxFrameSize(int remoteMaxFrameSize)
Transport
Transport.sasl()
in order to influence SASL behaviour.setInitialRemoteMaxFrameSize
in interface Transport
remoteMaxFrameSize
- the remote frame size to usepublic void setMaxFrameSize(int maxFrameSize)
setMaxFrameSize
in interface Transport
public int getChannelMax()
Transport
getChannelMax
in interface Transport
Transport.setChannelMax(int)
public void setChannelMax(int channelMax)
Transport
Transport.getRemoteChannelMax()
.setChannelMax
in interface Transport
channelMax
- the local channel-max to advertise to the peer, in range [0 - 2^16).public int getRemoteChannelMax()
Transport
Transport.getChannelMax()
.getRemoteChannelMax
in interface Transport
public ErrorCondition getCondition()
getCondition
in interface Endpoint
getCondition
in interface Transport
getCondition
in class EndpointImpl
public void setCondition(ErrorCondition error)
Endpoint
setCondition
in interface Endpoint
setCondition
in class EndpointImpl
public void bind(Connection conn)
public int input(byte[] bytes, int offset, int length)
Transport
public TransportResult oldApiCheckStateBeforeInput(int inputLength)
Transport.input(byte[], int, int)
public int output(byte[] bytes, int offset, int size)
Transport
public boolean writeInto(java.nio.ByteBuffer outputBuffer)
public Sasl sasl()
Transport
Sasl
object.public Ssl ssl(SslDomain sslDomain, SslPeerDetails sslPeerDetails)
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.
public Ssl ssl(SslDomain sslDomain)
Transport
Transport.ssl(SslDomain, SslPeerDetails)
but passing null for SslPeerDetails, meaning no SNI detail
is sent, hostname verification isn't supported etc when connecting.protected void writeFrame(int channel, FrameBody frameBody, ReadableBuffer payload, java.lang.Runnable onPayloadTooLarge)
protected ConnectionImpl getConnectionImpl()
getConnectionImpl
in class EndpointImpl
public void handleOpen(Open open, Binary payload, java.lang.Integer channel)
handleOpen
in interface FrameBody.FrameBodyHandler<java.lang.Integer>
public void handleBegin(Begin begin, Binary payload, java.lang.Integer channel)
handleBegin
in interface FrameBody.FrameBodyHandler<java.lang.Integer>
public void handleAttach(Attach attach, Binary payload, java.lang.Integer channel)
handleAttach
in interface FrameBody.FrameBodyHandler<java.lang.Integer>
public void handleFlow(Flow flow, Binary payload, java.lang.Integer channel)
handleFlow
in interface FrameBody.FrameBodyHandler<java.lang.Integer>
public void handleTransfer(Transfer transfer, Binary payload, java.lang.Integer channel)
handleTransfer
in interface FrameBody.FrameBodyHandler<java.lang.Integer>
public void handleDisposition(Disposition disposition, Binary payload, java.lang.Integer channel)
handleDisposition
in interface FrameBody.FrameBodyHandler<java.lang.Integer>
public void handleDetach(Detach detach, Binary payload, java.lang.Integer channel)
handleDetach
in interface FrameBody.FrameBodyHandler<java.lang.Integer>
public void handleEnd(End end, Binary payload, java.lang.Integer channel)
handleEnd
in interface FrameBody.FrameBodyHandler<java.lang.Integer>
public void handleClose(Close close, Binary payload, java.lang.Integer channel)
handleClose
in interface FrameBody.FrameBodyHandler<java.lang.Integer>
public boolean handleFrame(TransportFrame frame)
handleFrame
in interface FrameHandler
FrameHandler.isHandlingFrames()
public void closed(TransportException error)
closed
in interface FrameHandler
public boolean isHandlingFrames()
FrameHandler
FrameHandler.handleFrame(TransportFrame)
.isHandlingFrames
in interface FrameHandler
public ProtocolTracer getProtocolTracer()
getProtocolTracer
in interface ProtonJTransport
public void setProtocolTracer(ProtocolTracer protocolTracer)
setProtocolTracer
in interface ProtonJTransport
public java.nio.ByteBuffer getInputBuffer()
Transport
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.getInputBuffer
in interface Transport
public TransportResult processInput()
Transport
Transport.processInput()
calls on this object will
throw an exception.processInput
in interface Transport
Transport.getInputBuffer()
public java.nio.ByteBuffer getOutputBuffer()
Transport
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.getOutputBuffer
in interface Transport
public void outputConsumed()
Transport
Transport.getOutputBuffer()
is finished with, allowing implementation-dependent steps to be performed such as
reclaiming buffer space.outputConsumed
in interface Transport
public void process() throws TransportException
process
in interface Transport
TransportException
public void close_tail()
close_tail
in interface Transport
public void setIdleTimeout(int timeout)
setIdleTimeout
in interface Transport
timeout
- local idle timeout in millisecondspublic int getIdleTimeout()
getIdleTimeout
in interface Transport
public int getRemoteIdleTimeout()
getRemoteIdleTimeout
in interface Transport
public long tick(long now)
Transport
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.public long getFramesOutput()
getFramesOutput
in interface Transport
public long getFramesInput()
getFramesInput
in interface Transport
public void close_head()
close_head
in interface Transport
public java.lang.String toString()
toString
in class java.lang.Object
public void setFrameHandler(FrameHandler frameHandler)
getInputBuffer()
, getOutputBuffer()
, ssl(SslDomain)
etc).public void setSelectable(Selectable selectable)
public Selectable getSelectable()
public void setReactor(Reactor reactor)
public Reactor getReactor()
public void setEmitFlowEventOnSend(boolean emitFlowEventOnSend)
Transport
setEmitFlowEventOnSend
in interface Transport
emitFlowEventOnSend
- true if a flow event should be emitted, false otherwisepublic boolean isEmitFlowEventOnSend()
isEmitFlowEventOnSend
in interface Transport
public void setUseReadOnlyOutputBuffer(boolean value)
setUseReadOnlyOutputBuffer
in interface TransportInternal
public boolean isUseReadOnlyOutputBuffer()
isUseReadOnlyOutputBuffer
in interface TransportInternal
public void addTransportLayer(TransportLayer layer)
TransportInternal
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.addTransportLayer
in interface TransportInternal
layer
- the layer to add (if it was not previously added)public void setOutboundFrameSizeLimit(int limit)
Transport
setOutboundFrameSizeLimit
in interface Transport
limit
- the size limit to applypublic int getOutboundFrameSizeLimit()
getOutboundFrameSizeLimit
in interface Transport