BufferedOakDirectory extends Directory { @Override public long fileLength(String name) throws IOException { LOG.debug("[{}]fileLength({})", definition.getIndexPath(), name); if (bufferedForDelete.contains(name)) { String msg = String.format("already deleted: [%s] %s", definition.getIndexPath(), name); throw new FileNotFoundException(msg); } Directory dir = base; if (buffered.fileExists(name)) { dir = buffered; } return dir.fileLength(name); } BufferedOakDirectory(@NotNull NodeBuilder builder,
                                @NotNull String dataNodeName,
                                @NotNull LuceneIndexDefinition definition,
                                @Nullable BlobStore blobStore);  BufferedOakDirectory(@NotNull NodeBuilder builder,
                                @NotNull String dataNodeName,
                                @NotNull LuceneIndexDefinition definition,
                                @Nullable BlobStore blobStore,
                                @NotNull ActiveDeletedBlobCollectorFactory.BlobDeletionCallback blobDeletionCallback); static void setEnableWritingSingleBlobIndexFile(boolean val); static boolean isEnableWritingSingleBlobIndexFile(); @Override String[] listAll(); @Override boolean fileExists(String name); @Override void deleteFile(String name); @Override long fileLength(String name); @Override IndexOutput createOutput(String name, IOContext context); @Override void sync(Collection<String> names); @Override IndexInput openInput(String name, IOContext context); @Override Lock makeLock(String name); @Override void clearLock(String name); @Override void close(); @Override void setLockFactory(LockFactory lockFactory); @Override LockFactory getLockFactory(); static final String ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM; }
@Test public void fileLength() throws Exception { Directory base = createDir(builder, false); writeFile(base, "file"); base.close(); Directory buffered = createDir(builder, true); buffered.deleteFile("file"); try { buffered.fileLength("file"); fail("must throw FileNotFoundException"); } catch (FileNotFoundException expected) { } try { buffered.fileLength("unknown"); fail("must throw FileNotFoundException"); } catch (FileNotFoundException expected) { } buffered.close(); }