Search in sources :

Example 16 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testDeployAllTopologyChange.

/**
 * @throws Exception If failed.
 */
@Test
public void testDeployAllTopologyChange() throws Exception {
    Ignite client = grid(CLIENT_NODE_NAME);
    final AtomicBoolean finished = new AtomicBoolean();
    IgniteInternalFuture<Object> topChangeFut = runTopChanger(finished);
    try {
        int numServices = 50;
        int batchSize = 5;
        CountDownLatch latch = new CountDownLatch(numServices);
        IgnitePredicate<ClusterNode> depPred = new TestPredicate(getTestIgniteInstanceName());
        List<ServiceConfiguration> cfgs = getConfigs(depPred, numServices);
        subscribeExeLatch(cfgs, latch);
        int from = 0;
        while (from < numServices) {
            int to = Math.min(numServices, from + batchSize);
            client.services().deployAllAsync(cfgs.subList(from, to)).get(5000);
            from = to;
        }
        assertTrue(latch.await(120, TimeUnit.SECONDS));
        assertDeployedServices(client, cfgs);
    } finally {
        finished.set(true);
    }
    topChangeFut.get();
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) 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 17 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testDeployAllAsync.

/**
 * @throws Exception If failed.
 */
@Test
public void testDeployAllAsync() 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);
    IgniteFuture<Void> fut = client.services().deployAllAsync(cfgs);
    fut.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 18 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testCancelAll.

/**
 * @throws Exception If failed.
 */
@Test
public void testCancelAll() throws Exception {
    Ignite client = grid(CLIENT_NODE_NAME);
    List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
    CountDownLatch latch = new CountDownLatch(NUM_SERVICES);
    subscribeExeLatch(cfgs, latch);
    client.services().deployAll(cfgs);
    latch.await(30, TimeUnit.SECONDS);
    client.services().cancelAll();
    assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList());
}
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 19 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testDeployAllTopologyChangeFail.

/**
 * @throws Exception If failed.
 */
@Test
public void testDeployAllTopologyChangeFail() throws Exception {
    final Ignite client = grid(CLIENT_NODE_NAME);
    final AtomicBoolean finished = new AtomicBoolean();
    IgniteInternalFuture<Object> topChangeFut = runTopChanger(finished);
    try {
        int numServices = 200;
        int batchSize = 5;
        CountDownLatch latch = new CountDownLatch(numServices);
        IgnitePredicate<ClusterNode> depPred = new TestPredicate(getTestIgniteInstanceName());
        List<ServiceConfiguration> cfgs = getConfigs(depPred, numServices);
        List<ServiceConfiguration> failingCfgs = new ArrayList<>();
        subscribeExeLatch(cfgs, latch);
        int from = 0;
        while (from < numServices) {
            int to = Math.min(numServices, from + batchSize);
            List<ServiceConfiguration> cfgsBatch = cfgs.subList(from, to);
            ServiceConfiguration failingCfg = cfgsBatch.get(0);
            failingCfg.setName(null);
            failingCfgs.add(failingCfg);
            try {
                client.services().deployAllAsync(cfgsBatch).get(5000);
                fail("Should never reach here.");
            } catch (ServiceDeploymentException e) {
                assertEquals(1, e.getFailedConfigurations().size());
                ServiceConfiguration actFailedCfg = copyService(e.getFailedConfigurations().iterator().next());
                assertEquals(failingCfg, actFailedCfg);
                latch.countDown();
            }
            from = to;
        }
        assertTrue(latch.await(120, TimeUnit.SECONDS));
        cfgs.removeAll(failingCfgs);
        assertDeployedServices(client, cfgs);
    } finally {
        finished.set(true);
    }
    topChangeFut.get();
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ArrayList(java.util.ArrayList) ServiceDeploymentException(org.apache.ignite.services.ServiceDeploymentException) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 20 with ServiceConfiguration

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

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