net.tomp2p.connection
Class ConnectionHandler

java.lang.Object
  extended by net.tomp2p.connection.ConnectionHandler

public class ConnectionHandler
extends Object

Handles the server connections of a node, i.e. the connections a node is listening on.

Author:
Thomas Bocek

Field Summary
static String THREAD_NAME
           
static int UDP_LIMIT
           
 
Constructor Summary
ConnectionHandler(ConnectionHandler parent, Number160 id, KeyPair keyPair, PeerMap peerMap)
          Attaches a peer to an existing connection and use existing information.
ConnectionHandler(int udpPort, int tcpPort, Number160 id, Bindings bindings, int p2pID, ConnectionConfiguration configuration, File messageLogger, KeyPair keyPair, PeerMap peerMap, org.jboss.netty.util.Timer timer, int maxMessageSize, int maintenanceThreads, int replicationThreads, int workerThreads)
           
 
Method Summary
 void customLoggerMessage(String customMessage)
          Writes a custom message to the logger filter.
 ConnectionBean getConnectionBean()
           
 NATUtils getNATUtils()
           
 PeerBean getPeerBean()
           
 boolean isListening()
           
 void shutdown()
          Shuts down the dispatcher and frees resources.
 boolean startupTCP(InetSocketAddress listenAddressesTCP, DispatcherReply dispatcher, int maxMessageSize)
          Creates TCP channels and listens on them
 boolean startupUDP(InetSocketAddress listenAddressesUDP, DispatcherReply dispatcher)
          Creates UDP channels and listens on them
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THREAD_NAME

public static final String THREAD_NAME
See Also:
Constant Field Values

UDP_LIMIT

public static final int UDP_LIMIT
See Also:
Constant Field Values
Constructor Detail

ConnectionHandler

public ConnectionHandler(int udpPort,
                         int tcpPort,
                         Number160 id,
                         Bindings bindings,
                         int p2pID,
                         ConnectionConfiguration configuration,
                         File messageLogger,
                         KeyPair keyPair,
                         PeerMap peerMap,
                         org.jboss.netty.util.Timer timer,
                         int maxMessageSize,
                         int maintenanceThreads,
                         int replicationThreads,
                         int workerThreads)
                  throws IOException
Parameters:
udpPort -
tcpPort -
id -
bindings -
p2pID -
configuration -
messageLogger -
keyPair -
peerMap -
listeners -
peerConfiguration -
Throws:
Exception
IOException

ConnectionHandler

public ConnectionHandler(ConnectionHandler parent,
                         Number160 id,
                         KeyPair keyPair,
                         PeerMap peerMap)
Attaches a peer to an existing connection and use existing information. The following objects are never shared: id, keyPair, peerMap.

Parameters:
parent - The parent handler
id - The id of the child peer
keyPair - The keypair of the child peer
peerMap - The peer map of the child peer
Method Detail

getConnectionBean

public ConnectionBean getConnectionBean()
Returns:
The shared connection configuration

getPeerBean

public PeerBean getPeerBean()
Returns:
The non-shared peer configuration

getNATUtils

public NATUtils getNATUtils()
Returns:
The NAT utils to setup port forwarding using NAT-PMP and UPNP.

startupUDP

public boolean startupUDP(InetSocketAddress listenAddressesUDP,
                          DispatcherReply dispatcher)
Creates UDP channels and listens on them

Parameters:
listenAddressesUDP - The address to listen to
dispatcher - The dispatcher that handles incoming messages
Returns:
True if the channel was bound.

startupTCP

public boolean startupTCP(InetSocketAddress listenAddressesTCP,
                          DispatcherReply dispatcher,
                          int maxMessageSize)
Creates TCP channels and listens on them

Parameters:
listenAddressesTCP - the addresses which we will listen on
dispatcher - The dispatcher that handles incoming messages
maxMessageSize - The maximum message size that is tolerated
Returns:
True if the channel was bound.

customLoggerMessage

public void customLoggerMessage(String customMessage)
Writes a custom message to the logger filter. Only used if the logger filter has been setup properly.

Parameters:
customMessage - The custom message to print.

shutdown

public void shutdown()
Shuts down the dispatcher and frees resources. This closes all channels.


isListening

public boolean isListening()
Returns:
Returns true if this handler is attached to listen to an interface.


Copyright © 2013. All Rights Reserved.