Package org.bitcoinj.net
Class NioClientManager
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractExecutionThreadService
-
- org.bitcoinj.net.NioClientManager
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
,ClientConnectionManager
public class NioClientManager extends com.google.common.util.concurrent.AbstractExecutionThreadService implements ClientConnectionManager
A class which manages a set of client connections. Uses Java NIO to select network events and processes them in a single network processing thread.
-
-
Constructor Summary
Constructors Constructor Description NioClientManager()
Creates a new client manager which uses Java NIO for socket management.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeConnections(int n)
Closes n peer connectionsprotected java.util.concurrent.Executor
executor()
int
getConnectedClientCount()
Gets the number of connected peerscom.google.common.util.concurrent.ListenableFuture<java.net.SocketAddress>
openConnection(java.net.SocketAddress serverAddress, StreamConnection connection)
Creates a new connection to the given address, with the given connection used to handle incoming data.void
run()
void
triggerShutdown()
-
Methods inherited from class com.google.common.util.concurrent.AbstractExecutionThreadService
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, serviceName, shutDown, startAsync, startUp, state, stopAsync, toString
-
-
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
openConnection
public com.google.common.util.concurrent.ListenableFuture<java.net.SocketAddress> openConnection(java.net.SocketAddress serverAddress, StreamConnection connection)
Description copied from interface:ClientConnectionManager
Creates a new connection to the given address, with the given connection used to handle incoming data. Any errors that occur during connection will be returned in the given future, including errors that can occur immediately.- Specified by:
openConnection
in interfaceClientConnectionManager
-
triggerShutdown
public void triggerShutdown()
- Overrides:
triggerShutdown
in classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
getConnectedClientCount
public int getConnectedClientCount()
Description copied from interface:ClientConnectionManager
Gets the number of connected peers- Specified by:
getConnectedClientCount
in interfaceClientConnectionManager
-
closeConnections
public void closeConnections(int n)
Description copied from interface:ClientConnectionManager
Closes n peer connections- Specified by:
closeConnections
in interfaceClientConnectionManager
-
executor
protected java.util.concurrent.Executor executor()
- Overrides:
executor
in classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
-