use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class FirewallingMockConnectionManager method unblock.
public synchronized void unblock(Address address) {
blockedAddresses.remove(address);
Connection connection = getConnection(address);
if (connection instanceof DroppingConnection) {
connection.close(null, null);
}
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class FirewallingTcpIpConnectionManager method getOrConnect.
@Override
public synchronized Connection getOrConnect(Address address, boolean silent) {
Connection connection = getConnection(address);
if (connection != null) {
return connection;
}
if (blockedAddresses.contains(address)) {
connection = new DroppingConnection(address, this);
registerConnection(address, connection);
return connection;
}
return super.getOrConnect(address, silent);
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class TcpIpConnectionManager_ConnectMemberBaseTest method getOrConnect_whenAlreadyConnectedSameConnectionReturned.
@Test
public void getOrConnect_whenAlreadyConnectedSameConnectionReturned() throws UnknownHostException {
startAllConnectionManagers();
Connection c1 = connect(connManagerA, addressB);
Connection c2 = connManagerA.getOrConnect(addressB);
assertSame(c1, c2);
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class TcpIpConnectionManager_ConnectMemberBaseTest method getOrConnect_whenNotConnected_thenEventuallyConnectionAvailable.
// ================== getOrConnect ======================================================
@Test
public void getOrConnect_whenNotConnected_thenEventuallyConnectionAvailable() throws UnknownHostException {
startAllConnectionManagers();
Connection c = connManagerA.getOrConnect(addressB);
assertNull(c);
connect(connManagerA, addressB);
assertEquals(1, connManagerA.getActiveConnectionCount());
assertEquals(1, connManagerB.getActiveConnectionCount());
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class TcpIpConnectionManager_ConnectionListenerTest method whenConnectionAdded.
@Test
public void whenConnectionAdded() throws Exception {
startAllConnectionManagers();
final ConnectionListener listener = mock(ConnectionListener.class);
connManagerA.addConnectionListener(listener);
final Connection c = connect(connManagerA, addressB);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
listener.connectionAdded(c);
}
});
}
Aggregations