com.google.bitcoin.net
Class BlockingClientManager

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

public class BlockingClientManager
extends com.google.common.util.concurrent.AbstractIdleService
implements ClientConnectionManager

A thin wrapper around a set of BlockingClients.

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.


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
BlockingClientManager()
           
BlockingClientManager(SocketFactory socketFactory)
          Creates a blocking client manager that will obtain sockets from the given factory.
 
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 setConnectTimeoutMillis(int connectTimeoutMillis)
          Sets the number of milliseconds to wait before giving up on a connect attempt
protected  void shutDown()
           
protected  void startUp()
           
 
Methods inherited from class com.google.common.util.concurrent.AbstractIdleService
addListener, executor, isRunning, start, startAndWait, 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

BlockingClientManager

public BlockingClientManager()

BlockingClientManager

public BlockingClientManager(SocketFactory socketFactory)
Creates a blocking client manager that will obtain sockets from the given factory. Useful for customising how bitcoinj connects to the P2P network.

Method Detail

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

setConnectTimeoutMillis

public void setConnectTimeoutMillis(int connectTimeoutMillis)
Sets the number of milliseconds to wait before giving up on a connect attempt


startUp

protected void startUp()
                throws Exception
Specified by:
startUp in class com.google.common.util.concurrent.AbstractIdleService
Throws:
Exception

shutDown

protected void shutDown()
                 throws Exception
Specified by:
shutDown in class com.google.common.util.concurrent.AbstractIdleService
Throws:
Exception

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.