public class ClientConnection extends Object implements Connection
Connection
.
ClientConnection is a connection between a Hazelcast Client and a Hazelcast Member.Constructor and Description |
---|
ClientConnection(HazelcastClientInstanceImpl client,
int connectionId) |
ClientConnection(HazelcastClientInstanceImpl client,
int connectionId,
Channel channel) |
Modifier and Type | Method and Description |
---|---|
void |
close(String reason,
Throwable cause)
Closes this connection.
|
void |
decrementPendingPacketCount() |
boolean |
equals(Object o) |
Throwable |
getCloseCause()
Gets the cause this Connection was closed.
|
long |
getClosedTime()
Closed time is the first time connection.close called.
|
String |
getCloseReason()
Gets the reason this Connection was closed.
|
int |
getConnectedServerVersion() |
String |
getConnectedServerVersionString() |
ClientConnectionManager |
getConnectionManager() |
Address |
getEndPoint()
Gets the
Address of the other side of this Connection. |
InetAddress |
getInetAddress()
Returns remote address of this Connection.
|
InetSocketAddress |
getLocalSocketAddress() |
int |
getPendingPacketCount() |
int |
getPort()
The remote port.
|
InetSocketAddress |
getRemoteSocketAddress()
Returns the address of the endpoint this Connection is connected to, or
null if it is unconnected. |
long |
getStartTime() |
ConnectionType |
getType()
Returns the
ConnectionType of this Connection. |
void |
handleClientMessage(ClientMessage message) |
int |
hashCode() |
void |
incrementPendingPacketCount() |
protected void |
innerClose() |
boolean |
isAlive()
Checks if the Connection is alive.
|
boolean |
isAuthenticatedAsOwner() |
boolean |
isClient()
Checks if it is a client connection.
|
boolean |
isHeartBeating() |
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 |
setConnectedServerVersion(String connectedServerVersion) |
void |
setIsAuthenticatedAsOwner() |
void |
setRemoteEndpoint(Address remoteEndpoint) |
void |
setType(ConnectionType type)
Sets the type of the connection
|
String |
toString() |
boolean |
write(OutboundFrame frame)
Writes a outbound frame so it can be received by the other side of the connection.
|
public ClientConnection(HazelcastClientInstanceImpl client, int connectionId, Channel channel) throws IOException
IOException
public ClientConnection(HazelcastClientInstanceImpl client, int connectionId) throws IOException
IOException
public void incrementPendingPacketCount()
public void decrementPendingPacketCount()
public int getPendingPacketCount()
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 Address getEndPoint()
Connection
Address
of the other side of this Connection.
todo: rename to get remoteAddress?
getEndPoint
in interface Connection
public boolean isAlive()
Connection
isAlive
in interface Connection
public long lastReadTimeMillis()
Connection
lastReadTimeMillis
in interface Connection
public long lastWriteTimeMillis()
Connection
lastWriteTimeMillis
in interface Connection
public void setType(ConnectionType type)
Connection
setType
in interface Connection
type
- to be setpublic ConnectionType getType()
Connection
ConnectionType
of this Connection.getType
in interface Connection
null
is returned.public boolean isClient()
Connection
isClient
in interface Connection
public InetAddress getInetAddress()
Connection
getInetAddress
in interface Connection
null
if the connection is not alive.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 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 ClientConnectionManager getConnectionManager()
public void setRemoteEndpoint(Address remoteEndpoint)
public InetSocketAddress getLocalSocketAddress()
public void close(String reason, Throwable cause)
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
reason
- the reason this connection is going to be closed. Is allowed to be null.cause
- the Throwable responsible for closing this connection. Is allowed to be null.protected void innerClose() throws IOException
IOException
public Throwable getCloseCause()
Connection
getCloseCause
in interface Connection
()
,
Connection.close(String, Throwable)
public String getCloseReason()
Connection
getCloseReason
in interface Connection
Connection.getCloseCause()
,
Connection.close(String, Throwable)
public void handleClientMessage(ClientMessage message)
public boolean isHeartBeating()
public boolean isAuthenticatedAsOwner()
public void setIsAuthenticatedAsOwner()
public long getStartTime()
public long getClosedTime()
public void setConnectedServerVersion(String connectedServerVersion)
public int getConnectedServerVersion()
public String getConnectedServerVersionString()
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.