use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class SqlViewExporterSpiTest method testServices.
/**
*/
@Test
public void testServices() throws Exception {
ServiceConfiguration srvcCfg = new ServiceConfiguration();
srvcCfg.setName("service");
srvcCfg.setMaxPerNodeCount(1);
srvcCfg.setService(new DummyService());
ignite0.services().deploy(srvcCfg);
List<List<?>> srvs = execute(ignite0, "SELECT " + " NAME, " + " SERVICE_ID, " + " SERVICE_CLASS, " + " TOTAL_COUNT, " + " MAX_PER_NODE_COUNT, " + " CACHE_NAME, " + " AFFINITY_KEY, " + " NODE_FILTER, " + " STATICALLY_CONFIGURED, " + " ORIGIN_NODE_ID " + "FROM SYS.SERVICES");
assertEquals(ignite0.context().service().serviceDescriptors().size(), srvs.size());
List<?> sysView = srvs.iterator().next();
assertEquals(srvcCfg.getName(), sysView.get(0));
assertEquals(DummyService.class.getName(), sysView.get(2));
assertEquals(srvcCfg.getMaxPerNodeCount(), sysView.get(4));
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class KillCommandsTests method doTestCancelService.
/**
* Test cancel of the service.
*
* @param startCli Client node to start service.
* @param killCli Client node to kill service.
* @param srv Server node.
* @param svcCanceler Service cancel closure.
*/
public static void doTestCancelService(IgniteEx startCli, IgniteEx killCli, IgniteEx srv, Consumer<String> svcCanceler) throws Exception {
ServiceConfiguration scfg = new ServiceConfiguration();
scfg.setName(SVC_NAME);
scfg.setMaxPerNodeCount(1);
scfg.setNodeFilter(srv.cluster().predicate());
scfg.setService(new TestServiceImpl());
startCli.services().deploy(scfg);
SystemView<ServiceView> svcView = srv.context().systemView().view(SVCS_VIEW);
SystemView<ServiceView> killCliSvcView = killCli.context().systemView().view(SVCS_VIEW);
boolean res = waitForCondition(() -> svcView.size() == 1 && killCliSvcView.size() == 1, TIMEOUT);
assertTrue(res);
TestService svc = startCli.services().serviceProxy(SVC_NAME, TestService.class, true);
assertNotNull(svc);
svcCanceler.accept(SVC_NAME);
res = waitForCondition(() -> svcView.size() == 0, TIMEOUT);
assertTrue(res);
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceContinuousQueryRedeployTest method deployService.
/**
* @param ignite Ignite.
*/
private void deployService(final Ignite ignite) {
ServiceConfiguration svcCfg = new ServiceConfiguration();
svcCfg.setService(new ManagementService());
svcCfg.setName(SERVICE_NAME);
svcCfg.setTotalCount(1);
svcCfg.setMaxPerNodeCount(1);
svcCfg.setNodeFilter((IgnitePredicate<ClusterNode>) node -> !node.isClient());
ignite.services().deploy(svcCfg);
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceDeploymentCompoundFutureSelfTest method testWaitForCompletionOnFailingFuture.
/**
* @throws Exception If failed.
*/
@Test
public void testWaitForCompletionOnFailingFuture() throws Exception {
GridServiceDeploymentCompoundFuture<IgniteUuid> compFut = new GridServiceDeploymentCompoundFuture<>();
int failingFutsNum = 2;
int completingFutsNum = 5;
Collection<GridServiceDeploymentFuture> failingFuts = new ArrayList<>(completingFutsNum);
for (int i = 0; i < failingFutsNum; i++) {
ServiceConfiguration failingCfg = config("Failed-" + i);
GridServiceDeploymentFuture<IgniteUuid> failingFut = new GridServiceDeploymentFuture<>(failingCfg, IgniteUuid.randomUuid());
failingFuts.add(failingFut);
compFut.add(failingFut);
}
List<GridFutureAdapter<Object>> futs = new ArrayList<>(completingFutsNum);
for (int i = 0; i < completingFutsNum; i++) {
GridServiceDeploymentFuture<IgniteUuid> fut = new GridServiceDeploymentFuture<>(config(String.valueOf(i)), IgniteUuid.randomUuid());
futs.add(fut);
compFut.add(fut);
}
compFut.markInitialized();
List<Exception> causes = new ArrayList<>();
for (GridServiceDeploymentFuture fut : failingFuts) {
Exception cause = new Exception("Test error");
causes.add(cause);
fut.onDone(cause);
}
try {
compFut.get(100);
fail("Should never reach here.");
} catch (IgniteFutureTimeoutCheckedException e) {
log.info("Expected exception: " + e.getMessage());
}
for (GridFutureAdapter<Object> fut : futs) fut.onDone();
try {
compFut.get();
fail("Should never reach here.");
} catch (IgniteCheckedException ce) {
log.info("Expected exception: " + ce.getMessage());
IgniteException e = U.convertException(ce);
assertTrue(e instanceof ServiceDeploymentException);
Throwable[] supErrs = e.getSuppressed();
assertEquals(failingFutsNum, supErrs.length);
for (int i = 0; i < failingFutsNum; i++) assertEquals(causes.get(i), supErrs[i].getCause());
}
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class IgniteServiceReassignmentTest method testNodeRestart2.
/**
* @throws Exception If failed.
*/
@Test
public void testNodeRestart2() throws Exception {
startGrids(3);
ServiceConfiguration svcCfg = new ServiceConfiguration();
svcCfg.setName("DummyService");
svcCfg.setTotalCount(10);
svcCfg.setMaxPerNodeCount(1);
svcCfg.setService(new DummyService());
ignite(0).services().deploy(svcCfg);
for (int i = 0; i < 3; i++) assertEquals(42, serviceProxy(ignite(i)).foo());
for (int i = 0; i < 3; i++) startGrid(i + 3);
for (int i = 0; i < 3; i++) stopGrid(i);
for (int i = 0; i < 3; i++) assertEquals(42, serviceProxy(ignite(i + 3)).foo());
}
Aggregations