Search in sources :

Example 36 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.

the class JavaThinCompatibilityTest method testServicesWithCallerContextThrows.

/**
 */
private void testServicesWithCallerContextThrows() {
    X.println(">>>> Testing services with caller context throws");
    try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
        ServiceCallContext callCtx = ServiceCallContext.builder().put("key", "value").build();
        EchoServiceInterface svc = client.services().serviceProxy("test_service", EchoServiceInterface.class, callCtx);
        Throwable err = assertThrowsWithCause(() -> svc.echo(1), ClientFeatureNotSupportedByServerException.class);
        assertEquals("Feature " + SERVICE_INVOKE_CALLCTX.name() + " is not supported by the server", err.getMessage());
    }
}
Also used : ServiceCallContext(org.apache.ignite.services.ServiceCallContext) IgniteClient(org.apache.ignite.client.IgniteClient) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) ThinClientConfiguration(org.apache.ignite.configuration.ThinClientConfiguration)

Example 37 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.

the class JavaThinCompatibilityTest method testServicesWithCallerContext.

/**
 */
private void testServicesWithCallerContext() {
    X.println(">>>> Testing services with caller context");
    ServiceCallContext callCtx = ServiceCallContext.builder().put("key", "value").build();
    try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
        assertEquals("value", client.services().serviceProxy("ctx_service", CtxServiceInterface.class, callCtx).attribute("key"));
    }
}
Also used : ServiceCallContext(org.apache.ignite.services.ServiceCallContext) IgniteClient(org.apache.ignite.client.IgniteClient) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) ThinClientConfiguration(org.apache.ignite.configuration.ThinClientConfiguration)

Example 38 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration 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)

Example 39 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.

the class JavaThinCompatibilityTest method testContinuousQueries.

/**
 */
private void testContinuousQueries() throws Exception {
    X.println(">>>> Testing continuous queries");
    try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
        ClientCache<Object, Object> cache = client.getOrCreateCache("testContinuousQueries");
        List<CacheEntryEvent<?, ?>> allEvts = new ArrayList<>();
        cache.query(new ContinuousQuery<>().setLocalListener(evts -> evts.forEach(allEvts::add)));
        cache.put(0, 0);
        cache.put(0, 1);
        cache.remove(0);
        assertTrue(GridTestUtils.waitForCondition(() -> allEvts.size() == 3, 1_000L));
    }
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) BinaryObject(org.apache.ignite.binary.BinaryObject) ClientFeatureNotSupportedByServerException(org.apache.ignite.client.ClientFeatureNotSupportedByServerException) ClientCache(org.apache.ignite.client.ClientCache) ServiceContext(org.apache.ignite.services.ServiceContext) Map(java.util.Map) X(org.apache.ignite.internal.util.typedef.X) Cache(javax.cache.Cache) IgniteBinary(org.apache.ignite.IgniteBinary) QueryEntity(org.apache.ignite.cache.QueryEntity) ClientCacheConfiguration(org.apache.ignite.client.ClientCacheConfiguration) Parameterized(org.junit.runners.Parameterized) SERVICE_INVOKE_CALLCTX(org.apache.ignite.internal.client.thin.ProtocolBitmaskFeature.SERVICE_INVOKE_CALLCTX) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) GET_SERVICE_DESCRIPTORS(org.apache.ignite.internal.client.thin.ProtocolBitmaskFeature.GET_SERVICE_DESCRIPTORS) IgniteException(org.apache.ignite.IgniteException) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) NotNull(org.jetbrains.annotations.NotNull) ScanQuery(org.apache.ignite.cache.query.ScanQuery) Person(org.apache.ignite.client.Person) ComputeJob(org.apache.ignite.compute.ComputeJob) ComputeTaskAdapter(org.apache.ignite.compute.ComputeTaskAdapter) RunWith(org.junit.runner.RunWith) PlatformType(org.apache.ignite.platform.PlatformType) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ClusterNode(org.apache.ignite.cluster.ClusterNode) ComputeJobResult(org.apache.ignite.compute.ComputeJobResult) ClientTransaction(org.apache.ignite.client.ClientTransaction) IgniteClient(org.apache.ignite.client.IgniteClient) PlatformExpiryPolicy(org.apache.ignite.internal.processors.platform.cache.expiry.PlatformExpiryPolicy) Assume(org.junit.Assume) Duration(javax.cache.expiry.Duration) F(org.apache.ignite.internal.util.typedef.F) ServiceCallContext(org.apache.ignite.services.ServiceCallContext) CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) Ignite(org.apache.ignite.Ignite) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) ClientServiceDescriptor(org.apache.ignite.client.ClientServiceDescriptor) TimeUnit(java.util.concurrent.TimeUnit) CacheEntryEvent(javax.cache.event.CacheEntryEvent) Ignition(org.apache.ignite.Ignition) ThinClientConfiguration(org.apache.ignite.configuration.ThinClientConfiguration) ServiceContextResource(org.apache.ignite.resources.ServiceContextResource) Service(org.apache.ignite.services.Service) CacheMode(org.apache.ignite.cache.CacheMode) ClientConnectorConfiguration(org.apache.ignite.configuration.ClientConnectorConfiguration) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) IgniteClient(org.apache.ignite.client.IgniteClient) ArrayList(java.util.ArrayList) BinaryObject(org.apache.ignite.binary.BinaryObject) CacheEntryEvent(javax.cache.event.CacheEntryEvent) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) ThinClientConfiguration(org.apache.ignite.configuration.ThinClientConfiguration)

Example 40 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.

the class FunctionalQueryTest method testSqlParameterValidation.

/**
 * Tests {@link SqlFieldsQuery} parameter validation.
 */
@Test
public void testSqlParameterValidation() throws Exception {
    try (Ignite ignored = Ignition.start(Config.getServerConfiguration());
        IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER))) {
        // Set fields with reflection to bypass client-side validation and verify server-side check.
        SqlFieldsQuery qry = new SqlFieldsQuery("SELECT * FROM Person");
        Field updateBatchSize = SqlFieldsQuery.class.getDeclaredField("updateBatchSize");
        updateBatchSize.setAccessible(true);
        updateBatchSize.setInt(qry, -1);
        GridTestUtils.assertThrowsAnyCause(null, () -> client.query(qry).getAll(), ClientException.class, "updateBatchSize cannot be lower than 1");
        Field parts = SqlFieldsQuery.class.getDeclaredField("parts");
        parts.setAccessible(true);
        parts.set(qry, new int[] { -1 });
        qry.setUpdateBatchSize(2);
        GridTestUtils.assertThrowsAnyCause(null, () -> client.query(qry).getAll(), ClientException.class, "Illegal partition");
    }
}
Also used : Field(java.lang.reflect.Field) Ignite(org.apache.ignite.Ignite) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) Test(org.junit.Test)

Aggregations

ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)83 Test (org.junit.Test)44 IgniteClient (org.apache.ignite.client.IgniteClient)42 Ignite (org.apache.ignite.Ignite)28 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)23 BinaryObject (org.apache.ignite.binary.BinaryObject)14 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)14 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)14 List (java.util.List)11 Ignition (org.apache.ignite.Ignition)10 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)10 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)9 Collections (java.util.Collections)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 IgniteBinary (org.apache.ignite.IgniteBinary)7 Connection (java.sql.Connection)6 Arrays (java.util.Arrays)6 Map (java.util.Map)6 Consumer (java.util.function.Consumer)6 ScanQuery (org.apache.ignite.cache.query.ScanQuery)6