public class TcpTransport extends TransportThreadSupport implements Transport, Service, Runnable
Transport
interface using raw tcp/ipModifier and Type | Field and Description |
---|---|
protected TimeStampStream |
buffOut |
protected boolean |
closeAsync |
protected int |
connectionTimeout |
protected DataInputStream |
dataIn |
protected 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 URI |
localLocation |
protected String |
logWriterName
Name of the LogWriter implementation to use.
|
protected int |
minmumWireFormatVersion |
protected int |
receiveCounter |
protected URI |
remoteLocation |
protected Socket |
socket |
protected int |
socketBufferSize |
protected 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 AtomicReference<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,
Socket socket)
Initialize from a server Socket
|
TcpTransport(WireFormat wireFormat,
SocketFactory socketFactory,
URI remoteLocation,
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() |
String |
getDiffServ() |
int |
getIoBufferSize() |
int |
getJmxPort() |
Boolean |
getKeepAlive() |
String |
getLogWriterName() |
int |
getMinmumWireFormatVersion() |
int |
getReceiveCounter()
Returns a counter which gets incremented as data is read from the transport.
|
String |
getRemoteAddress() |
int |
getSocketBufferSize() |
int |
getSoLinger() |
int |
getSoTimeout() |
Boolean |
getTcpNoDelay() |
int |
getTypeOfService() |
WireFormat |
getWireFormat() |
protected void |
initialiseSocket(Socket sock)
Configures the socket for use
|
protected void |
initializeStreams() |
boolean |
isCloseAsync() |
boolean |
isDynamicManagement() |
boolean |
isStartLogging() |
boolean |
isTrace() |
boolean |
isUseLocalHost() |
<T> T |
narrow(Class<T> target)
narrow acceptance
|
void |
oneway(Object command)
A one way asynchronous send
|
protected Object |
readCommand() |
protected String |
resolveHostName(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(String diffServ) |
void |
setDynamicManagement(boolean useJmx) |
void |
setIoBufferSize(int ioBufferSize) |
void |
setJmxPort(int jmxPort) |
void |
setKeepAlive(Boolean keepAlive)
Enable/disable TCP KEEP_ALIVE mode
|
void |
setLogWriterName(String logFormat) |
void |
setMinmumWireFormatVersion(int minmumWireFormatVersion) |
void |
setSocketBufferSize(int socketBufferSize)
Sets the buffer size to use on the socket
|
void |
setSocketOptions(Map<String,Object> socketOptions) |
void |
setSoLinger(int soLinger)
Enable/disable soLinger
|
void |
setSoTimeout(int soTimeout)
Sets the socket timeout
|
void |
setStartLogging(boolean startLogging) |
void |
setTcpNoDelay(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.
|
String |
toString() |
getStackSize, isDaemon, setDaemon, setStackSize
asyncRequest, checkStarted, doConsume, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, onException, reconnect, request, request, setTransportListener, updateURIs
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
asyncRequest, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, reconnect, request, request, setTransportListener, updateURIs
protected final URI remoteLocation
protected final URI localLocation
protected final WireFormat wireFormat
protected int connectionTimeout
protected int soTimeout
protected int socketBufferSize
protected int ioBufferSize
protected boolean closeAsync
protected DataOutputStream dataOut
protected DataInputStream dataIn
protected TimeStampStream buffOut
protected int trafficClass
protected boolean diffServChosen
protected boolean typeOfServiceChosen
protected boolean trace
protected String logWriterName
protected boolean dynamicManagement
protected boolean startLogging
protected int jmxPort
protected boolean useLocalHost
protected int minmumWireFormatVersion
protected SocketFactory socketFactory
protected final AtomicReference<CountDownLatch> stoppedLatch
protected volatile int receiveCounter
public TcpTransport(WireFormat wireFormat, SocketFactory socketFactory, URI remoteLocation, URI localLocation) throws UnknownHostException, IOException
wireFormat
- socketFactory
- remoteLocation
- localLocation
- - e.g. local InetAddress and local portIOException
UnknownHostException
public TcpTransport(WireFormat wireFormat, Socket socket) throws IOException
wireFormat
- socket
- IOException
public void oneway(Object command) throws IOException
oneway
in interface Transport
IOException
protected void doRun() throws IOException
IOException
protected Object readCommand() throws IOException
IOException
public String getDiffServ()
public void setDiffServ(String diffServ) throws IllegalArgumentException
IllegalArgumentException
public int getTypeOfService()
public void setTypeOfService(int typeOfService)
public boolean isTrace()
public void setTrace(boolean trace)
public String getLogWriterName()
public void setLogWriterName(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 Boolean getKeepAlive()
public void setKeepAlive(Boolean keepAlive)
public void setSoLinger(int soLinger)
soLinger
- enabled if > -1, disabled if == -1, system default otherwisepublic int getSoLinger()
public Boolean getTcpNoDelay()
public void setTcpNoDelay(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 String resolveHostName(String host) throws UnknownHostException
UnknownHostException
protected void initialiseSocket(Socket sock) throws SocketException, IllegalArgumentException
sock
- the socketSocketException,
- IllegalArgumentException if setting the options
on the socket failed.SocketException
IllegalArgumentException
protected void doStart() throws Exception
doStart
in class TransportThreadSupport
Exception
protected void doStop(ServiceStopper stopper) throws Exception
doStop
in class ServiceSupport
Exception
public void stop() throws Exception
stop
in interface Service
stop
in class ServiceSupport
Exception
protected void initializeStreams() throws Exception
Exception
protected void closeStreams() throws IOException
IOException
public void setSocketOptions(Map<String,Object> socketOptions)
public String getRemoteAddress()
getRemoteAddress
in interface Transport
public <T> T narrow(Class<T> target)
TransportSupport
narrow
in interface Transport
narrow
in class TransportSupport
public int getReceiveCounter()
Transport
getReceiveCounter
in interface Transport
public WireFormat getWireFormat()
Copyright © 2005–2016 FuseSource, Corp.. All rights reserved.