Search in sources :

Example 1 with ClientProxy

use of com.hazelcast.client.impl.spi.ClientProxy in project hazelcast by hazelcast.

the class ClientCacheNearCacheLeakTest 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);
    ClientContext clientContext = ((ClientProxy) clientCache).getContext();
    RepairingTask repairingTask = clientContext.getRepairingTask(CacheService.SERVICE_NAME);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new ICacheDataStructureAdapter<K, V>(clientCache)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setCacheManager(cacheManager).setRepairingTask(repairingTask);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) RepairingTask(com.hazelcast.internal.nearcache.impl.invalidation.RepairingTask) ClientContext(com.hazelcast.client.impl.spi.ClientContext) Data(com.hazelcast.internal.serialization.Data) NearCacheTestContextBuilder(com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder) ClientProxy(com.hazelcast.client.impl.spi.ClientProxy) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) 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 2 with ClientProxy

use of com.hazelcast.client.impl.spi.ClientProxy in project hazelcast by hazelcast.

the class ClientCacheInvalidationMetaDataFetcherTest method getRepairingTask.

@SuppressWarnings("unchecked")
private RepairingTask getRepairingTask(String cacheName, int partition, long givenSequence, UUID givenUuid) {
    HazelcastInstance member = factory.newHazelcastInstance();
    distortRandomPartitionSequence(getPrefixedName(cacheName), partition, givenSequence, member);
    distortRandomPartitionUuid(partition, givenUuid, member);
    ClientConfig clientConfig = new ClientConfig().addNearCacheConfig(new NearCacheConfig(cacheName));
    HazelcastClientProxy client = (HazelcastClientProxy) factory.newHazelcastClient(clientConfig);
    CachingProvider clientCachingProvider = createClientCachingProvider(client);
    Cache<Integer, Integer> clientCache = clientCachingProvider.getCacheManager().createCache(cacheName, newCacheConfig());
    ClientContext clientContext = ((ClientProxy) clientCache).getContext();
    return clientContext.getRepairingTask(SERVICE_NAME);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientContext(com.hazelcast.client.impl.spi.ClientContext) ClientProxy(com.hazelcast.client.impl.spi.ClientProxy) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider) CachingProvider(javax.cache.spi.CachingProvider)

Example 3 with ClientProxy

use of com.hazelcast.client.impl.spi.ClientProxy in project hazelcast by hazelcast.

the class ProxyEqualityTest method testProxiesAreCached.

@Test
public void testProxiesAreCached() {
    ClientProxy ref1 = (ClientProxy) client1ClusterA.getSet(name);
    ClientProxy ref2 = (ClientProxy) client1ClusterA.getSet(name);
    assertSame(ref1, ref2);
}
Also used : ClientProxy(com.hazelcast.client.impl.spi.ClientProxy) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with ClientProxy

use of com.hazelcast.client.impl.spi.ClientProxy in project hazelcast by hazelcast.

the class ProxyEqualityTest method testTwoClientProxiesFromTheSameInstanceAreEquals.

@Test
public void testTwoClientProxiesFromTheSameInstanceAreEquals() {
    ClientProxy ref1 = (ClientProxy) client1ClusterA.getSet(name);
    ClientProxy ref2 = (ClientProxy) client1ClusterA.getSet(name);
    assertEquals(ref1, ref2);
}
Also used : ClientProxy(com.hazelcast.client.impl.spi.ClientProxy) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with ClientProxy

use of com.hazelcast.client.impl.spi.ClientProxy in project hazelcast by hazelcast.

the class ProxyEqualityTest method testTwoClientProxiesFromTwoDifferentClientsConnectedToTheSameInstanceAreNotEquals.

@Test
public void testTwoClientProxiesFromTwoDifferentClientsConnectedToTheSameInstanceAreNotEquals() {
    ClientProxy ref1 = (ClientProxy) client1ClusterA.getSet(name);
    ClientProxy ref2 = (ClientProxy) client2ClusterA.getSet(name);
    assertNotEquals(ref1, ref2);
}
Also used : ClientProxy(com.hazelcast.client.impl.spi.ClientProxy) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientProxy (com.hazelcast.client.impl.spi.ClientProxy)8 ClientConfig (com.hazelcast.client.config.ClientConfig)4 ClientContext (com.hazelcast.client.impl.spi.ClientContext)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)3 CacheTestSupport.createClientCachingProvider (com.hazelcast.cache.CacheTestSupport.createClientCachingProvider)2 NearCacheConfig (com.hazelcast.config.NearCacheConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)2 RepairingTask (com.hazelcast.internal.nearcache.impl.invalidation.RepairingTask)2 Data (com.hazelcast.internal.serialization.Data)2 CachingProvider (javax.cache.spi.CachingProvider)2 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)1 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)1 Config (com.hazelcast.config.Config)1 IMapDataStructureAdapter (com.hazelcast.internal.adapter.IMapDataStructureAdapter)1 NearCacheTestContextBuilder (com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder)1 NearCacheTestUtils.getBaseConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig)1