log.debugf("Removed file: %s from index: %s", name, indexName);
}
}
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()) {