public class TcpTransport extends TransportThreadSupport implements Transport, Service, java.lang.Runnable
Transport interface using raw tcp/ip| Modifier and Type | Field and Description |
|---|---|
protected TimeStampStream |
buffOut |
protected boolean |
closeAsync |
protected int |
connectionTimeout |
protected java.io.DataInputStream |
dataIn |
protected java.io.DataOutputStream |
dataOut |
protected boolean |
diffServChosen
Prevents setting both the Differentiated Services and Type of Service
transport options at the same time, since they share the same spot in
the TCP/IP packet headers.
|
protected boolean |
dynamicManagement
Specifies if the TransportLogger will be manageable by JMX or not.
|
protected int |
ioBufferSize |
protected int |
jmxPort
Specifies the port that will be used by the JMX server to manage
the TransportLoggers.
|
protected java.net.URI |
localLocation |
protected java.lang.String |
logWriterName
Name of the LogWriter implementation to use.
|
protected int |
minmumWireFormatVersion |
protected java.net.URI |
remoteLocation |
protected java.net.Socket |
socket |
protected int |
socketBufferSize |
protected javax.net.SocketFactory |
socketFactory |
protected int |
soTimeout |
protected boolean |
startLogging
startLogging=true -> the TransportLogger object of the Transport stack
will initially write messages to the log.
|
protected java.util.concurrent.atomic.AtomicReference<java.util.concurrent.CountDownLatch> |
stoppedLatch |
protected boolean |
trace
trace=true -> the Transport stack where this TcpTransport
object will be, will have a TransportLogger layer
trace=false -> the Transport stack where this TcpTransport
object will be, will NOT have a TransportLogger layer, and therefore
will never be able to print logging messages.
|
protected int |
trafficClass
The Traffic Class to be set on the socket.
|
protected boolean |
typeOfServiceChosen |
protected boolean |
useLocalHost |
protected WireFormat |
wireFormat |
| Constructor and Description |
|---|
TcpTransport(WireFormat wireFormat,
java.net.Socket socket)
Initialize from a server Socket
|
TcpTransport(WireFormat wireFormat,
javax.net.SocketFactory socketFactory,
java.net.URI remoteLocation,
java.net.URI localLocation)
Connect to a remote Node - e.g.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeStreams() |
protected void |
connect() |
protected void |
doRun() |
protected void |
doStart() |
protected void |
doStop(ServiceStopper stopper) |
int |
getConnectionTimeout() |
java.lang.String |
getDiffServ() |
int |
getIoBufferSize() |
int |
getJmxPort() |
java.lang.Boolean |
getKeepAlive() |
java.lang.String |
getLogWriterName() |
int |
getMinmumWireFormatVersion() |
int |
getReceiveCounter()
Returns a counter which gets incremented as data is read from the transport.
|
java.lang.String |
getRemoteAddress() |
int |
getSocketBufferSize() |
int |
getSoLinger() |
int |
getSoTimeout() |
java.lang.Boolean |
getTcpNoDelay() |
int |
getTypeOfService() |
WireFormat |
getWireFormat() |
protected void |
initialiseSocket(java.net.Socket sock)
Configures the socket for use
|
protected void |
initializeStreams() |
boolean |
isCloseAsync() |
boolean |
isDynamicManagement() |
boolean |
isStartLogging() |
boolean |
isTrace() |
boolean |
isUseLocalHost() |
<T> T |
narrow(java.lang.Class<T> target)
narrow acceptance
|
void |
oneway(java.lang.Object command)
A one way asynchronous send
|
protected java.lang.Object |
readCommand() |
protected java.lang.String |
resolveHostName(java.lang.String host) |
void |
run()
reads packets from a Socket
|
void |
setCloseAsync(boolean closeAsync) |
void |
setConnectionTimeout(int connectionTimeout)
Sets the timeout used to connect to the socket
|
void |
setDiffServ(java.lang.String diffServ) |
void |
setDynamicManagement(boolean useJmx) |
void |
setIoBufferSize(int ioBufferSize) |
void |
setJmxPort(int jmxPort) |
void |
setKeepAlive(java.lang.Boolean keepAlive)
Enable/disable TCP KEEP_ALIVE mode
|
void |
setLogWriterName(java.lang.String logFormat) |
void |
setMinmumWireFormatVersion(int minmumWireFormatVersion) |
void |
setSocketBufferSize(int socketBufferSize)
Sets the buffer size to use on the socket
|
void |
setSocketOptions(java.util.Map<java.lang.String,java.lang.Object> socketOptions) |
void |
setSoLinger(int soLinger)
Enable/disable soLinger
|
void |
setSoTimeout(int soTimeout)
Sets the socket timeout
|
void |
setStartLogging(boolean startLogging) |
void |
setTcpNoDelay(java.lang.Boolean tcpNoDelay)
Enable/disable the TCP_NODELAY option on the socket
|
void |
setTrace(boolean trace) |
void |
setTypeOfService(int typeOfService) |
void |
setUseLocalHost(boolean useLocalHost)
Sets whether 'localhost' or the actual local host name should be used to
make local connections.
|
void |
stop()
Override so that stop() blocks until the run thread is no longer running.
|
java.lang.String |
toString() |
getStackSize, isDaemon, setDaemon, setStackSizeasyncRequest, checkStarted, doConsume, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, onException, reconnect, request, request, setTransportListener, updateURIsaddServiceListener, dispose, isStarted, isStopped, isStopping, removeServiceListener, startclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitasyncRequest, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, reconnect, request, request, setTransportListener, updateURIsprotected final java.net.URI remoteLocation
protected final java.net.URI localLocation
protected final WireFormat wireFormat
protected int connectionTimeout
protected int soTimeout
protected int socketBufferSize
protected int ioBufferSize
protected boolean closeAsync
protected java.net.Socket socket
protected java.io.DataOutputStream dataOut
protected java.io.DataInputStream dataIn
protected TimeStampStream buffOut
protected int trafficClass
protected boolean diffServChosen
protected boolean typeOfServiceChosen
protected boolean trace
protected java.lang.String logWriterName
protected boolean dynamicManagement
protected boolean startLogging
protected int jmxPort
protected boolean useLocalHost
protected int minmumWireFormatVersion
protected javax.net.SocketFactory socketFactory
protected final java.util.concurrent.atomic.AtomicReference<java.util.concurrent.CountDownLatch> stoppedLatch
public TcpTransport(WireFormat wireFormat, javax.net.SocketFactory socketFactory, java.net.URI remoteLocation, java.net.URI localLocation) throws java.net.UnknownHostException, java.io.IOException
wireFormat - socketFactory - remoteLocation - localLocation - - e.g. local InetAddress and local portjava.io.IOExceptionjava.net.UnknownHostExceptionpublic TcpTransport(WireFormat wireFormat, java.net.Socket socket) throws java.io.IOException
wireFormat - socket - java.io.IOExceptionpublic void oneway(java.lang.Object command) throws java.io.IOException
public java.lang.String toString()
toString in class java.lang.Objectpublic void run()
run in interface java.lang.Runnableprotected void doRun() throws java.io.IOException
java.io.IOExceptionprotected java.lang.Object readCommand() throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getDiffServ()
public void setDiffServ(java.lang.String diffServ) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic int getTypeOfService()
public void setTypeOfService(int typeOfService)
public boolean isTrace()
public void setTrace(boolean trace)
public java.lang.String getLogWriterName()
public void setLogWriterName(java.lang.String logFormat)
public boolean isDynamicManagement()
public void setDynamicManagement(boolean useJmx)
public boolean isStartLogging()
public void setStartLogging(boolean startLogging)
public int getJmxPort()
public void setJmxPort(int jmxPort)
public int getMinmumWireFormatVersion()
public void setMinmumWireFormatVersion(int minmumWireFormatVersion)
public boolean isUseLocalHost()
public void setUseLocalHost(boolean useLocalHost)
public int getSocketBufferSize()
public void setSocketBufferSize(int socketBufferSize)
public int getSoTimeout()
public void setSoTimeout(int soTimeout)
public int getConnectionTimeout()
public void setConnectionTimeout(int connectionTimeout)
public java.lang.Boolean getKeepAlive()
public void setKeepAlive(java.lang.Boolean keepAlive)
public void setSoLinger(int soLinger)
soLinger - enabled if > -1, disabled if == -1, system default otherwisepublic int getSoLinger()
public java.lang.Boolean getTcpNoDelay()
public void setTcpNoDelay(java.lang.Boolean tcpNoDelay)
public int getIoBufferSize()
public void setIoBufferSize(int ioBufferSize)
ioBufferSize - the ioBufferSize to setpublic boolean isCloseAsync()
public void setCloseAsync(boolean closeAsync)
closeAsync - the closeAsync to setprotected java.lang.String resolveHostName(java.lang.String host) throws java.net.UnknownHostException
java.net.UnknownHostExceptionprotected void initialiseSocket(java.net.Socket sock) throws java.net.SocketException, java.lang.IllegalArgumentException
sock - SocketException, - IllegalArgumentException if setting the options
on the socket failed.java.net.SocketExceptionjava.lang.IllegalArgumentExceptionprotected void doStart() throws java.lang.Exception
doStart in class TransportThreadSupportjava.lang.Exceptionprotected void connect() throws java.lang.Exception
java.lang.Exceptionprotected void doStop(ServiceStopper stopper) throws java.lang.Exception
doStop in class ServiceSupportjava.lang.Exceptionpublic void stop() throws java.lang.Exception
stop in interface Servicestop in class ServiceSupportjava.lang.Exceptionprotected void initializeStreams() throws java.lang.Exception
java.lang.Exceptionprotected void closeStreams() throws java.io.IOException
java.io.IOExceptionpublic void setSocketOptions(java.util.Map<java.lang.String,java.lang.Object> socketOptions)
public java.lang.String getRemoteAddress()
getRemoteAddress in interface Transportpublic <T> T narrow(java.lang.Class<T> target)
TransportSupportnarrow in interface Transportnarrow in class TransportSupportpublic int getReceiveCounter()
TransportgetReceiveCounter in interface Transportpublic WireFormat getWireFormat()
Copyright © 2005-2012. All Rights Reserved.