public class TcpTransport extends ServiceBase implements Transport
Transport interface using raw tcp/ip| Modifier and Type | Class and Description |
|---|---|
(package private) class |
TcpTransport.CANCELED |
(package private) class |
TcpTransport.CANCELING |
(package private) class |
TcpTransport.CONNECTED |
(package private) class |
TcpTransport.CONNECTING |
(package private) static class |
TcpTransport.DISCONNECTED |
(package private) static class |
TcpTransport.OneWay |
(package private) class |
TcpTransport.RateLimitingChannel |
(package private) static class |
TcpTransport.SocketState |
ServiceBase.CallbackSupport, ServiceBase.STARTING, ServiceBase.State, ServiceBase.STOPPING| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.Executor |
blockingExecutor |
private Task |
CANCEL_HANDLER |
protected java.nio.channels.SocketChannel |
channel |
(package private) boolean |
closeOnCancel |
protected ProtocolCodec |
codec |
protected DispatchQueue |
dispatchQueue |
protected CustomDispatchSource<java.lang.Integer,java.lang.Integer> |
drainOutboundSource |
static int |
IPTOS_LOWCOST |
static int |
IPTOS_LOWDELAY |
static int |
IPTOS_RELIABILITY |
static int |
IPTOS_THROUGHPUT |
(package private) boolean |
keepAlive |
protected TransportListener |
listener |
(package private) java.net.SocketAddress |
localAddress |
(package private) static java.net.InetAddress |
localhost |
protected java.net.URI |
localLocation |
(package private) int |
maxReadRate |
(package private) int |
maxWriteRate |
protected TcpTransport.RateLimitingChannel |
rateLimitingChannel |
private DispatchSource |
readSource |
(package private) int |
receiveBufferSize |
(package private) boolean |
rejectingOffers |
(package private) java.net.SocketAddress |
remoteAddress |
protected java.net.URI |
remoteLocation |
(package private) int |
sendBufferSize |
protected TcpTransport.SocketState |
socketState |
(package private) int |
trafficClass |
protected boolean |
useLocalHost |
(package private) boolean |
writeResumedForCodecFlush |
private DispatchSource |
writeSource |
protected CustomDispatchSource<java.lang.Integer,java.lang.Integer> |
yieldSource |
_serviceState, CREATED, STARTED, STOPPED| Constructor and Description |
|---|
TcpTransport() |
| Modifier and Type | Method and Description |
|---|---|
private void |
_resumeRead() |
void |
_start(Task onCompleted) |
void |
_stop(Task onCompleted) |
private boolean |
assertConnected() |
void |
connected(java.nio.channels.SocketChannel channel) |
void |
connecting(java.net.URI remoteLocation,
java.net.URI localLocation) |
private void |
dispose() |
void |
drainInbound() |
void |
flush()
Forces a flush of any output buffers.
|
boolean |
full() |
java.util.concurrent.Executor |
getBlockingExecutor() |
DispatchQueue |
getDispatchQueue()
Returns the dispatch queue used by the transport
|
java.net.SocketAddress |
getLocalAddress() |
static java.net.InetAddress |
getLocalHost() |
int |
getMaxReadRate() |
int |
getMaxWriteRate() |
ProtocolCodec |
getProtocolCodec() |
java.nio.channels.ReadableByteChannel |
getReadChannel() |
int |
getReceiveBufferSize() |
java.net.SocketAddress |
getRemoteAddress() |
int |
getSendBufferSize() |
java.nio.channels.SocketChannel |
getSocketChannel() |
int |
getTrafficClass() |
TransportListener |
getTransportListener()
Returns the current transport listener
|
java.nio.channels.WritableByteChannel |
getWriteChannel() |
protected void |
initializeChannel() |
protected void |
initializeCodec() |
private void |
initRateLimitingChannel() |
boolean |
isClosed() |
boolean |
isCloseOnCancel() |
boolean |
isConnected() |
boolean |
isKeepAlive() |
boolean |
isUseLocalHost() |
boolean |
offer(java.lang.Object command)
A one way asynchronous send of a command.
|
protected void |
onConnected() |
void |
onTransportFailure(java.io.IOException error) |
protected java.lang.String |
resolveHostName(java.lang.String host) |
void |
resumeRead()
resume delivery of commands.
|
protected void |
resumeWrite() |
private void |
schedualRateAllowanceReset() |
void |
setBlockingExecutor(java.util.concurrent.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() |
private void |
trace(java.lang.String message) |
protected boolean |
transportFlush() |
getServiceState, start, start, stop, stopstatic java.net.InetAddress localhost
protected java.net.URI remoteLocation
protected java.net.URI localLocation
protected TransportListener listener
protected ProtocolCodec codec
protected java.nio.channels.SocketChannel channel
protected TcpTransport.SocketState socketState
protected DispatchQueue dispatchQueue
private DispatchSource readSource
private DispatchSource writeSource
protected CustomDispatchSource<java.lang.Integer,java.lang.Integer> drainOutboundSource
protected CustomDispatchSource<java.lang.Integer,java.lang.Integer> yieldSource
protected boolean useLocalHost
int maxReadRate
int maxWriteRate
int receiveBufferSize
int sendBufferSize
boolean closeOnCancel
boolean keepAlive
public static final int IPTOS_LOWCOST
public static final int IPTOS_RELIABILITY
public static final int IPTOS_THROUGHPUT
public static final int IPTOS_LOWDELAY
int trafficClass
protected TcpTransport.RateLimitingChannel rateLimitingChannel
java.net.SocketAddress localAddress
java.net.SocketAddress remoteAddress
protected java.util.concurrent.Executor blockingExecutor
private final Task CANCEL_HANDLER
boolean rejectingOffers
boolean writeResumedForCodecFlush
public static java.net.InetAddress getLocalHost()
throws java.net.UnknownHostException
java.net.UnknownHostExceptionpublic void connected(java.nio.channels.SocketChannel channel)
throws java.io.IOException,
java.lang.Exception
java.io.IOExceptionjava.lang.Exceptionprotected void initializeChannel()
throws java.lang.Exception
java.lang.Exceptionprotected void initializeCodec()
throws java.lang.Exception
java.lang.Exceptionprivate void initRateLimitingChannel()
public void connecting(java.net.URI remoteLocation,
java.net.URI localLocation)
throws java.lang.Exception
java.lang.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 java.lang.String resolveHostName(java.lang.String host)
throws java.net.UnknownHostException
java.net.UnknownHostExceptionprotected void onConnected()
throws java.io.IOException
java.io.IOExceptionprivate void schedualRateAllowanceReset()
private void dispose()
public void onTransportFailure(java.io.IOException error)
public boolean offer(java.lang.Object command)
Transportpublic void flush()
Transportprotected boolean transportFlush()
throws java.io.IOException
java.io.IOExceptionpublic void drainInbound()
drainInbound in interface Transportpublic java.net.SocketAddress getLocalAddress()
getLocalAddress in interface Transportpublic java.net.SocketAddress getRemoteAddress()
getRemoteAddress in interface Transportprivate boolean assertConnected()
public void suspendRead()
TransportsuspendRead in interface Transportpublic void resumeRead()
TransportresumeRead in interface Transportprivate void _resumeRead()
protected 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 java.lang.Exception
TransportsetProtocolCodec in interface Transportjava.lang.Exceptionpublic boolean isConnected()
isConnected in interface Transportpublic boolean isClosed()
public boolean isUseLocalHost()
public void setUseLocalHost(boolean useLocalHost)
private void trace(java.lang.String message)
public java.nio.channels.SocketChannel getSocketChannel()
public java.nio.channels.ReadableByteChannel getReadChannel()
getReadChannel in interface Transportpublic java.nio.channels.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 java.util.concurrent.Executor getBlockingExecutor()
getBlockingExecutor in interface Transportpublic void setBlockingExecutor(java.util.concurrent.Executor blockingExecutor)
setBlockingExecutor in interface Transportpublic boolean isCloseOnCancel()
public void setCloseOnCancel(boolean closeOnCancel)