protected CacheOperationProvider getOperationProvider(String name) { ICacheService service = getService(CacheService.SERVICE_NAME); CacheConfig cacheConfig = service.getCacheConfig(name); if (cacheConfig == null) { throw new CacheNotExistsException( "Cache config for cache " + name + " has not been created yet !"); } return service.getCacheOperationProvider(name, cacheConfig.getInMemoryFormat()); }
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.createCacheConfigIfAbsent(cacheConfig); return new CacheRecordStore( CACHE_NAME_PREFIX + cacheName, partitionId, nodeEngine, (AbstractCacheService) cacheService); }
@Override public void run() throws Exception { final ICacheService service = getService(); CacheConfig cacheConfig = service.getCacheConfig(name); if (cacheConfig == null) { cacheConfig = service.findCacheConfig(simpleName); if (cacheConfig != null) { cacheConfig.setManagerPrefix(name.substring(0, name.lastIndexOf(simpleName))); CacheConfig existingCacheConfig = service.putCacheConfigIfAbsent(cacheConfig); if (existingCacheConfig != null) { cacheConfig = existingCacheConfig; } } } response = cacheConfig; }
@Override public void run() throws Exception { final int partitionId = getPartitionId(); final InternalPartitionService partitionService = getNodeEngine().getPartitionService(); Set<Data> filteredKeys = new HashSet<Data>(); if (keys != null) { for (Data k : keys) { if (partitionService.getPartitionId(k) == partitionId) { filteredKeys.add(k); } } } if (filteredKeys.isEmpty()) { return; } try { final ICacheService service = getService(); cache = service.getOrCreateRecordStore(name, partitionId); final Set<Data> keysLoaded = cache.loadAll(filteredKeys, replaceExistingValues); shouldBackup = !keysLoaded.isEmpty(); if (shouldBackup) { backupRecords = new HashMap<Data, CacheRecord>(keysLoaded.size()); for (Data key : keysLoaded) { CacheRecord record = cache.getRecord(key); // Loaded keys may have been evicted, then record will be null. // So if the loaded key is evicted, don't send it to backup. if (record != null) { backupRecords.put(key, record); } } } } catch (CacheException e) { response = new CacheClearResponse(e); } }