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.
 org.jboss.netty.channel.ChannelFuture createTCPChannel(ReplyTimeoutHandler timeoutHandler, RequestHandlerTCP<? extends BaseFuture> requestHandler, FutureResponse futureResponse, int connectTimeoutMillis, InetSocketAddress recipient)
          Creates a TCP channel future.
 org.jboss.netty.channel.Channel createUDPChannel(ReplyTimeoutHandler timeoutHandler, RequestHandlerUDP<? extends BaseFuture> requestHandler, FutureResponse futureResponse, boolean broadcast)
          Creates a UDP channel.
 long getCreatorThread()
           
 String getName()
           
 int getPermits()
           
 boolean hasNoPermits()
           
 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 org.jboss.netty.channel.Channel createUDPChannel(ReplyTimeoutHandler timeoutHandler,
                                                        RequestHandlerUDP<? extends BaseFuture> requestHandler,
                                                        FutureResponse futureResponse,
                                                        boolean broadcast)
Creates a UDP channel.

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

createTCPChannel

public org.jboss.netty.channel.ChannelFuture createTCPChannel(ReplyTimeoutHandler timeoutHandler,
                                                              RequestHandlerTCP<? extends BaseFuture> requestHandler,
                                                              FutureResponse futureResponse,
                                                              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
futureResponse - The future object that takes care of future events
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 or null if we are shutting down.

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

hasNoPermits

public boolean hasNoPermits()
Returns:
Returns true if the channel creator has no permits anymore

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()


Copyright © 2012. All Rights Reserved.