public class TcpIpConnectionManager extends Object implements ConnectionManager, PacketHandler
Constructor and Description |
---|
TcpIpConnectionManager(IOService ioService,
ServerSocketChannel serverSocketChannel,
LoggingService loggingService,
MetricsRegistry metricsRegistry,
IOThreadingModel ioThreadingModel) |
TcpIpConnectionManager(IOService ioService,
ServerSocketChannel serverSocketChannel,
MetricsRegistry metricsRegistry,
HazelcastThreadGroup threadGroup,
LoggingService loggingService) |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionListener(ConnectionListener listener)
Registers a ConnectionListener.
|
void |
destroyConnection(Connection connection)
Destroys a connection.
|
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.
|
IOBalancer |
getIoBalancer() |
IOService |
getIoService() |
IOThreadingModel |
getIoThreadingModel() |
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() |
protected void |
initSocket(Socket socket) |
void |
interceptSocket(Socket socket,
boolean onAccept) |
boolean |
isLive() |
boolean |
isSocketInterceptorEnabled() |
boolean |
isSSLEnabled() |
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, MetricsRegistry metricsRegistry, HazelcastThreadGroup threadGroup, LoggingService loggingService)
public TcpIpConnectionManager(IOService ioService, ServerSocketChannel serverSocketChannel, LoggingService loggingService, MetricsRegistry metricsRegistry, IOThreadingModel ioThreadingModel)
public IOService getIoService()
public IOThreadingModel getIoThreadingModel()
public void interceptSocket(Socket socket, boolean onAccept) throws IOException
IOException
public boolean isSocketInterceptorEnabled()
public Set<TcpIpConnection> getActiveConnections()
public IOBalancer getIoBalancer()
public int getActiveConnectionCount()
ConnectionManager
getActiveConnectionCount
in interface ConnectionManager
public int getAllTextConnections()
ConnectionManager
getAllTextConnections
in interface ConnectionManager
public int getConnectionCount()
ConnectionManager
getConnectionCount
in interface ConnectionManager
public boolean isSSLEnabled()
public void incrementTextConnections()
public void addConnectionListener(ConnectionListener listener)
ConnectionManager
addConnectionListener
in interface ConnectionManager
listener
- the ConnectionListener to add.public void handle(Packet packet) throws Exception
PacketHandler
handle
in interface PacketHandler
packet
- the response packet to handleException
public boolean registerConnection(Address remoteEndPoint, Connection connection)
registerConnection
in interface ConnectionManager
public Connection getConnection(Address address)
ConnectionManager
getConnection
in interface ConnectionManager
address
- the remote side of the connection.public Connection getOrConnect(Address address)
ConnectionManager
getOrConnect
in interface ConnectionManager
address
- the address to connect to.ConnectionManager.getOrConnect(Address, boolean)
public Connection getOrConnect(Address address, boolean silent)
ConnectionManager
ConnectionManager.getConnection(Address)
.getOrConnect
in interface ConnectionManager
address
- the address to connect to.silent
- if logging should be done on debug level (silent=true) or on info level (silent=false).public void destroyConnection(Connection connection)
ConnectionManager
destroyConnection
in interface ConnectionManager
connection
- the Connection to destroy.public void start()
ConnectionManager
start
in interface ConnectionManager
public void stop()
ConnectionManager
ConnectionManager.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 ConnectionManager
public void shutdown()
ConnectionManager
shutdown
in interface ConnectionManager
public int getCurrentClientConnections()
ConnectionManager
getCurrentClientConnections
in interface ConnectionManager
public boolean isLive()
public boolean transmit(Packet packet, Connection connection)
ConnectionManager
transmit
in interface ConnectionManager
packet
- The Packet to transmit.connection
- The connection to where the Packet should be transmitted.public boolean transmit(Packet packet, Address target)
transmit
in interface ConnectionManager
packet
- 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 © 2016 Hazelcast, Inc.. All Rights Reserved.