Search in sources :

Example 81 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 82 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)

Example 83 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 84 with Config

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

the class QueryAdvancedTest method testUnknownPortableField_notCausesQueryException_withoutIndex.

@Test
public // see: https://github.com/hazelcast/hazelcast/issues/3927
void testUnknownPortableField_notCausesQueryException_withoutIndex() {
    String mapName = randomMapName();
    Config config = getConfig();
    config.getSerializationConfig().addPortableFactory(666, new PortableFactory() {

        public Portable create(int classId) {
            return new PortableEmployee();
        }
    });
    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    IMap<Integer, PortableEmployee> map = hazelcastInstance.getMap(mapName);
    for (int i = 0; i < 5; i++) {
        map.put(i, new PortableEmployee(i, "name_" + i));
    }
    Collection values = map.values(new SqlPredicate("notExist = name_0 OR a > 1"));
    assertEquals(3, values.size());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Portable(com.hazelcast.nio.serialization.Portable) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) PortableEmployee(com.hazelcast.query.SampleObjects.PortableEmployee) Collection(java.util.Collection) SqlPredicate(com.hazelcast.query.SqlPredicate) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 85 with Config

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

the class QueryAdvancedTest method testTwoMembersWithIndexes.

@Test
public void testTwoMembersWithIndexes() {
    Config config = getConfig();
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
    HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
    nodeFactory.newHazelcastInstance(config);
    IMap<String, Employee> map = instance.getMap("employees");
    map.addIndex("name", false);
    map.addIndex("age", true);
    map.addIndex("active", false);
    QueryBasicTest.doFunctionalQueryTest(map);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Employee(com.hazelcast.query.SampleObjects.Employee) PortableEmployee(com.hazelcast.query.SampleObjects.PortableEmployee) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) 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