Search in sources :

Example 51 with ServiceConfiguration

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

the class GridServiceDeploymentCompoundFutureSelfTest method testWaitForCompletionOnFailingFuture.

/**
 * @throws Exception If failed.
 */
@Test
public void testWaitForCompletionOnFailingFuture() throws Exception {
    GridServiceDeploymentCompoundFuture<IgniteUuid> compFut = new GridServiceDeploymentCompoundFuture<>();
    int failingFutsNum = 2;
    int completingFutsNum = 5;
    Collection<GridServiceDeploymentFuture> failingFuts = new ArrayList<>(completingFutsNum);
    for (int i = 0; i < failingFutsNum; i++) {
        ServiceConfiguration failingCfg = config("Failed-" + i);
        GridServiceDeploymentFuture<IgniteUuid> failingFut = new GridServiceDeploymentFuture<>(failingCfg, IgniteUuid.randomUuid());
        failingFuts.add(failingFut);
        compFut.add(failingFut);
    }
    List<GridFutureAdapter<Object>> futs = new ArrayList<>(completingFutsNum);
    for (int i = 0; i < completingFutsNum; i++) {
        GridServiceDeploymentFuture<IgniteUuid> fut = new GridServiceDeploymentFuture<>(config(String.valueOf(i)), IgniteUuid.randomUuid());
        futs.add(fut);
        compFut.add(fut);
    }
    compFut.markInitialized();
    List<Exception> causes = new ArrayList<>();
    for (GridServiceDeploymentFuture fut : failingFuts) {
        Exception cause = new Exception("Test error");
        causes.add(cause);
        fut.onDone(cause);
    }
    try {
        compFut.get(100);
        fail("Should never reach here.");
    } catch (IgniteFutureTimeoutCheckedException e) {
        log.info("Expected exception: " + e.getMessage());
    }
    for (GridFutureAdapter<Object> fut : futs) fut.onDone();
    try {
        compFut.get();
        fail("Should never reach here.");
    } catch (IgniteCheckedException ce) {
        log.info("Expected exception: " + ce.getMessage());
        IgniteException e = U.convertException(ce);
        assertTrue(e instanceof ServiceDeploymentException);
        Throwable[] supErrs = e.getSuppressed();
        assertEquals(failingFutsNum, supErrs.length);
        for (int i = 0; i < failingFutsNum; i++) assertEquals(causes.get(i), supErrs[i].getCause());
    }
}
Also used : ArrayList(java.util.ArrayList) ServiceDeploymentException(org.apache.ignite.services.ServiceDeploymentException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) ServiceDeploymentException(org.apache.ignite.services.ServiceDeploymentException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteException(org.apache.ignite.IgniteException) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 52 with ServiceConfiguration

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

the class IgniteServiceDeploymentClassLoadingDefaultMarshallerTest method serviceConfig.

/**
 * @return Service configuration.
 * @throws Exception If failed.
 */
private ServiceConfiguration serviceConfig() throws Exception {
    ServiceConfiguration srvCfg = new ServiceConfiguration();
    srvCfg.setNodeFilter(new TestNodeFilter(extClsLdrGrids));
    Class<Service> srvcCls = (Class<Service>) extClsLdr.loadClass(NOOP_SERVICE_CLS_NAME);
    Service srvc = srvcCls.newInstance();
    srvCfg.setService(srvc);
    srvCfg.setName("TestDeploymentService");
    srvCfg.setMaxPerNodeCount(1);
    return srvCfg;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Service(org.apache.ignite.services.Service)

Example 53 with ServiceConfiguration

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

the class IgniteServiceProxyTimeoutInitializedTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception {
    final IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    final ServiceConfiguration scfg = new ServiceConfiguration();
    if (igniteInstanceName.endsWith("0")) {
        scfg.setName("testService");
        scfg.setService(srvc);
        scfg.setMaxPerNodeCount(1);
        scfg.setTotalCount(1);
        scfg.setNodeFilter(new NodeFilter());
        final Map<String, String> attrs = new HashMap<>();
        attrs.put("clusterGroup", "0");
        cfg.setUserAttributes(attrs);
        cfg.setServiceConfiguration(scfg);
    }
    cfg.setMarshaller(null);
    final BinaryConfiguration binCfg = new BinaryConfiguration();
    // Despite defaults explicitly set to lower case.
    binCfg.setIdMapper(new BinaryBasicIdMapper(true));
    cfg.setBinaryConfiguration(binCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) HashMap(java.util.HashMap) BinaryBasicIdMapper(org.apache.ignite.binary.BinaryBasicIdMapper)

Example 54 with ServiceConfiguration

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

the class ServiceAuthorizationTest method serviceConfiguration.

/**
 * @return Test service configuration.
 */
private ServiceConfiguration serviceConfiguration() {
    ServiceConfiguration srvcCfg = new ServiceConfiguration();
    srvcCfg.setMaxPerNodeCount(1);
    srvcCfg.setName(TEST_SERVICE_NAME);
    srvcCfg.setService(new TestServiceImpl());
    return srvcCfg;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Example 55 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testCancelAllClashingNames.

/**
 * @throws Exception If failed.
 */
@Test
public void testCancelAllClashingNames() 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);
    List<String> names = new ArrayList<>();
    for (ServiceConfiguration cfg : cfgs) names.add(cfg.getName());
    int batchSize = 5;
    int from = 0;
    while (from < NUM_SERVICES) {
        int to = Math.min(NUM_SERVICES, from + batchSize);
        List<String> toCancel = new ArrayList<>(names.subList(from, to));
        toCancel.add(toCancel.get(0));
        client.services().cancelAll(toCancel);
        from = to;
    }
    assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList());
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) ArrayList(java.util.ArrayList) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) 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