Search in sources :

Example 26 with Service

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

the class IgniteServiceDeploymentClassLoadingDefaultMarshallerTest method serviceConfig.

/**
 * @return Service configuration.
 * @throws Exception If failed.
 */
private ServiceConfiguration serviceConfig() throws Exception {
    ServiceConfiguration srvCfg = new ServiceConfiguration();
    srvCfg.setNodeFilter(new TestNodeFilter(extClsLdrGrids));
    Class<Service> srvcCls = (Class<Service>) extClsLdr.loadClass(NOOP_SERVICE_CLS_NAME);
    Service srvc = srvcCls.newInstance();
    srvCfg.setService(srvc);
    srvCfg.setName("TestDeploymentService");
    srvCfg.setMaxPerNodeCount(1);
    return srvCfg;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Service(org.apache.ignite.services.Service)

Example 27 with Service

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

the class GridServiceProcessorMultiNodeSelfTest method testDeployOnEachProjectionNodeUpdateTopology.

/**
 * @throws Exception If failed.
 */
@Test
public void testDeployOnEachProjectionNodeUpdateTopology() throws Exception {
    // Prestart client node.
    Ignite client = startClientGrid("client", getConfiguration("client"));
    try {
        final String name = "serviceOnEachProjectionNodeUpdateTopology";
        IgniteEx g = randomGrid();
        int prestartedSrvcs = 1;
        CountDownLatch latch = new CountDownLatch(prestartedSrvcs);
        DummyService.exeLatch(name, latch);
        IgniteServices svcs = g.services(g.cluster().forClients());
        IgniteFuture<?> fut = svcs.deployNodeSingletonAsync(name, new DummyService());
        info("Deployed service: " + name);
        fut.get();
        info("Finished waiting for service future: " + name);
        latch.await();
        // Ensure service is deployed
        assertNotNull(client.services().serviceProxy(name, Service.class, false, 2000));
        assertEquals(name, prestartedSrvcs, DummyService.started(name));
        assertEquals(name, 0, DummyService.cancelled(name));
        int servers = 2;
        int clients = 2;
        latch = new CountDownLatch(clients);
        DummyService.exeLatch(name, latch);
        startExtraNodes(servers, clients);
        try {
            latch.await();
            waitForDeployment(name, clients);
            // Since we start extra nodes, there may be extra start and cancel events,
            // so we check only the difference between start and cancel and
            // not start and cancel events individually.
            assertEquals(name, clients + prestartedSrvcs, DummyService.started(name) - DummyService.cancelled(name));
            checkCount(name, g, clients + prestartedSrvcs);
        } finally {
            stopExtraNodes(servers + clients);
        }
    } finally {
        stopGrid("client");
    }
}
Also used : IgniteServices(org.apache.ignite.IgniteServices) IgniteEx(org.apache.ignite.internal.IgniteEx) Service(org.apache.ignite.services.Service) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 28 with Service

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

the class GridServiceProcessorMultiNodeSelfTest method testDeployOnEachNodeButClientUpdateTopology.

/**
 * @throws Exception If failed.
 */
@Test
public void testDeployOnEachNodeButClientUpdateTopology() throws Exception {
    // Prestart client node.
    Ignite client = startClientGrid("client", getConfiguration("client"));
    try {
        final String name = "serviceOnEachNodeButClientUpdateTopology";
        IgniteEx g = randomGrid();
        CountDownLatch latch = new CountDownLatch(nodeCount());
        DummyService.exeLatch(name, latch);
        IgniteServices svcs = g.services();
        IgniteFuture<?> fut = svcs.deployNodeSingletonAsync(name, new DummyService());
        info("Deployed service: " + name);
        fut.get();
        info("Finished waiting for service future: " + name);
        latch.await();
        // Ensure service is deployed
        assertNotNull(client.services().serviceProxy(name, Service.class, false, 2000));
        assertEquals(name, nodeCount(), DummyService.started(name));
        assertEquals(name, 0, DummyService.cancelled(name));
        int servers = 2;
        latch = new CountDownLatch(servers);
        DummyService.exeLatch(name, latch);
        int clients = 2;
        startExtraNodes(servers, clients);
        try {
            latch.await();
            waitForDeployment(name, servers);
            // Since we start extra nodes, there may be extra start and cancel events,
            // so we check only the difference between start and cancel and
            // not start and cancel events individually.
            assertEquals(name, nodeCount() + servers, DummyService.started(name) - DummyService.cancelled(name));
            checkCount(name, g, nodeCount() + servers);
        } finally {
            stopExtraNodes(servers + clients);
        }
    } finally {
        stopGrid("client");
    }
}
Also used : IgniteServices(org.apache.ignite.IgniteServices) IgniteEx(org.apache.ignite.internal.IgniteEx) Service(org.apache.ignite.services.Service) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 29 with Service

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

the class GridServiceProcessorMultiNodeSelfTest method testDeployOnEachNodeUpdateTopology.

/**
 * @throws Exception If failed.
 */
@Test
public void testDeployOnEachNodeUpdateTopology() throws Exception {
    // Prestart client node.
    Ignite client = startClientGrid("client", getConfiguration("client"));
    try {
        final String name = "serviceOnEachNodeUpdateTopology";
        IgniteEx g = randomGrid();
        final int prestartedNodes = nodeCount() + 1;
        CountDownLatch latch = new CountDownLatch(prestartedNodes);
        DummyService.exeLatch(name, latch);
        ServiceConfiguration srvcCfg = new ServiceConfiguration();
        srvcCfg.setNodeFilter(new CacheConfiguration.IgniteAllNodesPredicate());
        srvcCfg.setName(name);
        srvcCfg.setMaxPerNodeCount(1);
        srvcCfg.setService(new DummyService());
        IgniteServices svcs = g.services();
        IgniteFuture<?> fut = svcs.deployAsync(srvcCfg);
        info("Deployed service: " + name);
        fut.get();
        info("Finished waiting for service future: " + name);
        latch.await();
        // Ensure service is deployed
        assertNotNull(client.services().serviceProxy(name, Service.class, false, 2000));
        assertEquals(name, prestartedNodes, DummyService.started(name));
        assertEquals(name, 0, DummyService.cancelled(name));
        int servers = 2;
        int clients = 2;
        int extraNodes = servers + clients;
        latch = new CountDownLatch(extraNodes);
        DummyService.exeLatch(name, latch);
        startExtraNodes(servers, clients);
        try {
            latch.await();
            waitForDeployment(name, prestartedNodes + extraNodes);
            // Since we start extra nodes, there may be extra start and cancel events,
            // so we check only the difference between start and cancel and
            // not start and cancel events individually.
            assertEquals(name, prestartedNodes + extraNodes, DummyService.started(name) - DummyService.cancelled(name));
            checkCount(name, g, prestartedNodes + extraNodes);
        } finally {
            stopExtraNodes(extraNodes);
        }
    } finally {
        stopGrid("client");
    }
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteServices(org.apache.ignite.IgniteServices) IgniteEx(org.apache.ignite.internal.IgniteEx) Service(org.apache.ignite.services.Service) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Example 30 with Service

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

the class GridServiceProcessorProxySelfTest method testSingletonProxyInvocation.

/**
 * @throws Exception If failed.
 */
@Test
public void testSingletonProxyInvocation() throws Exception {
    final String name = "testProxyInvocationFromSeveralNodes";
    final Ignite ignite = grid(0);
    ignite.services(ignite.cluster().forLocal()).deployClusterSingleton(name, new MapServiceImpl<String, Integer>());
    for (int i = 1; i < nodeCount(); i++) {
        MapService<Integer, String> svc = grid(i).services().serviceProxy(name, MapService.class, false, 1_000L);
        // Make sure service is a proxy.
        assertFalse(svc instanceof Service);
        svc.put(i, Integer.toString(i));
    }
    assertEquals(nodeCount() - 1, ignite.services().serviceProxy(name, MapService.class, false).size());
}
Also used : Service(org.apache.ignite.services.Service) Ignite(org.apache.ignite.Ignite) Test(org.junit.Test)

Aggregations

Service (org.apache.ignite.services.Service)50 ExecutorService (java.util.concurrent.ExecutorService)22 PlatformService (org.apache.ignite.internal.processors.platform.services.PlatformService)18 Ignite (org.apache.ignite.Ignite)17 Test (org.junit.Test)17 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)15 ArrayList (java.util.ArrayList)11 ClusterNode (org.apache.ignite.cluster.ClusterNode)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 IgniteException (org.apache.ignite.IgniteException)9 IgniteEx (org.apache.ignite.internal.IgniteEx)9 ServiceConfiguration (org.apache.ignite.services.ServiceConfiguration)8 IgniteServices (org.apache.ignite.IgniteServices)6 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)6 IgniteInterruptedException (org.apache.ignite.IgniteInterruptedException)4 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)4 ServiceContext (org.apache.ignite.services.ServiceContext)4 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)4 IOException (java.io.IOException)3