Search in sources :

Example 11 with NearCacheTestContextBuilder

use of com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder in project hazelcast by hazelcast.

the class ClientCacheNearCacheInvalidationTest method createNearCacheTest.

private <K, V, NK, NV> NearCacheTestContext<K, V, NK, NV> createNearCacheTest(String cacheName, NearCacheConfig nearCacheConfig, CacheConfig<K, V> cacheConfig) {
    ClientConfig clientConfig = getClientConfig().setProperty(RECONCILIATION_INTERVAL_SECONDS.getName(), "0").addNearCacheConfig(nearCacheConfig);
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    CachingProvider provider = createClientCachingProvider(client);
    HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
    ICache<K, V> cache = cacheManager.createCache(cacheName, cacheConfig);
    NearCacheManager nearCacheManager = ((ClientCacheProxy) cache).getContext().getNearCacheManager(CacheService.SERVICE_NAME);
    NearCache<NK, NV> nearCache = nearCacheManager.getNearCache(cacheManager.getCacheNameWithPrefix(cacheName));
    NearCacheTestContextBuilder<K, V, NK, NV> builder = new NearCacheTestContextBuilder<>(nearCacheConfig, client.getSerializationService());
    return builder.setNearCacheInstance(client).setNearCacheAdapter(new ICacheDataStructureAdapter<>(cache)).setNearCacheManager(nearCacheManager).setNearCache(nearCache).build();
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCacheTestContextBuilder(com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder) ICacheDataStructureAdapter(com.hazelcast.internal.adapter.ICacheDataStructureAdapter) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager)

Example 12 with NearCacheTestContextBuilder

use of com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder 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);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCacheTestContextBuilder(com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder) Data(com.hazelcast.internal.serialization.Data) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

Example 13 with NearCacheTestContextBuilder

use of com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder 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);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCacheTestContextBuilder(com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder) Data(com.hazelcast.internal.serialization.Data) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

Example 14 with NearCacheTestContextBuilder

use of com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder in project hazelcast by hazelcast.

the class MapNearCacheBasicTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder(IMapMapStore mapStore) {
    Config configWithNearCache = createConfig(mapStore, true);
    HazelcastInstance nearCacheInstance = hazelcastFactory.newHazelcastInstance(configWithNearCache);
    IMap<K, V> nearCacheMap = nearCacheInstance.getMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheManager nearCacheManager = getMapNearCacheManager(nearCacheInstance);
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, getSerializationService(nearCacheInstance)).setNearCacheInstance(nearCacheInstance).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(nearCacheMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setLoader(mapStore).setHasLocalData(true);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) NearCacheTestUtils.getMapNearCacheManager(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager) NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) NearCacheTestContextBuilder(com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder) Data(com.hazelcast.internal.serialization.Data)

Example 15 with NearCacheTestContextBuilder

use of com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder in project hazelcast by hazelcast.

the class MapNearCacheLeakTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
    Config configWithNearCache = getConfig(true);
    HazelcastInstance nearCacheInstance = hazelcastFactory.newHazelcastInstance(configWithNearCache);
    IMap<K, V> nearCacheMap = nearCacheInstance.getMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheManager nearCacheManager = getMapNearCacheManager(nearCacheInstance);
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
    RepairingTask repairingTask = ((MapNearCacheManager) nearCacheManager).getRepairingTask();
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, getSerializationService(nearCacheInstance)).setNearCacheInstance(nearCacheInstance).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(nearCacheMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setHasLocalData(true).setRepairingTask(repairingTask);
}
Also used : NearCacheTestUtils.getMapNearCacheManager(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager) NearCacheTestUtils.getMapNearCacheManager(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager) NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) RepairingTask(com.hazelcast.internal.nearcache.impl.invalidation.RepairingTask) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) Data(com.hazelcast.internal.serialization.Data) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NearCacheTestContextBuilder(com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder)

Aggregations

NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)15 NearCacheTestContextBuilder (com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder)15 Data (com.hazelcast.internal.serialization.Data)13 ClientConfig (com.hazelcast.client.config.ClientConfig)9 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)9 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 NearCacheTestUtils.getMapNearCacheManager (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager)6 Config (com.hazelcast.config.Config)4 NearCacheTestUtils.getBaseConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig)4 CacheTestSupport.createClientCachingProvider (com.hazelcast.cache.CacheTestSupport.createClientCachingProvider)3 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)3 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)3 NearCacheTestUtils.createNearCacheConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig)3 CachingProvider (javax.cache.spi.CachingProvider)3 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)2 MapConfig (com.hazelcast.config.MapConfig)2 ICacheDataStructureAdapter (com.hazelcast.internal.adapter.ICacheDataStructureAdapter)2 RepairingTask (com.hazelcast.internal.nearcache.impl.invalidation.RepairingTask)2 HazelcastServerCacheManager (com.hazelcast.cache.impl.HazelcastServerCacheManager)1 ClientContext (com.hazelcast.client.impl.spi.ClientContext)1