Search in sources :

Example 26 with NearCacheConfig

use of com.hazelcast.config.NearCacheConfig 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)

Example 27 with NearCacheConfig

use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.

the class ClientMapNearCacheTest method newMaxIdleSecondsNearCacheConfig.

protected NearCacheConfig newMaxIdleSecondsNearCacheConfig() {
    NearCacheConfig nearCacheConfig = newNearCacheConfig();
    nearCacheConfig.setInvalidateOnChange(false);
    nearCacheConfig.setMaxIdleSeconds(MAX_IDLE_SECONDS);
    return nearCacheConfig;
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 28 with NearCacheConfig

use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.

the class ClientMapNearCacheTest method receives_one_clearEvent_after_mapClear_call_from_member.

@Test
public void receives_one_clearEvent_after_mapClear_call_from_member() {
    // start new member and populate map
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(newConfig());
    IMap<Integer, Integer> memberMap = member.getMap("test");
    populateMap(memberMap, 1000);
    // populate client near cache
    NearCacheConfig nearCacheConfig = newNearCacheConfig();
    ClientConfig clientConfig = newClientConfig();
    clientConfig.addNearCacheConfig(nearCacheConfig);
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    IMap<Integer, Integer> clientMap = client.getMap("test");
    populateNearCache(clientMap, 1000);
    // add test listener to count clear events
    final ClearEventCounterEventHandler handler = new ClearEventCounterEventHandler();
    ((NearCachedClientMapProxy) clientMap).addNearCacheInvalidationListener(handler);
    // clear map from member side
    memberMap.clear();
    // sleep for a while to see there is another clear event coming
    sleepSeconds(2);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertEquals("Expecting only 1 clear event", 1, handler.getClearEventCount());
        }
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NearCacheConfig(com.hazelcast.config.NearCacheConfig) AssertTask(com.hazelcast.test.AssertTask) ClientConfig(com.hazelcast.client.config.ClientConfig) NearCachedClientMapProxy(com.hazelcast.client.proxy.NearCachedClientMapProxy) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 29 with NearCacheConfig

use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.

the class ClientMapNearCacheTest method newNoInvalidationNearCacheConfig.

protected NearCacheConfig newNoInvalidationNearCacheConfig() {
    NearCacheConfig nearCacheConfig = newNearCacheConfig();
    nearCacheConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
    nearCacheConfig.setInvalidateOnChange(false);
    return nearCacheConfig;
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 30 with NearCacheConfig

use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.

the class ClientReplicatedMapTest method getClientConfigWithNearCacheInvalidationEnabled.

private ClientConfig getClientConfigWithNearCacheInvalidationEnabled() {
    ClientConfig config = new ClientConfig();
    NearCacheConfig nnc = new NearCacheConfig();
    nnc.setInvalidateOnChange(true);
    nnc.setInMemoryFormat(InMemoryFormat.OBJECT);
    config.addNearCacheConfig(nnc);
    return config;
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig)

Aggregations

NearCacheConfig (com.hazelcast.config.NearCacheConfig)212 Test (org.junit.Test)89 QuickTest (com.hazelcast.test.annotation.QuickTest)82 Config (com.hazelcast.config.Config)66 HazelcastInstance (com.hazelcast.core.HazelcastInstance)65 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)62 ClientConfig (com.hazelcast.client.config.ClientConfig)51 MapConfig (com.hazelcast.config.MapConfig)37 EvictionConfig (com.hazelcast.config.EvictionConfig)24 Before (org.junit.Before)17 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)16 CacheConfig (com.hazelcast.config.CacheConfig)15 ParallelTest (com.hazelcast.test.annotation.ParallelTest)15 NearCacheTestUtils.getBaseConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig)14 AssertTask (com.hazelcast.test.AssertTask)14 NightlyTest (com.hazelcast.test.annotation.NightlyTest)12 MapStoreConfig (com.hazelcast.config.MapStoreConfig)11 Data (com.hazelcast.nio.serialization.Data)11 MatchingPointConfigPatternMatcher (com.hazelcast.config.matcher.MatchingPointConfigPatternMatcher)10 CachingProvider (javax.cache.spi.CachingProvider)10