Search in sources :

Example 46 with ServiceConfiguration

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

the class ServiceReassignmentFunctionSelfTest method testClusterSingleton.

/**
 * @throws Exception In case of an error.
 */
@Test
public void testClusterSingleton() throws Exception {
    ServiceConfiguration cfg = new ServiceConfiguration();
    cfg.setName(TEST_SERVICE_NAME);
    cfg.setTotalCount(1);
    runTestReassignFunction(IgniteUuid.randomUuid(), cfg, null);
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Test(org.junit.Test)

Example 47 with ServiceConfiguration

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

the class ServiceReassignmentFunctionSelfTest method testNodeSingletonWithOldTop.

/**
 * @throws Exception In case of an error.
 */
@Test
public void testNodeSingletonWithOldTop() throws Exception {
    ServiceConfiguration cfg = new ServiceConfiguration();
    cfg.setName(TEST_SERVICE_NAME);
    cfg.setMaxPerNodeCount(1);
    IgniteUuid srvcId = IgniteUuid.randomUuid();
    TreeMap<UUID, Integer> oldTop = new TreeMap<>();
    for (ClusterNode node : nodes) oldTop.put(node.id(), 1);
    runTestReassignFunction(srvcId, cfg, oldTop);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteUuid(org.apache.ignite.lang.IgniteUuid) UUID(java.util.UUID) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 48 with ServiceConfiguration

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

the class IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest method serviceConfig.

/**
 * @param firstGrp First group flag.
 * @return Service configuration.
 * @throws Exception If failed.
 */
private ServiceConfiguration serviceConfig(final boolean firstGrp) throws Exception {
    ServiceConfiguration srvCfg = new ServiceConfiguration();
    srvCfg.setNodeFilter(new TestNodeFilter(firstGrp ? grp1 : grp2));
    Class<Service> srvcCls;
    if (firstGrp)
        srvcCls = (Class<Service>) extClsLdr1.loadClass(NOOP_SERVICE_CLS_NAME);
    else
        srvcCls = (Class<Service>) extClsLdr2.loadClass(NOOP_SERVICE_2_CLS_NAME);
    Service srvc = srvcCls.newInstance();
    srvCfg.setService(srvc);
    srvCfg.setName("TestDeploymentService" + (firstGrp ? 1 : 2));
    srvCfg.setMaxPerNodeCount(1);
    return srvCfg;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Service(org.apache.ignite.services.Service)

Example 49 with ServiceConfiguration

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

the class ReliabilityTest method testServiceMethodInvocationAfterFailover.

/**
 * Test that client can invoke service method with externalizable parameter after
 * cluster failover.
 */
@Test
public void testServiceMethodInvocationAfterFailover() throws Exception {
    PersonExternalizable person = new PersonExternalizable("Person 1");
    ServiceConfiguration testServiceConfig = new ServiceConfiguration();
    testServiceConfig.setName(SERVICE_NAME);
    testServiceConfig.setService(new TestService());
    testServiceConfig.setTotalCount(1);
    Ignite ignite = null;
    IgniteClient client = null;
    try {
        // Initialize cluster and client
        ignite = startGrid(getConfiguration().setServiceConfiguration(testServiceConfig));
        client = startClient(ignite);
        TestServiceInterface svc = client.services().serviceProxy(SERVICE_NAME, TestServiceInterface.class);
        // Invoke the service method with Externalizable parameter for the first time.
        // This triggers registration of the PersonExternalizable type in the cluter.
        String result = svc.testMethod(person);
        assertEquals("testMethod(PersonExternalizable person): " + person, result);
        // Kill the cluster node, clean up the working directory (with cached types)
        // and drop the client connection.
        ignite.close();
        U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), DataStorageConfiguration.DFLT_MARSHALLER_PATH, false));
        dropAllThinClientConnections();
        // Invoke the service.
        GridTestUtils.assertThrowsWithCause(() -> svc.testMethod(person), ClientConnectionException.class);
        // Restore the cluster and redeploy the service.
        ignite = startGrid(getConfiguration().setServiceConfiguration(testServiceConfig));
        // Invoke the service method with Externalizable parameter once again.
        // This should restore the client connection and trigger registration of the
        // PersonExternalizable once again.
        result = svc.testMethod(person);
        assertEquals("testMethod(PersonExternalizable person): " + person, result);
    } finally {
        if (ignite != null) {
            try {
                ignite.close();
            } catch (Throwable ignore) {
            }
        }
        if (client != null) {
            try {
                client.close();
            } catch (Throwable ignore) {
            }
        }
    }
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Ignite(org.apache.ignite.Ignite) Test(org.junit.Test) AbstractThinClientTest(org.apache.ignite.internal.client.thin.AbstractThinClientTest)

Example 50 with ServiceConfiguration

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

the class GridServiceContinuousQueryRedeployTest method deployService.

/**
 * @param ignite Ignite.
 */
private void deployService(final Ignite ignite) {
    ServiceConfiguration svcCfg = new ServiceConfiguration();
    svcCfg.setService(new ManagementService());
    svcCfg.setName(SERVICE_NAME);
    svcCfg.setTotalCount(1);
    svcCfg.setMaxPerNodeCount(1);
    svcCfg.setNodeFilter((IgnitePredicate<ClusterNode>) node -> !node.isClient());
    ignite.services().deploy(svcCfg);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) Callable(java.util.concurrent.Callable) Test(org.junit.Test) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) IgniteCache(org.apache.ignite.IgniteCache) ArrayList(java.util.ArrayList) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) List(java.util.List) CacheEntryEvent(javax.cache.event.CacheEntryEvent) ClusterNode(org.apache.ignite.cluster.ClusterNode) ServiceContext(org.apache.ignite.services.ServiceContext) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException) QueryCursor(org.apache.ignite.cache.query.QueryCursor) Service(org.apache.ignite.services.Service) CacheEntryUpdatedListener(javax.cache.event.CacheEntryUpdatedListener) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Collections(java.util.Collections) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

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