Search in sources :

Example 61 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testClashingNames.

/**
 * @throws Exception If failed.
 */
@Test
public void testClashingNames() throws Exception {
    Ignite client = grid(CLIENT_NODE_NAME);
    CountDownLatch latch = new CountDownLatch(NUM_SERVICES);
    List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
    subscribeExeLatch(cfgs, latch);
    List<ServiceConfiguration> fstBatch = cfgs.subList(0, NUM_SERVICES / 2);
    List<ServiceConfiguration> sndBatch = cfgs.subList(NUM_SERVICES / 4, NUM_SERVICES);
    IgniteFuture<Void> fstFut = client.services().deployAllAsync(fstBatch);
    IgniteFuture<Void> sndFut = client.services().deployAllAsync(sndBatch);
    fstFut.get();
    sndFut.get();
    assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
    assertDeployedServices(client, cfgs);
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 62 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testClashingNamesFail.

/**
 * @throws Exception If failed.
 */
@Test
public void testClashingNamesFail() throws Exception {
    Ignite client = grid(CLIENT_NODE_NAME);
    List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
    int numDepSvcs = NUM_SERVICES - 1;
    CountDownLatch latch = new CountDownLatch(numDepSvcs);
    List<ServiceConfiguration> fstBatch = cfgs.subList(0, NUM_SERVICES / 2);
    List<ServiceConfiguration> sndBatch = cfgs.subList(NUM_SERVICES / 4, NUM_SERVICES);
    subscribeExeLatch(cfgs, latch);
    IgniteFuture<Void> fut = client.services().deployAllAsync(fstBatch);
    ServiceConfiguration failingCfg = cfgs.get(NUM_SERVICES - 1);
    failingCfg.setName(null);
    assertFailingDeploy(client, false, sndBatch, failingCfg);
    fut.get();
    assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
    assertDeployedServices(client, cfgs.subList(0, numDepSvcs));
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 63 with ServiceConfiguration

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

the class GridServiceProcessorMultiNodeSelfTest method testDeployLimits.

/**
 * @throws Exception If failed.
 */
@SuppressWarnings("deprecation")
@Test
public void testDeployLimits() throws Exception {
    final String name = "serviceWithLimitsUpdateTopology";
    IgniteEx g = randomGrid();
    final int totalInstances = nodeCount() + 1;
    CountDownLatch latch = new CountDownLatch(nodeCount());
    DummyService.exeLatch(name, latch);
    ServiceConfiguration srvcCfg = new ServiceConfiguration();
    srvcCfg.setName(name);
    srvcCfg.setMaxPerNodeCount(1);
    srvcCfg.setTotalCount(totalInstances);
    srvcCfg.setService(new DummyService());
    IgniteServices svcs = g.services().withAsync();
    svcs.deploy(srvcCfg);
    IgniteFuture<?> fut = svcs.future();
    info("Deployed service: " + name);
    fut.get();
    info("Finished waiting for service future: " + name);
    latch.await();
    assertEquals(name, nodeCount(), DummyService.started(name));
    assertEquals(name, 0, DummyService.cancelled(name));
    checkCount(name, g.services().serviceDescriptors(), nodeCount());
    latch = new CountDownLatch(1);
    DummyService.exeLatch(name, latch);
    int extraNodes = 2;
    startExtraNodes(extraNodes);
    try {
        latch.await();
        waitForDeployment(name, totalInstances);
        // 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, totalInstances, DummyService.started(name) - DummyService.cancelled(name));
        checkCount(name, g, totalInstances);
    } finally {
        stopExtraNodes(extraNodes);
    }
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteServices(org.apache.ignite.IgniteServices) IgniteEx(org.apache.ignite.internal.IgniteEx) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 64 with ServiceConfiguration

use of org.apache.ignite.services.ServiceConfiguration 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 65 with ServiceConfiguration

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

the class GridServiceProcessorMultiNodeConfigSelfTest method services.

/**
 * {@inheritDoc}
 */
@Override
protected ServiceConfiguration[] services() {
    ServiceConfiguration cfg = new ServiceConfiguration();
    cfg.setName(CLUSTER_SINGLE);
    cfg.setMaxPerNodeCount(1);
    cfg.setTotalCount(1);
    cfg.setService(new DummyService());
    List<ServiceConfiguration> cfgs = new ArrayList<>();
    cfgs.add(cfg);
    cfg = new ServiceConfiguration();
    cfg.setName(NODE_SINGLE_BUT_CLIENT);
    cfg.setMaxPerNodeCount(1);
    cfg.setService(new DummyService());
    cfgs.add(cfg);
    cfg = new ServiceConfiguration();
    cfg.setName(AFFINITY);
    cfg.setCacheName(CACHE_NAME);
    cfg.setAffinityKey(AFFINITY_KEY);
    cfg.setMaxPerNodeCount(1);
    cfg.setTotalCount(1);
    cfg.setService(new AffinityService(AFFINITY_KEY));
    cfgs.add(cfg);
    cfg = new ServiceConfiguration();
    cfg.setName(NODE_SINGLE);
    cfg.setMaxPerNodeCount(1);
    cfg.setNodeFilter(new CacheConfiguration.IgniteAllNodesPredicate());
    cfg.setService(new DummyService());
    cfgs.add(cfg);
    cfg = new ServiceConfiguration();
    cfg.setName(NODE_SINGLE_WITH_LIMIT);
    cfg.setMaxPerNodeCount(1);
    cfg.setTotalCount(nodeCount() + 1);
    cfg.setService(new DummyService());
    cfgs.add(cfg);
    return cfgs.toArray(new ServiceConfiguration[cfgs.size()]);
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) ArrayList(java.util.ArrayList) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

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