Class TcpTransport
java.lang.Object
org.apache.qpid.protonj2.client.transport.netty5.TcpTransport
- All Implemented Interfaces:
- Transport
- Direct Known Subclasses:
- WebSocketTransport
TCP based transport that uses Netty as the underlying IO layer.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classprotected class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final io.netty5.bootstrap.Bootstrapprotected io.netty5.channel.Channelprotected final AtomicBooleanprotected final AtomicBooleanprotected final CountDownLatchprotected IOExceptionprotected Stringprotected TransportListenerprotected Netty5ProtonBufferAllocatorprotected final TransportOptionsprotected intprotected final SslOptions
- 
Constructor SummaryConstructorsConstructorDescriptionTcpTransport(io.netty5.bootstrap.Bootstrap bootstrap, TransportOptions options, SslOptions sslOptions) Create a newTcpTransportinstance with the given configuration.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddAdditionalHandlers(io.netty5.channel.ChannelPipeline pipeline) voidWaits interruptibly for theTransportto connect to the remote that was indicated in theTransport.connect(String, int, TransportListener)call.protected final voidvoidclose()Close the Transport, no additional send operations are accepted.connect(String host, int port, TransportListener listener) Performs the connect operation for the implemented Transport type such as a TCP socket connection, SSL/TLS handshake etc.protected io.netty5.channel.ChannelHandlerflush()Request a flush of all pending writes to the underlying connection.Gets a buffer allocator that can produceProtonBufferinstance that may be optimized for use with the underlying transport implementation.getHost()intgetPort()Returns a URI that contains some meaningful information about the remote connection such as a scheme that reflects the transport type and the remote host and port that the connection was instructed to connect to.protected StringGets the currently set TransportListener instanceprotected voidhandleConnected(io.netty5.channel.Channel connectedChannel) protected voidhandleTransportFailure(io.netty5.channel.Channel failedChannel, Throwable cause) booleanbooleanisSecure()write(ProtonBuffer output) Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.write(ProtonBuffer output, Runnable onComplete) Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.writeAndFlush(ProtonBuffer output) Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operationswriteAndFlush(ProtonBuffer output, Runnable onComplete) Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operations
- 
Field Details- 
connected
- 
closed
- 
connectedLatch
- 
options
- 
sslOptions
- 
bootstrapprotected final io.netty5.bootstrap.Bootstrap bootstrap
- 
channelprotected io.netty5.channel.Channel channel
- 
failureCause
- 
host
- 
portprotected int port
- 
listener
- 
nettyAllocator
 
- 
- 
Constructor Details- 
TcpTransportpublic TcpTransport(io.netty5.bootstrap.Bootstrap bootstrap, TransportOptions options, SslOptions sslOptions) Create a newTcpTransportinstance with the given configuration.- Parameters:
- bootstrap- the Netty- Bootstrapthat this transport's IO layer is bound to.
- options- the- TransportOptionsused to configure the socket connection.
- sslOptions- the- SslOptionsto use if the options indicate SSL is enabled.
 
 
- 
- 
Method Details- 
connectDescription copied from interface:TransportPerforms the connect operation for the implemented Transport type such as a TCP socket connection, SSL/TLS handshake etc. The connection operation itself will be performed as an asynchronous operation with the success or failure being communicated to the event pointTransportListener.transportError(Throwable). If the users wishes to perform a block on connect outcome theTransport.awaitConnect()method will wait for and or throw an error based on the connect outcome.- Specified by:
- connectin interface- Transport
- Parameters:
- host- The remote host that this- Transportshould attempt to connect to.
- port- The port on the remote host that this- Transportshould attempt to bind to.
- listener- The- TransportListenerthat will handle- Transportevents.
- Returns:
- this Transportinstance.
- Throws:
- IOException- if an error occurs while attempting the connect.
 
- 
awaitConnectDescription copied from interface:TransportWaits interruptibly for theTransportto connect to the remote that was indicated in theTransport.connect(String, int, TransportListener)call.- Specified by:
- awaitConnectin interface- Transport
- Throws:
- InterruptedException- If the wait mechanism was interrupted while waiting for a successful connect.
- IOException- If the- Transportfailed to connect or was closed before connected.
 
- 
isConnectedpublic boolean isConnected()- Specified by:
- isConnectedin interface- Transport
- Returns:
- true if transport is connected or false if the connection is down.
 
- 
isSecurepublic boolean isSecure()
- 
getHost
- 
getPortpublic int getPort()
- 
closeDescription copied from interface:TransportClose the Transport, no additional send operations are accepted.- Specified by:
- closein interface- Transport
- Throws:
- IOException- if an error occurs while closing the connection.
 
- 
getBufferAllocatorDescription copied from interface:TransportGets a buffer allocator that can produceProtonBufferinstance that may be optimized for use with the underlying transport implementation.- Specified by:
- getBufferAllocatorin interface- Transport
- Returns:
- a ProtonBufferAllocatorthat creates transport friendly buffers.
 
- 
writeDescription copied from interface:TransportWrites a chunk of data over the Transport connection without performing an explicit flush on the transport.- Specified by:
- writein interface- Transport
- Parameters:
- output- The buffer of data that is to be transmitted.
- Returns:
- this Transportinstance.
- Throws:
- IOException- if an error occurs during the write operation.
 
- 
writeDescription copied from interface:TransportWrites a chunk of data over the Transport connection without performing an explicit flush on the transport. This method allows for a completion callback that is signaled when the actual low level IO operation is completed which could be after this method has returned.- Specified by:
- writein interface- Transport
- Parameters:
- output- The buffer of data that is to be transmitted.
- onComplete- A- Runnablethat is invoked when the IO operation completes successfully.
- Returns:
- this Transportinstance.
- Throws:
- IOException- if an error occurs during the write operation.
 
- 
writeAndFlushDescription copied from interface:TransportWrites a chunk of data over the Transport connection and requests a flush of all pending queued write operations- Specified by:
- writeAndFlushin interface- Transport
- Parameters:
- output- The buffer of data that is to be transmitted.
- Returns:
- this Transportinstance.
- Throws:
- IOException- if an error occurs during the write operation.
 
- 
writeAndFlushDescription copied from interface:TransportWrites a chunk of data over the Transport connection and requests a flush of all pending queued write operations- Specified by:
- writeAndFlushin interface- Transport
- Parameters:
- output- The buffer of data that is to be transmitted.
- onComplete- A- Runnablethat is invoked when the IO operation completes successfully.
- Returns:
- this Transportinstance.
- Throws:
- IOException- if an error occurs during the write operation.
 
- 
flushDescription copied from interface:TransportRequest a flush of all pending writes to the underlying connection.- Specified by:
- flushin interface- Transport
- Returns:
- this Transportinstance.
- Throws:
- IOException- if an error occurs during the flush operation.
 
- 
getTransportListenerDescription copied from interface:TransportGets the currently set TransportListener instance- Specified by:
- getTransportListenerin interface- Transport
- Returns:
- the current TransportListener or null if none set.
 
- 
getTransportOptions- Specified by:
- getTransportOptionsin interface- Transport
- Returns:
- a TransportOptionsinstance copied from the immutable options given at create time..
 
- 
getSslOptions- Specified by:
- getSslOptionsin interface- Transport
- Returns:
- a SslOptionsinstance copied from the immutable options given at create time..
 
- 
getLocalPrincipal- Specified by:
- getLocalPrincipalin interface- Transport
- Returns:
- the local principal for a Transport that is using a secure connection.
 
- 
addAdditionalHandlersprotected void addAdditionalHandlers(io.netty5.channel.ChannelPipeline pipeline) 
- 
createChannelHandlerprotected io.netty5.channel.ChannelHandler createChannelHandler()
- 
handleConnected- Throws:
- Exception
 
- 
handleTransportFailure
- 
checkConnected- Throws:
- IOException
 
- 
getRemoteURIDescription copied from interface:TransportReturns a URI that contains some meaningful information about the remote connection such as a scheme that reflects the transport type and the remote host and port that the connection was instructed to connect to. If called before theTransport.connect(String, int, TransportListener)method this method returnsnull.- Specified by:
- getRemoteURIin interface- Transport
- Returns:
- a URI that reflects a meaningful view of the Transportremote connection details.
 
- 
getScheme
 
-