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));
}
}
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;
}
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();
}
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;
}
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);
}
}
}
Aggregations