public final class TcpIpConnection extends Object implements Connection
Connection
.
A TcpIpConnection
is not responsible for reading or writing data to a socket, this is done through:
SocketReader
: which care of reading from the socket and feeding it into the system/li>
SocketWriter
: which care of writing data to the socket.IOThreadingModel
Constructor and Description |
---|
TcpIpConnection(TcpIpConnectionManager connectionManager,
int connectionId,
SocketChannelWrapper socketChannel,
IOThreadingModel ioThreadingModel) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this connection.
|
void |
close(Throwable t) |
boolean |
equals(Object o) |
int |
getConnectionId() |
TcpIpConnectionManager |
getConnectionManager() |
Address |
getEndPoint()
Gets the
Address of the other side of this Connection. |
InetAddress |
getInetAddress()
Returns remote address of this Connection.
|
Object |
getMetricsId() |
TcpIpConnectionMonitor |
getMonitor() |
int |
getPort()
The remote port.
|
InetSocketAddress |
getRemoteSocketAddress()
Returns the address of the endpoint this Connection is connected to, or
null if it is unconnected. |
SocketChannelWrapper |
getSocketChannelWrapper() |
SocketReader |
getSocketReader() |
SocketWriter |
getSocketWriter() |
ConnectionType |
getType()
Returns the
ConnectionType of this Connection. |
int |
hashCode() |
boolean |
isAlive()
Checks if the Connection is alive.
|
boolean |
isClient()
Checks if it is a client connection.
|
long |
lastReadTimeMillis()
Returns the clock time in milliseconds of the most recent read using this connection.
|
long |
lastWriteTimeMillis()
Returns the clock time in milliseconds of the most recent write using this connection.
|
void |
setEndPoint(Address endPoint) |
void |
setMonitor(TcpIpConnectionMonitor monitor) |
void |
setReceiveBufferSize(int size) |
void |
setSendBufferSize(int size) |
void |
setType(ConnectionType type)
Sets the type of the connection
|
void |
start()
Starts this connection.
|
String |
toString() |
boolean |
write(OutboundFrame frame)
Writes a outbound frame so it can be received by the other side of the connection.
|
public TcpIpConnection(TcpIpConnectionManager connectionManager, int connectionId, SocketChannelWrapper socketChannel, IOThreadingModel ioThreadingModel)
public SocketReader getSocketReader()
public SocketWriter getSocketWriter()
public ConnectionType getType()
Connection
ConnectionType
of this Connection.getType
in interface Connection
null
is returned.public void setType(ConnectionType type)
Connection
setType
in interface Connection
type
- to be setpublic TcpIpConnectionManager getConnectionManager()
public SocketChannelWrapper getSocketChannelWrapper()
public InetAddress getInetAddress()
Connection
getInetAddress
in interface Connection
null
if the connection is not alive.public int getPort()
Connection
todo: rename to getRemotePort? And do we need it because we already have getEndPoint which returns an address which includes port. It is only used in testing
getPort
in interface Connection
public InetSocketAddress getRemoteSocketAddress()
Connection
null
if it is unconnected.getRemoteSocketAddress
in interface Connection
todo: do we really need this method because we have getInetAddress, InetSocketAddress and getEndPoint.
public boolean isAlive()
Connection
isAlive
in interface Connection
public long lastWriteTimeMillis()
Connection
lastWriteTimeMillis
in interface Connection
public long lastReadTimeMillis()
Connection
lastReadTimeMillis
in interface Connection
public Address getEndPoint()
Connection
Address
of the other side of this Connection.
todo: rename to get remoteAddress?
getEndPoint
in interface Connection
public void setEndPoint(Address endPoint)
public void setMonitor(TcpIpConnectionMonitor monitor)
public TcpIpConnectionMonitor getMonitor()
public int getConnectionId()
public Object getMetricsId()
public void setSendBufferSize(int size) throws SocketException
SocketException
public void setReceiveBufferSize(int size) throws SocketException
SocketException
public boolean isClient()
Connection
isClient
in interface Connection
public void start()
public boolean write(OutboundFrame frame)
Connection
The frame could be stored in an internal queue before it actually is written, so this call does not need to be a synchronous call.
write
in interface Connection
frame
- the frame to write.public void close()
Connection
Pending packets on this connection are discarded
If the Connection is already closed, the call is ignored. So it can safely be called multiple times.
close
in interface Connection
public void close(Throwable t)
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.