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)
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)
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 AutoCloseableExceptionpublic <T> Link<T> open(SocketAddress remoteAddr, Encoder<? super T> encoder, LinkListener<? super T> listener) throws IOException
open in interface TransportremoteAddr - the remote socket addressencoder - the encoderlistener - the link listenerIOExceptionpublic <T> Link<T> get(SocketAddress remoteAddr)
public SocketAddress getLocalAddress()
getLocalAddress in interface Transportpublic int getListeningPort()
getListeningPort in interface Transportpublic void registerErrorHandler(EventHandler<Exception> handler)
registerErrorHandler in interface Transporthandler - the exception event handlerCopyright © 2015 The Apache Software Foundation. All rights reserved.