use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class ClientMapNearCacheBasicTest method createNearCacheContextBuilder.
private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
ClientConfig clientConfig = getClientConfig();
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
IMap<K, V> clientMap = client.getMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = ((ClientMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager);
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class ClientMapNearCachePreloaderTest method createNearCacheContextBuilder.
private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
IMap<K, V> clientMap = client.getMap(nearCacheConfig.getName());
NearCacheManager nearCacheManager = ((ClientMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(nearCacheConfig.getName());
return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager);
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class NearCachedClientMapProxy method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
NearCacheConfig nearCacheConfig = getContext().getClientConfig().getNearCacheConfig(name);
serializeKeys = nearCacheConfig.isSerializeKeys();
NearCacheManager nearCacheManager = getContext().getNearCacheManager(getServiceName());
nearCache = nearCacheManager.getOrCreateNearCache(name, nearCacheConfig);
if (nearCacheConfig.isInvalidateOnChange()) {
registerInvalidationListener();
}
if (nearCacheConfig.getPreloaderConfig().isEnabled()) {
nearCacheManager.startPreloading(nearCache, new IMapDataStructureAdapter<>(this));
}
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class ClientReplicatedMapNearCacheLeakTest method createNearCacheContextBuilder.
private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
ClientConfig clientConfig = getClientConfig();
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
ReplicatedMap<K, V> clientMap = client.getReplicatedMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = ((ClientReplicatedMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new ReplicatedMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager);
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class NearCacheManagerTestSupport method doCreateAndGetNearCache.
void doCreateAndGetNearCache() {
NearCacheManager nearCacheManager = createNearCacheManager();
assertNull(nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME));
NearCache createdNearCache1 = createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME);
assertNotNull(createdNearCache1);
NearCache createdNearCache2 = createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME);
assertNotNull(createdNearCache2);
assertEquals(createdNearCache1, createdNearCache2);
Collection<NearCache> nearCaches = nearCacheManager.listAllNearCaches();
assertEquals(1, nearCaches.size());
assertEquals(createdNearCache1, nearCaches.iterator().next());
}
Aggregations