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();
}
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);
}
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);
}
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;
}
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());
}
Aggregations