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 voidcloseConnections(int n)Closes n peer connectionsprotected java.util.concurrent.Executorexecutor()intgetConnectedClientCount()Gets the number of connected peersListenableCompletableFuture<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.voidrun()voidtriggerShutdown()-
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:
runin classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
openConnection
public ListenableCompletableFuture<java.net.SocketAddress> openConnection(java.net.SocketAddress serverAddress, StreamConnection connection)
Description copied from interface:ClientConnectionManagerCreates 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:
openConnectionin interfaceClientConnectionManager
-
triggerShutdown
public void triggerShutdown()
- Overrides:
triggerShutdownin classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
getConnectedClientCount
public int getConnectedClientCount()
Description copied from interface:ClientConnectionManagerGets the number of connected peers- Specified by:
getConnectedClientCountin interfaceClientConnectionManager
-
closeConnections
public void closeConnections(int n)
Description copied from interface:ClientConnectionManagerCloses n peer connections- Specified by:
closeConnectionsin interfaceClientConnectionManager
-
executor
protected java.util.concurrent.Executor executor()
- Overrides:
executorin classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
-