use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class TcpIpConnectionManager_TransmitTest method withConnection_whenConnectionWriteFails.
@Test
public void withConnection_whenConnectionWriteFails() {
Connection connection = mock(Connection.class);
Packet packet = new Packet(serializationService.toBytes("foo"));
when(connection.write(packet)).thenReturn(false);
boolean result = connManagerA.transmit(packet, connection);
assertFalse(result);
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class TcpIpConnection_AbstractTest method connect.
protected TcpIpConnection connect(final TcpIpConnectionManager connectionManager, final Address address) {
connectionManager.getOrConnect(address);
final AtomicReference<TcpIpConnection> ref = new AtomicReference<TcpIpConnection>();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Connection c = connectionManager.getConnection(address);
assertNotNull(c);
ref.set((TcpIpConnection) c);
}
});
return ref.get();
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class ClientConnectionManagerImpl method getOrTriggerConnect.
@Override
public Connection getOrTriggerConnect(Address target, boolean asOwner) {
Connection connection = getConnection(target, asOwner);
if (connection != null) {
return connection;
}
triggerConnect(target, asOwner);
return null;
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class TcpIpConnectionManager method stop.
@Override
public synchronized void stop() {
if (!live) {
return;
}
live = false;
logger.finest("Stopping ConnectionManager");
shutdownAcceptorThread();
for (SocketChannelWrapper socketChannel : acceptedSockets) {
closeResource(socketChannel);
}
for (Connection conn : connectionsMap.values()) {
destroySilently(conn, "TcpIpConnectionManager is stopping");
}
for (TcpIpConnection conn : activeConnections) {
destroySilently(conn, "TcpIpConnectionManager is stopping");
}
ioThreadingModel.shutdown();
acceptedSockets.clear();
connectionsInProgress.clear();
connectionsMap.clear();
monitors.clear();
activeConnections.clear();
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class TcpIpConnectionManager method toString.
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Connections {");
for (Connection conn : connectionsMap.values()) {
sb.append("\n");
sb.append(conn);
}
sb.append("\nlive=");
sb.append(live);
sb.append("\n}");
return sb.toString();
}
Aggregations