Search in sources :

Example 86 with NearCacheConfig

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

the class NearCacheRecordStoreTestSupport method putAndRemoveRecord.

void putAndRemoveRecord(InMemoryFormat inMemoryFormat) {
    NearCacheConfig nearCacheConfig = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME, inMemoryFormat);
    NearCacheRecordStore<Integer, String> nearCacheRecordStore = createNearCacheRecordStore(nearCacheConfig, inMemoryFormat);
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        nearCacheRecordStore.put(i, null, "Record-" + i, null);
        // ensure that they are stored
        assertNotNull(nearCacheRecordStore.get(i));
    }
    assertEquals(DEFAULT_RECORD_COUNT, nearCacheRecordStore.size());
    for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
        nearCacheRecordStore.invalidate(i);
        assertNull(nearCacheRecordStore.get(i));
    }
    assertEquals(0, nearCacheRecordStore.size());
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 87 with NearCacheConfig

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

the class ClientConfigXmlGeneratorTest method nearCache.

@Test
public void nearCache() {
    NearCacheConfig expected = createNearCacheConfig(randomString()).setPreloaderConfig(new NearCachePreloaderConfig().setEnabled(true).setDirectory(randomString()).setStoreInitialDelaySeconds(randomInt()).setStoreIntervalSeconds(randomInt())).setEvictionConfig(new EvictionConfig().setEvictionPolicy(LFU).setMaxSizePolicy(USED_NATIVE_MEMORY_SIZE).setComparatorClassName(randomString()).setSize(randomInt()));
    clientConfig.addNearCacheConfig(expected);
    Map<String, NearCacheConfig> actual = newConfigViaGenerator().getNearCacheConfigMap();
    assertMap(clientConfig.getNearCacheConfigMap(), actual);
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig) NearCachePreloaderConfig(com.hazelcast.config.NearCachePreloaderConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 88 with NearCacheConfig

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

the class ClientConfigXmlGeneratorTest method createNearCacheConfig.

private NearCacheConfig createNearCacheConfig(String name) {
    NearCacheConfig expected = new NearCacheConfig();
    expected.setInMemoryFormat(InMemoryFormat.NATIVE).setSerializeKeys(true).setInvalidateOnChange(false).setTimeToLiveSeconds(randomInt()).setMaxIdleSeconds(randomInt()).setLocalUpdatePolicy(CACHE_ON_UPDATE).setName(name);
    return expected;
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 89 with NearCacheConfig

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

the class ClientMapNearCacheTest method testNearCache_whenInMemoryFormatIsNative_thenThrowIllegalArgumentException.

@Test(expected = InvalidConfigurationException.class)
public void testNearCache_whenInMemoryFormatIsNative_thenThrowIllegalArgumentException() {
    NearCacheConfig nearCacheConfig = newNearCacheConfig().setInMemoryFormat(InMemoryFormat.NATIVE);
    getNearCachedMapFromClient(nearCacheConfig);
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 90 with NearCacheConfig

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

the class ClientMapNearCacheTest method testNearCacheGetAsyncTwice.

@Test
public void testNearCacheGetAsyncTwice() throws Exception {
    NearCacheConfig nearCacheConfig = newNearCacheConfig().setInMemoryFormat(InMemoryFormat.OBJECT);
    IMap<Integer, Integer> map = getNearCachedMapFromClient(nearCacheConfig);
    map.getAsync(1).toCompletableFuture().get();
    sleepMillis(1000);
    assertNull(map.getAsync(1).toCompletableFuture().get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

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