use of org.apache.ignite.client.ClientServiceDescriptor in project ignite by apache.
the class ClientServicesImpl method serviceDescriptors.
/**
* {@inheritDoc}
*/
@Override
public Collection<ClientServiceDescriptor> serviceDescriptors() {
return ch.service(ClientOperation.SERVICE_GET_DESCRIPTORS, req -> checkGetServiceDescriptorsSupported(req.clientChannel().protocolCtx()), res -> {
try (BinaryReaderExImpl reader = utils.createBinaryReader(res.in())) {
int sz = res.in().readInt();
Collection<ClientServiceDescriptor> svcs = new ArrayList<>(sz);
for (int i = 0; i < sz; i++) svcs.add(readServiceDescriptor(reader));
return svcs;
} catch (IOException e) {
throw new ClientException(e);
}
});
}
use of org.apache.ignite.client.ClientServiceDescriptor in project ignite by apache.
the class ServicesTest method testServiceDescriptors.
/**
* Test service descriptors returned correctly.
*/
@Test
public void testServiceDescriptors() throws Exception {
try (IgniteClient client = startClient(0)) {
Collection<ClientServiceDescriptor> svcs = client.services().serviceDescriptors();
assertNotNull(svcs);
assertEquals(3, svcs.size());
assertTrue(svcs.stream().filter(svc -> svc.name().equals(NODE_ID_SERVICE_NAME)).peek(svc -> {
assertEquals(NODE_ID_SERVICE_NAME, svc.name());
assertEquals(TestNodeIdService.class.getName(), svc.serviceClass());
assertEquals(0, svc.totalCount());
assertEquals(1, svc.maxPerNodeCount());
assertNull(svc.cacheName());
assertEquals(grid(0).localNode().id(), svc.originNodeId());
assertEquals(PlatformType.JAVA, svc.platformType());
assertDescriptorsEquals(svc, client.services().serviceDescriptor(NODE_ID_SERVICE_NAME));
}).findFirst().isPresent());
assertTrue(svcs.stream().filter(svc -> svc.name().equals(NODE_SINGLTON_SERVICE_NAME)).peek(svc -> {
assertEquals(NODE_SINGLTON_SERVICE_NAME, svc.name());
assertEquals(TestService.class.getName(), svc.serviceClass());
assertEquals(0, svc.totalCount());
assertEquals(1, svc.maxPerNodeCount());
assertNull(svc.cacheName());
assertEquals(grid(0).localNode().id(), svc.originNodeId());
assertEquals(PlatformType.JAVA, svc.platformType());
assertDescriptorsEquals(svc, client.services().serviceDescriptor(NODE_SINGLTON_SERVICE_NAME));
}).findFirst().isPresent());
assertTrue(svcs.stream().filter(svc -> svc.name().equals(CLUSTER_SINGLTON_SERVICE_NAME)).peek(svc -> {
assertEquals(CLUSTER_SINGLTON_SERVICE_NAME, svc.name());
assertEquals(TestService.class.getName(), svc.serviceClass());
assertEquals(1, svc.totalCount());
assertEquals(1, svc.maxPerNodeCount());
assertEquals(DEFAULT_CACHE_NAME, svc.cacheName());
assertEquals(grid(0).localNode().id(), svc.originNodeId());
assertEquals(PlatformType.JAVA, svc.platformType());
assertDescriptorsEquals(svc, client.services().serviceDescriptor(CLUSTER_SINGLTON_SERVICE_NAME));
}).findFirst().isPresent());
assertThrowsWithCause(() -> {
client.services().serviceDescriptor("unknown");
}, ClientException.class);
}
}
use of org.apache.ignite.client.ClientServiceDescriptor in project ignite by apache.
the class JavaThinCompatibilityTest method testServiceDescriptors.
/**
*/
private void testServiceDescriptors() {
X.println(">>>> Testing services descriptors");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
assertEquals(2, client.services().serviceDescriptors().size());
ClientServiceDescriptor svc = client.services().serviceDescriptor("test_service");
assertEquals("test_service", svc.name());
assertEquals(EchoService.class.getName(), svc.serviceClass());
assertEquals(0, svc.totalCount());
assertEquals(1, svc.maxPerNodeCount());
assertNull(svc.cacheName());
assertEquals(grid(0).localNode().id(), svc.originNodeId());
assertEquals(PlatformType.JAVA, svc.platformType());
}
}
Aggregations