@Test public void testDoUpload() throws IOException { Path path = clientPath.resolve("c.txt"); await(client.upload("1/c.txt") .then(consumer -> ChannelFileReader.open(newCachedThreadPool(), path) .then(file -> file.withBufferSize(BUFFER_SIZE).streamTo(consumer)))); assertArrayEquals(Files.readAllBytes(path), Files.readAllBytes(storagePath.resolve("1/c.txt"))); }
private Promise<ChannelConsumer<ByteBuf>> doUpload(Path path, long size, long offset) throws StacklessException, IOException { if (offset > size) { throw OFFSET_TOO_BIG; } long skip = lazyOverrides ? size - offset : 0; FileChannel channel = FileChannel.open(path, set(CREATE, WRITE)); return Promise.of(ChannelFileWriter.create(executor, channel) .withOffset(offset + skip) .transformWith(ChannelByteRanger.drop(skip))); }
LocalFsClient implements FsClient, EventloopService, EventloopJmxBeanEx { private Promise<ChannelConsumer<ByteBuf>> doUpload(Path path, long size, long offset) throws StacklessException, IOException { if (offset > size) { throw OFFSET_TOO_BIG; } long skip = lazyOverrides ? size - offset : 0; FileChannel channel = FileChannel.open(path, set(CREATE, WRITE)); return Promise.of(ChannelFileWriter.create(executor, channel) .withOffset(offset + skip) .transformWith(ChannelByteRanger.drop(skip))); } }
LocalFsClient implements FsClient, EventloopService, EventloopJmxBeanEx { private Promise<ChannelConsumer<ByteBuf>> doUpload(Path path, long size, long offset) throws StacklessException, IOException { if (offset > size) { throw OFFSET_TOO_BIG; } long skip = lazyOverrides ? size - offset : 0; FileChannel channel = FileChannel.open(path, set(CREATE, WRITE)); return Promise.of(ChannelFileWriter.create(executor, channel) .withOffset(offset + skip) .transformWith(ChannelByteRanger.drop(skip))); } private  LocalFsClient(Eventloop eventloop, Path storage, Executor executor); }
LocalFsClient implements FsClient, EventloopService, EventloopJmxBeanEx { private Promise<ChannelConsumer<ByteBuf>> doUpload(Path path, long size, long offset) throws StacklessException, IOException { if (offset > size) { throw OFFSET_TOO_BIG; } long skip = lazyOverrides ? size - offset : 0; FileChannel channel = FileChannel.open(path, set(CREATE, WRITE)); return Promise.of(ChannelFileWriter.create(executor, channel) .withOffset(offset + skip) .transformWith(ChannelByteRanger.drop(skip))); } 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(); }
LocalFsClient implements FsClient, EventloopService, EventloopJmxBeanEx { private Promise<ChannelConsumer<ByteBuf>> doUpload(Path path, long size, long offset) throws StacklessException, IOException { if (offset > size) { throw OFFSET_TOO_BIG; } long skip = lazyOverrides ? size - offset : 0; FileChannel channel = FileChannel.open(path, set(CREATE, WRITE)); return Promise.of(ChannelFileWriter.create(executor, channel) .withOffset(offset + skip) .transformWith(ChannelByteRanger.drop(skip))); } 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; }