use of com.hazelcast.config.InMemoryFormat in project hazelcast by hazelcast.
the class ConfigValidator method checkMapMaxSizePolicyPerInMemoryFormat.
static void checkMapMaxSizePolicyPerInMemoryFormat(MapConfig mapConfig) {
MaxSizePolicy maxSizePolicy = mapConfig.getEvictionConfig().getMaxSizePolicy();
InMemoryFormat inMemoryFormat = mapConfig.getInMemoryFormat();
if (inMemoryFormat == NATIVE) {
if (!MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES.contains(maxSizePolicy)) {
throwNotMatchingMaxSizePolicy(inMemoryFormat, maxSizePolicy, MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES);
}
} else {
if (!MAP_SUPPORTED_ON_HEAP_MAX_SIZE_POLICIES.contains(maxSizePolicy)) {
throwNotMatchingMaxSizePolicy(inMemoryFormat, maxSizePolicy, MAP_SUPPORTED_ON_HEAP_MAX_SIZE_POLICIES);
}
}
}
use of com.hazelcast.config.InMemoryFormat in project hazelcast by hazelcast.
the class AbstractNearCachePreloaderTest method assertNearCacheContent.
private static void assertNearCacheContent(NearCacheTestContext<?, ?, ?, ?> context, int keyCount, KeyType keyType) {
InMemoryFormat inMemoryFormat = context.nearCacheConfig.getInMemoryFormat();
for (int i = 0; i < keyCount; i++) {
Object key = createKey(keyType, i);
Object nearCacheKey = getNearCacheKey(context, key);
String value = context.serializationService.toObject(getValueFromNearCache(context, nearCacheKey));
assertEqualsFormat("Expected value %s in Near Cache, but found %s (%s)", "value-" + i, value, context.stats);
assertNearCacheRecord(getRecordFromNearCache(context, nearCacheKey), i, inMemoryFormat);
}
}
use of com.hazelcast.config.InMemoryFormat in project hazelcast by hazelcast.
the class EntryProcessorTest method testExecuteOnEntriesWithEntryListener.
@Test
public void testExecuteOnEntriesWithEntryListener() {
IMap<String, String> map = createHazelcastInstance(getConfig()).getMap(MAP_NAME);
map.put("key", "value");
CountDownLatch latch = new CountDownLatch(1);
map.addEntryListener((EntryUpdatedListener<String, String>) event -> {
String val = event.getValue();
String oldValue = event.getOldValue();
if ("newValue".equals(val) && ((inMemoryFormat == BINARY || inMemoryFormat == NATIVE) && "value".equals(oldValue) || inMemoryFormat == OBJECT && null == oldValue)) {
latch.countDown();
}
}, true);
map.executeOnEntries(entry -> {
entry.setValue("newValue");
return 5;
});
assertOpenEventually(latch, 5);
}
use of com.hazelcast.config.InMemoryFormat in project hazelcast by hazelcast.
the class EntryProcessorTest method testExecuteOnKeysWithEntryListener.
@Test
public void testExecuteOnKeysWithEntryListener() {
IMap<String, String> map = createHazelcastInstance(getConfig()).getMap(MAP_NAME);
map.put("key", "value");
final CountDownLatch latch = new CountDownLatch(1);
map.addEntryListener((EntryUpdatedListener<String, String>) event -> {
String val = event.getValue();
String oldValue = event.getOldValue();
if ("newValue".equals(val) && ((inMemoryFormat == BINARY || inMemoryFormat == NATIVE) && "value".equals(oldValue) || inMemoryFormat == OBJECT && null == oldValue)) {
latch.countDown();
}
}, true);
HashSet<String> keys = new HashSet<>();
keys.add("key");
map.executeOnKeys(keys, entry -> {
entry.setValue("newValue");
return 5;
});
assertOpenEventually(latch, 5);
}
Aggregations