Search in sources :

Example 11 with Config

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

the class LocalMapStatsTest method testLocalMapStats_withMemberGroups.

@Test
public void testLocalMapStats_withMemberGroups() throws Exception {
    final String mapName = randomMapName();
    final String[] firstMemberGroup = { "127.0.0.1", "127.0.0.2" };
    final String[] secondMemberGroup = { "127.0.0.3" };
    final Config config = createConfig(mapName, firstMemberGroup, secondMemberGroup);
    final String[] addressArray = concatenateArrays(firstMemberGroup, secondMemberGroup);
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(addressArray);
    final HazelcastInstance node1 = factory.newHazelcastInstance(config);
    final HazelcastInstance node2 = factory.newHazelcastInstance(config);
    final HazelcastInstance node3 = factory.newHazelcastInstance(config);
    final IMap<Object, Object> test = node3.getMap(mapName);
    test.put(1, 1);
    assertBackupEntryCount(1, mapName, factory.getAllHazelcastInstances());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 12 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 13 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)

Example 14 with Config

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

the class MapInvalidationMetaDataMigrationTest method newConfig.

protected Config newConfig(String mapName) {
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setInMemoryFormat(getNearCacheInMemoryFormat());
    nearCacheConfig.setName(mapName);
    nearCacheConfig.setInvalidateOnChange(true);
    nearCacheConfig.setCacheLocalEntries(true);
    MapConfig mapConfig = new MapConfig(mapName);
    mapConfig.setNearCacheConfig(nearCacheConfig);
    mapConfig.setBackupCount(0).setAsyncBackupCount(0);
    Config config = getConfig();
    return config.addMapConfig(mapConfig);
}
Also used : MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapConfig(com.hazelcast.config.MapConfig)

Example 15 with Config

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

the class MapInvalidationMetaDataMigrationTest method sequences_migrated_whenOneNodeContinuouslyStartsAndStops.

@Test
public void sequences_migrated_whenOneNodeContinuouslyStartsAndStops() throws Exception {
    final String mapName = "test";
    final Config config = newConfig(mapName);
    final 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);
    final AtomicBoolean stop = new AtomicBoolean();
    Thread shadow = new Thread(new Runnable() {

        public void run() {
            while (!stop.get()) {
                HazelcastInstance instance = factory.newHazelcastInstance(config);
                waitAllForSafeState(instance);
                sleepSeconds(5);
                instance.shutdown();
            }
        }
    });
    shadow.start();
    sleepSeconds(20);
    stop.set(true);
    shadow.join();
    instance2.shutdown();
    Map<Integer, Long> destination = getPartitionToSequenceMap(mapName, instance1);
    assertEquals(source, destination);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

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