Search in sources :

Example 71 with NearCacheConfig

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

the class TxnMapNearCacheInvalidationTest method testTxnInvalidatesNearCache.

private void testTxnInvalidatesNearCache(InvalidatorTxnOp invalidatorTxnTask) {
    final String mapName = "test";
    final int numberOfEntries = 1000;
    NearCacheConfig nearCacheConfig = createNearCacheConfig(mapName).setInvalidateOnChange(true);
    Config config = smallInstanceConfig();
    config.getMapConfig(mapName).setNearCacheConfig(nearCacheConfig);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance hz = factory.newHazelcastInstance(config);
    factory.newHazelcastInstance(config);
    factory.newHazelcastInstance(config);
    IMap<Integer, Integer> map = hz.getMap(mapName);
    // 1. populate Near Cache
    invalidatorTxnTask.doPopulateNearCache(map, numberOfEntries);
    // 2. run a txn task which causes invalidation
    hz.executeTransaction(invalidatorTxnTask.createTxnTask(mapName, numberOfEntries));
    // 3. assert
    invalidatorTxnTask.doAssertion(map, numberOfEntries);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory)

Example 72 with NearCacheConfig

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

the class InMemoryFormatTest method testNativeNearCache_throwsException.

@Test(expected = InvalidConfigurationException.class)
public void testNativeNearCache_throwsException() throws Exception {
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setInMemoryFormat(InMemoryFormat.NATIVE);
    Config config = getConfig();
    config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
    HazelcastInstance member = createHazelcastInstance(config);
    member.getMap("default");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 73 with NearCacheConfig

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

the class IssuesTest method testIssue174NearCacheContainsKeySingleNode.

@Test
public void testIssue174NearCacheContainsKeySingleNode() {
    int n = 1;
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(n);
    Config config = getConfig();
    config.setClusterName("testIssue174NearCacheContainsKeySingleNode");
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
    HazelcastInstance h = factory.newHazelcastInstance(config);
    IMap<String, String> map = h.getMap("testIssue174NearCacheContainsKeySingleNode");
    map.put("key", "value");
    assertTrue(map.containsKey("key"));
    h.shutdown();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) GlobalSerializerConfig(com.hazelcast.config.GlobalSerializerConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 74 with NearCacheConfig

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

the class EvictionTest method testIssue585ZeroTTLShouldPreventEvictionWithSet.

@Test
public void testIssue585ZeroTTLShouldPreventEvictionWithSet() {
    MapConfig mapConfig = newMapConfig("testIssue585ZeroTTLShouldPreventEvictionWithSet").setNearCacheConfig(new NearCacheConfig());
    Config config = getConfig().setClusterName("testIssue585ZeroTTLShouldPreventEvictionWithSet").addMapConfig(mapConfig);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
    HazelcastInstance h = factory.newHazelcastInstance(config);
    IMap<String, String> map = h.getMap("testIssue585ZeroTTLShouldPreventEvictionWithSet");
    map.set("key", "value", 1, SECONDS);
    map.set("key", "value2", 0, SECONDS);
    sleepAtLeastSeconds(2);
    assertEquals("value2", map.get("key"));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapConfig(com.hazelcast.config.MapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 75 with NearCacheConfig

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

the class HazelcastConnectorTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    Config config = smallInstanceConfig();
    config.getCacheConfig("*").getEventJournalConfig().setEnabled(true);
    config.getMapConfig("stream*").getEventJournalConfig().setEnabled(true);
    config.getMapConfig("nearCache*").setNearCacheConfig(new NearCacheConfig());
    initialize(2, config);
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) BeforeClass(org.junit.BeforeClass)

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