Search in sources :

Example 41 with Config

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

the class MapStoreWriteBehindTest method testIssue1085WriteBehindBackupWithLongRunnigMapStore.

@Test(timeout = 120000)
public void testIssue1085WriteBehindBackupWithLongRunnigMapStore() throws InterruptedException {
    final String name = randomMapName("testIssue1085WriteBehindBackup");
    final int expectedStoreCount = 3;
    final int nodeCount = 3;
    Config config = getConfig();
    config.setProperty(GroupProperty.MAP_REPLICA_SCHEDULED_TASK_DELAY_SECONDS.getName(), "30");
    MapConfig writeBehindBackupConfig = config.getMapConfig(name);
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setWriteDelaySeconds(5);
    final MapStoreWithStoreCount mapStore = new MapStoreWithStoreCount(expectedStoreCount, 300, 50);
    mapStoreConfig.setImplementation(mapStore);
    writeBehindBackupConfig.setMapStoreConfig(mapStoreConfig);
    // create nodes.
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
    HazelcastInstance node1 = factory.newHazelcastInstance(config);
    HazelcastInstance node2 = factory.newHazelcastInstance(config);
    HazelcastInstance node3 = factory.newHazelcastInstance(config);
    // create corresponding keys.
    final String keyOwnedByNode1 = generateKeyOwnedBy(node1);
    final String keyOwnedByNode2 = generateKeyOwnedBy(node2);
    final String keyOwnedByNode3 = generateKeyOwnedBy(node3);
    // put one key value pair per node.
    final IMap<String, Integer> map = node1.getMap(name);
    map.put(keyOwnedByNode1, 1);
    map.put(keyOwnedByNode2, 2);
    map.put(keyOwnedByNode3, 3);
    // shutdown node2.
    node2.getLifecycleService().shutdown();
    // wait store ops. finish.
    mapStore.awaitStores();
    // we should see at least expected store count.
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            int storeOperationCount = mapStore.count.intValue();
            assertTrue("expected : " + expectedStoreCount + ", actual : " + storeOperationCount, expectedStoreCount <= storeOperationCount);
        }
    });
}
Also used : MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) MapStoreWithStoreCount(com.hazelcast.map.impl.mapstore.MapStoreTest.MapStoreWithStoreCount) MapStoreConfig(com.hazelcast.config.MapStoreConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) MapConfig(com.hazelcast.config.MapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 42 with Config

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

the class MapStoreWriteBehindTest method testWriteBehindUpdateSameKey.

@Test(timeout = 120000)
public void testWriteBehindUpdateSameKey() throws Exception {
    final TestMapStore testMapStore = new TestMapStore(2, 0, 0);
    testMapStore.setLoadAllKeys(false);
    Config config = newConfig(testMapStore, 5);
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
    HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
    nodeFactory.newHazelcastInstance(config);
    IMap<Object, Object> map = instance.getMap("map");
    map.put("key", "value");
    Thread.sleep(2000);
    map.put("key", "value2");
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals("value2", testMapStore.getStore().get("key"));
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TestMapStore(com.hazelcast.map.impl.mapstore.MapStoreTest.TestMapStore) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 43 with Config

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

the class LiteMemberMapNearCacheBasicTest method createConfig.

protected Config createConfig(NearCacheConfig nearCacheConfig, boolean liteMember) {
    Config config = getConfig().setLiteMember(liteMember);
    config.getMapConfig(DEFAULT_NEAR_CACHE_NAME).setNearCacheConfig(nearCacheConfig);
    return config;
}
Also used : NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.NearCacheTestUtils.createNearCacheConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 44 with Config

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

the class MapNearCacheBasicTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
    Config config = getConfig();
    config.getMapConfig(DEFAULT_NEAR_CACHE_NAME).setNearCacheConfig(nearCacheConfig);
    HazelcastInstance[] instances = hazelcastFactory.newInstances(config);
    HazelcastInstance member = instances[0];
    IMap<K, V> map = member.getMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheManager nearCacheManager = getMapNearCacheManager(member);
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
    return new NearCacheTestContext<K, V, Data, String>(getSerializationService(member), member, new IMapDataStructureAdapter<K, V>(map), true, nearCache, nearCacheManager);
}
Also used : NearCacheTestContext(com.hazelcast.internal.nearcache.NearCacheTestContext) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCacheTestUtils.getMapNearCacheManager(com.hazelcast.internal.nearcache.NearCacheTestUtils.getMapNearCacheManager) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.NearCacheTestUtils.createNearCacheConfig) Config(com.hazelcast.config.Config) Data(com.hazelcast.nio.serialization.Data)

Example 45 with Config

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

the class TxnMapNearCacheBasicTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
    Config config = getConfig();
    config.getMapConfig(DEFAULT_NEAR_CACHE_NAME).setNearCacheConfig(nearCacheConfig);
    HazelcastInstance[] instances = hazelcastFactory.newInstances(config);
    HazelcastInstance member = instances[0];
    // this creates the Near Cache instance
    member.getMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheManager nearCacheManager = getMapNearCacheManager(member);
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
    return new NearCacheTestContext<K, V, Data, String>(getSerializationService(member), member, new TransactionalMapDataStructureAdapter<K, V>(member, DEFAULT_NEAR_CACHE_NAME), false, nearCache, nearCacheManager);
}
Also used : NearCacheTestContext(com.hazelcast.internal.nearcache.NearCacheTestContext) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCacheTestUtils.getMapNearCacheManager(com.hazelcast.internal.nearcache.NearCacheTestUtils.getMapNearCacheManager) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.NearCacheTestUtils.createNearCacheConfig) Config(com.hazelcast.config.Config) Data(com.hazelcast.nio.serialization.Data)

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