Search in sources :

Example 26 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.

the class ClientCacheNearCacheSerializationCountTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
    Config config = getConfig();
    prepareSerializationConfig(config.getSerializationConfig());
    ClientConfig clientConfig = getClientConfig();
    if (nearCacheConfig != null) {
        clientConfig.addNearCacheConfig(nearCacheConfig);
    }
    prepareSerializationConfig(clientConfig.getSerializationConfig());
    CacheConfig<K, V> cacheConfig = createCacheConfig(cacheInMemoryFormat);
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    CachingProvider memberProvider = HazelcastServerCachingProvider.createCachingProvider(member);
    HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) memberProvider.getCacheManager();
    NearCacheManager nearCacheManager = client.client.getNearCacheManager();
    CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
    HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
    String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(DEFAULT_NEAR_CACHE_NAME);
    ICache<K, V> clientCache = cacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
    ICache<K, V> memberCache = memberCacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
    return new NearCacheTestContext<K, V, Data, String>(client.getSerializationService(), client, member, new ICacheDataStructureAdapter<K, V>(clientCache), new ICacheDataStructureAdapter<K, V>(memberCache), false, nearCache, nearCacheManager, cacheManager, memberCacheManager);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) ClientConfig(com.hazelcast.client.config.ClientConfig) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.NearCacheTestUtils.createNearCacheConfig) Config(com.hazelcast.config.Config) CacheConfig(com.hazelcast.config.CacheConfig) HazelcastServerCacheManager(com.hazelcast.cache.impl.HazelcastServerCacheManager) Data(com.hazelcast.nio.serialization.Data) NearCacheTestContext(com.hazelcast.internal.nearcache.NearCacheTestContext) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager)

Example 27 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.

the class ClientCacheNearCacheBasicTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder(CacheConfig<K, V> cacheConfig) {
    ClientConfig clientConfig = getClientConfig();
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    CachingProvider provider = createClientCachingProvider(client);
    HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
    ICache<K, V> clientCache = cacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
    NearCacheManager nearCacheManager = ((ClientCacheProxy) clientCache).getContext().getNearCacheManager(clientCache.getServiceName());
    String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(DEFAULT_NEAR_CACHE_NAME);
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new ICacheDataStructureAdapter<K, V>(clientCache)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setCacheManager(cacheManager);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) Data(com.hazelcast.internal.serialization.Data) ICacheDataStructureAdapter(com.hazelcast.internal.adapter.ICacheDataStructureAdapter) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager)

Example 28 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.

the class ClientCacheNearCachePreloaderTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder(CacheConfig<K, V> cacheConfig) {
    ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    CachingProvider provider = createClientCachingProvider(client);
    HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
    String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(nearCacheConfig.getName());
    ICache<K, V> clientCache = cacheManager.createCache(nearCacheConfig.getName(), cacheConfig);
    NearCacheManager nearCacheManager = ((ClientCacheProxy) clientCache).getContext().getNearCacheManager(clientCache.getServiceName());
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new ICacheDataStructureAdapter<>(clientCache)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setCacheManager(cacheManager);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) Data(com.hazelcast.internal.serialization.Data) ICacheDataStructureAdapter(com.hazelcast.internal.adapter.ICacheDataStructureAdapter) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager)

Example 29 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.

the class ClientCacheNearCacheSerializationCountTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder(CacheConfig<K, V> cacheConfig) {
    ClientConfig clientConfig = getClientConfig();
    if (nearCacheConfig != null) {
        clientConfig.addNearCacheConfig(nearCacheConfig);
    }
    prepareSerializationConfig(clientConfig.getSerializationConfig());
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    CachingProvider provider = createClientCachingProvider(client);
    HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
    String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(DEFAULT_NEAR_CACHE_NAME);
    ICache<K, V> clientCache = cacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
    NearCacheManager nearCacheManager = ((ClientCacheProxy) clientCache).getContext().getNearCacheManager(clientCache.getServiceName());
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new ICacheDataStructureAdapter<>(clientCache)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setCacheManager(cacheManager);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) Data(com.hazelcast.internal.serialization.Data) 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) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager)

Example 30 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager 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)

Aggregations

NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)40 ClientConfig (com.hazelcast.client.config.ClientConfig)22 Data (com.hazelcast.internal.serialization.Data)21 HazelcastInstance (com.hazelcast.core.HazelcastInstance)19 NearCacheTestContextBuilder (com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder)15 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)13 Config (com.hazelcast.config.Config)12 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)11 Data (com.hazelcast.nio.serialization.Data)11 CachingProvider (javax.cache.spi.CachingProvider)11 NearCacheTestUtils.getMapNearCacheManager (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager)10 NearCacheTestContext (com.hazelcast.internal.nearcache.NearCacheTestContext)9 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)8 NearCacheTestUtils.getBaseConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig)8 NearCacheTestUtils.createNearCacheConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig)7 CacheTestSupport.createClientCachingProvider (com.hazelcast.cache.CacheTestSupport.createClientCachingProvider)6 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)6 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)6 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)5 MapConfig (com.hazelcast.config.MapConfig)5