public class TcpTransport extends ServiceBase implements Transport
Transport interface using raw tcp/ipServiceBase.STARTING, ServiceBase.State, ServiceBase.STOPPING| Modifier and Type | Field and Description |
|---|---|
protected Executor |
blockingExecutor |
protected SocketChannel |
channel |
protected ProtocolCodec |
codec |
protected DispatchQueue |
dispatchQueue |
protected CustomDispatchSource<Integer,Integer> |
drainOutboundSource |
static int |
IPTOS_LOWCOST |
static int |
IPTOS_LOWDELAY |
static int |
IPTOS_RELIABILITY |
static int |
IPTOS_THROUGHPUT |
protected TransportListener |
listener |
protected URI |
localLocation |
protected org.fusesource.hawtdispatch.transport.TcpTransport.RateLimitingChannel |
rateLimitingChannel |
protected URI |
remoteLocation |
protected org.fusesource.hawtdispatch.transport.TcpTransport.SocketState |
socketState |
protected boolean |
useLocalHost |
protected CustomDispatchSource<Integer,Integer> |
yieldSource |
_serviceState, CREATED, STARTED, STOPPED| Constructor and Description |
|---|
TcpTransport() |
| Modifier and Type | Method and Description |
|---|---|
void |
_start(Task onCompleted) |
void |
_stop(Task onCompleted) |
void |
connected(SocketChannel channel) |
void |
connecting(URI remoteLocation,
URI localLocation) |
void |
drainInbound() |
void |
flush()
Forces a flush of any output buffers.
|
boolean |
full() |
Executor |
getBlockingExecutor() |
DispatchQueue |
getDispatchQueue()
Returns the dispatch queue used by the transport
|
SocketAddress |
getLocalAddress() |
static InetAddress |
getLocalHost() |
int |
getMaxReadRate() |
int |
getMaxWriteRate() |
ProtocolCodec |
getProtocolCodec() |
ReadableByteChannel |
getReadChannel() |
int |
getReceiveBufferSize() |
SocketAddress |
getRemoteAddress() |
int |
getSendBufferSize() |
SocketChannel |
getSocketChannel() |
int |
getTrafficClass() |
TransportListener |
getTransportListener()
Returns the current transport listener
|
WritableByteChannel |
getWriteChannel() |
protected void |
initializeChannel() |
protected void |
initializeCodec() |
boolean |
isClosed() |
boolean |
isCloseOnCancel() |
boolean |
isConnected() |
boolean |
isKeepAlive() |
boolean |
isUseLocalHost() |
boolean |
offer(Object command)
A one way asynchronous send of a command.
|
protected void |
onConnected() |
void |
onTransportFailure(IOException error) |
protected String |
resolveHostName(String host) |
void |
resumeRead()
resume delivery of commands.
|
protected void |
resumeWrite() |
void |
setBlockingExecutor(Executor blockingExecutor) |
void |
setCloseOnCancel(boolean closeOnCancel) |
void |
setDispatchQueue(DispatchQueue queue)
Sets the dispatch queue used by the transport
|
void |
setKeepAlive(boolean keepAlive) |
void |
setMaxReadRate(int maxReadRate) |
void |
setMaxWriteRate(int maxWriteRate) |
void |
setProtocolCodec(ProtocolCodec protocolCodec)
Sets the protocol codec for the transport
|
void |
setReceiveBufferSize(int receiveBufferSize) |
void |
setSendBufferSize(int sendBufferSize) |
void |
setTrafficClass(int trafficClass) |
void |
setTransportListener(TransportListener transportListener)
Registers an inbound command listener
|
void |
setUseLocalHost(boolean useLocalHost)
Sets whether 'localhost' or the actual local host name should be used to
make local connections.
|
void |
suspendRead()
suspend delivery of commands.
|
protected void |
suspendWrite() |
protected boolean |
transportFlush() |
getServiceState, start, start, stop, stopprotected URI remoteLocation
protected URI localLocation
protected TransportListener listener
protected ProtocolCodec codec
protected SocketChannel channel
protected org.fusesource.hawtdispatch.transport.TcpTransport.SocketState socketState
protected DispatchQueue dispatchQueue
protected CustomDispatchSource<Integer,Integer> drainOutboundSource
protected CustomDispatchSource<Integer,Integer> yieldSource
protected boolean useLocalHost
public static final int IPTOS_LOWCOST
public static final int IPTOS_RELIABILITY
public static final int IPTOS_THROUGHPUT
public static final int IPTOS_LOWDELAY
protected org.fusesource.hawtdispatch.transport.TcpTransport.RateLimitingChannel rateLimitingChannel
protected Executor blockingExecutor
public TcpTransport()
public static InetAddress getLocalHost() throws UnknownHostException
UnknownHostExceptionpublic void connected(SocketChannel channel) throws IOException, Exception
IOExceptionExceptionprotected void initializeChannel() throws Exception
Exceptionprotected void initializeCodec() throws Exception
Exceptionpublic void connecting(URI remoteLocation, URI localLocation) throws Exception
Exceptionpublic DispatchQueue getDispatchQueue()
TransportgetDispatchQueue in interface TransportgetDispatchQueue in class ServiceBasepublic void setDispatchQueue(DispatchQueue queue)
TransportsetDispatchQueue in interface Transportpublic void _start(Task onCompleted)
_start in class ServiceBasepublic void _stop(Task onCompleted)
_stop in class ServiceBaseprotected String resolveHostName(String host) throws UnknownHostException
UnknownHostExceptionprotected void onConnected() throws IOException
IOExceptionpublic void onTransportFailure(IOException error)
public boolean offer(Object command)
Transportpublic void flush()
Transportprotected boolean transportFlush() throws IOException
IOExceptionpublic void drainInbound()
drainInbound in interface Transportpublic SocketAddress getLocalAddress()
getLocalAddress in interface Transportpublic SocketAddress getRemoteAddress()
getRemoteAddress in interface Transportpublic void suspendRead()
TransportsuspendRead in interface Transportpublic void resumeRead()
TransportresumeRead in interface Transportprotected void suspendWrite()
protected void resumeWrite()
public TransportListener getTransportListener()
TransportgetTransportListener in interface Transportpublic void setTransportListener(TransportListener transportListener)
TransportsetTransportListener in interface Transportpublic ProtocolCodec getProtocolCodec()
getProtocolCodec in interface Transportpublic void setProtocolCodec(ProtocolCodec protocolCodec) throws Exception
TransportsetProtocolCodec in interface TransportExceptionpublic boolean isConnected()
isConnected in interface Transportpublic boolean isClosed()
public boolean isUseLocalHost()
public void setUseLocalHost(boolean useLocalHost)
public SocketChannel getSocketChannel()
public ReadableByteChannel getReadChannel()
getReadChannel in interface Transportpublic WritableByteChannel getWriteChannel()
getWriteChannel in interface Transportpublic int getMaxReadRate()
public void setMaxReadRate(int maxReadRate)
public int getMaxWriteRate()
public void setMaxWriteRate(int maxWriteRate)
public int getTrafficClass()
public void setTrafficClass(int trafficClass)
public int getReceiveBufferSize()
public void setReceiveBufferSize(int receiveBufferSize)
public int getSendBufferSize()
public void setSendBufferSize(int sendBufferSize)
public boolean isKeepAlive()
public void setKeepAlive(boolean keepAlive)
public Executor getBlockingExecutor()
getBlockingExecutor in interface Transportpublic void setBlockingExecutor(Executor blockingExecutor)
setBlockingExecutor in interface Transportpublic boolean isCloseOnCancel()
public void setCloseOnCancel(boolean closeOnCancel)
Copyright © 2010-2013 FuseSource, Corp.. All Rights Reserved.