Search in sources :

Example 41 with Connection

use of com.hazelcast.internal.nio.Connection in project hazelcast by hazelcast.

the class OperationLossTest method when_connectionDroppedWithoutMemberLeaving_then_jobRestarts.

private void when_connectionDroppedWithoutMemberLeaving_then_jobRestarts(boolean useLightJob) {
    DAG dag = new DAG();
    Vertex source = dag.newVertex("source", () -> new NoOutputSourceP()).localParallelism(1);
    Vertex sink = dag.newVertex("sink", DiagnosticProcessors.writeLoggerP());
    dag.edge(between(source, sink).distributed());
    Job job = useLightJob ? instance().getJet().newLightJob(dag) : instance().getJet().newJob(dag);
    assertTrueEventually(() -> assertEquals(2, NoOutputSourceP.initCount.get()));
    Connection connection = ImdgUtil.getMemberConnection(getNodeEngineImpl(instance()), getAddress(instances()[1]));
    // When
    connection.close(null, null);
    System.out.println("connection closed");
    sleepSeconds(1);
    // Then
    NoOutputSourceP.proceedLatch.countDown();
    if (useLightJob) {
        assertThatThrownBy(job::join).hasMessageContaining("The member was reconnected");
    } else {
        job.join();
        assertEquals(4, NoOutputSourceP.initCount.get());
    }
}
Also used : NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Connection(com.hazelcast.internal.nio.Connection) Job(com.hazelcast.jet.Job)

Aggregations

Connection (com.hazelcast.internal.nio.Connection)41 Test (org.junit.Test)14 QuickTest (com.hazelcast.test.annotation.QuickTest)11 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)8 ServerConnection (com.hazelcast.internal.server.ServerConnection)7 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)7 ClientConnection (com.hazelcast.client.impl.connection.ClientConnection)6 Address (com.hazelcast.cluster.Address)6 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)5 Member (com.hazelcast.cluster.Member)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 ConnectionListener (com.hazelcast.internal.nio.ConnectionListener)5 ClientConnectionManager (com.hazelcast.client.impl.connection.ClientConnectionManager)4 ILogger (com.hazelcast.logging.ILogger)4 QueryId (com.hazelcast.sql.impl.QueryId)4 Map (java.util.Map)4 UUID (java.util.UUID)4 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)3 TargetDisconnectedException (com.hazelcast.spi.exception.TargetDisconnectedException)3 IOException (java.io.IOException)3