Search in sources :

Example 1 with ServiceDescriptor

use of org.apache.ignite.services.ServiceDescriptor in project ignite by apache.

the class ClosureServiceClientsNodesTest method testClientService.

/**
     * @throws Exception If failed.
     */
public void testClientService() throws Exception {
    UUID clientNodeId = grid(0).cluster().localNode().id();
    for (int i = 0; i < NODES_CNT; i++) {
        log.info("Iteration: " + i);
        final Ignite ignite = grid(i);
        ignite.services(ignite.cluster().forClients()).deployNodeSingleton(SINGLETON_NAME, new TestService());
        final ClusterGroup grp = ignite.cluster();
        assertEquals(NODES_CNT, grp.nodes().size());
        GridTestUtils.waitForCondition(new GridAbsPredicate() {

            @Override
            public boolean apply() {
                return ignite.services(grp).serviceDescriptors().size() == 1;
            }
        }, 5000);
        Collection<ServiceDescriptor> srvDscs = ignite.services(grp).serviceDescriptors();
        assertEquals(1, srvDscs.size());
        Map<UUID, Integer> nodesMap = F.first(srvDscs).topologySnapshot();
        assertEquals(1, nodesMap.size());
        for (Map.Entry<UUID, Integer> nodeInfo : nodesMap.entrySet()) {
            assertEquals(clientNodeId, nodeInfo.getKey());
            assertEquals(1, nodeInfo.getValue().intValue());
        }
        ignite.services().cancelAll();
    }
}
Also used : GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) ServiceDescriptor(org.apache.ignite.services.ServiceDescriptor) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) Map(java.util.Map)

Example 2 with ServiceDescriptor

use of org.apache.ignite.services.ServiceDescriptor in project ignite by apache.

the class ClosureServiceClientsNodesTest method testDefaultService.

/**
     * @throws Exception If failed.
     */
public void testDefaultService() throws Exception {
    UUID clientNodeId = grid(0).cluster().localNode().id();
    for (int i = 0; i < NODES_CNT; i++) {
        log.info("Iteration: " + i);
        final Ignite ignite = grid(i);
        ignite.services().deployNodeSingleton(SINGLETON_NAME, new TestService());
        final ClusterGroup grp = ignite.cluster();
        assertEquals(NODES_CNT, grp.nodes().size());
        GridTestUtils.waitForCondition(new GridAbsPredicate() {

            @Override
            public boolean apply() {
                return ignite.services(grp).serviceDescriptors().size() == 1;
            }
        }, 5000);
        Collection<ServiceDescriptor> srvDscs = ignite.services(grp).serviceDescriptors();
        assertEquals(1, srvDscs.size());
        Map<UUID, Integer> nodesMap = F.first(srvDscs).topologySnapshot();
        assertEquals(NODES_CNT - 1, nodesMap.size());
        for (Map.Entry<UUID, Integer> nodeInfo : nodesMap.entrySet()) {
            assertFalse(clientNodeId.equals(nodeInfo.getKey()));
            assertEquals(1, nodeInfo.getValue().intValue());
        }
        ignite.services().cancelAll();
    }
}
Also used : GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) ServiceDescriptor(org.apache.ignite.services.ServiceDescriptor) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) Map(java.util.Map)

Aggregations

Map (java.util.Map)2 UUID (java.util.UUID)2 Ignite (org.apache.ignite.Ignite)2 ClusterGroup (org.apache.ignite.cluster.ClusterGroup)2 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)2 ServiceDescriptor (org.apache.ignite.services.ServiceDescriptor)2