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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new client manager which uses Java NIO for socket management. -
Method Summary
Modifier and TypeMethodDescriptionvoidcloseConnections(int n) Closes n peer connectionsprotected Executorexecutor()intGets the number of connected peersopenConnection(SocketAddress serverAddress, StreamConnection connection) Creates a new connection to the given address, with the given connection used to handle incoming data.voidrun()voidMethods inherited from class com.google.common.util.concurrent.AbstractExecutionThreadService
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, serviceName, shutDown, startAsync, startUp, state, stopAsync, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.common.util.concurrent.Service
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
-
Constructor Details
-
NioClientManager
public NioClientManager()Creates a new client manager which uses Java NIO for socket management. Uses a single thread to handle all select calls.
-
-
Method Details
-
run
public void run()- Specified by:
runin classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
openConnection
public ListenableCompletableFuture<SocketAddress> openConnection(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
- Overrides:
executorin classcom.google.common.util.concurrent.AbstractExecutionThreadService
-