Search in sources :

Example 71 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ClientMapTest method setup.

@Before
public void setup() {
    Config config = getConfig();
    config.getMapConfig("flushMap").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1000).setImplementation(flushMapStore));
    config.getMapConfig("putTransientMap").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1000).setImplementation(transientMapStore));
    server = hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getSerializationConfig().addPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID, new PortableFactory() {

        public Portable create(int classId) {
            return new NamedPortable();
        }
    });
    client = hazelcastFactory.newHazelcastClient(clientConfig);
}
Also used : Portable(com.hazelcast.nio.serialization.Portable) NamedPortable(com.hazelcast.nio.serialization.NamedPortable) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) NamedPortable(com.hazelcast.nio.serialization.NamedPortable) Before(org.junit.Before)

Example 72 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class LocalMapStatsUnderOnGoingClientUpdateTest method setUp.

@Before
public void setUp() throws Exception {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getNetworkConfig().setConnectionAttemptLimit(100);
    client = factory.newHazelcastClient(clientConfig);
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Example 73 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ClientMapRecordStateStressTest method all_records_are_readable_state_in_the_end.

@Test
public void all_records_are_readable_state_in_the_end() throws Exception {
    HazelcastInstance member = factory.newHazelcastInstance();
    factory.newHazelcastInstance();
    factory.newHazelcastInstance();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.addNearCacheConfig(newNearCacheConfig());
    HazelcastInstance client = factory.newHazelcastClient(clientConfig);
    IMap memberMap = member.getMap(mapName);
    // initial population of imap from member
    for (int i = 0; i < KEY_SPACE; i++) {
        memberMap.put(i, i);
    }
    List<Thread> threads = new ArrayList<Thread>();
    // member
    for (int i = 0; i < PUT_THREAD_COUNT; i++) {
        Put put = new Put(memberMap);
        threads.add(put);
    }
    // client
    IMap clientMap = client.getMap(mapName);
    for (int i = 0; i < GET_ALL_THREAD_COUNT; i++) {
        GetAll getAll = new GetAll(clientMap);
        threads.add(getAll);
    }
    for (int i = 0; i < GET_THREAD_COUNT; i++) {
        Get get = new Get(clientMap);
        threads.add(get);
    }
    for (int i = 0; i < REMOVE_THREAD_COUNT; i++) {
        Remove remove = new Remove(clientMap);
        threads.add(remove);
    }
    for (int i = 0; i < CLEAR_THREAD_COUNT; i++) {
        Clear clear = new Clear(clientMap);
        threads.add(clear);
    }
    // start threads
    for (Thread thread : threads) {
        thread.start();
    }
    // stress for a while
    sleepSeconds(TEST_RUN_SECONDS);
    // stop threads
    stop.set(true);
    for (Thread thread : threads) {
        thread.join();
    }
    assertFinalRecordStateIsReadPermitted(clientMap, getSerializationService(member));
}
Also used : IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ArrayList(java.util.ArrayList) ClientConfig(com.hazelcast.client.config.ClientConfig) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 74 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ClientNearCacheBatchInvalidationTest method testBatchInvalidationRemovesEntries.

@Test
public void testBatchInvalidationRemovesEntries() {
    Config config = getConfig();
    configureBatching(config, true, 10, 1);
    HazelcastInstance server = factory.newHazelcastInstance(config);
    factory.newHazelcastInstance(config);
    ClientConfig clientConfig = newClientConfig(mapName);
    HazelcastInstance client = factory.newHazelcastClient(clientConfig);
    makeSureConnectedToServers(client, 2);
    IMap<Integer, Integer> serverMap = server.getMap(mapName);
    IMap<Integer, Integer> clientMap = client.getMap(mapName);
    int size = 1000;
    // fill serverMap
    for (int i = 0; i < size; i++) {
        serverMap.put(i, i);
    }
    // fill Near Cache on client
    for (int i = 0; i < size; i++) {
        clientMap.get(i);
    }
    // generate invalidation data
    for (int i = 0; i < size; i++) {
        serverMap.put(i, i);
    }
    assertNearCacheSizeEventually(clientMap, 0);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 75 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ClientNearCacheBatchInvalidationTest method newClientConfig.

protected ClientConfig newClientConfig(String mapName) {
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setInMemoryFormat(getNearCacheInMemoryFormat());
    nearCacheConfig.setName(mapName);
    nearCacheConfig.setInvalidateOnChange(true);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.addNearCacheConfig(nearCacheConfig);
    return clientConfig;
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig)

Aggregations

ClientConfig (com.hazelcast.client.config.ClientConfig)214 Test (org.junit.Test)129 HazelcastInstance (com.hazelcast.core.HazelcastInstance)110 QuickTest (com.hazelcast.test.annotation.QuickTest)107 ParallelTest (com.hazelcast.test.annotation.ParallelTest)81 Config (com.hazelcast.config.Config)45 NearCacheConfig (com.hazelcast.config.NearCacheConfig)32 NightlyTest (com.hazelcast.test.annotation.NightlyTest)32 CountDownLatch (java.util.concurrent.CountDownLatch)25 AssertTask (com.hazelcast.test.AssertTask)20 Before (org.junit.Before)20 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)16 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)15 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)13 CachingProvider (javax.cache.spi.CachingProvider)13 IMap (com.hazelcast.core.IMap)12 LifecycleListener (com.hazelcast.core.LifecycleListener)12 LifecycleEvent (com.hazelcast.core.LifecycleEvent)11 Data (com.hazelcast.nio.serialization.Data)11 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)10