org.glassfish.grizzly.nio.transport
Class TCPNIOConnectorHandler

java.lang.Object
  extended by org.glassfish.grizzly.AbstractSocketConnectorHandler
      extended by org.glassfish.grizzly.nio.transport.TCPNIOConnectorHandler
All Implemented Interfaces:
ConnectorHandler<java.net.SocketAddress>, SocketConnectorHandler

public class TCPNIOConnectorHandler
extends AbstractSocketConnectorHandler

TCP NIO transport client side ConnectorHandler implementation

Author:
Alexey Stashok

Nested Class Summary
static class TCPNIOConnectorHandler.Builder
           
 
Field Summary
protected  long connectionTimeoutMillis
           
protected static int DEFAULT_CONNECTION_TIMEOUT
           
protected  boolean isReuseAddress
           
 
Fields inherited from class org.glassfish.grizzly.AbstractSocketConnectorHandler
probes, transport
 
Constructor Summary
protected TCPNIOConnectorHandler(TCPNIOTransport transport)
           
 
Method Summary
static TCPNIOConnectorHandler.Builder builder(TCPNIOTransport transport)
          Return the TCPNIOConnectorHandler builder.
 GrizzlyFuture<Connection> connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, CompletionHandler<Connection> completionHandler)
          Creates, initializes socket, binds it to the specific local and remote SocketAddress and returns Connection, representing socket.
protected  GrizzlyFuture<Connection> connectAsync(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, CompletionHandler<Connection> completionHandler)
           
protected  GrizzlyFuture<Connection> connectSync(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, CompletionHandler<Connection> completionHandler)
           
 long getSyncConnectTimeout(java.util.concurrent.TimeUnit timeUnit)
           
 boolean isReuseAddress()
           
protected static void onConnectedAsync(TCPNIOConnection connection, FutureImpl<Connection> connectFuture, CompletionHandler<Connection> completionHandler)
           
 void setReuseAddress(boolean isReuseAddress)
           
 void setSyncConnectTimeout(long timeout, java.util.concurrent.TimeUnit timeUnit)
           
protected
<E> E
waitNIOFuture(java.util.concurrent.Future<E> future)
           
 
Methods inherited from class org.glassfish.grizzly.AbstractSocketConnectorHandler
addMonitoringProbe, connect, connect, connect, connect, getMonitoringProbes, getProcessor, getProcessorSelector, preConfigure, removeMonitoringProbe, setProcessor, setProcessorSelector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONNECTION_TIMEOUT

protected static final int DEFAULT_CONNECTION_TIMEOUT
See Also:
Constant Field Values

isReuseAddress

protected boolean isReuseAddress

connectionTimeoutMillis

protected volatile long connectionTimeoutMillis
Constructor Detail

TCPNIOConnectorHandler

protected TCPNIOConnectorHandler(TCPNIOTransport transport)
Method Detail

connect

public GrizzlyFuture<Connection> connect(java.net.SocketAddress remoteAddress,
                                         java.net.SocketAddress localAddress,
                                         CompletionHandler<Connection> completionHandler)
                                  throws java.io.IOException
Description copied from interface: ConnectorHandler
Creates, initializes socket, binds it to the specific local and remote SocketAddress and returns Connection, representing socket.

Specified by:
connect in interface ConnectorHandler<java.net.SocketAddress>
Specified by:
connect in class AbstractSocketConnectorHandler
Parameters:
remoteAddress - remote address to connect to.
localAddress - local address to bind socket to.
completionHandler - CompletionHandler.
Returns:
Future of connect operation, which could be used to get resulting Connection.
Throws:
java.io.IOException

connectSync

protected GrizzlyFuture<Connection> connectSync(java.net.SocketAddress remoteAddress,
                                                java.net.SocketAddress localAddress,
                                                CompletionHandler<Connection> completionHandler)
                                         throws java.io.IOException
Throws:
java.io.IOException

connectAsync

protected GrizzlyFuture<Connection> connectAsync(java.net.SocketAddress remoteAddress,
                                                 java.net.SocketAddress localAddress,
                                                 CompletionHandler<Connection> completionHandler)
                                          throws java.io.IOException
Throws:
java.io.IOException

onConnectedAsync

protected static void onConnectedAsync(TCPNIOConnection connection,
                                       FutureImpl<Connection> connectFuture,
                                       CompletionHandler<Connection> completionHandler)

isReuseAddress

public boolean isReuseAddress()

setReuseAddress

public void setReuseAddress(boolean isReuseAddress)

getSyncConnectTimeout

public long getSyncConnectTimeout(java.util.concurrent.TimeUnit timeUnit)

setSyncConnectTimeout

public void setSyncConnectTimeout(long timeout,
                                  java.util.concurrent.TimeUnit timeUnit)

waitNIOFuture

protected <E> E waitNIOFuture(java.util.concurrent.Future<E> future)
                   throws java.io.IOException
Throws:
java.io.IOException

builder

public static TCPNIOConnectorHandler.Builder builder(TCPNIOTransport transport)
Return the TCPNIOConnectorHandler builder.

Parameters:
transport - TCPNIOTransport.
Returns:
the TCPNIOConnectorHandler builder.


Copyright © 2011 Oracle Corpration. All Rights Reserved.