public abstract class AbstractAsyncSocketTransport extends Object implements AsyncSocketTransport
ConnectionState for all connections to the same host and port and issues only one retry for all connections.| Modifier and Type | Field and Description | 
|---|---|
| protected AsyncSocketTransportConfig | config | 
| protected ConnectionStatus | connectionStatusConnectionStatus of this connection. | 
| protected String | connectionString | 
| protected String | host | 
| protected long | lastConnectTimeLast time a successful connection was made. | 
| protected long | lastUseTimeLast time this connection was used. | 
| protected int | port | 
| protected int | serverIndex | 
| protected AsyncSocketTransportFactory | transportFactory | 
| Constructor and Description | 
|---|
| AbstractAsyncSocketTransport(String phost,
                            int pport) | 
| Modifier and Type | Method and Description | 
|---|---|
| void | connect(AsyncHandler<Boolean> handler)Connects to Socket and calls handler with true on success and false with
 Exception on failure. | 
| protected abstract void | connectInternal(AsyncHandler<Boolean> handler)Connect Method to be implemented by sub-class. | 
| AsyncSocketTransportConfig | getConfig()Gets the AsyncSocketTransport config in use. | 
| String | getConnectionString()Gets the Connection String in the form of host:port so that it does not have to be constructed
 each time. | 
| long | getDownSince()Returns the millisecond time since this connection was down. | 
| String | getHost()Gets the host. | 
| int | getPort()Gets the port. | 
| long | getRetryInterval()The current retry interval as per the exponential fall back calculation. | 
| int | getServerIndex()Gets an index identifying the server. | 
| ConnectionStatus | getStatus()Returns the Connection Status | 
| AsyncSocketTransportFactory | getTransportFactory()Returns the transportFactory for this connection. | 
| boolean | isStale()Checks if the connection is stale as per configured idle timeout. | 
| void | setConfig(AsyncSocketTransportConfig pconfig)Sets the AsyncSocketTransport config to use. | 
| String | toString()Returns a String representation containing the host and port. | 
| protected void | updateConnectionStatus(ConnectionStatus status,
                      Throwable e)Method to update the connection status. | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, flush, read, requiresFlush, writeprotected final String host
protected final int port
protected final String connectionString
protected int serverIndex
protected AsyncSocketTransportFactory transportFactory
protected AsyncSocketTransportConfig config
protected long lastUseTime
protected long lastConnectTime
protected volatile ConnectionStatus connectionStatus
public AbstractAsyncSocketTransport(String phost, int pport)
phost - Server Hostpport - Server Portprotected abstract void connectInternal(AsyncHandler<Boolean> handler)
handler - handler to call when connection is completedprotected void updateConnectionStatus(ConnectionStatus status, Throwable e)
status - New Connection Statuse - Exception in case the Connection Status is DOWNpublic ConnectionStatus getStatus()
AsyncSocketTransportgetStatus in interface AsyncSocketTransportpublic void connect(AsyncHandler<Boolean> handler)
AsyncSocketTransportconnect in interface AsyncSocketTransporthandler - Handler to callpublic AsyncSocketTransportFactory getTransportFactory()
public long getDownSince()
AsyncSocketTransportgetDownSince in interface AsyncSocketTransportpublic long getRetryInterval()
AsyncSocketTransportgetRetryInterval in interface AsyncSocketTransportpublic AsyncSocketTransportConfig getConfig()
AsyncSocketTransportgetConfig in interface AsyncSocketTransportpublic void setConfig(AsyncSocketTransportConfig pconfig)
AsyncSocketTransportsetConfig in interface AsyncSocketTransportpconfig - to usepublic boolean isStale()
AsyncSocketTransportisStale in interface AsyncSocketTransportpublic String toString()
public String getHost()
ServerInfogetHost in interface ServerInfopublic int getPort()
ServerInfogetPort in interface ServerInfopublic String getConnectionString()
ServerInfogetConnectionString in interface ServerInfopublic int getServerIndex()
ServerInfogetServerIndex in interface ServerInfoCopyright © 2013- Suresh Mahalingam. All Rights Reserved.