use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorAbstractSelfTest method testDeployOnEachNodeOld.
/**
* @throws Exception If failed.
*/
@Test
public void testDeployOnEachNodeOld() throws Exception {
Ignite g = randomGrid();
String name = "serviceOnEachNodeOld";
CountDownLatch latch = new CountDownLatch(nodeCount());
DummyService.exeLatch(name, latch);
IgniteServices svcs = g.services().withAsync();
svcs.deployNodeSingleton(name, new DummyService());
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());
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorStopSelfTest method testStopDuringDeployment.
/**
* @throws Exception If failed.
*/
@Test
public void testStopDuringDeployment() throws Exception {
final CountDownLatch depLatch = new CountDownLatch(1);
final CountDownLatch finishLatch = new CountDownLatch(1);
final Ignite ignite = startGrid(0);
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
IgniteServices svcs = ignite.services();
IgniteFuture f = svcs.deployClusterSingletonAsync("myClusterSingletonService", new TestServiceImpl());
depLatch.countDown();
try {
f.get();
} catch (IgniteException ignored) {
finishLatch.countDown();
} finally {
finishLatch.countDown();
}
return null;
}
}, "deploy-thread");
depLatch.await();
Ignition.stopAll(true);
boolean wait = finishLatch.await(15, TimeUnit.SECONDS);
if (!wait)
U.dumpThreads(log);
assertTrue("Deploy future isn't completed", wait);
fut.get();
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class IgniteServiceDynamicCachesSelfTest method testDeployCalledBeforeCacheStart.
/**
* @throws Exception If failed.
*/
@Test
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void testDeployCalledBeforeCacheStart() throws Exception {
String cacheName = "cache";
CacheConfiguration ccfg = new CacheConfiguration(cacheName);
ccfg.setBackups(1);
IgniteEx ig = grid(0);
final IgniteServices svcs = ig.services();
final String svcName = "myService";
ig.createCache(ccfg);
Object key = primaryKey(ig.cache(cacheName));
ig.destroyCache(cacheName);
awaitPartitionMapExchange();
GridTestUtils.assertThrowsWithCause(() -> {
svcs.deployKeyAffinitySingleton(svcName, new TestService(), cacheName, key);
return null;
}, ServiceDeploymentException.class);
ig.createCache(ccfg);
svcs.deployKeyAffinitySingleton(svcName, new TestService(), cacheName, key);
try {
boolean res = GridTestUtils.waitForCondition(new PA() {
@Override
public boolean apply() {
return svcs.service(svcName) != null;
}
}, 10 * 1000);
assertTrue("Service was not deployed", res);
info("stopping cache: " + cacheName);
ig.destroyCache(cacheName);
res = GridTestUtils.waitForCondition(new PA() {
@Override
public boolean apply() {
return svcs.service(svcName) == null;
}
}, 10 * 1000);
assertTrue("Service was not undeployed", res);
} finally {
ig.services().cancelAll();
ig.destroyCache(cacheName);
}
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorAbstractSelfTest method testDeployMultiple1Old.
/**
* @throws Exception If failed.
*/
@Test
public void testDeployMultiple1Old() throws Exception {
Ignite g = randomGrid();
String name = "serviceMultiple1Old";
CountDownLatch latch = new CountDownLatch(nodeCount() * 2);
DummyService.exeLatch(name, latch);
IgniteServices svcs = g.services().withAsync();
svcs.deployMultiple(name, new DummyService(), nodeCount() * 2, 3);
IgniteFuture<?> fut = svcs.future();
info("Deployed service: " + name);
fut.get();
info("Finished waiting for service future: " + name);
latch.await();
assertEquals(name, nodeCount() * 2, DummyService.started(name));
assertEquals(name, 0, DummyService.cancelled(name));
checkCount(name, g.services().serviceDescriptors(), nodeCount() * 2);
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorAbstractSelfTest method testDifferentConfigurationOld.
/**
* @throws Exception If failed.
*/
@Test
public void testDifferentConfigurationOld() throws Exception {
String name = "dupServiceOld";
IgniteServices svcs1 = randomGrid().services().withAsync();
IgniteServices svcs2 = randomGrid().services().withAsync();
svcs1.deployClusterSingleton(name, new DummyService());
IgniteFuture<?> fut1 = svcs1.future();
svcs2.deployNodeSingleton(name, new DummyService());
IgniteFuture<?> fut2 = svcs2.future();
Exception err1 = null;
try {
fut1.get();
} catch (ServiceDeploymentException e) {
if (e.getMessage().contains("Failed to deploy some services."))
err1 = e;
else
throw new IllegalStateException("An unexpeted error caught while deploying service.", e);
}
try {
fut2.get();
if (err1 == null)
fail("Failed to receive mismatching configuration exception.");
} catch (Exception e) {
if (!e.getMessage().contains("Failed to deploy some service"))
throw new IllegalStateException("An unexpeted error caught while concurrent deploying.", e);
}
}
Aggregations