Search in sources :

Example 76 with Config

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

the class NearCacheTest method getMapConfiguredWithMaxSizeAndPolicy.

private IMap<Integer, Integer> getMapConfiguredWithMaxSizeAndPolicy(EvictionPolicy evictionPolicy, int maxSize) {
    String mapName = randomMapName();
    Config config = getConfig();
    config.getMapConfig(mapName).setNearCacheConfig(newNearCacheConfigWithEntryCountEviction(evictionPolicy, maxSize));
    HazelcastInstance instance = createHazelcastInstance(config);
    return instance.getMap(mapName);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 77 with Config

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

the class NearCacheTest method test_whenEmptyMap_thenPopulatedNearCacheShouldReturnNull_neverNULL_OBJECT.

@Test
public void test_whenEmptyMap_thenPopulatedNearCacheShouldReturnNull_neverNULL_OBJECT() {
    int size = 10;
    String mapName = randomMapName();
    Config config = getConfig();
    config.getMapConfig(mapName).setNearCacheConfig(newNearCacheConfig());
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
    HazelcastInstance instance = factory.newHazelcastInstance(config);
    // populate map
    IMap<Integer, Integer> map = instance.getMap(mapName);
    for (int i = 0; i < size; i++) {
        // populate Near Cache
        assertNull(map.get(i));
        // fetch value from Near Cache
        assertNull(map.get(i));
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 78 with Config

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

the class NearCacheTestSupport method createNearCachedMapConfigWithMapStoreConfig.

protected Config createNearCachedMapConfigWithMapStoreConfig(String mapName) {
    SimpleMapStore store = new SimpleMapStore();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(store);
    Config config = createNearCachedMapConfig(mapName);
    config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
    return config;
}
Also used : MapConfig(com.hazelcast.config.MapConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig)

Example 79 with Config

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

the class InvalidationMemberAddRemoveTest method createConfig.

protected Config createConfig() {
    Config config = new Config();
    config.setProperty("hazelcast.invalidation.reconciliation.interval.seconds", Integer.toString(RECONCILIATION_INTERVAL_SECONDS));
    config.setProperty("hazelcast.invalidation.max.tolerated.miss.count", "0");
    config.setProperty("hazelcast.map.invalidation.batch.enabled", "true");
    config.setProperty("hazelcast.map.invalidation.batch.size", Integer.toString(INVALIDATION_BATCH_SIZE));
    config.setProperty("hazelcast.partition.count", "271");
    return config;
}
Also used : Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 80 with Config

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

the class MapInvalidationMetaDataMigrationTest method uuids_migrated_whenSourceNodeShutdown.

@Test
public void uuids_migrated_whenSourceNodeShutdown() throws Exception {
    String mapName = "test";
    Config config = newConfig(mapName);
    HazelcastInstance instance1 = factory.newHazelcastInstance(config);
    IMap<Object, Object> map = instance1.getMap(mapName);
    for (int i = 0; i < 10000; i++) {
        map.put(i, i);
    }
    Map<Integer, UUID> source1 = getPartitionToUuidMap(instance1);
    HazelcastInstance instance2 = factory.newHazelcastInstance(config);
    HazelcastInstance instance3 = factory.newHazelcastInstance(config);
    waitAllForSafeState(instance1, instance2, instance3);
    instance1.shutdown();
    Map<Integer, UUID> destination2 = getPartitionToUuidMap(instance2);
    Map<Integer, UUID> destination3 = getPartitionToUuidMap(instance3);
    Map<Integer, UUID> merged = mergeOwnedPartitionUuids(destination2, destination3, getNodeEngineImpl(instance2).getPartitionService());
    assertEquals(source1, merged);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) UUID(java.util.UUID) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Config (com.hazelcast.config.Config)1190 Test (org.junit.Test)838 HazelcastInstance (com.hazelcast.core.HazelcastInstance)815 QuickTest (com.hazelcast.test.annotation.QuickTest)718 ParallelTest (com.hazelcast.test.annotation.ParallelTest)648 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)361 MapConfig (com.hazelcast.config.MapConfig)341 MapStoreConfig (com.hazelcast.config.MapStoreConfig)211 CountDownLatch (java.util.concurrent.CountDownLatch)145 NightlyTest (com.hazelcast.test.annotation.NightlyTest)142 NearCacheConfig (com.hazelcast.config.NearCacheConfig)125 Before (org.junit.Before)115 AssertTask (com.hazelcast.test.AssertTask)113 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)93 MapIndexConfig (com.hazelcast.config.MapIndexConfig)91 ClientConfig (com.hazelcast.client.config.ClientConfig)83 IMap (com.hazelcast.core.IMap)81 GroupConfig (com.hazelcast.config.GroupConfig)69 ListenerConfig (com.hazelcast.config.ListenerConfig)60 JoinConfig (com.hazelcast.config.JoinConfig)59