Search in sources :

Example 11 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class AbstractCacheService method cacheEntryListenerRegistered.

public void cacheEntryListenerRegistered(String name, CacheEntryListenerConfiguration cacheEntryListenerConfiguration) {
    CacheConfig cacheConfig = getCacheConfig(name);
    if (cacheConfig == null) {
        throw new IllegalStateException("CacheConfig does not exist for cache " + name);
    }
    cacheConfig.addCacheEntryListenerConfiguration(cacheEntryListenerConfiguration);
}
Also used : CacheConfig(com.hazelcast.config.CacheConfig)

Example 12 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class HazelcastServerCacheManager method createCacheConfig.

@Override
protected <K, V> CacheConfig<K, V> createCacheConfig(String cacheName, CacheConfig<K, V> config, boolean createAlsoOnOthers, boolean syncCreate) {
    CacheConfig<K, V> currentCacheConfig = cacheService.getCacheConfig(cacheName);
    OperationService operationService = nodeEngine.getOperationService();
    // Create cache config on all nodes.
    CacheCreateConfigOperation op = new CacheCreateConfigOperation(config, createAlsoOnOthers);
    // Run "CacheCreateConfigOperation" on this node. Its itself handles interaction with other nodes.
    // This operation doesn't block operation thread even "syncCreate" is specified.
    // In that case, scheduled thread is used, not operation thread.
    InternalCompletableFuture future = operationService.invokeOnTarget(CacheService.SERVICE_NAME, op, nodeEngine.getThisAddress());
    if (syncCreate) {
        return (CacheConfig<K, V>) future.join();
    } else {
        return currentCacheConfig;
    }
}
Also used : CacheCreateConfigOperation(com.hazelcast.cache.impl.operation.CacheCreateConfigOperation) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) OperationService(com.hazelcast.spi.OperationService) CacheConfig(com.hazelcast.config.CacheConfig)

Example 13 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class HazelcastServerCacheManager method getCacheConfig.

@Override
protected <K, V> CacheConfig<K, V> getCacheConfig(String cacheNameWithPrefix, String cacheName) {
    CacheGetConfigOperation op = new CacheGetConfigOperation(cacheNameWithPrefix, cacheName);
    int partitionId = nodeEngine.getPartitionService().getPartitionId(cacheNameWithPrefix);
    InternalCompletableFuture<CacheConfig> f = nodeEngine.getOperationService().invokeOnPartition(CacheService.SERVICE_NAME, op, partitionId);
    return f.join();
}
Also used : CacheGetConfigOperation(com.hazelcast.cache.impl.operation.CacheGetConfigOperation) CacheConfig(com.hazelcast.config.CacheConfig)

Example 14 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class CacheReplicationOperation method writeInternal.

@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    int confSize = configs.size();
    out.writeInt(confSize);
    for (CacheConfig config : configs) {
        out.writeObject(config);
    }
    int count = data.size();
    out.writeInt(count);
    long now = Clock.currentTimeMillis();
    for (Map.Entry<String, Map<Data, CacheRecord>> entry : data.entrySet()) {
        Map<Data, CacheRecord> cacheMap = entry.getValue();
        int subCount = cacheMap.size();
        out.writeInt(subCount);
        out.writeUTF(entry.getKey());
        for (Map.Entry<Data, CacheRecord> e : cacheMap.entrySet()) {
            final Data key = e.getKey();
            final CacheRecord record = e.getValue();
            if (record.isExpiredAt(now)) {
                continue;
            }
            out.writeData(key);
            out.writeObject(record);
        }
        // Empty data will terminate the iteration for read in case
        // expired entries were found while serializing, since the
        // real subCount will then be different from the one written
        // before
        out.writeData(null);
    }
    nearCacheStateHolder.writeData(out);
}
Also used : CacheRecord(com.hazelcast.cache.impl.record.CacheRecord) Data(com.hazelcast.nio.serialization.Data) CacheConfig(com.hazelcast.config.CacheConfig) HashMap(java.util.HashMap) Map(java.util.Map)

Example 15 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class AbstractCacheService method cacheEntryListenerDeregistered.

public void cacheEntryListenerDeregistered(String name, CacheEntryListenerConfiguration cacheEntryListenerConfiguration) {
    CacheConfig cacheConfig = getCacheConfig(name);
    if (cacheConfig == null) {
        throw new IllegalStateException("CacheConfig does not exist for cache " + name);
    }
    cacheConfig.removeCacheEntryListenerConfiguration(cacheEntryListenerConfiguration);
}
Also used : CacheConfig(com.hazelcast.config.CacheConfig)

Aggregations

CacheConfig (com.hazelcast.config.CacheConfig)77 Test (org.junit.Test)30 CacheManager (javax.cache.CacheManager)28 QuickTest (com.hazelcast.test.annotation.QuickTest)27 ParallelTest (com.hazelcast.test.annotation.ParallelTest)25 CachingProvider (javax.cache.spi.CachingProvider)16 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)14 AssertTask (com.hazelcast.test.AssertTask)13 NearCacheConfig (com.hazelcast.config.NearCacheConfig)11 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 ICacheService (com.hazelcast.cache.impl.ICacheService)8 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)8 ICache (com.hazelcast.cache.ICache)5 ClientConfig (com.hazelcast.client.config.ClientConfig)5 Config (com.hazelcast.config.Config)5 Data (com.hazelcast.nio.serialization.Data)5 CacheService (com.hazelcast.cache.impl.CacheService)4 HazelcastServerCachingProvider.createCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider.createCachingProvider)4 Map (java.util.Map)4