com.google.bitcoin.net
Class NioClientManager

java.lang.Object
  extended by com.google.common.util.concurrent.AbstractExecutionThreadService
      extended by com.google.bitcoin.net.NioClientManager
All Implemented Interfaces:
ClientConnectionManager, com.google.common.util.concurrent.Service

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
NioClientManager()
          Creates a new client manager which uses Java NIO for socket management.
 
Method Summary
 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 run()
           
 void triggerShutdown()
           
 
Methods inherited from class com.google.common.util.concurrent.AbstractExecutionThreadService
addListener, executor, getServiceName, isRunning, shutDown, start, startAndWait, startUp, state, stop, stopAndWait, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.common.util.concurrent.Service
addListener, isRunning, start, startAndWait, state, stop, stopAndWait
 

Constructor Detail

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 Detail

run

public void run()
Specified by:
run in class com.google.common.util.concurrent.AbstractExecutionThreadService

openConnection

public void openConnection(SocketAddress serverAddress,
                           StreamParser parser)
Description copied from interface: ClientConnectionManager
Creates a new connection to the given address, with the given parser used to handle incoming data.

Specified by:
openConnection in interface ClientConnectionManager

triggerShutdown

public void triggerShutdown()
Overrides:
triggerShutdown in class com.google.common.util.concurrent.AbstractExecutionThreadService

getConnectedClientCount

public int getConnectedClientCount()
Description copied from interface: ClientConnectionManager
Gets the number of connected peers

Specified by:
getConnectedClientCount in interface ClientConnectionManager

closeConnections

public void closeConnections(int n)
Description copied from interface: ClientConnectionManager
Closes n peer connections

Specified by:
closeConnections in interface ClientConnectionManager


Copyright © 2014. All rights reserved.