Search in sources :

Example 16 with NearCacheConfig

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

the class InvalidationMemberAddRemoveTest method createNearCacheConfig.

@Override
protected NearCacheConfig createNearCacheConfig(InMemoryFormat inMemoryFormat) {
    NearCacheConfig nearCacheConfig = super.createNearCacheConfig(inMemoryFormat);
    nearCacheConfig.setInvalidateOnChange(true).getEvictionConfig().setMaximumSizePolicy(ENTRY_COUNT).setSize(MAX_VALUE);
    return nearCacheConfig;
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 17 with NearCacheConfig

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

the class InvalidationMetadataDistortionTest method createNearCacheConfig.

@Override
protected NearCacheConfig createNearCacheConfig(InMemoryFormat inMemoryFormat) {
    NearCacheConfig nearCacheConfig = super.createNearCacheConfig(inMemoryFormat);
    nearCacheConfig.setInvalidateOnChange(true).getEvictionConfig().setMaximumSizePolicy(ENTRY_COUNT).setSize(MAX_VALUE);
    return nearCacheConfig;
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 18 with NearCacheConfig

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

the class ClientCacheProxyTest method isCacheOnUpdate_not_prints_warning_message_for_policy_CACHE_ON_UPDATE.

@Test
public void isCacheOnUpdate_not_prints_warning_message_for_policy_CACHE_ON_UPDATE() throws Exception {
    NearCacheConfig nearCacheConfig = new NearCacheConfig().setLocalUpdatePolicy(CACHE_ON_UPDATE);
    TestLogger logger = new TestLogger();
    new ClientCacheProxy(new CacheConfig()).isCacheOnUpdate(nearCacheConfig, "cacheName", logger);
    assertNull(logger.message);
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 19 with NearCacheConfig

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

the class ClientNearCacheTestSupport method putToCacheAndRemoveFromOtherNodeThenCantGetUpdatedFromClientNearCache.

protected void putToCacheAndRemoveFromOtherNodeThenCantGetUpdatedFromClientNearCache(InMemoryFormat inMemoryFormat) {
    NearCacheConfig nearCacheConfig = createNearCacheConfig(inMemoryFormat);
    nearCacheConfig.setInvalidateOnChange(true);
    NearCacheTestContext nearCacheTestContext1 = createNearCacheTest(DEFAULT_CACHE_NAME, nearCacheConfig);
    final NearCacheTestContext nearCacheTestContext2 = createNearCacheTest(DEFAULT_CACHE_NAME, nearCacheConfig);
    // put cache record from client-1
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        nearCacheTestContext1.cache.put(i, generateValueFromKey(i));
    }
    // get records from client-2
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        final Integer key = i;
        final String value = nearCacheTestContext2.cache.get(key);
        // records are stored in the cache as async not sync, so these records will be there in cache eventually
        assertTrueEventually(new AssertTask() {

            @Override
            public void run() throws Exception {
                Data keyData = nearCacheTestContext2.serializationService.toData(key);
                assertEquals(value, nearCacheTestContext2.nearCache.get(keyData));
            }
        });
    }
    // delete cache record from client-1
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        nearCacheTestContext1.cache.remove(i);
    }
    // can't get deleted records from client-2
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        final int key = i;
        // records are stored in the Near Cache will be invalidated eventually, since cache records are updated.
        assertTrueEventually(new AssertTask() {

            @Override
            public void run() throws Exception {
                Data keyData = nearCacheTestContext2.serializationService.toData(key);
                assertNull(nearCacheTestContext2.nearCache.get(keyData));
            }
        });
    }
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig) AssertTask(com.hazelcast.test.AssertTask) Data(com.hazelcast.nio.serialization.Data) CacheLoaderException(javax.cache.integration.CacheLoaderException)

Example 20 with NearCacheConfig

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

the class ClientNearCacheTestSupport method putAndGetFromCacheAndThenGetFromClientNearCache.

protected void putAndGetFromCacheAndThenGetFromClientNearCache(InMemoryFormat inMemoryFormat) {
    NearCacheConfig nearCacheConfig = createNearCacheConfig(inMemoryFormat);
    NearCacheTestContext nearCacheTestContext = createNearCacheTestAndFillWithData(DEFAULT_CACHE_NAME, nearCacheConfig);
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        assertNull(nearCacheTestContext.nearCache.get(nearCacheTestContext.serializationService.toData(i)));
    }
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        // get records so they will be stored in Near Cache
        nearCacheTestContext.cache.get(i);
    }
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        String expectedValue = generateValueFromKey(i);
        Data keyData = nearCacheTestContext.serializationService.toData(i);
        assertEquals(expectedValue, nearCacheTestContext.nearCache.get(keyData));
    }
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig) Data(com.hazelcast.nio.serialization.Data)

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