Search in sources :

Example 1 with DummyService

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"));
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) DummyService(org.apache.ignite.internal.processors.service.DummyService) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) Test(org.junit.Test)

Example 2 with DummyService

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());
}
Also used : DummyService(org.apache.ignite.internal.processors.service.DummyService) IgniteServices(org.apache.ignite.IgniteServices) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 3 with DummyService

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();
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) DummyService(org.apache.ignite.internal.processors.service.DummyService) IgniteServices(org.apache.ignite.IgniteServices) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 4 with DummyService

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));
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) DummyService(org.apache.ignite.internal.processors.service.DummyService) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) CommandList(org.apache.ignite.internal.commandline.CommandList) List(java.util.List) Test(org.junit.Test)

Example 5 with DummyService

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());
}
Also used : CIX1(org.apache.ignite.internal.util.typedef.CIX1) DummyService(org.apache.ignite.internal.processors.service.DummyService) IgniteFuture(org.apache.ignite.lang.IgniteFuture) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteCallable(org.apache.ignite.lang.IgniteCallable) Ignite(org.apache.ignite.Ignite) CAX(org.apache.ignite.internal.util.typedef.CAX) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) GridCommonTest(org.apache.ignite.testframework.junits.common.GridCommonTest)

Aggregations

DummyService (org.apache.ignite.internal.processors.service.DummyService)6 Test (org.junit.Test)6 Ignite (org.apache.ignite.Ignite)3 ServiceConfiguration (org.apache.ignite.services.ServiceConfiguration)3 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 IgniteServices (org.apache.ignite.IgniteServices)2 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CompositeData (javax.management.openmbean.CompositeData)1 TabularDataSupport (javax.management.openmbean.TabularDataSupport)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 ClusterGroup (org.apache.ignite.cluster.ClusterGroup)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 CommandList (org.apache.ignite.internal.commandline.CommandList)1 AbstractExporterSpiTest (org.apache.ignite.internal.metric.AbstractExporterSpiTest)1 CAX (org.apache.ignite.internal.util.typedef.CAX)1 CIX1 (org.apache.ignite.internal.util.typedef.CIX1)1