Search in sources :

Example 11 with IgniteServices

use of org.apache.ignite.IgniteServices in project ignite by apache.

the class GridServiceProcessorAbstractSelfTest method testDeployMultiple2Old.

/**
 * @throws Exception If failed.
 */
@Test
public void testDeployMultiple2Old() throws Exception {
    Ignite g = randomGrid();
    String name = "serviceMultiple2Old";
    int cnt = nodeCount() * 2 + 1;
    CountDownLatch latch = new CountDownLatch(cnt);
    DummyService.exeLatch(name, latch);
    IgniteServices svcs = g.services().withAsync();
    svcs.deployMultiple(name, new DummyService(), cnt, 3);
    IgniteFuture<?> fut = svcs.future();
    info("Deployed service: " + name);
    fut.get();
    info("Finished waiting for service future: " + name);
    latch.await();
    assertEquals(name, cnt, DummyService.started(name));
    assertEquals(name, 0, DummyService.cancelled(name));
    checkCount(name, g.services().serviceDescriptors(), cnt);
}
Also used : IgniteServices(org.apache.ignite.IgniteServices) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) GridCommonTest(org.apache.ignite.testframework.junits.common.GridCommonTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 12 with IgniteServices

use of org.apache.ignite.IgniteServices in project ignite by apache.

the class IgniteServiceConfigVariationsFullApiTest method testDeploy.

/**
 * Tests deployment.
 *
 * @throws Exception If failed.
 */
@Test
public void testDeploy() throws Exception {
    runInAllDataModes(new ServiceTestRunnable(false, new DeployClosure() {

        @Override
        public void run(IgniteServices services, String svcName, TestService svc) throws Exception {
            services.deployClusterSingleton(svcName, (Service) svc);
            ServiceConfiguration cfg = new ServiceConfiguration();
            cfg.setName(svcName);
            cfg.setService((Service) svc);
            cfg.setTotalCount(1);
            cfg.setMaxPerNodeCount(1);
            cfg.setNodeFilter(services.clusterGroup().predicate());
            services.deploy(cfg);
            waitForServiceDeploymentIfNeeded(services, svcName);
        }
    }));
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteServices(org.apache.ignite.IgniteServices) IgniteConfigVariationsAbstractTest(org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest) Test(org.junit.Test)

Example 13 with IgniteServices

use of org.apache.ignite.IgniteServices in project ignite by apache.

the class GridServiceProcessorMultiNodeSelfTest method testSingletonUpdateTopology.

/**
 * @throws Exception If failed.
 */
@Test
public void testSingletonUpdateTopology() throws Exception {
    String name = "serviceSingletonUpdateTopology";
    IgniteEx g = randomGrid();
    CountDownLatch latch = new CountDownLatch(1);
    DummyService.exeLatch(name, latch);
    IgniteServices svcs = g.services();
    IgniteFuture<?> fut = svcs.deployClusterSingletonAsync(name, new DummyService());
    info("Deployed service: " + name);
    fut.get();
    info("Finished waiting for service future: " + name);
    latch.await();
    Assert.assertEquals(name, 1, DummyService.started(name));
    Assert.assertEquals(name, 0, DummyService.cancelled(name));
    int nodeCnt = 2;
    startExtraNodes(nodeCnt);
    try {
        Assert.assertEquals(name, 1, DummyService.started(name));
        Assert.assertEquals(name, 0, DummyService.cancelled(name));
        info(">>> Passed checks.");
        checkCount(name, g, 1);
    } finally {
        stopExtraNodes(nodeCnt);
    }
}
Also used : IgniteServices(org.apache.ignite.IgniteServices) IgniteEx(org.apache.ignite.internal.IgniteEx) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 14 with IgniteServices

use of org.apache.ignite.IgniteServices in project ignite by apache.

the class GridServiceProcessorMultiNodeSelfTest method testAffinityDeployUpdateTopology.

/**
 * @throws Exception If failed.
 */
@Test
public void testAffinityDeployUpdateTopology() throws Exception {
    IgniteEx g = randomGrid();
    final Integer affKey = 1;
    // Store a cache key.
    g.cache(CACHE_NAME).put(affKey, affKey.toString());
    final String name = "serviceAffinityUpdateTopology";
    IgniteServices svcs = g.services();
    IgniteFuture<?> fut = svcs.deployKeyAffinitySingletonAsync(name, new AffinityService(affKey), CACHE_NAME, affKey);
    info("Deployed service: " + name);
    fut.get();
    info("Finished waiting for service future: " + name);
    checkCount(name, g.services().serviceDescriptors(), 1);
    int nodeCnt = 2;
    startExtraNodes(nodeCnt);
    try {
        checkCount(name, g, 1);
    } finally {
        stopExtraNodes(nodeCnt);
    }
}
Also used : IgniteServices(org.apache.ignite.IgniteServices) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test)

Example 15 with IgniteServices

use of org.apache.ignite.IgniteServices in project ignite by apache.

the class GridMarshallerAbstractTest method testServices.

/**
 * @throws Exception If failed.
 */
@Test
public void testServices() throws Exception {
    IgniteConfiguration cfg = optimize(getConfiguration("g1"));
    try (Ignite g1 = G.start(cfg)) {
        IgniteServices services = grid().services(grid().cluster().forNode(g1.cluster().localNode()));
        services.deployNodeSingleton("test", new DummyService());
        GridMarshallerTestBean inBean = newTestBean(services);
        byte[] buf = marshal(inBean);
        GridMarshallerTestBean outBean = unmarshal(buf);
        assert inBean.getObjectField() != null;
        assert outBean.getObjectField() != null;
        assert inBean.getObjectField().getClass().equals(IgniteServicesImpl.class);
        assert outBean.getObjectField().getClass().equals(IgniteServicesImpl.class);
        assert inBean != outBean;
        assert inBean.equals(outBean);
        ClusterGroup inPrj = services.clusterGroup();
        ClusterGroup outPrj = ((IgniteServices) outBean.getObjectField()).clusterGroup();
        assert inPrj.getClass().equals(outPrj.getClass());
        assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes());
        outBean.checkNullResources();
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) DummyService(org.apache.ignite.internal.processors.service.DummyService) IgniteServices(org.apache.ignite.IgniteServices) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

IgniteServices (org.apache.ignite.IgniteServices)30 Test (org.junit.Test)26 Ignite (org.apache.ignite.Ignite)19 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)15 CountDownLatch (java.util.concurrent.CountDownLatch)11 GridCommonTest (org.apache.ignite.testframework.junits.common.GridCommonTest)9 IgniteException (org.apache.ignite.IgniteException)8 IgniteEx (org.apache.ignite.internal.IgniteEx)8 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)4 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)3 Service (org.apache.ignite.services.Service)3 ServiceConfiguration (org.apache.ignite.services.ServiceConfiguration)3 DummyService (org.apache.ignite.internal.processors.service.DummyService)2 PA (org.apache.ignite.internal.util.typedef.PA)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ClusterGroup (org.apache.ignite.cluster.ClusterGroup)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1