Search in sources :

Example 1 with LongInitializedTestService

use of org.apache.ignite.internal.processors.service.inner.LongInitializedTestService in project ignite by apache.

the class ServiceDeploymentOnClientDisconnectTest method testServiceDeploymentExchangeProcessingOnReconnect.

/**
 * @throws Exception In case of an error.
 */
@Test
public void testServiceDeploymentExchangeProcessingOnReconnect() throws Exception {
    IgniteEx client = client();
    IgniteFuture fut = client.services().deployNodeSingletonAsync("testService1", new LongInitializedTestService(10_000L));
    client.services().deployNodeSingletonAsync("testService2", new LongInitializedTestService(10_000L));
    server().close();
    IgniteFuture reconnectFut = null;
    try {
        fut.get();
        fail("Client disconnected exception was expected.");
    } catch (IgniteClientDisconnectedException e) {
        reconnectFut = e.reconnectFuture();
    }
    assertNotNull(reconnectFut);
    startGrid(0);
    reconnectFut.get(CLIENT_RECONNECT_WAIT_TIMEOUT);
    assertEquals(2, client.cluster().topologyVersion());
    assertEquals(0, client.services().serviceDescriptors().size());
    client.services().deployNodeSingleton("testService3", MyServiceFactory.create());
    final MyService proxy = client.services().serviceProxy("testService3", MyService.class, false, 2_000);
    assertNotNull(proxy);
    assertEquals(42, proxy.hello());
}
Also used : MyService(org.apache.ignite.internal.processors.service.inner.MyService) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteFuture(org.apache.ignite.lang.IgniteFuture) LongInitializedTestService(org.apache.ignite.internal.processors.service.inner.LongInitializedTestService) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with LongInitializedTestService

use of org.apache.ignite.internal.processors.service.inner.LongInitializedTestService in project ignite by apache.

the class ServiceDeploymentOnClientDisconnectTest method testInitiatorDeploymentFutureCompletionOnClientDisconnect.

/**
 */
@Test
public void testInitiatorDeploymentFutureCompletionOnClientDisconnect() {
    IgniteFuture fut = client().services().deployNodeSingletonAsync("testService", new LongInitializedTestService(10_000L));
    server().close();
    GridTestUtils.assertThrowsWithCause((Runnable) fut::get, IgniteClientDisconnectedException.class);
}
Also used : IgniteFuture(org.apache.ignite.lang.IgniteFuture) LongInitializedTestService(org.apache.ignite.internal.processors.service.inner.LongInitializedTestService) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with LongInitializedTestService

use of org.apache.ignite.internal.processors.service.inner.LongInitializedTestService in project ignite by apache.

the class ServiceDeploymentProcessingOnCoordinatorLeftTest method testDeploymentProcessingOnCoordinatorLeaveTopology2.

/**
 * @throws Exception In case of an error.
 */
@Test
public void testDeploymentProcessingOnCoordinatorLeaveTopology2() throws Exception {
    try {
        IgniteEx ignite0 = (IgniteEx) startGrids(5);
        ((BlockingTcpDiscoverySpi) ignite0.context().discovery().getInjectedDiscoverySpi()).block();
        IgniteEx ignite4 = grid(4);
        IgniteFuture depFut = ignite4.services().deployNodeSingletonAsync("testService", new LongInitializedTestService(5000L));
        IgniteFuture depFut2 = ignite4.services().deployNodeSingletonAsync("testService2", new LongInitializedTestService(5000L));
        assertEquals(ignite0.localNode(), U.oldest(ignite4.cluster().nodes(), null));
        stopNode(ignite0);
        depFut.get(getTestTimeout());
        depFut2.get(TEST_FUTURE_WAIT_TIMEOUT);
        Ignite ignite2 = grid(2);
        assertNotNull(ignite2.services().service("testService"));
        assertNotNull(ignite2.services().service("testService2"));
        IgniteEx ignite1 = grid(1);
        ((BlockingTcpDiscoverySpi) ignite0.context().discovery().getInjectedDiscoverySpi()).block();
        IgniteFuture undepFut = ignite4.services().cancelAsync("testService");
        IgniteFuture undepFut2 = ignite4.services().cancelAsync("testService2");
        assertEquals(ignite1.localNode(), U.oldest(ignite4.cluster().nodes(), null));
        stopNode(ignite1);
        undepFut.get(TEST_FUTURE_WAIT_TIMEOUT);
        undepFut2.get(TEST_FUTURE_WAIT_TIMEOUT);
        assertNull(ignite4.services().service("testService"));
        assertNull(ignite4.services().service("testService2"));
    } finally {
        stopAllGrids();
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteFuture(org.apache.ignite.lang.IgniteFuture) LongInitializedTestService(org.apache.ignite.internal.processors.service.inner.LongInitializedTestService) Ignite(org.apache.ignite.Ignite) Test(org.junit.Test)

Example 4 with LongInitializedTestService

use of org.apache.ignite.internal.processors.service.inner.LongInitializedTestService in project ignite by apache.

the class ServiceDeploymentProcessingOnCoordinatorLeftTest method testDeploymentProcessingOnCoordinatorLeaveTopology.

/**
 * @throws Exception In case of an error.
 */
@Test
public void testDeploymentProcessingOnCoordinatorLeaveTopology() throws Exception {
    try {
        IgniteEx ignite0 = (IgniteEx) startGrids(4);
        ((BlockingTcpDiscoverySpi) ignite0.context().discovery().getInjectedDiscoverySpi()).block();
        IgniteEx ignite2 = grid(2);
        IgniteFuture fut = ignite2.services().deployNodeSingletonAsync("testService", new LongInitializedTestService(5000L));
        IgniteFuture fut2 = ignite2.services().deployNodeSingletonAsync("testService2", new LongInitializedTestService(5000L));
        IgniteFuture fut3 = ignite2.services().deployNodeSingletonAsync("testService3", new LongInitializedTestService(5000L));
        assertEquals(ignite0.localNode(), U.oldest(ignite2.cluster().nodes(), null));
        stopNode(ignite0);
        fut.get(TEST_FUTURE_WAIT_TIMEOUT);
        fut2.get(TEST_FUTURE_WAIT_TIMEOUT);
        fut3.get(TEST_FUTURE_WAIT_TIMEOUT);
        IgniteEx ignite3 = grid(3);
        assertNotNull(ignite3.services().service("testService"));
        assertNotNull(ignite3.services().service("testService2"));
        assertNotNull(ignite3.services().service("testService3"));
    } finally {
        stopAllGrids();
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteFuture(org.apache.ignite.lang.IgniteFuture) LongInitializedTestService(org.apache.ignite.internal.processors.service.inner.LongInitializedTestService) Test(org.junit.Test)

Example 5 with LongInitializedTestService

use of org.apache.ignite.internal.processors.service.inner.LongInitializedTestService in project ignite by apache.

the class ServiceDeploymentProcessingOnNodesLeftTest method testDeploymentProcessingOnServersAndClientsLeaveTopology.

/**
 * @throws Exception In case of an error.
 */
@Test
public void testDeploymentProcessingOnServersAndClientsLeaveTopology() throws Exception {
    try {
        Ignite ignite0 = startGrids(4);
        IgniteEx client1 = startClientGrid(getConfiguration("client1"));
        IgniteEx client2 = startClientGrid(getConfiguration("client2"));
        IgniteEx ignite1 = grid(1);
        ((BlockingTcpCommunicationSpi) client1.configuration().getCommunicationSpi()).block();
        ((BlockingTcpCommunicationSpi) client2.configuration().getCommunicationSpi()).block();
        ((BlockingTcpCommunicationSpi) ignite1.configuration().getCommunicationSpi()).block();
        ServiceConfiguration srvcCfg = new ServiceConfiguration();
        srvcCfg.setName("testService");
        srvcCfg.setMaxPerNodeCount(1);
        srvcCfg.setService(new LongInitializedTestService(10_000));
        srvcCfg.setNodeFilter(new AlwaysTruePredicate<>());
        IgniteFuture fut = ignite0.services().deployAsync(srvcCfg);
        stopNode(client1);
        stopNode(client2);
        stopNode(ignite1);
        fut.get(TEST_FUTURE_WAIT_TIMEOUT);
        assertNotNull(ignite0.services().service("testService"));
        IgniteEx ignite3 = grid(3);
        assertNotNull(ignite3.services().service("testService"));
    } finally {
        stopAllGrids();
    }
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteFuture(org.apache.ignite.lang.IgniteFuture) Ignite(org.apache.ignite.Ignite) LongInitializedTestService(org.apache.ignite.internal.processors.service.inner.LongInitializedTestService) Test(org.junit.Test)

Aggregations

LongInitializedTestService (org.apache.ignite.internal.processors.service.inner.LongInitializedTestService)6 IgniteFuture (org.apache.ignite.lang.IgniteFuture)6 Test (org.junit.Test)6 IgniteEx (org.apache.ignite.internal.IgniteEx)5 Ignite (org.apache.ignite.Ignite)2 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)2 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)1 MyService (org.apache.ignite.internal.processors.service.inner.MyService)1 ServiceConfiguration (org.apache.ignite.services.ServiceConfiguration)1