Search in sources :

Example 71 with ServiceConfiguration

use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.

the class KillCommandsTests method doTestCancelService.

/**
 * Test cancel of the service.
 *
 * @param startCli Client node to start service.
 * @param killCli Client node to kill service.
 * @param srv Server node.
 * @param svcCanceler Service cancel closure.
 */
public static void doTestCancelService(IgniteEx startCli, IgniteEx killCli, IgniteEx srv, Consumer<String> svcCanceler) throws Exception {
    ServiceConfiguration scfg = new ServiceConfiguration();
    scfg.setName(SVC_NAME);
    scfg.setMaxPerNodeCount(1);
    scfg.setNodeFilter(srv.cluster().predicate());
    scfg.setService(new TestServiceImpl());
    startCli.services().deploy(scfg);
    SystemView<ServiceView> svcView = srv.context().systemView().view(SVCS_VIEW);
    SystemView<ServiceView> killCliSvcView = killCli.context().systemView().view(SVCS_VIEW);
    boolean res = waitForCondition(() -> svcView.size() == 1 && killCliSvcView.size() == 1, TIMEOUT);
    assertTrue(res);
    TestService svc = startCli.services().serviceProxy(SVC_NAME, TestService.class, true);
    assertNotNull(svc);
    svcCanceler.accept(SVC_NAME);
    res = waitForCondition(() -> svcView.size() == 0, TIMEOUT);
    assertTrue(res);
}
Also used : ServiceView(org.apache.ignite.spi.systemview.view.ServiceView) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Aggregations

ServiceConfiguration (org.apache.ignite.services.ServiceConfiguration)71 Test (org.junit.Test)29 Ignite (org.apache.ignite.Ignite)20 ArrayList (java.util.ArrayList)18 CountDownLatch (java.util.concurrent.CountDownLatch)18 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)15 ClusterNode (org.apache.ignite.cluster.ClusterNode)10 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)9 IgniteUuid (org.apache.ignite.lang.IgniteUuid)8 ServiceDeploymentException (org.apache.ignite.services.ServiceDeploymentException)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 UUID (java.util.UUID)6 IgniteException (org.apache.ignite.IgniteException)6 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)5 IgniteEx (org.apache.ignite.internal.IgniteEx)5 HashMap (java.util.HashMap)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 Service (org.apache.ignite.services.Service)4 HashSet (java.util.HashSet)3 List (java.util.List)3