use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorAbstractSelfTest method testDeployMultiple2Old.
/**
* @throws Exception If failed.
*/
@Test
public void testDeployMultiple2Old() throws Exception {
Ignite g = randomGrid();
String name = "serviceMultiple2Old";
int cnt = nodeCount() * 2 + 1;
CountDownLatch latch = new CountDownLatch(cnt);
DummyService.exeLatch(name, latch);
IgniteServices svcs = g.services().withAsync();
svcs.deployMultiple(name, new DummyService(), cnt, 3);
IgniteFuture<?> fut = svcs.future();
info("Deployed service: " + name);
fut.get();
info("Finished waiting for service future: " + name);
latch.await();
assertEquals(name, cnt, DummyService.started(name));
assertEquals(name, 0, DummyService.cancelled(name));
checkCount(name, g.services().serviceDescriptors(), cnt);
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class IgniteServiceConfigVariationsFullApiTest method testDeploy.
/**
* Tests deployment.
*
* @throws Exception If failed.
*/
@Test
public void testDeploy() throws Exception {
runInAllDataModes(new ServiceTestRunnable(false, new DeployClosure() {
@Override
public void run(IgniteServices services, String svcName, TestService svc) throws Exception {
services.deployClusterSingleton(svcName, (Service) svc);
ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setName(svcName);
cfg.setService((Service) svc);
cfg.setTotalCount(1);
cfg.setMaxPerNodeCount(1);
cfg.setNodeFilter(services.clusterGroup().predicate());
services.deploy(cfg);
waitForServiceDeploymentIfNeeded(services, svcName);
}
}));
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorMultiNodeSelfTest method testSingletonUpdateTopology.
/**
* @throws Exception If failed.
*/
@Test
public void testSingletonUpdateTopology() throws Exception {
String name = "serviceSingletonUpdateTopology";
IgniteEx g = randomGrid();
CountDownLatch latch = new CountDownLatch(1);
DummyService.exeLatch(name, latch);
IgniteServices svcs = g.services();
IgniteFuture<?> fut = svcs.deployClusterSingletonAsync(name, new DummyService());
info("Deployed service: " + name);
fut.get();
info("Finished waiting for service future: " + name);
latch.await();
Assert.assertEquals(name, 1, DummyService.started(name));
Assert.assertEquals(name, 0, DummyService.cancelled(name));
int nodeCnt = 2;
startExtraNodes(nodeCnt);
try {
Assert.assertEquals(name, 1, DummyService.started(name));
Assert.assertEquals(name, 0, DummyService.cancelled(name));
info(">>> Passed checks.");
checkCount(name, g, 1);
} finally {
stopExtraNodes(nodeCnt);
}
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorMultiNodeSelfTest method testAffinityDeployUpdateTopology.
/**
* @throws Exception If failed.
*/
@Test
public void testAffinityDeployUpdateTopology() throws Exception {
IgniteEx g = randomGrid();
final Integer affKey = 1;
// Store a cache key.
g.cache(CACHE_NAME).put(affKey, affKey.toString());
final String name = "serviceAffinityUpdateTopology";
IgniteServices svcs = g.services();
IgniteFuture<?> fut = svcs.deployKeyAffinitySingletonAsync(name, new AffinityService(affKey), CACHE_NAME, affKey);
info("Deployed service: " + name);
fut.get();
info("Finished waiting for service future: " + name);
checkCount(name, g.services().serviceDescriptors(), 1);
int nodeCnt = 2;
startExtraNodes(nodeCnt);
try {
checkCount(name, g, 1);
} finally {
stopExtraNodes(nodeCnt);
}
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridMarshallerAbstractTest method testServices.
/**
* @throws Exception If failed.
*/
@Test
public void testServices() throws Exception {
IgniteConfiguration cfg = optimize(getConfiguration("g1"));
try (Ignite g1 = G.start(cfg)) {
IgniteServices services = grid().services(grid().cluster().forNode(g1.cluster().localNode()));
services.deployNodeSingleton("test", new DummyService());
GridMarshallerTestBean inBean = newTestBean(services);
byte[] buf = marshal(inBean);
GridMarshallerTestBean outBean = unmarshal(buf);
assert inBean.getObjectField() != null;
assert outBean.getObjectField() != null;
assert inBean.getObjectField().getClass().equals(IgniteServicesImpl.class);
assert outBean.getObjectField().getClass().equals(IgniteServicesImpl.class);
assert inBean != outBean;
assert inBean.equals(outBean);
ClusterGroup inPrj = services.clusterGroup();
ClusterGroup outPrj = ((IgniteServices) outBean.getObjectField()).clusterGroup();
assert inPrj.getClass().equals(outPrj.getClass());
assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes());
outBean.checkNullResources();
}
}
Aggregations