Search in sources :

Example 56 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method copyService.

/**
 * @param cfg Config.
 * @return Copy of provided configuration.
 */
private ServiceConfiguration copyService(ServiceConfiguration cfg) {
    ServiceConfiguration cfgCp = new ServiceConfiguration();
    cfgCp.setName(cfg.getName());
    cfgCp.setMaxPerNodeCount(cfg.getMaxPerNodeCount());
    cfgCp.setTotalCount(cfg.getTotalCount());
    cfgCp.setAffinityKey(cfg.getAffinityKey());
    cfgCp.setCacheName(cfg.getCacheName());
    cfgCp.setName(cfg.getName());
    cfgCp.setService(cfg.getService());
    cfgCp.setNodeFilter(cfg.getNodeFilter());
    return cfgCp;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Example 57 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testClashingNameDifferentConfig.

/**
 * @throws Exception If failed.
 */
@Test
public void testClashingNameDifferentConfig() 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 - 1);
    subscribeExeLatch(cfgs, latch);
    client.services().deployAll(fstBatch);
    ServiceConfiguration failingCfg = copyService(cfgs.get(NUM_SERVICES - 1));
    // Same name, different config.
    failingCfg.setName(fstBatch.get(0).getName());
    failingCfg.setTotalCount(fstBatch.get(0).getTotalCount() + 1);
    sndBatch.add(failingCfg);
    assertFailingDeploy(client, false, sndBatch, failingCfg);
    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 58 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testCancelAllTopologyChange.

/**
 * @throws Exception If failed.
 */
@Test
public void testCancelAllTopologyChange() throws Exception {
    IgniteEx client = grid(CLIENT_NODE_NAME);
    int numServices = 500;
    List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), numServices);
    CountDownLatch latch = new CountDownLatch(numServices);
    subscribeExeLatch(cfgs, latch);
    client.services().deployAll(cfgs);
    latch.await(30, TimeUnit.SECONDS);
    final AtomicBoolean finished = new AtomicBoolean();
    IgniteInternalFuture<Object> topChangeFut = runTopChanger(finished);
    List<String> names = new ArrayList<>();
    for (ServiceConfiguration cfg : cfgs) names.add(cfg.getName());
    try {
        int batchSize = 5;
        int from = 0;
        while (from < numServices) {
            int to = Math.min(numServices, from + batchSize);
            log.info("Trying to cancel services [" + from + ".." + to + ")");
            client.services().cancelAllAsync(names.subList(from, to)).get(5000);
            from = to;
        }
        assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList());
    } finally {
        finished.set(true);
    }
    topChangeFut.get();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 59 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method assertDeployedServices.

/**
 * @param client Client Ignite instance.
 * @param expCfgs Configurations of services that are expected to be deployed.
 */
private void assertDeployedServices(Ignite client, Collection<ServiceConfiguration> expCfgs) {
    Set<String> expNames = new HashSet<>();
    Set<String> actNames = new HashSet<>();
    for (ServiceConfiguration cfg : expCfgs) expNames.add(cfg.getName());
    for (ServiceDescriptor desc : client.services().serviceDescriptors()) actNames.add(desc.name());
    assertEquals(expNames, actNames);
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) ServiceDescriptor(org.apache.ignite.services.ServiceDescriptor) HashSet(java.util.HashSet)

Example 60 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method getConfigs.

/**
 * @param nodePred Node predicate.
 * @param numServices Number of configurations to generate.
 * @return Generated services configurations.
 */
private List<ServiceConfiguration> getConfigs(IgnitePredicate<ClusterNode> nodePred, int numServices) {
    List<ServiceConfiguration> cfgs = new ArrayList<>(numServices);
    for (int i = 0; i < numServices; i++) {
        String name = "testService-" + i;
        ServiceConfiguration cfg = new ServiceConfiguration();
        cfg.setName(name);
        cfg.setTotalCount(1);
        cfg.setMaxPerNodeCount(1);
        cfg.setService(new DummyService());
        cfg.setNodeFilter(nodePred);
        cfgs.add(cfg);
    }
    return cfgs;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) ArrayList(java.util.ArrayList)

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