Search in sources :

Example 21 with ServiceConfiguration

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

the class SystemCacheNotConfiguredTest method serviceConfiguration.

/**
 * @return Service configuration.
 */
private ServiceConfiguration serviceConfiguration() {
    ServiceConfiguration svcCfg = new ServiceConfiguration();
    svcCfg.setName("service");
    svcCfg.setTotalCount(1);
    svcCfg.setService(new SimpleServiceImpl());
    return svcCfg;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Example 22 with ServiceConfiguration

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

the class ServiceDeploymentOnActivationTest method checkRedeployment.

/**
 * @param srvsNum Number of server nodes to start.
 * @param clientsNum Number of client nodes to start.
 * @param nodeFilter Node filter.
 * @param deps Expected number of deployed services.
 * @param isStatic Static or dynamic service deployment is used.
 * @throws Exception If failed.
 */
private void checkRedeployment(int srvsNum, int clientsNum, IgnitePredicate<ClusterNode> nodeFilter, int deps, boolean isStatic) throws Exception {
    if (isStatic)
        srvcCfg = getServiceConfiguration(nodeFilter);
    CountDownLatch exeLatch = new CountDownLatch(deps);
    CountDownLatch cancelLatch = new CountDownLatch(deps);
    DummyService.exeLatch(SERVICE_NAME, exeLatch);
    DummyService.cancelLatch(SERVICE_NAME, cancelLatch);
    for (int i = 0; i < srvsNum; i++) startGrid(i);
    for (int i = 0; i < clientsNum; i++) startClientGrid(srvsNum + i);
    Ignite ignite = grid(0);
    ignite.cluster().active(true);
    if (!isStatic) {
        ServiceConfiguration srvcCfg = getServiceConfiguration(nodeFilter);
        ignite.services().deploy(srvcCfg);
    }
    assertTrue(exeLatch.await(10, TimeUnit.SECONDS));
    ignite.cluster().active(false);
    assertTrue(cancelLatch.await(10, TimeUnit.SECONDS));
    exeLatch = new CountDownLatch(deps);
    DummyService.exeLatch(SERVICE_NAME, exeLatch);
    ignite.cluster().active(true);
    assertTrue(exeLatch.await(10, TimeUnit.SECONDS));
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 23 with ServiceConfiguration

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

the class ServiceDeploymentOutsideBaselineTest method getClusterSingletonServiceConfiguration.

/**
 * @return Test service configuration.
 */
private ServiceConfiguration getClusterSingletonServiceConfiguration() {
    ServiceConfiguration srvcCfg = new ServiceConfiguration();
    srvcCfg.setName(SERVICE_NAME);
    srvcCfg.setService(new DummyService());
    srvcCfg.setTotalCount(1);
    return srvcCfg;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Example 24 with ServiceConfiguration

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

the class GridServiceProcessorAbstractSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    ServiceConfiguration[] svcs = services();
    if (svcs != null)
        c.setServiceConfiguration(svcs);
    CacheConfiguration cc = new CacheConfiguration(DEFAULT_CACHE_NAME);
    cc.setName(CACHE_NAME);
    cc.setCacheMode(CacheMode.PARTITIONED);
    cc.setBackups(nodeCount());
    c.setCacheConfiguration(cc);
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 25 with ServiceConfiguration

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

the class ServiceReassignmentFunctionSelfTest method testClusterSingletonWithOldTop.

/**
 * @throws Exception In case of an error.
 */
@Test
public void testClusterSingletonWithOldTop() throws Exception {
    ServiceConfiguration cfg = new ServiceConfiguration();
    cfg.setName(TEST_SERVICE_NAME);
    cfg.setTotalCount(1);
    IgniteUuid srvcId = IgniteUuid.randomUuid();
    TreeMap<UUID, Integer> oldTop = new TreeMap<>();
    ClusterNode randomNode = nodes.get(new Random().nextInt(nodes.size()));
    oldTop.put(randomNode.id(), 1);
    runTestReassignFunction(srvcId, cfg, oldTop);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Random(java.util.Random) IgniteUuid(org.apache.ignite.lang.IgniteUuid) UUID(java.util.UUID) TreeMap(java.util.TreeMap) 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