public class NettyMessagingTransport extends Object implements Transport
Constructor and Description |
---|
NettyMessagingTransport(String hostAddress,
int port,
EStage<TransportEvent> clientStage,
EStage<TransportEvent> serverStage,
int numberOfTries,
int retryTimeout)
Deprecated.
use the constructor that takes a TcpProvider instead
|
NettyMessagingTransport(String hostAddress,
int port,
EStage<TransportEvent> clientStage,
EStage<TransportEvent> serverStage,
int numberOfTries,
int retryTimeout,
TcpPortProvider tcpPortProvider)
Constructs a messaging transport
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all channels and releases all resources
|
<T> Link<T> |
get(SocketAddress remoteAddr)
Returns a link for the remote address if already cached; otherwise, returns null
|
int |
getListeningPort()
Gets a server listening port of this transport
|
SocketAddress |
getLocalAddress()
Gets a server local socket address of this transport
|
<T> Link<T> |
open(SocketAddress remoteAddr,
Encoder<? super T> encoder,
LinkListener<? super T> listener)
Returns a link for the remote address if cached; otherwise opens, caches and returns
When it opens a link for the remote address, only one attempt for the address is made at a given time
|
void |
registerErrorHandler(EventHandler<Exception> handler)
Registers the exception event handler
|
public NettyMessagingTransport(String hostAddress, int port, EStage<TransportEvent> clientStage, EStage<TransportEvent> serverStage, int numberOfTries, int retryTimeout, TcpPortProvider tcpPortProvider)
hostAddress
- the server host addressport
- the server listening port; when it is 0, randomly assign a port numberclientStage
- the client-side stage that handles transport eventsserverStage
- the server-side stage that handles transport eventsnumberOfTries
- the number of tries of connectionretryTimeout
- the timeout of reconnectiontcpPortProvider
- gives an iterator that produces random tcp ports in a range@Deprecated public NettyMessagingTransport(String hostAddress, int port, EStage<TransportEvent> clientStage, EStage<TransportEvent> serverStage, int numberOfTries, int retryTimeout)
hostAddress
- the server host addressport
- the server listening port; when it is 0, randomly assign a port numberclientStage
- the client-side stage that handles transport eventsserverStage
- the server-side stage that handles transport eventsnumberOfTries
- the number of tries of connectionretryTimeout
- the timeout of reconnectionpublic void close() throws Exception
close
in interface AutoCloseable
Exception
public <T> Link<T> open(SocketAddress remoteAddr, Encoder<? super T> encoder, LinkListener<? super T> listener) throws IOException
open
in interface Transport
remoteAddr
- the remote socket addressencoder
- the encoderlistener
- the link listenerIOException
public <T> Link<T> get(SocketAddress remoteAddr)
public SocketAddress getLocalAddress()
getLocalAddress
in interface Transport
public int getListeningPort()
getListeningPort
in interface Transport
public void registerErrorHandler(EventHandler<Exception> handler)
registerErrorHandler
in interface Transport
handler
- the exception event handlerCopyright © 2015 The Apache Software Foundation. All rights reserved.