Search in sources :

Example 16 with HazelcastClientProxy

use of com.hazelcast.client.impl.HazelcastClientProxy in project hazelcast by hazelcast.

the class ClientMapNearCachePreloaderTest method createClientContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createClientContext() {
    ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    IMap<K, V> clientMap = client.getMap(nearCacheConfig.getName());
    NearCacheManager nearCacheManager = client.client.getNearCacheManager();
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(nearCacheConfig.getName());
    return new NearCacheTestContext<K, V, Data, String>(client.getSerializationService(), client, null, new IMapDataStructureAdapter<K, V>(clientMap), null, false, nearCache, nearCacheManager);
}
Also used : NearCacheTestContext(com.hazelcast.internal.nearcache.NearCacheTestContext) NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) Data(com.hazelcast.nio.serialization.Data) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy)

Example 17 with HazelcastClientProxy

use of com.hazelcast.client.impl.HazelcastClientProxy 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 18 with HazelcastClientProxy

use of com.hazelcast.client.impl.HazelcastClientProxy in project hazelcast by hazelcast.

the class ClientCacheStatsTest method testNearCacheStatsWhenNearCacheEnabled.

@Test
public void testNearCacheStatsWhenNearCacheEnabled() {
    String cacheName = randomName();
    CacheConfig cacheConfig = createCacheConfig();
    cacheConfig.setName(cacheName);
    ClientConfig clientConfig = ((HazelcastClientProxy) client).getClientConfig();
    clientConfig.addNearCacheConfig(new NearCacheConfig().setName(cacheName));
    ICache<Integer, String> cache = createCache(cacheName, cacheConfig);
    CacheStatistics stats = cache.getLocalCacheStatistics();
    assertNotNull(stats.getNearCacheStatistics());
}
Also used : CacheStatistics(com.hazelcast.cache.CacheStatistics) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) CacheStatsTest(com.hazelcast.cache.stats.CacheStatsTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)18 ClientConfig (com.hazelcast.client.config.ClientConfig)13 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)9 HazelcastInstance (com.hazelcast.core.HazelcastInstance)9 Data (com.hazelcast.nio.serialization.Data)9 CachingProvider (javax.cache.spi.CachingProvider)9 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)8 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)7 NearCacheTestContext (com.hazelcast.internal.nearcache.NearCacheTestContext)6 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)5 HazelcastClientInstanceImpl (com.hazelcast.client.impl.HazelcastClientInstanceImpl)5 CacheConfig (com.hazelcast.config.CacheConfig)5 NearCacheConfig (com.hazelcast.config.NearCacheConfig)5 Config (com.hazelcast.config.Config)4 Test (org.junit.Test)4 HazelcastServerCacheManager (com.hazelcast.cache.impl.HazelcastServerCacheManager)3 NightlyTest (com.hazelcast.test.annotation.NightlyTest)3 CacheManager (javax.cache.CacheManager)3 ClientCacheProxy (com.hazelcast.client.cache.impl.ClientCacheProxy)2 XmlClientConfigBuilder (com.hazelcast.client.config.XmlClientConfigBuilder)2