Search in sources :

Example 6 with ICacheRecordStore

use of com.hazelcast.cache.impl.ICacheRecordStore in project hazelcast by hazelcast.

the class CacheRecordStoreTest method putObjectAndGetDataFromCacheRecordStore.

@Test
public void putObjectAndGetDataFromCacheRecordStore() {
    ICacheRecordStore cacheRecordStore = createCacheRecordStore(InMemoryFormat.BINARY);
    putAndGetFromCacheRecordStore(cacheRecordStore, InMemoryFormat.BINARY);
}
Also used : ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with ICacheRecordStore

use of com.hazelcast.cache.impl.ICacheRecordStore in project hazelcast by hazelcast.

the class CacheRecordStoreTestSupport method createCacheRecordStore.

protected ICacheRecordStore createCacheRecordStore(HazelcastInstance instance, String cacheName, int partitionId, InMemoryFormat inMemoryFormat) {
    NodeEngine nodeEngine = getNodeEngine(instance);
    ICacheService cacheService = getCacheService(instance);
    CacheConfig cacheConfig = createCacheConfig(cacheName, inMemoryFormat);
    cacheService.putCacheConfigIfAbsent(cacheConfig);
    return new CacheRecordStore(CACHE_NAME_PREFIX + cacheName, partitionId, nodeEngine, (AbstractCacheService) cacheService);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) CacheRecordStore(com.hazelcast.cache.impl.CacheRecordStore) ICacheService(com.hazelcast.cache.impl.ICacheService) CacheConfig(com.hazelcast.config.CacheConfig)

Example 8 with ICacheRecordStore

use of com.hazelcast.cache.impl.ICacheRecordStore in project hazelcast by hazelcast.

the class CacheGetAllOperation method run.

public void run() {
    ICacheService service = getService();
    ICacheRecordStore cache = service.getOrCreateRecordStore(name, getPartitionId());
    int partitionId = getPartitionId();
    Set<Data> partitionKeySet = new HashSet<Data>();
    for (Data key : keys) {
        if (partitionId == getNodeEngine().getPartitionService().getPartitionId(key)) {
            partitionKeySet.add(key);
        }
    }
    response = cache.getAll(partitionKeySet, expiryPolicy);
}
Also used : ICacheService(com.hazelcast.cache.impl.ICacheService) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) Data(com.hazelcast.nio.serialization.Data) HashSet(java.util.HashSet)

Example 9 with ICacheRecordStore

use of com.hazelcast.cache.impl.ICacheRecordStore in project hazelcast by hazelcast.

the class CacheReplicationOperation method run.

@Override
public void run() throws Exception {
    ICacheService service = getService();
    for (Map.Entry<String, Map<Data, CacheRecord>> entry : data.entrySet()) {
        ICacheRecordStore cache = service.getOrCreateRecordStore(entry.getKey(), getPartitionId());
        cache.clear();
        Map<Data, CacheRecord> map = entry.getValue();
        Iterator<Map.Entry<Data, CacheRecord>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<Data, CacheRecord> next = iterator.next();
            Data key = next.getKey();
            CacheRecord record = next.getValue();
            iterator.remove();
            cache.putRecord(key, record);
        }
    }
    data.clear();
    if (getReplicaIndex() == 0) {
        nearCacheStateHolder.applyState();
    }
}
Also used : CacheRecord(com.hazelcast.cache.impl.record.CacheRecord) ICacheService(com.hazelcast.cache.impl.ICacheService) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) Data(com.hazelcast.nio.serialization.Data) HashMap(java.util.HashMap) Map(java.util.Map)

Example 10 with ICacheRecordStore

use of com.hazelcast.cache.impl.ICacheRecordStore in project hazelcast by hazelcast.

the class CacheRecordStoreTest method putObjectAndGetObjectFromCacheRecordStore.

@Test
public void putObjectAndGetObjectFromCacheRecordStore() {
    ICacheRecordStore cacheRecordStore = createCacheRecordStore(InMemoryFormat.OBJECT);
    putAndGetFromCacheRecordStore(cacheRecordStore, InMemoryFormat.OBJECT);
}
Also used : ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)12 ICacheService (com.hazelcast.cache.impl.ICacheService)9 Data (com.hazelcast.nio.serialization.Data)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Node (com.hazelcast.instance.Node)3 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)3 SerializationService (com.hazelcast.spi.serialization.SerializationService)3 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 CacheRecordStore (com.hazelcast.cache.impl.CacheRecordStore)1 CacheRecord (com.hazelcast.cache.impl.record.CacheRecord)1 CacheConfig (com.hazelcast.config.CacheConfig)1 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 CacheLoaderException (javax.cache.integration.CacheLoaderException)1