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();
}
}
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();
}
}
Aggregations