use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class NearCachedMapProxyImpl method initialize.
@Override
public void initialize() {
super.initialize();
mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
NearCacheConfig nearCacheConfig = mapConfig.getNearCacheConfig();
nearCache = mapNearCacheManager.getOrCreateNearCache(name, nearCacheConfig);
if (invalidateOnChange) {
registerInvalidationListener();
}
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testNearCache_shutdownClient.
@Test
public void testNearCache_shutdownClient() {
ClientConfig clientConfig = new ClientConfig();
NearCacheConfig invalidateConfig = new NearCacheConfig();
String mapName = randomMapName();
invalidateConfig.setName(mapName);
invalidateConfig.setInvalidateOnChange(true);
clientConfig.addNearCacheConfig(invalidateConfig);
hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
IMap<Integer, Integer> map = client.getMap(mapName);
map.get(1);
// test should finish without throwing any exception.
client.shutdown();
}
use of com.hazelcast.config.NearCacheConfig 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().setMaxSizePolicy(ENTRY_COUNT).setSize(1);
NearCacheConfig nearCacheConfig = new NearCacheConfig().setName(mapName).setEvictionConfig(evictionConfig);
ClientConfig clientConfig = new ClientConfig().addNearCacheConfig(nearCacheConfig);
CountDownLatch disconnectedLatch = new CountDownLatch(1);
CountDownLatch finishedLatch = new CountDownLatch(1);
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Long.MAX_VALUE);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
IMap<Object, Object> map = client.getMap(mapName);
client.getLifecycleService().addLifecycleListener(event -> {
if (event.getState() == CLIENT_DISCONNECTED) {
disconnectedLatch.countDown();
map.get(1);
map.get(2);
finishedLatch.countDown();
}
});
instance.shutdown();
assertOpenEventually(disconnectedLatch);
hazelcastFactory.newHazelcastInstance();
assertOpenEventually(finishedLatch);
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testNearCache_WhenRegisteredNodeIsDead.
@Test
public void testNearCache_WhenRegisteredNodeIsDead() {
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Long.MAX_VALUE);
String mapName = randomMapName();
NearCacheConfig nearCacheConfig = new NearCacheConfig();
nearCacheConfig.setName(mapName);
nearCacheConfig.setInvalidateOnChange(true);
clientConfig.addNearCacheConfig(nearCacheConfig);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
IMap<Object, Object> map = client.getMap(mapName);
map.put("a", "b");
// populate Near Cache
map.get("a");
instance.shutdown();
hazelcastFactory.newHazelcastInstance();
assertTrueEventually(() -> assertNull(map.get("a")));
}
use of com.hazelcast.config.NearCacheConfig in project hazelcast by hazelcast.
the class ClientNearCacheConfigTest method testSpecificNearCacheConfig_whenAsteriskAtTheEnd.
@Test
public void testSpecificNearCacheConfig_whenAsteriskAtTheEnd() {
final ClientConfig clientConfig = new ClientConfig();
final NearCacheConfig genericNearCacheConfig = new NearCacheConfig();
genericNearCacheConfig.setName("map*");
clientConfig.addNearCacheConfig(genericNearCacheConfig);
final NearCacheConfig specificNearCacheConfig = new NearCacheConfig();
specificNearCacheConfig.setName("mapStudent*");
clientConfig.addNearCacheConfig(specificNearCacheConfig);
final NearCacheConfig mapFoo = clientConfig.getNearCacheConfig("mapFoo");
final NearCacheConfig mapStudentFoo = clientConfig.getNearCacheConfig("mapStudentFoo");
assertEquals(genericNearCacheConfig, mapFoo);
assertEquals(specificNearCacheConfig, mapStudentFoo);
}
Aggregations