Search in sources :

Example 36 with NearCacheConfig

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

the class NearCacheRecordStoreTestSupport method clearRecordsOrDestroyStore.

protected void clearRecordsOrDestroyStore(InMemoryFormat inMemoryFormat, boolean destroy) {
    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, "Record-" + i);
        // ensure that they are stored
        assertNotNull(nearCacheRecordStore.get(i));
    }
    if (destroy) {
        nearCacheRecordStore.destroy();
    } else {
        nearCacheRecordStore.clear();
    }
    assertEquals(0, nearCacheRecordStore.size());
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 37 with NearCacheConfig

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

the class NearCacheTestSupport method doConfigureInvalidateOnChangeForNearCache.

protected void doConfigureInvalidateOnChangeForNearCache() {
    NearCacheConfig config1 = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME + "-1", DEFAULT_MEMORY_FORMAT);
    NearCacheConfig config2 = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME + "-2", DEFAULT_MEMORY_FORMAT);
    config1.setInvalidateOnChange(false);
    config2.setInvalidateOnChange(true);
    NearCache nearCache1 = createNearCache(config1.getName(), config1, createManagedNearCacheRecordStore());
    NearCache nearCache2 = createNearCache(config2.getName(), config2, createManagedNearCacheRecordStore());
    // show that NearCache gets "isInvalidateOnChange" configuration from specified NearCacheConfig
    assertFalse(nearCache1.isInvalidatedOnChange());
    assertTrue(nearCache2.isInvalidatedOnChange());
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 38 with NearCacheConfig

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

the class NearCacheTestSupport method doConfigureInMemoryFormatForNearCache.

protected void doConfigureInMemoryFormatForNearCache() {
    NearCacheConfig config1 = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME + "-1", DEFAULT_MEMORY_FORMAT);
    NearCacheConfig config2 = createNearCacheConfig(DEFAULT_NEAR_CACHE_NAME + "-2", DEFAULT_MEMORY_FORMAT);
    config1.setInMemoryFormat(InMemoryFormat.OBJECT);
    config2.setInMemoryFormat(InMemoryFormat.BINARY);
    NearCache nearCache1 = createNearCache(config1.getName(), config1, createManagedNearCacheRecordStore());
    NearCache nearCache2 = createNearCache(config2.getName(), config2, createManagedNearCacheRecordStore());
    // show that NearCache gets "inMemoryFormat" configuration from specified NearCacheConfig
    assertEquals(InMemoryFormat.OBJECT, nearCache1.getInMemoryFormat());
    assertEquals(InMemoryFormat.BINARY, nearCache2.getInMemoryFormat());
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 39 with NearCacheConfig

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

the class MetaDataGeneratorTest method destroying_map_removes_related_metadata.

@Test
public void destroying_map_removes_related_metadata() throws Exception {
    final String mapName = "test";
    Config config = new Config();
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    config.getMapConfig(mapName).setNearCacheConfig(nearCacheConfig);
    HazelcastInstance member = createHazelcastInstance(config);
    IMap map = member.getMap(mapName);
    map.put(1, 1);
    final MetaDataGenerator metaDataGenerator = getMetaDataGenerator(member);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertNotNull(metaDataGenerator.sequenceGenerators.get(mapName));
        }
    });
    map.destroy();
    assertNull(metaDataGenerator.sequenceGenerators.get(mapName));
}
Also used : IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) AssertTask(com.hazelcast.test.AssertTask) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 40 with NearCacheConfig

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

the class ClientReplicatedMapNearCacheBasicTest method testSerializeKeys_notSupported.

@Test(expected = InvalidConfigurationException.class)
public void testSerializeKeys_notSupported() {
    hazelcastFactory.newHazelcastInstance();
    ClientConfig clientConfig = new ClientConfig();
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setSerializeKeys(true).setInMemoryFormat(inMemoryFormat);
    nearCacheConfig.setName("test");
    clientConfig.addNearCacheConfig(nearCacheConfig);
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    client.getReplicatedMap("test");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) AbstractNearCacheBasicTest(com.hazelcast.internal.nearcache.impl.AbstractNearCacheBasicTest) 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