Search in sources :

Example 21 with HazelcastClientProxy

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

the class ClientCacheStatsTest method testNearCacheStats_whenNearCacheEnabled.

private void testNearCacheStats_whenNearCacheEnabled() {
    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.clientside.HazelcastClientProxy) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 22 with HazelcastClientProxy

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

the class FencedLockClientBasicTest method test_sessionIsClosedOnCPSubsystemReset.

@Test
public void test_sessionIsClosedOnCPSubsystemReset() throws Exception {
    lock.lock();
    instances[0].getCPSubsystem().getCPSubsystemManagementService().reset().toCompletableFuture().get();
    assertTrueEventually(() -> {
        HazelcastClientProxy clientProxy = (HazelcastClientProxy) client;
        ClientProxySessionManager proxySessionManager = clientProxy.client.getProxySessionManager();
        assertEquals(NO_SESSION_ID, proxySessionManager.getSession((RaftGroupId) lock.getGroupId()));
    });
}
Also used : ClientProxySessionManager(com.hazelcast.client.cp.internal.session.ClientProxySessionManager) RaftGroupId(com.hazelcast.cp.internal.RaftGroupId) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) FencedLockBasicTest(com.hazelcast.cp.internal.datastructures.lock.FencedLockBasicTest)

Example 23 with HazelcastClientProxy

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

the class SessionAwareSemaphoreClientBasicTest method testDrain_ReleasesSessionProperly.

@Test
public void testDrain_ReleasesSessionProperly() throws InterruptedException {
    int permits = 20;
    assertTrue(semaphore.init(permits));
    final int drainPermits = semaphore.drainPermits();
    HazelcastClientProxy clientProxy = (HazelcastClientProxy) client;
    ClientProxySessionManager proxySessionManager = clientProxy.client.getProxySessionManager();
    SessionAwareSemaphoreProxy proxy = (SessionAwareSemaphoreProxy) semaphore;
    RaftGroupId groupId = (RaftGroupId) proxy.getGroupId();
    final long session = proxySessionManager.getSession(groupId);
    assertEquals(drainPermits, proxySessionManager.getSessionAcquireCount(groupId, session));
}
Also used : ClientProxySessionManager(com.hazelcast.client.cp.internal.session.ClientProxySessionManager) RaftGroupId(com.hazelcast.cp.internal.RaftGroupId) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) SessionAwareSemaphoreBasicTest(com.hazelcast.cp.internal.datastructures.semaphore.SessionAwareSemaphoreBasicTest) Test(org.junit.Test)

Example 24 with HazelcastClientProxy

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

the class MCTrustedInterfacesTest method testGetSystemPropertiesMessageTask_passing.

@Test
public void testGetSystemPropertiesMessageTask_passing() throws Exception {
    HazelcastInstance client = factory.newHazelcastClient(new ClientConfig(), "222.222.222.222");
    HazelcastClientInstanceImpl clientImpl = ((HazelcastClientProxy) client).client;
    ClientInvocation invocation = new ClientInvocation(clientImpl, MCGetSystemPropertiesCodec.encodeRequest(), null);
    ClientDelegatingFuture<List<Map.Entry<String, String>>> future = new ClientDelegatingFuture<>(invocation.invoke(), clientImpl.getSerializationService(), MCGetSystemPropertiesCodec::decodeResponse);
    assertFalse(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS).isEmpty());
}
Also used : MCGetSystemPropertiesCodec(com.hazelcast.client.impl.protocol.codec.MCGetSystemPropertiesCodec) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) List(java.util.List) ArrayList(java.util.ArrayList) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) Map(java.util.Map) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 25 with HazelcastClientProxy

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

the class ClientMapNearCacheLeakTest 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);
    ClientContext clientContext = ((ClientProxy) clientMap).getContext();
    RepairingTask repairingTask = clientContext.getRepairingTask(MapService.SERVICE_NAME);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).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) IMapDataStructureAdapter(com.hazelcast.internal.adapter.IMapDataStructureAdapter) 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)

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