Search in sources :

Example 11 with ServiceConfiguration

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

the class GridServiceMetricsTest method testServiceMetricsEnabledDisabled.

/**
 * Checks service metrics are enabled / disabled properly.
 */
@Test
public void testServiceMetricsEnabledDisabled() throws Exception {
    IgniteEx ignite = startGrid();
    ServiceConfiguration srvcCfg = serviceCfg(MyServiceFactory.create(), 0, 1);
    srvcCfg.setStatisticsEnabled(false);
    ignite.services().deploy(srvcCfg);
    assertNull(METRICS_MUST_NOT_BE_CREATED, findMetricRegistry(ignite.context().metric(), SRVC_NAME));
    ignite.services().cancel(SRVC_NAME);
    srvcCfg.setStatisticsEnabled(true);
    ignite.services().deploy(srvcCfg);
    assertNotNull("Service metric registry must be created.", findMetricRegistry(ignite.context().metric(), SRVC_NAME));
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 12 with ServiceConfiguration

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

the class ServiceStaticConfigTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setAuthenticationEnabled(true);
    cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
    ServiceConfiguration srvcCfg = new ServiceConfiguration();
    srvcCfg.setName(SVC_NAME);
    srvcCfg.setMaxPerNodeCount(1);
    srvcCfg.setService(new CounterService());
    cfg.setServiceConfiguration(srvcCfg);
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Example 13 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method deployAllFail.

/**
 * @param async If {@code true}, then asynchronous method of deployment will be performed.
 * @throws Exception If failed.
 */
private void deployAllFail(boolean async) throws Exception {
    Ignite client = grid(CLIENT_NODE_NAME);
    CountDownLatch latch = new CountDownLatch(NUM_SERVICES - 1);
    List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
    subscribeExeLatch(cfgs, latch);
    ServiceConfiguration failingCfg = cfgs.get(cfgs.size() - 1);
    failingCfg.setName(null);
    assertFailingDeploy(client, async, cfgs, failingCfg);
    assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
    assertDeployedServices(client, cfgs.subList(0, cfgs.size() - 1));
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 14 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testDeployAll.

/**
 * @throws Exception If failed.
 */
@Test
public void testDeployAll() throws Exception {
    Ignite client = grid(CLIENT_NODE_NAME);
    CountDownLatch latch = new CountDownLatch(NUM_SERVICES);
    List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
    subscribeExeLatch(cfgs, latch);
    client.services().deployAll(cfgs);
    assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
    assertDeployedServices(client, cfgs);
}
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 15 with ServiceConfiguration

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

the class GridServiceProcessorBatchDeploySelfTest method testCancelAllAsync.

/**
 * @throws Exception If failed.
 */
@Test
public void testCancelAllAsync() 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);
    IgniteFuture<Void> fut = client.services().cancelAllAsync();
    fut.get();
    assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList());
}
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)

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