net.tomp2p.connection
Class ChannelCreator

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

public class ChannelCreator
extends Object

Creates the channels. This class is created by ConnectionReservation and should never be called directly.

Author:
Thomas Bocek

Method Summary
 org.jboss.netty.channel.ChannelFuture close(PeerAddress destination)
          Closes a permanent connection.
 FutureChannel createTCPChannel(ReplyTimeoutHandler timeoutHandler, RequestHandlerTCP<? extends BaseFuture> requestHandler, int connectTimeoutMillis, InetSocketAddress recipient)
          Creates a TCP channel future.
 FutureChannel createUDPChannel(ReplyTimeoutHandler timeoutHandler, RequestHandlerUDP<? extends BaseFuture> requestHandler, boolean broadcast)
          Creates a UDP channel.
 long getCreatorThread()
           
 int getCurrentPermits()
           
 String getName()
           
 int getPermits()
           
 boolean isKeepAliveAndReuse()
           
 void shutdown()
          Shuts down this channelcreator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createUDPChannel

public FutureChannel createUDPChannel(ReplyTimeoutHandler timeoutHandler,
                                      RequestHandlerUDP<? extends BaseFuture> requestHandler,
                                      boolean broadcast)
Creates a UDP channel.

Parameters:
timeoutHandler - The handler that deals with timeouts
requestHandler - The handler that deals with incoming replies
broadcast - Set to true if broadcast is allowed
Returns:
The created channel or null if we are shutting down.

createTCPChannel

public FutureChannel createTCPChannel(ReplyTimeoutHandler timeoutHandler,
                                      RequestHandlerTCP<? extends BaseFuture> requestHandler,
                                      int connectTimeoutMillis,
                                      InetSocketAddress recipient)
Creates a TCP channel future. Once the future finishes, the channel can be used to connect to peers.

Parameters:
timeoutHandler - The handler that deals with timeouts
requestHandler - The handler that deals with incoming replies
connectTimeoutMillis - The timeout after which a connection attempt is considered a failure
recipient - The recipient to create the connection. If the recipient is already open, the connection will be reused.
Returns:
The channel future

close

public org.jboss.netty.channel.ChannelFuture close(PeerAddress destination)
Closes a permanent connection. If no connection existent, then this method returns

Parameters:
destination - The address of the destination peer of the permanent connection.
Returns:
The ChannelFuture of the close operation or null if the connection was not in the cached map.

getPermits

public int getPermits()
Returns:
The number of permits, which is the max. number of allowed parallel connections

getCurrentPermits

public int getCurrentPermits()

shutdown

public void shutdown()
Shuts down this channelcreator. That means a flag is set and if a connection should be created, null is returned.


getName

public String getName()
Returns:
The name of this ChannelCreator, used for debugging

getCreatorThread

public long getCreatorThread()

isKeepAliveAndReuse

public boolean isKeepAliveAndReuse()
Returns:
True if we created a keep-alive connection with this creator


Copyright © 2013. All Rights Reserved.