LocalFsClient implements FsClient, EventloopService, EventloopJmxBeanEx { @Override public Promise<ChannelSupplier<ByteBuf>> download(@NotNull String name, long offset, long length) { checkArgument(offset >= 0, "offset < 0"); checkArgument(length >= -1, "length < -1"); return Promise.ofBlockingCallable(executor, () -> { FilenameInfo info = getInfo(name); if (info == null || info.isTombstone()) { throw FILE_NOT_FOUND; } return info; }) .then(info -> ChannelFileReader.open(executor, info.getFilePath())) .map(consumer -> consumer .withBufferSize(readerBufferSize) .withOffset(offset) .withLength(length == -1 ? Long.MAX_VALUE : length) .withEndOfStream(eos -> eos.whenComplete(readFinishPromise.recordStats()))) .whenComplete(toLogger(logger, TRACE, "download", name, offset, length, this)) .whenComplete(readBeginPromise.recordStats()); } private  LocalFsClient(Eventloop eventloop, Path storage, Executor executor); static LocalFsClient create(Eventloop eventloop, Executor executor, Path storageDir); LocalFsClient withLazyOverrides(boolean lazyOverrides); LocalFsClient withDefaultRevision(long defaultRevision); LocalFsClient withRevisions(); LocalFsClient withRevisions(FileNamingScheme namingScheme, Duration tombstoneTtl); LocalFsClient withReaderBufferSize(MemSize size); @Override Promise<ChannelConsumer<ByteBuf>> upload(@NotNull String name, long offset, long revision); @Override Promise<ChannelSupplier<ByteBuf>> download(@NotNull String name, long offset, long length); @Override Promise<List<FileMetadata>> listEntities(@NotNull String glob); @Override Promise<List<FileMetadata>> list(@NotNull String glob); @Override Promise<Void> move(@NotNull String name, @NotNull String target, long targetRevision, long tombstoneRevision); @Override Promise<Void> moveDir(@NotNull String name, @NotNull String target, long targetRevision, long removeRevision); @Override Promise<Void> copy(@NotNull String name, @NotNull String target, long targetRevision); @Override Promise<Void> delete(@NotNull String name, long revision); @Override Promise<Void> ping(); @Override Promise<FileMetadata> getMetadata(@NotNull String name); @Override FsClient subfolder(@NotNull String folder); @NotNull @Override Eventloop getEventloop(); @NotNull @Override Promise<Void> start(); @NotNull @Override Promise<Void> stop(); Promise<Void> cleanup(); Promise<Void> remove(String name); @Override String toString(); @JmxAttribute PromiseStats getWriteBeginPromise(); @JmxAttribute PromiseStats getWriteFinishPromise(); @JmxAttribute PromiseStats getReadBeginPromise(); @JmxAttribute PromiseStats getReadFinishPromise(); @JmxAttribute PromiseStats getListPromise(); @JmxAttribute PromiseStats getMovePromise(); @JmxAttribute PromiseStats getSingleMovePromise(); @JmxAttribute PromiseStats getCopyPromise(); @JmxAttribute PromiseStats getSingleCopyPromise(); @JmxAttribute PromiseStats getDeletePromise(); @JmxAttribute PromiseStats getSingleDeletePromise(); static final FileNamingScheme REVISION_NAMING_SCHEME; static final Duration DEFAULT_TOMBSTONE_TTL; static final char FILE_SEPARATOR_CHAR; static final String FILE_SEPARATOR; }
@Test public void testDownloadNonExistingFile() { Throwable e = awaitException(client.download("no_file.txt")); assertSame(FILE_NOT_FOUND, e); }