Class TransportImpl
- java.lang.Object
-
- org.apache.qpid.proton.engine.impl.EndpointImpl
-
- org.apache.qpid.proton.engine.impl.TransportImpl
-
- All Implemented Interfaces:
FrameBody.FrameBodyHandler<java.lang.Integer>,Endpoint,Extendable,FrameHandler,TransportInternal,ProtonJEndpoint,ProtonJTransport,Transport
public class TransportImpl extends EndpointImpl implements ProtonJTransport, FrameBody.FrameBodyHandler<java.lang.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 useTransport.Factory.create()instead
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTransportLayer(TransportLayer layer)Add aTransportLayerto the transport, wrapping the input and output process handlers in the state they currently exist.voidbind(Connection conn)intcapacity()voidclose_head()voidclose_tail()voidclosed(TransportException error)intgetChannelMax()Gets the local channel-max value to be advertised to the remote peerErrorConditiongetCondition()protected ConnectionImplgetConnectionImpl()longgetFramesInput()longgetFramesOutput()intgetIdleTimeout()java.nio.ByteBuffergetInputBuffer()Get a buffer that can be used to write input data into the transport.intgetMaxFrameSize()Get the maximum frame size for the transportintgetOutboundFrameSizeLimit()java.nio.ByteBuffergetOutputBuffer()Get a read-only byte buffer containing the transport's pending output.ProtocolTracergetProtocolTracer()ReactorgetReactor()intgetRemoteChannelMax()Gets the remote value of channel-max, as advertised by the peer on its Open frame.intgetRemoteIdleTimeout()intgetRemoteMaxFrameSize()SelectablegetSelectable()voidhandleAttach(Attach attach, Binary payload, java.lang.Integer channel)voidhandleBegin(Begin begin, Binary payload, java.lang.Integer channel)voidhandleClose(Close close, Binary payload, java.lang.Integer channel)voidhandleDetach(Detach detach, Binary payload, java.lang.Integer channel)voidhandleDisposition(Disposition disposition, Binary payload, java.lang.Integer channel)voidhandleEnd(End end, Binary payload, java.lang.Integer channel)voidhandleFlow(Flow flow, Binary payload, java.lang.Integer channel)booleanhandleFrame(TransportFrame frame)voidhandleOpen(Open open, Binary payload, java.lang.Integer channel)voidhandleTransfer(Transfer transfer, Binary payload, java.lang.Integer channel)java.nio.ByteBufferhead()intinput(byte[] bytes, int offset, int length)Processes the provided input.booleanisClosed()booleanisEmitFlowEventOnSend()booleanisHandlingFrames()Returns whether I am currently able to handle frames.booleanisUseReadOnlyOutputBuffer()TransportResultoldApiCheckStateBeforeInput(int inputLength)This method is public as it is used by Python layer.intoutput(byte[] bytes, int offset, int size)Has the transport produce up to size bytes placing the result into dest beginning at position offset.voidoutputConsumed()Informs the transport that the output buffer returned byTransport.getOutputBuffer()is finished with, allowing implementation-dependent steps to be performed such as reclaiming buffer space.intpending()voidpop(int bytes)voidprocess()TransportResultprocessInput()Tell the transport to process the data written to the input buffer.Saslsasl()Signal the transport to expect SASL frames used to establish a SASL layer prior to performing the AMQP protocol version negotiation.voidsetChannelMax(int channelMax)Set the local value of channel-max, to be advertised to the peer on the Open frame emitted by the transport.voidsetCondition(ErrorCondition error)Set the local error conditionvoidsetEmitFlowEventOnSend(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.voidsetFrameHandler(FrameHandler frameHandler)Override the default frame handler.voidsetIdleTimeout(int timeout)voidsetInitialRemoteMaxFrameSize(int remoteMaxFrameSize)Allows overriding the initial remote-max-frame-size to a value greater than the default 512bytes.voidsetMaxFrameSize(int maxFrameSize)voidsetOutboundFrameSizeLimit(int limit)Set an upper limit on the size of outgoing frames that will be sent to the peer.voidsetProtocolTracer(ProtocolTracer protocolTracer)voidsetReactor(Reactor reactor)voidsetSelectable(Selectable selectable)voidsetUseReadOnlyOutputBuffer(boolean value)Sslssl(SslDomain sslDomain)Equivalent toTransport.ssl(SslDomain, SslPeerDetails)but passing null for SslPeerDetails, meaning no SNI detail is sent, hostname verification isn't supported etc when connecting.Sslssl(SslDomain sslDomain, SslPeerDetails sslPeerDetails)Wrap this transport's output and input to apply SSL encryption and decryption respectively.java.nio.ByteBuffertail()longtick(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.StringtoString()voidtrace(int levels)voidunbind()protected voidwriteFrame(int channel, FrameBody frameBody, ReadableBuffer payload, java.lang.Runnable onPayloadTooLarge)booleanwriteInto(java.nio.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 Detail
-
TransportImpl
public TransportImpl()
Application code should useTransport.Factory.create()instead
-
-
Method Detail
-
getMaxFrameSize
public int getMaxFrameSize()
Description copied from interface:TransportGet the maximum frame size for the transport- Specified by:
getMaxFrameSizein interfaceTransport- Returns:
- the maximum frame size
-
getRemoteMaxFrameSize
public int getRemoteMaxFrameSize()
- Specified by:
getRemoteMaxFrameSizein interfaceTransport
-
setInitialRemoteMaxFrameSize
public void setInitialRemoteMaxFrameSize(int remoteMaxFrameSize)
Description copied from interface:TransportAllows 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 beforeTransport.sasl()in order to influence SASL behaviour.- Specified by:
setInitialRemoteMaxFrameSizein interfaceTransport- Parameters:
remoteMaxFrameSize- the remote frame size to use
-
setMaxFrameSize
public void setMaxFrameSize(int maxFrameSize)
- Specified by:
setMaxFrameSizein interfaceTransport
-
getChannelMax
public int getChannelMax()
Description copied from interface:TransportGets the local channel-max value to be advertised to the remote peer- Specified by:
getChannelMaxin interfaceTransport- Returns:
- the local channel-max value
- See Also:
Transport.setChannelMax(int)
-
setChannelMax
public void setChannelMax(int channelMax)
Description copied from interface:TransportSet 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 usingTransport.getRemoteChannelMax().- Specified by:
setChannelMaxin interfaceTransport- Parameters:
channelMax- the local channel-max to advertise to the peer, in range [0 - 2^16).
-
getRemoteChannelMax
public int getRemoteChannelMax()
Description copied from interface:TransportGets the remote value of channel-max, as advertised by the peer on its Open frame. The local peers advertised channel-max can be observed usingTransport.getChannelMax().- Specified by:
getRemoteChannelMaxin interfaceTransport- Returns:
- the remote channel-max value
-
getCondition
public ErrorCondition getCondition()
- Specified by:
getConditionin interfaceEndpoint- Specified by:
getConditionin interfaceTransport- Overrides:
getConditionin classEndpointImpl- Returns:
- the local endpoint error, or null if there is none
-
setCondition
public void setCondition(ErrorCondition error)
Description copied from interface:EndpointSet the local error condition- Specified by:
setConditionin interfaceEndpoint- Overrides:
setConditionin classEndpointImpl
-
bind
public void bind(Connection conn)
-
input
public int input(byte[] bytes, int offset, int length)Description copied from interface:TransportProcesses the provided input.
-
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:TransportHas the transport produce up to size bytes placing the result into dest beginning at position offset.
-
writeInto
public boolean writeInto(java.nio.ByteBuffer outputBuffer)
-
sasl
public Sasl sasl()
Description copied from interface:TransportSignal 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 sameSaslobject.
-
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 sameSslobject, regardless of the parameters supplied.Note that sslDomain must implement
ProtonSslEngineProvider. This is not possible enforce at the API level becauseProtonSslEngineProvideris not part of the public Proton API.
-
ssl
public Ssl ssl(SslDomain sslDomain)
Description copied from interface:TransportEquivalent toTransport.ssl(SslDomain, SslPeerDetails)but passing null for SslPeerDetails, meaning no SNI detail is sent, hostname verification isn't supported etc when connecting.
-
writeFrame
protected void writeFrame(int channel, FrameBody frameBody, ReadableBuffer payload, java.lang.Runnable onPayloadTooLarge)
-
getConnectionImpl
protected ConnectionImpl getConnectionImpl()
- Specified by:
getConnectionImplin classEndpointImpl
-
handleOpen
public void handleOpen(Open open, Binary payload, java.lang.Integer channel)
- Specified by:
handleOpenin interfaceFrameBody.FrameBodyHandler<java.lang.Integer>
-
handleBegin
public void handleBegin(Begin begin, Binary payload, java.lang.Integer channel)
- Specified by:
handleBeginin interfaceFrameBody.FrameBodyHandler<java.lang.Integer>
-
handleAttach
public void handleAttach(Attach attach, Binary payload, java.lang.Integer channel)
- Specified by:
handleAttachin interfaceFrameBody.FrameBodyHandler<java.lang.Integer>
-
handleFlow
public void handleFlow(Flow flow, Binary payload, java.lang.Integer channel)
- Specified by:
handleFlowin interfaceFrameBody.FrameBodyHandler<java.lang.Integer>
-
handleTransfer
public void handleTransfer(Transfer transfer, Binary payload, java.lang.Integer channel)
- Specified by:
handleTransferin interfaceFrameBody.FrameBodyHandler<java.lang.Integer>
-
handleDisposition
public void handleDisposition(Disposition disposition, Binary payload, java.lang.Integer channel)
- Specified by:
handleDispositionin interfaceFrameBody.FrameBodyHandler<java.lang.Integer>
-
handleDetach
public void handleDetach(Detach detach, Binary payload, java.lang.Integer channel)
- Specified by:
handleDetachin interfaceFrameBody.FrameBodyHandler<java.lang.Integer>
-
handleEnd
public void handleEnd(End end, Binary payload, java.lang.Integer channel)
- Specified by:
handleEndin interfaceFrameBody.FrameBodyHandler<java.lang.Integer>
-
handleClose
public void handleClose(Close close, Binary payload, java.lang.Integer channel)
- Specified by:
handleClosein interfaceFrameBody.FrameBodyHandler<java.lang.Integer>
-
handleFrame
public boolean handleFrame(TransportFrame frame)
- Specified by:
handleFramein interfaceFrameHandler- Returns:
- false on end of stream
- See Also:
FrameHandler.isHandlingFrames()
-
closed
public void closed(TransportException error)
- Specified by:
closedin interfaceFrameHandler
-
isHandlingFrames
public boolean isHandlingFrames()
Description copied from interface:FrameHandlerReturns whether I am currently able to handle frames. MUST be checked before callingFrameHandler.handleFrame(TransportFrame).- Specified by:
isHandlingFramesin interfaceFrameHandler
-
getProtocolTracer
public ProtocolTracer getProtocolTracer()
- Specified by:
getProtocolTracerin interfaceProtonJTransport
-
setProtocolTracer
public void setProtocolTracer(ProtocolTracer protocolTracer)
- Specified by:
setProtocolTracerin interfaceProtonJTransport
-
getInputBuffer
public java.nio.ByteBuffer getInputBuffer()
Description copied from interface:TransportGet 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. OnceTransport.processInput()is called the buffer must not be used.- Specified by:
getInputBufferin interfaceTransport
-
processInput
public TransportResult processInput()
Description copied from interface:TransportTell 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 subsequentTransport.processInput()calls on this object will throw an exception.- Specified by:
processInputin interfaceTransport- Returns:
- the result of processing the data, which indicates success or failure.
- See Also:
Transport.getInputBuffer()
-
getOutputBuffer
public java.nio.ByteBuffer getOutputBuffer()
Description copied from interface:TransportGet 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. OnceTransport.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:
getOutputBufferin interfaceTransport
-
outputConsumed
public void outputConsumed()
Description copied from interface:TransportInforms the transport that the output buffer returned byTransport.getOutputBuffer()is finished with, allowing implementation-dependent steps to be performed such as reclaiming buffer space.- Specified by:
outputConsumedin interfaceTransport
-
process
public void process() throws TransportException- Specified by:
processin interfaceTransport- Throws:
TransportException
-
close_tail
public void close_tail()
- Specified by:
close_tailin interfaceTransport
-
setIdleTimeout
public void setIdleTimeout(int timeout)
- Specified by:
setIdleTimeoutin interfaceTransport- Parameters:
timeout- local idle timeout in milliseconds
-
getIdleTimeout
public int getIdleTimeout()
- Specified by:
getIdleTimeoutin interfaceTransport- Returns:
- local idle timeout in milliseconds
-
getRemoteIdleTimeout
public int getRemoteIdleTimeout()
- Specified by:
getRemoteIdleTimeoutin interfaceTransport- Returns:
- remote idle timeout in milliseconds
-
tick
public long tick(long now)
Description copied from interface:TransportPrompt 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 fromSystem.currentTimeMillis()or derived fromSystem.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.
-
getFramesOutput
public long getFramesOutput()
- Specified by:
getFramesOutputin interfaceTransport
-
getFramesInput
public long getFramesInput()
- Specified by:
getFramesInputin interfaceTransport
-
close_head
public void close_head()
- Specified by:
close_headin interfaceTransport
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.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:TransportConfigure 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:
setEmitFlowEventOnSendin interfaceTransport- Parameters:
emitFlowEventOnSend- true if a flow event should be emitted, false otherwise
-
isEmitFlowEventOnSend
public boolean isEmitFlowEventOnSend()
- Specified by:
isEmitFlowEventOnSendin interfaceTransport
-
setUseReadOnlyOutputBuffer
public void setUseReadOnlyOutputBuffer(boolean value)
- Specified by:
setUseReadOnlyOutputBufferin interfaceTransportInternal
-
isUseReadOnlyOutputBuffer
public boolean isUseReadOnlyOutputBuffer()
- Specified by:
isUseReadOnlyOutputBufferin interfaceTransportInternal
-
addTransportLayer
public void addTransportLayer(TransportLayer layer)
Description copied from interface:TransportInternalAdd aTransportLayerto 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:
addTransportLayerin interfaceTransportInternal- Parameters:
layer- the layer to add (if it was not previously added)
-
setOutboundFrameSizeLimit
public void setOutboundFrameSizeLimit(int limit)
Description copied from interface:TransportSet 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:
setOutboundFrameSizeLimitin interfaceTransport- Parameters:
limit- the size limit to apply
-
getOutboundFrameSizeLimit
public int getOutboundFrameSizeLimit()
- Specified by:
getOutboundFrameSizeLimitin interfaceTransport
-
-