Search in sources :

Example 6 with ClientContext

use of com.hazelcast.client.spi.ClientContext in project hazelcast by hazelcast.

the class NearCachedClientMapProxy method getConnectedServerVersion.

private int getConnectedServerVersion() {
    ClientContext clientContext = getClientContext();
    ClientClusterService clusterService = clientContext.getClusterService();
    Address ownerConnectionAddress = clusterService.getOwnerConnectionAddress();
    HazelcastClientInstanceImpl client = getClient();
    ClientConnectionManager connectionManager = client.getConnectionManager();
    Connection connection = connectionManager.getConnection(ownerConnectionAddress);
    if (connection == null) {
        logger.warning(format("No owner connection is available, " + "near cached cache %s will be started in legacy mode", name));
        return UNKNOWN_HAZELCAST_VERSION;
    }
    return ((ClientConnection) connection).getConnectedServerVersion();
}
Also used : Address(com.hazelcast.nio.Address) ClientContext(com.hazelcast.client.spi.ClientContext) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) Connection(com.hazelcast.nio.Connection) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) ClientConnectionManager(com.hazelcast.client.connection.ClientConnectionManager) ClientClusterService(com.hazelcast.client.spi.ClientClusterService)

Example 7 with ClientContext

use of com.hazelcast.client.spi.ClientContext in project hazelcast by hazelcast.

the class ClientMapMetaDataFetcherTest method getRepairingTask.

private RepairingTask getRepairingTask(String mapName, int partition, long givenSequence, UUID givenUuid) {
    HazelcastInstance member = factory.newHazelcastInstance();
    distortRandomPartitionSequence(mapName, partition, givenSequence, member);
    distortRandomPartitionUuid(partition, givenUuid, member);
    ClientConfig clientConfig = new ClientConfig().addNearCacheConfig(new NearCacheConfig(mapName));
    HazelcastInstance client = factory.newHazelcastClient(clientConfig);
    IMap<Integer, Integer> clientMap = client.getMap(mapName);
    ClientContext clientContext = ((NearCachedClientMapProxy) clientMap).getClientContext();
    return clientContext.getRepairingTask(SERVICE_NAME);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientContext(com.hazelcast.client.spi.ClientContext) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) NearCachedClientMapProxy(com.hazelcast.client.proxy.NearCachedClientMapProxy)

Example 8 with ClientContext

use of com.hazelcast.client.spi.ClientContext in project hazelcast by hazelcast.

the class ClientCacheMetaDataFetcherTest method getRepairingTask.

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 = HazelcastClientCachingProvider.createCachingProvider(client);
    Cache<Integer, Integer> clientCache = clientCachingProvider.getCacheManager().createCache(cacheName, newCacheConfig());
    ClientContext clientContext = ((ClientCacheProxy) clientCache).getClientContext();
    return clientContext.getRepairingTask(SERVICE_NAME);
}
Also used : ClientCacheProxy(com.hazelcast.client.cache.impl.ClientCacheProxy) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientContext(com.hazelcast.client.spi.ClientContext) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)

Example 9 with ClientContext

use of com.hazelcast.client.spi.ClientContext in project hazelcast by hazelcast.

the class ClientDurableExecutorServiceProxy method onInitialize.

@Override
protected void onInitialize() {
    ClientContext context = getContext();
    ClientPartitionService partitionService = context.getPartitionService();
    partitionCount = partitionService.getPartitionCount();
}
Also used : ClientContext(com.hazelcast.client.spi.ClientContext) ClientPartitionService(com.hazelcast.client.spi.ClientPartitionService)

Aggregations

ClientContext (com.hazelcast.client.spi.ClientContext)9 NearCacheConfig (com.hazelcast.config.NearCacheConfig)4 ClientConfig (com.hazelcast.client.config.ClientConfig)2 ClientConnectionManager (com.hazelcast.client.connection.ClientConnectionManager)2 ClientConnection (com.hazelcast.client.connection.nio.ClientConnection)2 HazelcastClientInstanceImpl (com.hazelcast.client.impl.HazelcastClientInstanceImpl)2 ClientClusterService (com.hazelcast.client.spi.ClientClusterService)2 ClientTransactionManagerService (com.hazelcast.client.spi.ClientTransactionManagerService)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 Address (com.hazelcast.nio.Address)2 Connection (com.hazelcast.nio.Connection)2 ClientCacheProxy (com.hazelcast.client.cache.impl.ClientCacheProxy)1 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)1 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)1 NearCachedClientMapProxy (com.hazelcast.client.proxy.NearCachedClientMapProxy)1 ClientPartitionService (com.hazelcast.client.spi.ClientPartitionService)1 IMapDataStructureAdapter (com.hazelcast.internal.adapter.IMapDataStructureAdapter)1 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)1 TransactionContext (com.hazelcast.transaction.TransactionContext)1 CachingProvider (javax.cache.spi.CachingProvider)1