Search in sources :

Example 1 with ClientContext

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

the class AbstractClientInternalCacheProxy method getConnectedServerVersion.

private int getConnectedServerVersion() {
    ClientContext clientContext = getContext();
    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 2 with ClientContext

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

the class ClientReplicatedMapProxy method initNearCache.

private void initNearCache() {
    ClientContext context = getContext();
    NearCacheConfig nearCacheConfig = context.getClientConfig().getNearCacheConfig(name);
    if (nearCacheConfig == null) {
        return;
    }
    nearCache = context.getNearCacheManager().getOrCreateNearCache(name, nearCacheConfig);
    if (nearCache.isInvalidatedOnChange()) {
        addNearCacheInvalidateListener();
    }
}
Also used : ClientContext(com.hazelcast.client.spi.ClientContext) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 3 with ClientContext

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

the class XAResourceProxy method getGroupName.

private String getGroupName() {
    ClientContext context = getContext();
    ClientTransactionManagerService transactionManager = context.getTransactionManager();
    return transactionManager.getGroupName();
}
Also used : ClientContext(com.hazelcast.client.spi.ClientContext) ClientTransactionManagerService(com.hazelcast.client.spi.ClientTransactionManagerService)

Example 4 with ClientContext

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

the class XAResourceProxy method createTransactionContext.

private TransactionContext createTransactionContext(Xid xid) {
    ClientContext clientContext = getContext();
    ClientTransactionManagerService transactionManager = clientContext.getTransactionManager();
    TransactionContext context = transactionManager.newXATransactionContext(xid, timeoutInSeconds.get());
    getTransaction(context).begin();
    return context;
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) ClientContext(com.hazelcast.client.spi.ClientContext) ClientTransactionManagerService(com.hazelcast.client.spi.ClientTransactionManagerService)

Example 5 with ClientContext

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

the class NearCachedClientMapProxy method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    ClientContext context = getContext();
    logger = context.getLoggingService().getLogger(getClass());
    NearCacheConfig nearCacheConfig = context.getClientConfig().getNearCacheConfig(name);
    NearCacheManager nearCacheManager = context.getNearCacheManager();
    IMapDataStructureAdapter<K, V> adapter = new IMapDataStructureAdapter<K, V>(this);
    nearCache = nearCacheManager.getOrCreateNearCache(name, nearCacheConfig, adapter);
    invalidateOnChange = nearCache.isInvalidatedOnChange();
    if (invalidateOnChange) {
        addNearCacheInvalidationListener(new ConnectedServerVersionAwareNearCacheEventHandler());
    }
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) ClientContext(com.hazelcast.client.spi.ClientContext) IMapDataStructureAdapter(com.hazelcast.internal.adapter.IMapDataStructureAdapter) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

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