use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class EvictionTest method testRandomEvictionPolicyWorks.
@Test
public void testRandomEvictionPolicyWorks() throws Exception {
Config config = getConfig();
int maxSize = 300;
config.getMapConfig("test").setEvictionPolicy(RANDOM).getMaxSizeConfig().setSize(maxSize).setMaxSizePolicy(PER_NODE);
HazelcastInstance node = createHazelcastInstance(config);
IMap<Integer, Integer> map = node.getMap("test");
for (int i = 0; i < 500; i++) {
map.put(i, i);
}
int size = map.size();
String message = "map-size should be smaller than max-size but found [map-size = %d and max-size = %d]";
assertTrue(format(message, size, maxSize), size <= maxSize);
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class InMemoryFormatTest method testIssue2622.
/**
* if statistics enabled InMemoryFormat.Object does not work
*/
@Test
public void testIssue2622() {
final String mapName = randomString();
Config config = new Config();
final MapConfig mapConfig = new MapConfig(mapName);
mapConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
mapConfig.setStatisticsEnabled(true);
config.addMapConfig(mapConfig);
final HazelcastInstance instance = createHazelcastInstance(config);
final IMap<String, SerializationValue> map = instance.getMap(mapName);
final SerializationValue serializationValue = new SerializationValue();
map.put("key", serializationValue);
// EntryProcessor should not trigger de-serialization
map.executeOnKey("key", new AbstractEntryProcessor<String, SerializationValue>() {
@Override
public Object process(final Map.Entry<String, SerializationValue> entry) {
return null;
}
});
assertEquals(1, SerializationValue.deSerializeCount.get());
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class InMemoryFormatTest method testNativeNearCache_throwsException.
@Test(expected = IllegalArgumentException.class)
public void testNativeNearCache_throwsException() throws Exception {
NearCacheConfig nearCacheConfig = new NearCacheConfig();
nearCacheConfig.setInMemoryFormat(InMemoryFormat.NATIVE);
Config config = getConfig();
config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
HazelcastInstance member = createHazelcastInstance(config);
member.getMap("default");
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class InMemoryFormatTest method testNativeIMap_throwsException.
@Test(expected = IllegalArgumentException.class)
public void testNativeIMap_throwsException() throws Exception {
Config config = getConfig();
config.getMapConfig("default").setInMemoryFormat(InMemoryFormat.NATIVE);
HazelcastInstance member = createHazelcastInstance(config);
member.getMap("default");
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class InterceptorTest method testGetAll_withGetInterceptor.
@Test
public void testGetAll_withGetInterceptor() throws InterruptedException {
HazelcastInstance instance1 = createHazelcastInstance(getConfig());
IMap<Integer, String> map = instance1.getMap(randomString());
map.addInterceptor(new SimpleInterceptor());
Set<Integer> set = new HashSet<Integer>();
for (int i = 0; i < 100; i++) {
map.put(i, String.valueOf(i));
set.add(i);
}
Map<Integer, String> allValues = map.getAll(set);
for (int i = 0; i < 100; i++) {
assertEquals(String.valueOf(i) + ":", allValues.get(i));
}
}
Aggregations