Search in sources :

Example 1 with EVT_CLIENT_NODE_DISCONNECTED

use of org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED in project ignite by apache.

the class ServiceDeploymentOnClientDisconnectTest method runTaskWhenDisconnected.

/**
 * Apply given task on disconnected client node.
 *
 * @param task Task.
 * @throws InterruptedException If interrupted.
 */
private void runTaskWhenDisconnected(final Runnable task) throws InterruptedException {
    Ignite client = client();
    CountDownLatch latch = new CountDownLatch(1);
    client.events().localListen((IgnitePredicate<Event>) evt -> {
        latch.countDown();
        return false;
    }, EVT_CLIENT_NODE_DISCONNECTED);
    server().close();
    assertTrue(latch.await(CLIENT_FAILURE_DETECTION_TIMEOUT * 2 + CLIENT_FAILURE_DETECTION_TIMEOUT / 10, TimeUnit.MILLISECONDS));
    task.run();
}
Also used : IgniteFuture(org.apache.ignite.lang.IgniteFuture) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Event(org.apache.ignite.events.Event) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) LongInitializedTestService(org.apache.ignite.internal.processors.service.inner.LongInitializedTestService) ClusterGroupAdapter(org.apache.ignite.internal.cluster.ClusterGroupAdapter) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) MyServiceFactory(org.apache.ignite.internal.processors.service.inner.MyServiceFactory) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) EVT_CLIENT_NODE_DISCONNECTED(org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) MyService(org.apache.ignite.internal.processors.service.inner.MyService) Event(org.apache.ignite.events.Event) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 TimeUnit (java.util.concurrent.TimeUnit)1 Ignite (org.apache.ignite.Ignite)1 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 Event (org.apache.ignite.events.Event)1 EVT_CLIENT_NODE_DISCONNECTED (org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED)1 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 ClusterGroupAdapter (org.apache.ignite.internal.cluster.ClusterGroupAdapter)1 LongInitializedTestService (org.apache.ignite.internal.processors.service.inner.LongInitializedTestService)1 MyService (org.apache.ignite.internal.processors.service.inner.MyService)1 MyServiceFactory (org.apache.ignite.internal.processors.service.inner.MyServiceFactory)1 IgniteFuture (org.apache.ignite.lang.IgniteFuture)1 IgnitePredicate (org.apache.ignite.lang.IgnitePredicate)1 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)1 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1 Test (org.junit.Test)1