use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorAbstractSelfTest method testDeploySingletonOld.
/**
* @throws Exception If failed.
*/
@Test
public void testDeploySingletonOld() throws Exception {
Ignite g = randomGrid();
String name = "serviceSingletonOld";
CountDownLatch latch = new CountDownLatch(1);
DummyService.exeLatch(name, latch);
IgniteServices svcs = g.services().withAsync();
svcs.deployClusterSingleton(name, new DummyService());
IgniteFuture<?> fut = svcs.future();
info("Deployed service: " + name);
fut.get();
info("Finished waiting for service future: " + name);
latch.await();
assertEquals(name, 1, DummyService.started(name));
assertEquals(name, 0, DummyService.cancelled(name));
checkCount(name, g.services().serviceDescriptors(), 1);
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorAbstractSelfTest method testSameConfigurationOld.
/**
* @throws Exception If failed.
*/
@Test
public void testSameConfigurationOld() 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.deployClusterSingleton(name, new DummyService());
IgniteFuture<?> fut2 = svcs2.future();
info("Deployed service: " + name);
fut1.get();
info("Finished waiting for service future1: " + name);
// This must succeed without exception because configuration is the same.
fut2.get();
info("Finished waiting for service future2: " + name);
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class GridServiceProcessorAbstractSelfTest method testDifferentConfiguration.
/**
* @throws Exception If failed.
*/
@Test
public void testDifferentConfiguration() throws Exception {
String name = "dupService";
IgniteServices svcs1 = randomGrid().services();
IgniteServices svcs2 = randomGrid().services();
IgniteFuture<?> fut1 = svcs1.deployClusterSingletonAsync(name, new DummyService());
IgniteFuture<?> fut2 = svcs2.deployNodeSingletonAsync(name, new DummyService());
info("Deployed service: " + name);
try {
fut1.get();
info("Finished waiting for service future: " + name);
fut2.get();
fail("Failed to receive mismatching configuration exception.");
} catch (IgniteException e) {
info("Received mismatching configuration exception: " + e.getMessage());
}
}
use of org.apache.ignite.IgniteServices 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.IgniteServices 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");
}
}
Aggregations