void deleteFile(final String name) { fileOps.deleteFileName(name); readLocks.deleteOrReleaseReadLock(name); if (log.isDebugEnabled()) { log.debugf("Removed file: %s from index: %s from %s", name, indexName, getAddress(chunksCache)); } }
IndexOutput createOutput(final String name) { if(log.isDebugEnabled()) { log.tracef("Creating output file %s in index %s from %s", name, indexName, getAddress(metadataCache)); } if (IndexFileNames.SEGMENTS.equals(name)) { return new InfinispanIndexOutput(metadataCache, chunksCache, segmentsGenFileKey, chunkSize, fileOps, affinitySegmentId); } else { final FileCacheKey key = new FileCacheKey(indexName, name, affinitySegmentId); // creating new file, metadata is added on flush() or close() of // IndexOutPut return new InfinispanIndexOutput(metadataCache, chunksCache, key, chunkSize, fileOps, affinitySegmentId); } }
void deleteFile(final String name) { fileOps.deleteFileName(name); readLocks.deleteOrReleaseReadLock(name); if (log.isDebugEnabled()) { log.debugf("Removed file: %s from index: %s from %s", name, indexName, getAddress(chunksCache)); } }
IndexOutput createOutput(final String name) { if(log.isDebugEnabled()) { log.tracef("Creating output file %s in index %s from %s", name, indexName, getAddress(metadataCache)); } if (IndexFileNames.SEGMENTS.equals(name)) { return new InfinispanIndexOutput(metadataCache, chunksCache, segmentsGenFileKey, chunkSize, fileOps, affinitySegmentId); } else { final FileCacheKey key = new FileCacheKey(indexName, name, affinitySegmentId); // creating new file, metadata is added on flush() or close() of // IndexOutPut return new InfinispanIndexOutput(metadataCache, chunksCache, key, chunkSize, fileOps, affinitySegmentId); } }
/** * Makes sure the Cache is updated. * @param fileList the new content */ @GuardedBy("writeLock") private void updateFileList(FileListCacheValue fileList) { if (writeAsync) { cacheNoRetrieve.putAsync(fileListCacheKey, fileList); } else { if (trace) { log.tracef("Updating file listing view from %s", getAddress(cacheNoRetrieve)); } cacheNoRetrieve.put(fileListCacheKey, fileList); } }
/** * Makes sure the Cache is updated. * @param fileList the new content */ @GuardedBy("writeLock") private void updateFileList(FileListCacheValue fileList) { if (writeAsync) { cacheNoRetrieve.putAsync(fileListCacheKey, fileList); } else { if (trace) { log.tracef("Updating file listing view from %s", getAddress(cacheNoRetrieve)); } cacheNoRetrieve.put(fileListCacheKey, fileList); } }
void renameFile(final String from, final String to) { final FileCacheKey fromKey = new FileCacheKey(indexName, from, affinitySegmentId); final FileMetadata metadata = metadataCache.get(fromKey); final int bufferSize = metadata.getBufferSize(); // preparation: copy all chunks to new keys int i = -1; Object ob; do { final ChunkCacheKey fromChunkKey = new ChunkCacheKey(indexName, from, ++i, bufferSize, affinitySegmentId); ob = chunksCache.get(fromChunkKey); if (ob == null) { break; } final ChunkCacheKey toChunkKey = new ChunkCacheKey(indexName, to, i, bufferSize, affinitySegmentId); chunksCache.withFlags(Flag.IGNORE_RETURN_VALUES).put(toChunkKey, ob); } while (true); // rename metadata first metadataCache.put(new FileCacheKey(indexName, to, affinitySegmentId), metadata); fileOps.removeAndAdd(from, to); // now trigger deletion of old file chunks: readLocks.deleteOrReleaseReadLock(from); if (trace) { log.tracef("Renamed file from: %s to: %s in index %s from %s", from, to, indexName, getAddress(metadataCache)); } }
void renameFile(final String from, final String to) { final FileCacheKey fromKey = new FileCacheKey(indexName, from, affinitySegmentId); final FileMetadata metadata = metadataCache.get(fromKey); final int bufferSize = metadata.getBufferSize(); // preparation: copy all chunks to new keys int i = -1; Object ob; do { final ChunkCacheKey fromChunkKey = new ChunkCacheKey(indexName, from, ++i, bufferSize, affinitySegmentId); ob = chunksCache.get(fromChunkKey); if (ob == null) { break; } final ChunkCacheKey toChunkKey = new ChunkCacheKey(indexName, to, i, bufferSize, affinitySegmentId); chunksCache.withFlags(Flag.IGNORE_RETURN_VALUES).put(toChunkKey, ob); } while (true); // rename metadata first metadataCache.put(new FileCacheKey(indexName, to, affinitySegmentId), metadata); fileOps.removeAndAdd(from, to); // now trigger deletion of old file chunks: readLocks.deleteOrReleaseReadLock(from); if (trace) { log.tracef("Renamed file from: %s to: %s in index %s from %s", from, to, indexName, getAddress(metadataCache)); } }