@Override public void close() { currentBufferSize = 0; bufferPosition = 0; currentLoadedChunk = -1; buffer = null; if (isClone) return; readLocks.deleteOrReleaseReadLock(filename); if (trace) { log.tracef("Closed IndexInput for file:%s in index: %s", filename, fileKey.getIndexName()); } }
IndexInputContext openInput(final String name) throws IOException { final FileCacheKey fileKey = new FileCacheKey(indexName, name); final FileMetadata fileMetadata = metadataCache.get(fileKey); if (fileMetadata == null) { throw new FileNotFoundException("Error loading metadata for index file: " + fileKey); } else if (fileMetadata.getSize() <= fileMetadata.getBufferSize()) { //files smaller than chunkSize don't need a readLock return new IndexInputContext(chunksCache, fileKey, fileMetadata, null); } else { boolean locked = readLocks.acquireReadLock(name); if (!locked) { // safest reaction is to tell this file doesn't exist anymore. throw new FileNotFoundException("Error loading metadata for index file: " + fileKey); } return new IndexInputContext(chunksCache, fileKey, fileMetadata, readLocks); } }
IndexInputContext openInput(final String name) throws IOException { final FileCacheKey fileKey = new FileCacheKey(indexName, name, affinitySegmentId); FileMetadata fileMetadata; try { fileMetadata = metadataCache.get(fileKey); } catch (PersistenceException pe) { //When loading through the LuceneCacheLoader, a valid FileNotFoundException would be wrapped by a PersistenceException: //just ignore it so that we re-throw the needed FileNotFoundException fileMetadata = null; } if (fileMetadata == null) { throw new FileNotFoundException("Error loading metadata for index file: " + fileKey); } else if (!fileMetadata.isMultiChunked()) { //files smaller than chunkSize don't need a readLock return new IndexInputContext(chunksCache, fileKey, fileMetadata, null, affinitySegmentId); } else { boolean locked = readLocks.acquireReadLock(name); if (!locked) { // safest reaction is to tell this file doesn't exist anymore. throw new FileNotFoundException("Error loading metadata for index file: " + fileKey); } return new IndexInputContext(chunksCache, fileKey, fileMetadata, readLocks, affinitySegmentId); } }
@Override public void close() { currentBufferSize = 0; bufferPosition = 0; currentLoadedChunk = -1; buffer = null; if (isClone) return; readLocks.deleteOrReleaseReadLock(filename); if (trace) { log.tracef("Closed IndexInput for file:%s in index: %s", filename, fileKey.getIndexName()); } }
IndexInputContext openInput(final String name) throws IOException { final FileCacheKey fileKey = new FileCacheKey(indexName, name, affinitySegmentId); FileMetadata fileMetadata; try { fileMetadata = metadataCache.get(fileKey); } catch (PersistenceException pe) { //When loading through the LuceneCacheLoader, a valid FileNotFoundException would be wrapped by a PersistenceException: //just ignore it so that we re-throw the needed FileNotFoundException fileMetadata = null; } if (fileMetadata == null) { throw new FileNotFoundException("Error loading metadata for index file: " + fileKey); } else if (!fileMetadata.isMultiChunked()) { //files smaller than chunkSize don't need a readLock return new IndexInputContext(chunksCache, fileKey, fileMetadata, null, affinitySegmentId); } else { boolean locked = readLocks.acquireReadLock(name); if (!locked) { // safest reaction is to tell this file doesn't exist anymore. throw new FileNotFoundException("Error loading metadata for index file: " + fileKey); } return new IndexInputContext(chunksCache, fileKey, fileMetadata, readLocks, affinitySegmentId); } }
@Override public void close() { currentBufferSize = 0; bufferPosition = 0; currentLoadedChunk = -1; buffer = null; if (isClone) return; readLocks.deleteOrReleaseReadLock(filename); if (trace) { log.tracef("Closed IndexInput for file:%s in index: %s", filename, fileKey.getIndexName()); } }
/** * {@inheritDoc} */ @Override public IndexInput openInput(String name) throws IOException { final FileCacheKey fileKey = new FileCacheKey(indexName, name); FileMetadata fileMetadata = metadataCache.get(fileKey); if (fileMetadata == null) { throw new FileNotFoundException("Error loading metadata for index file: " + fileKey); } else if (fileMetadata.getSize() <= fileMetadata.getBufferSize()) { //files smaller than chunkSize don't need a readLock IndexInputContext iic = new IndexInputContext(chunksCache, fileKey, fileMetadata, null); return new SingleChunkIndexInput(iic); } else { boolean locked = readLocks.acquireReadLock(name); if (!locked) { // safest reaction is to tell this file doesn't exist anymore. throw new FileNotFoundException("Error loading metadata for index file: " + fileKey); } IndexInputContext iic = new IndexInputContext(chunksCache, fileKey, fileMetadata, readLocks); return new InfinispanIndexInputV3(iic); } }
void deleteFile(final String name) { fileOps.deleteFileName(name); readLocks.deleteOrReleaseReadLock(name); if (log.isDebugEnabled()) { log.debugf("Removed file: %s from index: %s", name, indexName); } }
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)); } }
/** * {@inheritDoc} */ @Override public void deleteFile(String name) { ensureOpen(); fileOps.deleteFileName(name); readLocks.deleteOrReleaseReadLock(name); if (log.isDebugEnabled()) { log.debugf("Removed file: %s from index: %s", name, indexName); } }
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)); } }
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); 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); ob = chunksCache.get(fromChunkKey); if (ob == null) { break; } final ChunkCacheKey toChunkKey = new ChunkCacheKey(indexName, to, i, bufferSize); chunksCache.withFlags(Flag.IGNORE_RETURN_VALUES).put(toChunkKey, ob); } while (true); // rename metadata first metadataCache.put(new FileCacheKey(indexName, to), metadata); fileOps.removeAndAdd(from, to); // now trigger deletion of old file chunks: readLocks.deleteOrReleaseReadLock(from); if (log.isTraceEnabled()) { log.tracef("Renamed file from: %s to: %s in index %s", from, to, indexName); } }
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)); } }
public void renameFile(String from, String to) { ensureOpen(); final FileCacheKey fromKey = new FileCacheKey(indexName, from); final FileMetadata metadata = metadataCache.get(fromKey); final int bufferSize = metadata.getBufferSize(); // preparation: copy all chunks to new keys int i = -1; Object ob; do { ChunkCacheKey fromChunkKey = new ChunkCacheKey(indexName, from, ++i, bufferSize); ob = chunksCache.get(fromChunkKey); if (ob == null) { break; } ChunkCacheKey toChunkKey = new ChunkCacheKey(indexName, to, i, bufferSize); chunksCache.withFlags(Flag.IGNORE_RETURN_VALUES).put(toChunkKey, ob); } while (true); // rename metadata first metadataCache.put(new FileCacheKey(indexName, to), metadata); fileOps.removeAndAdd(from, to); // now trigger deletion of old file chunks: readLocks.deleteOrReleaseReadLock(from); if (log.isTraceEnabled()) { log.tracef("Renamed file from: %s to: %s in index %s", from, to, indexName); } }