Search in sources :

Example 1 with ICacheRecordStore

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

the class CacheNearCacheStateHolder method prepare.

void prepare(CachePartitionSegment segment) {
    ICacheService cacheService = segment.getCacheService();
    MetaDataGenerator metaData = getPartitionMetaDataGenerator(cacheService);
    int partitionId = segment.getPartitionId();
    partitionUuid = metaData.getUuidOrNull(partitionId);
    cacheNameSequencePairs = new ArrayList(segment.getCacheConfigs().size());
    Iterator<ICacheRecordStore> iter = segment.recordStoreIterator();
    while (iter.hasNext()) {
        ICacheRecordStore cacheRecordStore = iter.next();
        String cacheName = cacheRecordStore.getName();
        cacheNameSequencePairs.add(cacheName);
        cacheNameSequencePairs.add(metaData.currentSequence(cacheName, partitionId));
    }
}
Also used : ICacheService(com.hazelcast.cache.impl.ICacheService) ArrayList(java.util.ArrayList) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)

Example 2 with ICacheRecordStore

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

the class CachePutBackupOperation method runInternal.

@Override
public void runInternal() throws Exception {
    ICacheService service = getService();
    ICacheRecordStore cache = service.getOrCreateRecordStore(name, getPartitionId());
    cache.putRecord(key, cacheRecord);
    response = Boolean.TRUE;
}
Also used : ICacheService(com.hazelcast.cache.impl.ICacheService) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore)

Example 3 with ICacheRecordStore

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

the class CacheReplicationOperation method prepare.

public final void prepare(CachePartitionSegment segment, Collection<ServiceNamespace> namespaces, int replicaIndex) {
    for (ServiceNamespace namespace : namespaces) {
        ObjectNamespace ns = (ObjectNamespace) namespace;
        ICacheRecordStore recordStore = segment.getRecordStore(ns.getObjectName());
        if (recordStore == null) {
            continue;
        }
        CacheConfig cacheConfig = recordStore.getConfig();
        if (cacheConfig.getTotalBackupCount() >= replicaIndex) {
            storeRecordsToReplicate(recordStore);
        }
    }
    configs.addAll(segment.getCacheConfigs());
    nearCacheStateHolder.prepare(segment, namespaces);
    classesAlwaysAvailable = segment.getCacheService().getNodeEngine().getTenantControlService().getTenantControlFactory().isClassesAlwaysAvailable();
}
Also used : ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) PreJoinCacheConfig(com.hazelcast.cache.impl.PreJoinCacheConfig) CacheConfig(com.hazelcast.config.CacheConfig)

Example 4 with ICacheRecordStore

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

the class CacheSizeOperation method run.

@Override
public void run() throws Exception {
    ICacheService service = getService();
    ICacheRecordStore cache = service.getRecordStore(name, getPartitionId());
    response = cache != null ? cache.size() : 0;
}
Also used : ICacheService(com.hazelcast.cache.impl.ICacheService) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore)

Example 5 with ICacheRecordStore

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

the class CachePutAllTest method testPutAll.

@Test
public void testPutAll() {
    ICache<String, String> cache = createCache();
    String cacheName = cache.getName();
    Map<String, String> entries = createAndFillEntries();
    cache.putAll(entries);
    // Verify that put-all works
    for (Map.Entry<String, String> entry : entries.entrySet()) {
        String key = entry.getKey();
        String expectedValue = entries.get(key);
        String actualValue = cache.get(key);
        assertEquals(expectedValue, actualValue);
    }
    Node node = getNode(hazelcastInstance);
    InternalPartitionService partitionService = node.getPartitionService();
    SerializationService serializationService = node.getSerializationService();
    // Verify that backup of put-all works
    for (Map.Entry<String, String> entry : entries.entrySet()) {
        String key = entry.getKey();
        String expectedValue = entries.get(key);
        Data keyData = serializationService.toData(key);
        int keyPartitionId = partitionService.getPartitionId(keyData);
        for (int i = 0; i < INSTANCE_COUNT; i++) {
            Node n = getNode(hazelcastInstances[i]);
            ICacheService cacheService = n.getNodeEngine().getService(ICacheService.SERVICE_NAME);
            ICacheRecordStore recordStore = cacheService.getRecordStore("/hz/" + cacheName, keyPartitionId);
            assertNotNull(recordStore);
            String actualValue = serializationService.toObject(recordStore.get(keyData, null));
            assertEquals(expectedValue, actualValue);
        }
    }
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) ICacheService(com.hazelcast.cache.impl.ICacheService) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) HashMap(java.util.HashMap) Map(java.util.Map) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)21 ICacheService (com.hazelcast.cache.impl.ICacheService)13 QuickTest (com.hazelcast.test.annotation.QuickTest)7 Test (org.junit.Test)7 Data (com.hazelcast.internal.serialization.Data)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Node (com.hazelcast.instance.impl.Node)3 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)3 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 Accessors.getNode (com.hazelcast.test.Accessors.getNode)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 CacheConfig (com.hazelcast.config.CacheConfig)2 CachePartitionSegment (com.hazelcast.cache.impl.CachePartitionSegment)1 CacheRecordStore (com.hazelcast.cache.impl.CacheRecordStore)1 CacheService (com.hazelcast.cache.impl.CacheService)1 PreJoinCacheConfig (com.hazelcast.cache.impl.PreJoinCacheConfig)1 CacheRecord (com.hazelcast.cache.impl.record.CacheRecord)1 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)1 ObjectNamespace (com.hazelcast.internal.services.ObjectNamespace)1