use of org.apache.ignite.internal.processors.service.DummyService in project ignite by apache.
the class JmxExporterSpiTest method testServices.
/**
*/
@Test
public void testServices() throws Exception {
ServiceConfiguration srvcCfg = new ServiceConfiguration();
srvcCfg.setName("service");
srvcCfg.setMaxPerNodeCount(1);
srvcCfg.setService(new DummyService());
ignite.services().deploy(srvcCfg);
TabularDataSupport srvs = systemView(SVCS_VIEW);
assertEquals(ignite.context().service().serviceDescriptors().size(), srvs.size());
CompositeData sysView = srvs.get(new Object[] { 0 });
assertEquals(srvcCfg.getName(), sysView.get("name"));
assertEquals(srvcCfg.getMaxPerNodeCount(), sysView.get("maxPerNodeCount"));
assertEquals(DummyService.class.getName(), sysView.get("serviceClass"));
}
use of org.apache.ignite.internal.processors.service.DummyService in project ignite by apache.
the class IgniteClientReconnectServicesTest method testReconnect.
/**
* @throws Exception If failed.
*/
@Test
public void testReconnect() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
IgniteServices services = client.services();
services.deployClusterSingleton("testReconnect", new TestServiceImpl());
TestService srvc = services.serviceProxy("testReconnect", TestService.class, false);
assertNotNull(srvc);
long topVer = grid(0).cluster().topologyVersion();
assertEquals((Object) topVer, srvc.test());
Ignite srv = ignite(0);
reconnectClientNode(client, srv, null);
CountDownLatch latch = new CountDownLatch(1);
DummyService.exeLatch("testReconnect2", latch);
services.deployClusterSingleton("testReconnect2", new DummyService());
assertTrue(latch.await(5000, TimeUnit.MILLISECONDS));
assertEquals((Object) (topVer + 2), srvc.test());
}
use of org.apache.ignite.internal.processors.service.DummyService 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();
}
}
use of org.apache.ignite.internal.processors.service.DummyService in project ignite by apache.
the class SystemViewCommandTest method testServices.
/**
*/
@Test
public void testServices() {
ServiceConfiguration srvcCfg = new ServiceConfiguration();
srvcCfg.setName("service");
srvcCfg.setMaxPerNodeCount(1);
srvcCfg.setService(new DummyService());
ignite0.services().deploy(srvcCfg);
List<List<String>> srvsView = systemView(ignite0, SVCS_VIEW);
assertEquals(1, srvsView.size());
List<String> sysView = srvsView.get(0);
// name
assertEquals(srvcCfg.getName(), sysView.get(1));
// serviceClass
assertEquals(DummyService.class.getName(), sysView.get(2));
// maxPerNodeCount
assertEquals(Integer.toString(srvcCfg.getMaxPerNodeCount()), sysView.get(6));
}
use of org.apache.ignite.internal.processors.service.DummyService in project ignite by apache.
the class GridJobServicesAddNodeTest method testServiceDescriptorsJob.
/**
* @throws Exception If test failed.
*/
@Test
public void testServiceDescriptorsJob() throws Exception {
final int tasks = 5000;
final int threads = 10;
final Ignite ignite1 = grid(1);
final CountDownLatch latch = new CountDownLatch(tasks);
final AtomicInteger jobsCnt = new AtomicInteger();
final AtomicInteger resCnt = new AtomicInteger();
ignite1.services().deployClusterSingleton("jobsSvc", new DummyService());
GridTestUtils.runMultiThreadedAsync(new CAX() {
@Override
public void applyx() throws IgniteCheckedException {
while (true) {
int cnt = jobsCnt.incrementAndGet();
if (cnt > 5000)
break;
IgniteCallable<Boolean> job;
job = new ServiceDescriptorsJob();
IgniteFuture<Boolean> fut = ignite1.compute().callAsync(job);
if (cnt % LOG_MOD == 0)
X.println("Submitted jobs: " + cnt);
fut.listen(new CIX1<IgniteFuture<Boolean>>() {
@Override
public void applyx(IgniteFuture<Boolean> f) {
try {
assert f.get();
long cnt = resCnt.incrementAndGet();
if (cnt % LOG_MOD == 0)
X.println("Results count: " + cnt);
} finally {
latch.countDown();
}
}
});
IgniteUtils.sleep(5);
}
}
}, threads, "TEST-THREAD");
int additionalNodesStarted = 0;
while (!latch.await(threads, TimeUnit.MILLISECONDS)) {
if (additionalNodesStarted++ <= MAX_ADD_NODES) {
startGrid(2 + additionalNodesStarted);
}
}
assertEquals("Jobs cnt != Results cnt", jobsCnt.get() - threads, resCnt.get());
}
Aggregations