use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method testClashingNames.
/**
* @throws Exception If failed.
*/
@Test
public void testClashingNames() 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);
List<ServiceConfiguration> fstBatch = cfgs.subList(0, NUM_SERVICES / 2);
List<ServiceConfiguration> sndBatch = cfgs.subList(NUM_SERVICES / 4, NUM_SERVICES);
IgniteFuture<Void> fstFut = client.services().deployAllAsync(fstBatch);
IgniteFuture<Void> sndFut = client.services().deployAllAsync(sndBatch);
fstFut.get();
sndFut.get();
assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
assertDeployedServices(client, cfgs);
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method testClashingNamesFail.
/**
* @throws Exception If failed.
*/
@Test
public void testClashingNamesFail() throws Exception {
Ignite client = grid(CLIENT_NODE_NAME);
List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
int numDepSvcs = NUM_SERVICES - 1;
CountDownLatch latch = new CountDownLatch(numDepSvcs);
List<ServiceConfiguration> fstBatch = cfgs.subList(0, NUM_SERVICES / 2);
List<ServiceConfiguration> sndBatch = cfgs.subList(NUM_SERVICES / 4, NUM_SERVICES);
subscribeExeLatch(cfgs, latch);
IgniteFuture<Void> fut = client.services().deployAllAsync(fstBatch);
ServiceConfiguration failingCfg = cfgs.get(NUM_SERVICES - 1);
failingCfg.setName(null);
assertFailingDeploy(client, false, sndBatch, failingCfg);
fut.get();
assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
assertDeployedServices(client, cfgs.subList(0, numDepSvcs));
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorMultiNodeSelfTest method testDeployLimits.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("deprecation")
@Test
public void testDeployLimits() throws Exception {
final String name = "serviceWithLimitsUpdateTopology";
IgniteEx g = randomGrid();
final int totalInstances = nodeCount() + 1;
CountDownLatch latch = new CountDownLatch(nodeCount());
DummyService.exeLatch(name, latch);
ServiceConfiguration srvcCfg = new ServiceConfiguration();
srvcCfg.setName(name);
srvcCfg.setMaxPerNodeCount(1);
srvcCfg.setTotalCount(totalInstances);
srvcCfg.setService(new DummyService());
IgniteServices svcs = g.services().withAsync();
svcs.deploy(srvcCfg);
IgniteFuture<?> fut = svcs.future();
info("Deployed service: " + name);
fut.get();
info("Finished waiting for service future: " + name);
latch.await();
assertEquals(name, nodeCount(), DummyService.started(name));
assertEquals(name, 0, DummyService.cancelled(name));
checkCount(name, g.services().serviceDescriptors(), nodeCount());
latch = new CountDownLatch(1);
DummyService.exeLatch(name, latch);
int extraNodes = 2;
startExtraNodes(extraNodes);
try {
latch.await();
waitForDeployment(name, totalInstances);
// Since we start extra nodes, there may be extra start and cancel events,
// so we check only the difference between start and cancel and
// not start and cancel events individually.
assertEquals(name, totalInstances, DummyService.started(name) - DummyService.cancelled(name));
checkCount(name, g, totalInstances);
} finally {
stopExtraNodes(extraNodes);
}
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorMultiNodeSelfTest method testDeployOnEachNodeUpdateTopology.
/**
* @throws Exception If failed.
*/
@Test
public void testDeployOnEachNodeUpdateTopology() throws Exception {
// Prestart client node.
Ignite client = startClientGrid("client", getConfiguration("client"));
try {
final String name = "serviceOnEachNodeUpdateTopology";
IgniteEx g = randomGrid();
final int prestartedNodes = nodeCount() + 1;
CountDownLatch latch = new CountDownLatch(prestartedNodes);
DummyService.exeLatch(name, latch);
ServiceConfiguration srvcCfg = new ServiceConfiguration();
srvcCfg.setNodeFilter(new CacheConfiguration.IgniteAllNodesPredicate());
srvcCfg.setName(name);
srvcCfg.setMaxPerNodeCount(1);
srvcCfg.setService(new DummyService());
IgniteServices svcs = g.services();
IgniteFuture<?> fut = svcs.deployAsync(srvcCfg);
info("Deployed service: " + name);
fut.get();
info("Finished waiting for service future: " + name);
latch.await();
// Ensure service is deployed
assertNotNull(client.services().serviceProxy(name, Service.class, false, 2000));
assertEquals(name, prestartedNodes, DummyService.started(name));
assertEquals(name, 0, DummyService.cancelled(name));
int servers = 2;
int clients = 2;
int extraNodes = servers + clients;
latch = new CountDownLatch(extraNodes);
DummyService.exeLatch(name, latch);
startExtraNodes(servers, clients);
try {
latch.await();
waitForDeployment(name, prestartedNodes + extraNodes);
// Since we start extra nodes, there may be extra start and cancel events,
// so we check only the difference between start and cancel and
// not start and cancel events individually.
assertEquals(name, prestartedNodes + extraNodes, DummyService.started(name) - DummyService.cancelled(name));
checkCount(name, g, prestartedNodes + extraNodes);
} finally {
stopExtraNodes(extraNodes);
}
} finally {
stopGrid("client");
}
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorMultiNodeConfigSelfTest method services.
/**
* {@inheritDoc}
*/
@Override
protected ServiceConfiguration[] services() {
ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setName(CLUSTER_SINGLE);
cfg.setMaxPerNodeCount(1);
cfg.setTotalCount(1);
cfg.setService(new DummyService());
List<ServiceConfiguration> cfgs = new ArrayList<>();
cfgs.add(cfg);
cfg = new ServiceConfiguration();
cfg.setName(NODE_SINGLE_BUT_CLIENT);
cfg.setMaxPerNodeCount(1);
cfg.setService(new DummyService());
cfgs.add(cfg);
cfg = new ServiceConfiguration();
cfg.setName(AFFINITY);
cfg.setCacheName(CACHE_NAME);
cfg.setAffinityKey(AFFINITY_KEY);
cfg.setMaxPerNodeCount(1);
cfg.setTotalCount(1);
cfg.setService(new AffinityService(AFFINITY_KEY));
cfgs.add(cfg);
cfg = new ServiceConfiguration();
cfg.setName(NODE_SINGLE);
cfg.setMaxPerNodeCount(1);
cfg.setNodeFilter(new CacheConfiguration.IgniteAllNodesPredicate());
cfg.setService(new DummyService());
cfgs.add(cfg);
cfg = new ServiceConfiguration();
cfg.setName(NODE_SINGLE_WITH_LIMIT);
cfg.setMaxPerNodeCount(1);
cfg.setTotalCount(nodeCount() + 1);
cfg.setService(new DummyService());
cfgs.add(cfg);
return cfgs.toArray(new ServiceConfiguration[cfgs.size()]);
}
Aggregations