Search in sources :

Example 61 with Config

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

the class EntryProcessorTest method testEntryProcessorNoDeserializationWithObjectFormat.

@Test
public void testEntryProcessorNoDeserializationWithObjectFormat() {
    // EntryProcessor contract difference between OBJECT and BINARY
    int expectedDeserializationCount = inMemoryFormat == OBJECT ? 0 : 1;
    Config cfg = getConfig();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
    HazelcastInstance instance = factory.newHazelcastInstance(cfg);
    IMap<String, MyObject> map = instance.getMap(MAP_NAME);
    map.executeOnKey("key", new StoreOperation());
    Integer serialized = (Integer) map.executeOnKey("key", new FetchDeSerializedCount());
    assertEquals(expectedDeserializationCount, serialized.intValue());
    instance.shutdown();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 62 with Config

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

the class EntryProcessorTest method executionOrderTest.

@Test
public void executionOrderTest() {
    Config cfg = getConfig();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
    HazelcastInstance instance1 = factory.newHazelcastInstance(cfg);
    final int maxTasks = 20;
    final Object key = "key";
    final IMap<Object, List<Integer>> processorMap = instance1.getMap(MAP_NAME);
    processorMap.put(key, new ArrayList<Integer>());
    for (int i = 0; i < maxTasks; i++) {
        processorMap.submitToKey(key, new SimpleEntryProcessor(i));
    }
    List<Integer> expectedOrder = new ArrayList<Integer>();
    for (int i = 0; i < maxTasks; i++) {
        expectedOrder.add(i);
    }
    assertTrueEventually(new AssertTask() {

        public void run() throws Exception {
            List<Integer> actualOrder = processorMap.get(key);
            assertEquals("failed to execute all entry processor tasks", maxTasks, actualOrder.size());
        }
    });
    List<Integer> actualOrder = processorMap.get(key);
    assertEquals("entry processor tasks executed in unexpected order", expectedOrder, actualOrder);
}
Also used : MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) EntryObject(com.hazelcast.query.EntryObject) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 63 with Config

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

the class EvictionMaxSizePolicyTest method testUsedHeapSizePolicy.

@Test
public void testUsedHeapSizePolicy() {
    final int perNodeHeapMaxSizeInMegaBytes = 10;
    final int nodeCount = 1;
    final String mapName = randomMapName();
    final Config config = createConfig(USED_HEAP_SIZE, perNodeHeapMaxSizeInMegaBytes, mapName);
    final Collection<IMap> maps = createMaps(mapName, config, nodeCount);
    setTestSizeEstimator(maps, MEGABYTES.toBytes(1));
    populateMaps(maps, 100);
    assertUsedHeapSizePolicyWorks(maps, perNodeHeapMaxSizeInMegaBytes);
}
Also used : IMap(com.hazelcast.core.IMap) MaxSizeConfig(com.hazelcast.config.MaxSizeConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 64 with Config

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

the class EvictionMaxSizePolicyTest method createConfig.

Config createConfig(MaxSizeConfig.MaxSizePolicy maxSizePolicy, int maxSize, String mapName) {
    Config config = getConfig();
    config.setProperty(GroupProperty.PARTITION_COUNT.getName(), String.valueOf(PARTITION_COUNT));
    MaxSizeConfig msc = new MaxSizeConfig();
    msc.setMaxSizePolicy(maxSizePolicy);
    msc.setSize(maxSize);
    MapConfig mapConfig = config.getMapConfig(mapName);
    mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
    mapConfig.setEvictionPercentage(25);
    mapConfig.setMaxSizeConfig(msc);
    mapConfig.setMinEvictionCheckMillis(0L);
    return config;
}
Also used : MaxSizeConfig(com.hazelcast.config.MaxSizeConfig) MaxSizeConfig(com.hazelcast.config.MaxSizeConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig)

Example 65 with Config

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

the class EvictionMaxSizePolicyTest method testOwnerAndBackupEntryCountsAreEqualAfterEviction_whenPerNodeMaxSizePolicyIsUsed.

@Test
public void testOwnerAndBackupEntryCountsAreEqualAfterEviction_whenPerNodeMaxSizePolicyIsUsed() throws Exception {
    String mapName = randomMapName();
    Config config = createConfig(PER_NODE, 300, mapName);
    TestHazelcastInstanceFactory instanceFactory = createHazelcastInstanceFactory(2);
    HazelcastInstance node1 = instanceFactory.newHazelcastInstance(config);
    HazelcastInstance node2 = instanceFactory.newHazelcastInstance(config);
    IMap<Integer, Integer> map1 = node1.getMap(mapName);
    for (int i = 0; i < 2222; i++) {
        map1.put(i, i);
    }
    IMap map2 = node2.getMap(mapName);
    LocalMapStats localMapStats1 = map1.getLocalMapStats();
    LocalMapStats localMapStats2 = map2.getLocalMapStats();
    assertEquals(localMapStats1.getOwnedEntryCount(), localMapStats2.getBackupEntryCount());
    assertEquals(localMapStats2.getOwnedEntryCount(), localMapStats1.getBackupEntryCount());
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MaxSizeConfig(com.hazelcast.config.MaxSizeConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) 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