Search in sources :

Example 11 with HazelcastClientProxy

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

the class ClientCacheClearTest method registerInvalidationListener.

private void registerInvalidationListener(EventHandler handler, String nameWithPrefix) {
    ListenerMessageCodec listenerCodec = createInvalidationListenerCodec(nameWithPrefix);
    HazelcastClientProxy hzClient = (HazelcastClientProxy) client;
    final HazelcastClientInstanceImpl clientInstance = hzClient.client;
    clientInstance.getListenerService().registerListener(listenerCodec, handler);
}
Also used : ListenerMessageCodec(com.hazelcast.client.impl.spi.impl.ListenerMessageCodec) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

Example 12 with HazelcastClientProxy

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

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

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

the class ClientCacheReconciliationTest method createCacheFromNewClient.

private Cache<Integer, Integer> createCacheFromNewClient(String cacheName) {
    HazelcastClientProxy client = (HazelcastClientProxy) factory.newHazelcastClient(clientConfig);
    CachingProvider clientCachingProvider = createClientCachingProvider(client);
    CacheManager cacheManager = clientCachingProvider.getCacheManager();
    Cache<Integer, Integer> cache = cacheManager.createCache(cacheName, cacheConfig);
    assertInstanceOf(NearCachedClientCacheProxy.class, cache);
    return cache;
}
Also used : CacheManager(javax.cache.CacheManager) 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)

Example 15 with HazelcastClientProxy

use of com.hazelcast.client.impl.clientside.HazelcastClientProxy in project spring-boot by spring-projects.

the class HazelcastAutoConfigurationClientTests method autoConfiguredClientConfigUsesApplicationClassLoader.

@Test
void autoConfiguredClientConfigUsesApplicationClassLoader() {
    this.contextRunner.withPropertyValues("spring.hazelcast.config=org/springframework/boot/autoconfigure/" + "hazelcast/hazelcast-client-specific.xml").run((context) -> {
        HazelcastInstance hazelcast = context.getBean(HazelcastInstance.class);
        assertThat(hazelcast).isInstanceOf(HazelcastClientProxy.class);
        ClientConfig clientConfig = ((HazelcastClientProxy) hazelcast).getClientConfig();
        assertThat(clientConfig.getClassLoader()).isSameAs(context.getSourceApplicationContext().getClassLoader());
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) Test(org.junit.jupiter.api.Test)

Aggregations

HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)42 ClientConfig (com.hazelcast.client.config.ClientConfig)27 Test (org.junit.Test)16 QuickTest (com.hazelcast.test.annotation.QuickTest)14 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)13 CachingProvider (javax.cache.spi.CachingProvider)13 CacheTestSupport.createClientCachingProvider (com.hazelcast.cache.CacheTestSupport.createClientCachingProvider)12 Data (com.hazelcast.internal.serialization.Data)12 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 NearCacheTestContextBuilder (com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder)9 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)7 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)7 ClientMetricsConfig (com.hazelcast.client.config.ClientMetricsConfig)6 NearCacheConfig (com.hazelcast.config.NearCacheConfig)6 Config (com.hazelcast.config.Config)5 CacheManager (javax.cache.CacheManager)5 CacheConfig (com.hazelcast.config.CacheConfig)4 ICacheDataStructureAdapter (com.hazelcast.internal.adapter.ICacheDataStructureAdapter)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4