Search in sources :

Example 16 with Config

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

the class MapInvalidationMetaDataMigrationTest method sequences_migrated_whenNewlyJoinedNodesShutdown.

@Test
public void sequences_migrated_whenNewlyJoinedNodesShutdown() 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, Long> source = getPartitionToSequenceMap(mapName, instance1);
    HazelcastInstance instance2 = factory.newHazelcastInstance(config);
    waitAllForSafeState(instance2);
    instance1.shutdown();
    HazelcastInstance instance3 = factory.newHazelcastInstance(config);
    waitAllForSafeState(instance3);
    instance2.shutdown();
    waitAllForSafeState(instance3);
    Map<Integer, Long> destination = getPartitionToSequenceMap(mapName, instance3);
    for (Map.Entry<Integer, Long> entry : source.entrySet()) {
        Integer key = entry.getKey();
        Long first = entry.getValue();
        Long last = destination.get(key);
        assertEquals(first, last);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) HashMap(java.util.HashMap) Map(java.util.Map) IMap(com.hazelcast.core.IMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 17 with Config

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

the class MemberMapRecordStateStressTest method all_records_are_readable_state_in_the_end.

@Test
public void all_records_are_readable_state_in_the_end() throws Exception {
    HazelcastInstance member1 = factory.newHazelcastInstance();
    HazelcastInstance member2 = factory.newHazelcastInstance();
    Config config = new Config();
    config.getMapConfig(mapName).setNearCacheConfig(newNearCacheConfig());
    HazelcastInstance nearCachedMember = factory.newHazelcastInstance(config);
    IMap memberMap = member1.getMap(mapName);
    // initial population of imap from member
    for (int i = 0; i < KEY_SPACE; i++) {
        memberMap.put(i, i);
    }
    List<Thread> threads = new ArrayList<Thread>();
    // member
    for (int i = 0; i < PUT_THREAD_COUNT; i++) {
        Put put = new Put(memberMap);
        threads.add(put);
    }
    // nearCachedMap
    IMap nearCachedMap = nearCachedMember.getMap(mapName);
    // member
    for (int i = 0; i < PUT_LOCAL_THREAD_COUNT; i++) {
        Put put = new Put(nearCachedMap);
        threads.add(put);
    }
    for (int i = 0; i < GET_ALL_THREAD_COUNT; i++) {
        GetAll getAll = new GetAll(nearCachedMap);
        threads.add(getAll);
    }
    for (int i = 0; i < GET_THREAD_COUNT; i++) {
        Get get = new Get(nearCachedMap);
        threads.add(get);
    }
    for (int i = 0; i < REMOVE_THREAD_COUNT; i++) {
        Remove remove = new Remove(nearCachedMap);
        threads.add(remove);
    }
    for (int i = 0; i < CLEAR_THREAD_COUNT; i++) {
        Clear clear = new Clear(nearCachedMap);
        threads.add(clear);
    }
    // start threads
    for (Thread thread : threads) {
        thread.start();
    }
    // stress for a while
    sleepSeconds(TEST_RUN_SECONDS);
    // stop threads
    stop.set(true);
    for (Thread thread : threads) {
        thread.join();
    }
    assertFinalRecordStateIsReadPermitted(member1, ((NearCachedMapProxyImpl) nearCachedMap).getNearCache());
}
Also used : IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ArrayList(java.util.ArrayList) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 18 with Config

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

the class NearCacheBatchInvalidationTest method testBatchInvalidationRemovesEntries.

@Test
public void testBatchInvalidationRemovesEntries() throws Exception {
    String mapName = randomMapName();
    Config config = newConfig(mapName);
    config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "1");
    configureBatching(config, true, 12, 1);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance node1 = factory.newHazelcastInstance(config);
    HazelcastInstance node2 = factory.newHazelcastInstance(config);
    final IMap<Integer, Integer> map1 = node1.getMap(mapName);
    final IMap<Integer, Integer> map2 = node2.getMap(mapName);
    int size = 1000;
    // fill map-1
    for (int i = 0; i < size; i++) {
        map1.put(i, i);
    }
    // fill Near Cache on node-1
    for (int i = 0; i < size; i++) {
        map1.get(i);
    }
    // fill Near Cache on node-2
    for (int i = 0; i < size; i++) {
        map2.get(i);
    }
    // generate invalidation data
    for (int i = 0; i < size; i++) {
        map1.put(i, i);
    }
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            NearCache nearCache1 = ((NearCachedMapProxyImpl) map1).getNearCache();
            NearCache nearCache2 = ((NearCachedMapProxyImpl) map2).getNearCache();
            assertEquals(0, nearCache1.size() + nearCache2.size());
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) AssertTask(com.hazelcast.test.AssertTask) NearCache(com.hazelcast.internal.nearcache.NearCache) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 19 with Config

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

the class MapQueryEngineImpl_queryLocalPartitions_resultSizeLimitTest method setup.

@Before
public void setup() {
    Config config = new Config();
    config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "" + PARTITION_COUNT);
    config.setProperty(GroupProperty.QUERY_RESULT_SIZE_LIMIT.getName(), "" + RESULT_SIZE_LIMIT);
    HazelcastInstance hz = createHazelcastInstance(config);
    map = hz.getMap(randomName());
    MapService mapService = getNodeEngineImpl(hz).getService(MapService.SERVICE_NAME);
    queryEngine = new MapQueryEngineImpl(mapService.getMapServiceContext());
    // we fill all partitions, so we get the NodeResultLimit for all partitions as well
    QueryResultSizeLimiter resultSizeLimiter = queryEngine.getQueryResultSizeLimiter();
    limit = (int) resultSizeLimiter.getNodeResultLimit(PARTITION_COUNT);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapService(com.hazelcast.map.impl.MapService) Before(org.junit.Before)

Example 20 with Config

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

the class NearCacheLiteMemberTest method createConfig.

public static Config createConfig(String mapName, boolean liteMember) {
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setInvalidateOnChange(true);
    Config config = new Config();
    config.setLiteMember(liteMember);
    config.getMapConfig(mapName).setNearCacheConfig(nearCacheConfig);
    return config;
}
Also used : Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Aggregations

Config (com.hazelcast.config.Config)2458 Test (org.junit.Test)1570 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1465 QuickTest (com.hazelcast.test.annotation.QuickTest)1286 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1003 MapConfig (com.hazelcast.config.MapConfig)599 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)497 MapStoreConfig (com.hazelcast.config.MapStoreConfig)300 NearCacheConfig (com.hazelcast.config.NearCacheConfig)270 Before (org.junit.Before)242 ClientConfig (com.hazelcast.client.config.ClientConfig)228 SlowTest (com.hazelcast.test.annotation.SlowTest)204 NightlyTest (com.hazelcast.test.annotation.NightlyTest)186 CountDownLatch (java.util.concurrent.CountDownLatch)182 IndexConfig (com.hazelcast.config.IndexConfig)162 JoinConfig (com.hazelcast.config.JoinConfig)142 ParallelTest (com.hazelcast.test.annotation.ParallelTest)141 AssertTask (com.hazelcast.test.AssertTask)131 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)126 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)125