public class TcpIpConnectionManager extends Object implements ConnectionManager, PacketHandler
| Constructor and Description |
|---|
TcpIpConnectionManager(IOService ioService,
ServerSocketChannel serverSocketChannel,
LoggingService loggingService,
MetricsRegistry metricsRegistry,
EventLoopGroup eventLoopGroup) |
TcpIpConnectionManager(IOService ioService,
ServerSocketChannel serverSocketChannel,
LoggingService loggingService,
MetricsRegistry metricsRegistry,
EventLoopGroup eventLoopGroup,
HazelcastProperties properties) |
| Modifier and Type | Method and Description |
|---|---|
void |
addConnectionListener(ConnectionListener listener)
Registers a ConnectionListener.
|
int |
getActiveConnectionCount()
Gets the number of active connections.
|
Set<TcpIpConnection> |
getActiveConnections() |
int |
getAllTextConnections()
Gets the number of text connections (rest/memcache)
|
Connection |
getConnection(Address address)
Gets the connection for a given address.
|
int |
getConnectionCount()
Gets the total number of connections.
|
int |
getCurrentClientConnections()
Gets the number of client connections.
|
EventLoopGroup |
getEventLoopGroup() |
IOService |
getIoService() |
Connection |
getOrConnect(Address address)
Gets the existing connection for a given address or connects.
|
Connection |
getOrConnect(Address address,
boolean silent)
Gets the existing connection for a given address.
|
void |
handle(Packet packet)
Signals the PacketHandler that there is a packet to be handled.
|
void |
incrementTextConnections() |
boolean |
isLive() |
void |
onConnectionClose(Connection connection)
Deals with cleaning up a closed connection.
|
boolean |
registerConnection(Address remoteEndPoint,
Connection connection) |
void |
shutdown()
Shutdowns ConnectionManager completely.
|
void |
start()
Starts ConnectionManager, initializes its resources, starts threads, etc.
|
void |
stop()
Stops ConnectionManager, releases its resources, stops threads, etc.
|
String |
toString() |
boolean |
transmit(Packet packet,
Address target)
Retries sending packet maximum 5 times until connection to target becomes available.
|
boolean |
transmit(Packet packet,
Connection connection)
Transmits a packet to a certain connection.
|
public TcpIpConnectionManager(IOService ioService, ServerSocketChannel serverSocketChannel, LoggingService loggingService, MetricsRegistry metricsRegistry, EventLoopGroup eventLoopGroup)
public TcpIpConnectionManager(IOService ioService, ServerSocketChannel serverSocketChannel, LoggingService loggingService, MetricsRegistry metricsRegistry, EventLoopGroup eventLoopGroup, HazelcastProperties properties)
public IOService getIoService()
public EventLoopGroup getEventLoopGroup()
public Set<TcpIpConnection> getActiveConnections()
public int getActiveConnectionCount()
ConnectionManagergetActiveConnectionCount in interface ConnectionManagerpublic int getAllTextConnections()
ConnectionManagergetAllTextConnections in interface ConnectionManagerpublic int getConnectionCount()
ConnectionManagergetConnectionCount in interface ConnectionManagerpublic void incrementTextConnections()
public void addConnectionListener(ConnectionListener listener)
ConnectionListenableaddConnectionListener in interface ConnectionListenablelistener - the ConnectionListener to add.public void handle(Packet packet) throws Exception
PacketHandlerhandle in interface PacketHandlerpacket - the response packet to handleExceptionpublic boolean registerConnection(Address remoteEndPoint, Connection connection)
registerConnection in interface ConnectionManagerpublic Connection getConnection(Address address)
ConnectionManagergetConnection in interface ConnectionManageraddress - the remote side of the connectionpublic Connection getOrConnect(Address address)
ConnectionManagergetOrConnect in interface ConnectionManageraddress - the address to connect tonull if no connection existsConnectionManager.getOrConnect(Address, boolean)public Connection getOrConnect(Address address, boolean silent)
ConnectionManagernull.
When the connection is established at some point in time, it can be retrieved using the
ConnectionManager.getConnection(Address).
getOrConnect in interface ConnectionManageraddress - the address to connect tosilent - if logging should be done on debug level (silent=true) or on info level (silent=false)public void onConnectionClose(Connection connection)
TcpIpConnection.close(String, Throwable) method where it is protected against multiple closes.onConnectionClose in interface ConnectionManagerpublic void start()
ConnectionManagerIf it is already started, then this method has no effect.
start in interface ConnectionManagerpublic void stop()
ConnectionManagerConnectionManager.start().
This method has no effect if it is already stopped or shutdown.
Currently stop is called during the merge process to detach node from the current cluster. After
node becomes ready to join to the new cluster, start is called to re-initialize the ConnectionManager.
stop in interface ConnectionManagerpublic void shutdown()
ConnectionManagerThis method has no effect if it is already shutdown.
shutdown in interface ConnectionManagerpublic int getCurrentClientConnections()
ConnectionManagergetCurrentClientConnections in interface ConnectionManagerpublic boolean isLive()
public boolean transmit(Packet packet, Connection connection)
ConnectionManager
If this method is called with a null connection, the call returns false.
transmit in interface ConnectionManagerpacket - the packet to transmitconnection - he connection to where the Packet should be transmittedtrue if the transmit was a success, false if a failure (there is no guarantee that the packet is
actually going to be received since the packet perhaps is stuck in some buffer; it just means that it's buffered somewhere)public boolean transmit(Packet packet, Address target)
transmit in interface ConnectionManagerpacket - The Packet to transmit.target - The address of the target machine where the Packet should be transmitted.ConnectionManager.transmit(com.hazelcast.nio.Packet, com.hazelcast.nio.Connection)Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.