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); } }
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); } }
/** * {@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); } }