public class BlockingClientManager extends com.google.common.util.concurrent.AbstractIdleService implements ClientConnectionManager
A thin wrapper around a set of BlockingClient
s.
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.
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
|
void |
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, executor, isRunning, start, startAndWait, state, stop, stopAndWait, toString
public BlockingClientManager()
public BlockingClientManager(SocketFactory socketFactory)
public void openConnection(SocketAddress serverAddress, StreamParser parser)
ClientConnectionManager
openConnection
in interface ClientConnectionManager
public void setConnectTimeoutMillis(int connectTimeoutMillis)
protected void startUp() throws Exception
startUp
in class com.google.common.util.concurrent.AbstractIdleService
Exception
protected void shutDown() throws Exception
shutDown
in class com.google.common.util.concurrent.AbstractIdleService
Exception
public int getConnectedClientCount()
ClientConnectionManager
getConnectedClientCount
in interface ClientConnectionManager
public void closeConnections(int n)
ClientConnectionManager
closeConnections
in interface ClientConnectionManager
Copyright © 2014. All rights reserved.