public class BlockingClientManager extends AbstractIdleService implements ClientConnectionManager
A thin wrapper around a set of BlockingClients.
Generally, using NioClient and NioClientManager should be preferred over BlockingClient
and BlockingClientManager as they scale significantly better, unless you wish to connect over a proxy or use
some other network settings that cannot be set using NIO.
Service.Listener, Service.State| Constructor and Description |
|---|
BlockingClientManager() |
BlockingClientManager(SocketFactory socketFactory)
Creates a blocking client manager that will obtain sockets from the given factory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
closeConnections(int n)
Closes n peer connections
|
int |
getConnectedClientCount()
Gets the number of connected peers
|
ListenableFuture<SocketAddress> |
openConnection(SocketAddress serverAddress,
StreamParser parser)
Creates a new connection to the given address, with the given parser used to handle incoming data.
|
void |
setConnectTimeoutMillis(int connectTimeoutMillis)
Sets the number of milliseconds to wait before giving up on a connect attempt
|
protected void |
shutDown() |
protected void |
startUp() |
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, start, startAndWait, startAsync, state, stop, stopAndWait, stopAsync, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, start, startAndWait, startAsync, state, stop, stopAndWait, stopAsyncpublic BlockingClientManager()
public BlockingClientManager(SocketFactory socketFactory)
public ListenableFuture<SocketAddress> openConnection(SocketAddress serverAddress, StreamParser parser)
ClientConnectionManageropenConnection in interface ClientConnectionManagerpublic void setConnectTimeoutMillis(int connectTimeoutMillis)
protected void startUp()
throws Exception
startUp in class AbstractIdleServiceExceptionprotected void shutDown()
throws Exception
shutDown in class AbstractIdleServiceExceptionpublic int getConnectedClientCount()
ClientConnectionManagergetConnectedClientCount in interface ClientConnectionManagerpublic void closeConnections(int n)
ClientConnectionManagercloseConnections in interface ClientConnectionManagerCopyright © 2016. All rights reserved.