Search in sources :

Example 1 with ClientServiceDescriptor

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);
        }
    });
}
Also used : BinaryReaderExImpl(org.apache.ignite.internal.binary.BinaryReaderExImpl) ClientServiceDescriptor(org.apache.ignite.client.ClientServiceDescriptor) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ClientException(org.apache.ignite.client.ClientException)

Example 2 with ClientServiceDescriptor

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);
    }
}
Also used : ClientClusterGroup(org.apache.ignite.client.ClientClusterGroup) Arrays(java.util.Arrays) Person(org.apache.ignite.client.Person) PlatformType(org.apache.ignite.platform.PlatformType) HashSet(java.util.HashSet) ClientException(org.apache.ignite.client.ClientException) ServiceContext(org.apache.ignite.services.ServiceContext) IgniteClient(org.apache.ignite.client.IgniteClient) Map(java.util.Map) BinaryArray(org.apache.ignite.internal.binary.BinaryArray) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) F(org.apache.ignite.internal.util.typedef.F) ServiceCallContext(org.apache.ignite.services.ServiceCallContext) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) Collection(java.util.Collection) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) Test(org.junit.Test) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) ServiceCallContextBuilder(org.apache.ignite.services.ServiceCallContextBuilder) ClientServiceDescriptor(org.apache.ignite.client.ClientServiceDescriptor) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) ServiceContextResource(org.apache.ignite.resources.ServiceContextResource) Service(org.apache.ignite.services.Service) IGNITE_USE_BINARY_ARRAYS(org.apache.ignite.IgniteSystemProperties.IGNITE_USE_BINARY_ARRAYS) IgniteClient(org.apache.ignite.client.IgniteClient) ClientServiceDescriptor(org.apache.ignite.client.ClientServiceDescriptor) Test(org.junit.Test)

Example 3 with ClientServiceDescriptor

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());
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) ClientServiceDescriptor(org.apache.ignite.client.ClientServiceDescriptor) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) ThinClientConfiguration(org.apache.ignite.configuration.ThinClientConfiguration)

Aggregations

ClientServiceDescriptor (org.apache.ignite.client.ClientServiceDescriptor)3 ClientException (org.apache.ignite.client.ClientException)2 IgniteClient (org.apache.ignite.client.IgniteClient)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 UUID (java.util.UUID)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 TimeUnit (java.util.concurrent.TimeUnit)1 Ignite (org.apache.ignite.Ignite)1 IGNITE_USE_BINARY_ARRAYS (org.apache.ignite.IgniteSystemProperties.IGNITE_USE_BINARY_ARRAYS)1 ClientClusterGroup (org.apache.ignite.client.ClientClusterGroup)1 Person (org.apache.ignite.client.Person)1 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)1 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)1 BinaryArray (org.apache.ignite.internal.binary.BinaryArray)1 BinaryReaderExImpl (org.apache.ignite.internal.binary.BinaryReaderExImpl)1