Search in sources :

Example 66 with ServiceConfiguration

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

the class GridServiceProcessorProxySelfTest method deployNodeSingleton.

/**
 * Deploys {@link MapServiceImpl} service over the cluster as node singleton.
 *
 * @param svcName Service name
 * @param withStat If {@code true}, enabled the serive metrics {@link ServiceConfiguration#setStatisticsEnabled(boolean)}.
 */
private void deployNodeSingleton(String svcName, boolean withStat) throws InterruptedException {
    ServiceConfiguration svcCfg = new ServiceConfiguration();
    svcCfg.setName(svcName);
    svcCfg.setMaxPerNodeCount(1);
    svcCfg.setTotalCount(nodeCount());
    svcCfg.setService(new MapServiceImpl<String, Integer>());
    svcCfg.setStatisticsEnabled(withStat);
    grid(0).services().deploy(svcCfg);
    awaitPartitionMapExchange();
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Example 67 with ServiceConfiguration

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

the class ServiceDeploymentOnActivationTest method getServiceConfiguration.

/**
 * @param nodeFilter Node filter.
 * @return Service configuration.
 */
private ServiceConfiguration getServiceConfiguration(IgnitePredicate<ClusterNode> nodeFilter) {
    ServiceConfiguration srvcCfg = new ServiceConfiguration();
    srvcCfg.setName(SERVICE_NAME);
    srvcCfg.setMaxPerNodeCount(1);
    srvcCfg.setNodeFilter(nodeFilter);
    srvcCfg.setService(new DummyService());
    return srvcCfg;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Example 68 with ServiceConfiguration

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

the class ServiceDeploymentProcessingOnNodesLeftTest method testDeploymentProcessingOnServersAndClientsLeaveTopology.

/**
 * @throws Exception In case of an error.
 */
@Test
public void testDeploymentProcessingOnServersAndClientsLeaveTopology() throws Exception {
    try {
        Ignite ignite0 = startGrids(4);
        IgniteEx client1 = startClientGrid(getConfiguration("client1"));
        IgniteEx client2 = startClientGrid(getConfiguration("client2"));
        IgniteEx ignite1 = grid(1);
        ((BlockingTcpCommunicationSpi) client1.configuration().getCommunicationSpi()).block();
        ((BlockingTcpCommunicationSpi) client2.configuration().getCommunicationSpi()).block();
        ((BlockingTcpCommunicationSpi) ignite1.configuration().getCommunicationSpi()).block();
        ServiceConfiguration srvcCfg = new ServiceConfiguration();
        srvcCfg.setName("testService");
        srvcCfg.setMaxPerNodeCount(1);
        srvcCfg.setService(new LongInitializedTestService(10_000));
        srvcCfg.setNodeFilter(new AlwaysTruePredicate<>());
        IgniteFuture fut = ignite0.services().deployAsync(srvcCfg);
        stopNode(client1);
        stopNode(client2);
        stopNode(ignite1);
        fut.get(TEST_FUTURE_WAIT_TIMEOUT);
        assertNotNull(ignite0.services().service("testService"));
        IgniteEx ignite3 = grid(3);
        assertNotNull(ignite3.services().service("testService"));
    } finally {
        stopAllGrids();
    }
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteFuture(org.apache.ignite.lang.IgniteFuture) Ignite(org.apache.ignite.Ignite) LongInitializedTestService(org.apache.ignite.internal.processors.service.inner.LongInitializedTestService) Test(org.junit.Test)

Example 69 with ServiceConfiguration

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

the class ServiceInfoSelfTest method configuration.

/**
 * @return Service configuration.
 */
private ServiceConfiguration configuration() {
    ServiceConfiguration cfg = new ServiceConfiguration();
    cfg.setName("testConfig");
    cfg.setTotalCount(10);
    cfg.setMaxPerNodeCount(3);
    cfg.setCacheName("testCacheName");
    cfg.setAffinityKey("testAffKey");
    cfg.setService(new TestService());
    cfg.setNodeFilter(ClusterNode::isLocal);
    return cfg;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Example 70 with ServiceConfiguration

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

the class SqlViewExporterSpiTest method testServices.

/**
 */
@Test
public void testServices() throws Exception {
    ServiceConfiguration srvcCfg = new ServiceConfiguration();
    srvcCfg.setName("service");
    srvcCfg.setMaxPerNodeCount(1);
    srvcCfg.setService(new DummyService());
    ignite0.services().deploy(srvcCfg);
    List<List<?>> srvs = execute(ignite0, "SELECT " + "  NAME, " + "  SERVICE_ID, " + "  SERVICE_CLASS, " + "  TOTAL_COUNT, " + "  MAX_PER_NODE_COUNT, " + "  CACHE_NAME, " + "  AFFINITY_KEY, " + "  NODE_FILTER, " + "  STATICALLY_CONFIGURED, " + "  ORIGIN_NODE_ID " + "FROM SYS.SERVICES");
    assertEquals(ignite0.context().service().serviceDescriptors().size(), srvs.size());
    List<?> sysView = srvs.iterator().next();
    assertEquals(srvcCfg.getName(), sysView.get(0));
    assertEquals(DummyService.class.getName(), sysView.get(2));
    assertEquals(srvcCfg.getMaxPerNodeCount(), sysView.get(4));
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) DummyService(org.apache.ignite.internal.processors.service.DummyService) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) AbstractExporterSpiTest(org.apache.ignite.internal.metric.AbstractExporterSpiTest) 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