use of com.hazelcast.config.EvictionConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testDeadlock_whenDoingOperationFromLifecycleListener_withNearCache.
@Test
public void testDeadlock_whenDoingOperationFromLifecycleListener_withNearCache() {
String mapName = randomMapName();
EvictionConfig evictionConfig = new EvictionConfig().setMaximumSizePolicy(ENTRY_COUNT).setSize(1);
NearCacheConfig nearCacheConfig = new NearCacheConfig().setName(mapName).setEvictionConfig(evictionConfig);
ClientConfig clientConfig = new ClientConfig().addNearCacheConfig(nearCacheConfig).setExecutorPoolSize(1);
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
hazelcastFactory.newHazelcastInstance();
final CountDownLatch latch = new CountDownLatch(1);
final IMap<Object, Object> map = client.getMap(mapName);
client.getLifecycleService().addLifecycleListener(new LifecycleListener() {
@Override
public void stateChanged(LifecycleEvent event) {
if (event.getState() == LifecycleState.CLIENT_DISCONNECTED) {
map.get(1);
map.get(2);
latch.countDown();
}
}
});
instance.shutdown();
assertOpenEventually(latch);
}
use of com.hazelcast.config.EvictionConfig in project hazelcast by hazelcast.
the class TestJCache method cacheConfigXmlTest_ComparatorBean.
@Test
public void cacheConfigXmlTest_ComparatorBean() {
assertNotNull(instance1);
CacheSimpleConfig cacheConfigWithComparatorClassName = instance1.getConfig().getCacheConfig("cacheWithComparatorBean");
assertNotNull(cacheConfigWithComparatorClassName);
EvictionConfig evictionConfig = cacheConfigWithComparatorClassName.getEvictionConfig();
assertNotNull(evictionConfig);
assertEquals(MyEvictionPolicyComparator.class, evictionConfig.getComparator().getClass());
}
use of com.hazelcast.config.EvictionConfig in project hazelcast by hazelcast.
the class TestJCache method cacheConfigXmlTest_ComparatorClassName.
@Test
public void cacheConfigXmlTest_ComparatorClassName() {
assertNotNull(instance1);
CacheSimpleConfig cacheConfigWithComparatorClassName = instance1.getConfig().getCacheConfig("cacheWithComparatorClassName");
assertNotNull(cacheConfigWithComparatorClassName);
EvictionConfig evictionConfig = cacheConfigWithComparatorClassName.getEvictionConfig();
assertNotNull(evictionConfig);
assertEquals("com.mycompany.MyEvictionPolicyComparator", evictionConfig.getComparatorClassName());
}
use of com.hazelcast.config.EvictionConfig in project hazelcast by hazelcast.
the class QueryCacheConfigBuilderHelper method getEvictionConfig.
private EvictionConfig getEvictionConfig(final Node node) {
final EvictionConfig evictionConfig = new EvictionConfig();
final Node size = node.getAttributes().getNamedItem("size");
final Node maxSizePolicy = node.getAttributes().getNamedItem("max-size-policy");
final Node evictionPolicy = node.getAttributes().getNamedItem("eviction-policy");
if (size != null) {
evictionConfig.setSize(Integer.parseInt(getTextContent(size)));
}
if (maxSizePolicy != null) {
evictionConfig.setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.valueOf(upperCaseInternal(getTextContent(maxSizePolicy))));
}
if (evictionPolicy != null) {
evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(upperCaseInternal(getTextContent(evictionPolicy))));
}
return evictionConfig;
}
use of com.hazelcast.config.EvictionConfig in project hazelcast by hazelcast.
the class CacheEvictionPolicyComparatorTest method test_evictionPolicyComparator_with_comparatorInstance_when_maxSizePolicy_is_entryCount.
@Test
public void test_evictionPolicyComparator_with_comparatorInstance_when_maxSizePolicy_is_entryCount() {
int partitionCount = Integer.parseInt(GroupProperty.PARTITION_COUNT.getDefaultValue());
int iterationCount = (EntryCountCacheEvictionChecker.calculateMaxPartitionSize(EvictionConfig.DEFAULT_MAX_ENTRY_COUNT, partitionCount) * partitionCount) * 2;
EvictionConfig evictionConfig = new EvictionConfig().setComparator(new MyEvictionPolicyComparator());
do_test_evictionPolicyComparator(evictionConfig, iterationCount);
}
Aggregations