Search in sources :

Example 16 with ClientCacheConfiguration

use of org.apache.ignite.client.ClientCacheConfiguration in project ignite by apache.

the class CacheAsyncTest method testGetOrCreateCacheAsyncByNameCreatesCacheWhenNotExists.

/**
 * Tests async cache creation.
 */
@Test
public void testGetOrCreateCacheAsyncByNameCreatesCacheWhenNotExists() throws Exception {
    ClientCacheConfiguration cfg = new ClientCacheConfiguration().setName(TMP_CACHE_NAME).setBackups(5);
    assertTrue(client.getOrCreateCacheAsync(cfg).thenApply(x -> client.cacheNames().contains(TMP_CACHE_NAME)).toCompletableFuture().get());
    ClientCacheConfiguration resCfg = client.cache(TMP_CACHE_NAME).getConfiguration();
    assertEquals(5, resCfg.getBackups());
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) Person(org.apache.ignite.client.Person) ImmutableSet(com.google.common.collect.ImmutableSet) CachePeekMode(org.apache.ignite.cache.CachePeekMode) CancellationException(java.util.concurrent.CancellationException) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) IgniteClientFuture(org.apache.ignite.client.IgniteClientFuture) Test(org.junit.Test) AtomicReference(java.util.concurrent.atomic.AtomicReference) ClientCache(org.apache.ignite.client.ClientCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Objects(java.util.Objects) ClientException(org.apache.ignite.client.ClientException) BinaryObjectException(org.apache.ignite.binary.BinaryObjectException) IgniteClient(org.apache.ignite.client.IgniteClient) PersonBinarylizable(org.apache.ignite.client.PersonBinarylizable) Map(java.util.Map) X(org.apache.ignite.internal.util.typedef.X) Collections(java.util.Collections) ClientCacheConfiguration(org.apache.ignite.client.ClientCacheConfiguration) ClientCacheConfiguration(org.apache.ignite.client.ClientCacheConfiguration) Test(org.junit.Test)

Example 17 with ClientCacheConfiguration

use of org.apache.ignite.client.ClientCacheConfiguration in project ignite by apache.

the class WrongQueryEntityFieldTypeTest method withThinClient.

/**
 * Perform action with Thin client.
 */
private void withThinClient(BiConsumer<IgniteClient, ClientCache<Integer, Object>> consumer) throws Exception {
    startGrids(gridCnt);
    try (IgniteClient cli = Ignition.startClient(new ClientConfiguration().setAddresses("127.0.0.1:10800"))) {
        ClientCache<Integer, Object> cache = cli.createCache(new ClientCacheConfiguration().setName("TEST").setAtomicityMode(mode).setBackups(backups).setQueryEntities(queryEntity()));
        consumer.accept(cli, cache);
        assertFalse(sysThreadFail);
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) ClientCacheConfiguration(org.apache.ignite.client.ClientCacheConfiguration)

Aggregations

ClientCacheConfiguration (org.apache.ignite.client.ClientCacheConfiguration)17 IgniteClient (org.apache.ignite.client.IgniteClient)12 Test (org.junit.Test)9 Collection (java.util.Collection)6 Map (java.util.Map)6 Objects (java.util.Objects)6 CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)6 ClientCache (org.apache.ignite.client.ClientCache)5 ClientException (org.apache.ignite.client.ClientException)5 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 ImmutableSet (com.google.common.collect.ImmutableSet)4 Collections (java.util.Collections)4 CancellationException (java.util.concurrent.CancellationException)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)4 CachePeekMode (org.apache.ignite.cache.CachePeekMode)4 IgniteClientFuture (org.apache.ignite.client.IgniteClientFuture)4 Person (org.apache.ignite.client.Person)4 PersonBinarylizable (org.apache.ignite.client.PersonBinarylizable)4