use of org.apache.ignite.services.Service 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;
}
use of org.apache.ignite.services.Service in project ignite by apache.
the class GridServiceProcessorMultiNodeSelfTest method testDeployOnEachProjectionNodeUpdateTopology.
/**
* @throws Exception If failed.
*/
@Test
public void testDeployOnEachProjectionNodeUpdateTopology() throws Exception {
// Prestart client node.
Ignite client = startClientGrid("client", getConfiguration("client"));
try {
final String name = "serviceOnEachProjectionNodeUpdateTopology";
IgniteEx g = randomGrid();
int prestartedSrvcs = 1;
CountDownLatch latch = new CountDownLatch(prestartedSrvcs);
DummyService.exeLatch(name, latch);
IgniteServices svcs = g.services(g.cluster().forClients());
IgniteFuture<?> fut = svcs.deployNodeSingletonAsync(name, new DummyService());
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, prestartedSrvcs, DummyService.started(name));
assertEquals(name, 0, DummyService.cancelled(name));
int servers = 2;
int clients = 2;
latch = new CountDownLatch(clients);
DummyService.exeLatch(name, latch);
startExtraNodes(servers, clients);
try {
latch.await();
waitForDeployment(name, clients);
// 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, clients + prestartedSrvcs, DummyService.started(name) - DummyService.cancelled(name));
checkCount(name, g, clients + prestartedSrvcs);
} finally {
stopExtraNodes(servers + clients);
}
} finally {
stopGrid("client");
}
}
use of org.apache.ignite.services.Service in project ignite by apache.
the class GridServiceProcessorMultiNodeSelfTest method testDeployOnEachNodeButClientUpdateTopology.
/**
* @throws Exception If failed.
*/
@Test
public void testDeployOnEachNodeButClientUpdateTopology() throws Exception {
// Prestart client node.
Ignite client = startClientGrid("client", getConfiguration("client"));
try {
final String name = "serviceOnEachNodeButClientUpdateTopology";
IgniteEx g = randomGrid();
CountDownLatch latch = new CountDownLatch(nodeCount());
DummyService.exeLatch(name, latch);
IgniteServices svcs = g.services();
IgniteFuture<?> fut = svcs.deployNodeSingletonAsync(name, new DummyService());
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, nodeCount(), DummyService.started(name));
assertEquals(name, 0, DummyService.cancelled(name));
int servers = 2;
latch = new CountDownLatch(servers);
DummyService.exeLatch(name, latch);
int clients = 2;
startExtraNodes(servers, clients);
try {
latch.await();
waitForDeployment(name, servers);
// 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, nodeCount() + servers, DummyService.started(name) - DummyService.cancelled(name));
checkCount(name, g, nodeCount() + servers);
} finally {
stopExtraNodes(servers + clients);
}
} finally {
stopGrid("client");
}
}
use of org.apache.ignite.services.Service 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.Service in project ignite by apache.
the class GridServiceProcessorProxySelfTest method testSingletonProxyInvocation.
/**
* @throws Exception If failed.
*/
@Test
public void testSingletonProxyInvocation() throws Exception {
final String name = "testProxyInvocationFromSeveralNodes";
final Ignite ignite = grid(0);
ignite.services(ignite.cluster().forLocal()).deployClusterSingleton(name, new MapServiceImpl<String, Integer>());
for (int i = 1; i < nodeCount(); i++) {
MapService<Integer, String> svc = grid(i).services().serviceProxy(name, MapService.class, false, 1_000L);
// Make sure service is a proxy.
assertFalse(svc instanceof Service);
svc.put(i, Integer.toString(i));
}
assertEquals(nodeCount() - 1, ignite.services().serviceProxy(name, MapService.class, false).size());
}
Aggregations