/** * Same as {@link io.vertx.rxjava.core.file.AsyncFile#flush} but the handler will be called when the flush is complete or if an error occurs * @return * @deprecated use {@link #rxFlush} instead */ @Deprecated() public Observable<Void> flushObservable() { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); flush(handler.toHandler()); return handler; }
public static AsyncFile newInstance(io.vertx.core.file.AsyncFile arg) { return arg != null ? new AsyncFile(arg) : null; } }
public synchronized io.vertx.rx.java.WriteStreamSubscriber<io.vertx.rxjava.core.buffer.Buffer> toSubscriber() { if (subscriber == null) { java.util.function.Function<io.vertx.rxjava.core.buffer.Buffer, io.vertx.core.buffer.Buffer> conv = io.vertx.rxjava.core.buffer.Buffer::getDelegate; subscriber = io.vertx.rx.java.RxHelper.toSubscriber(getDelegate(), conv); } return subscriber; }
AtomicLong bytesWritten = new AtomicLong(); file.endHandler(v -> { file.close(); out.end(); fileClosed.set(true); file.endHandler(null); file.close(); file.exceptionHandler(exceptionHandler); out.exceptionHandler(exceptionHandler); file.handler(data -> { out.write(data.getDelegate()); progress.setCurrent(bytesWritten.getAndAdd(data.length())); if (out.writeQueueFull()) { file.pause(); out.drainHandler(v -> file.resume());
/** * Handle a pause message * @param msg the message */ private void onPause(Message<Boolean> msg) { Boolean paused = msg.body(); if (paused == null || !paused) { if (this.paused) { log.info("Resuming import"); this.paused = false; for (AsyncFile f : filesBeingImported) { f.resume(); } } } else { if (!this.paused) { log.info("Pausing import"); this.paused = true; for (AsyncFile f : filesBeingImported) { f.pause(); } } } }
/** * Close the file. The actual close happens asynchronously. * The handler will be called when the close is complete, or an error occurs. * @return * @deprecated use {@link #rxClose} instead */ @Deprecated() public Observable<Void> closeObservable() { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); close(handler.toHandler()); return handler; }
/** * Write a {@link io.vertx.rxjava.core.buffer.Buffer} to the file at position <code>position</code> in the file, asynchronously. * <p> * If <code>position</code> lies outside of the current size * of the file, the file will be enlarged to encompass it. * <p> * When multiple writes are invoked on the same file * there are no guarantees as to order in which those writes actually occur * <p> * The handler will be called when the write is complete, or if an error occurs. * @param buffer the buffer to write * @param position the position in the file to write it at * @return a reference to this, so the API can be used fluently * @deprecated use {@link #rxWrite} instead */ @Deprecated() public Observable<Void> writeObservable(io.vertx.rxjava.core.buffer.Buffer buffer, long position) { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); write(buffer, position, handler.toHandler()); return handler; }
/** * Close the file. The actual close happens asynchronously. * The handler will be called when the close is complete, or an error occurs. * @return */ public Single<Void> rxClose() { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { close(fut); })); }
/** * Write a {@link io.vertx.rxjava.core.buffer.Buffer} to the file at position <code>position</code> in the file, asynchronously. * <p> * If <code>position</code> lies outside of the current size * of the file, the file will be enlarged to encompass it. * <p> * When multiple writes are invoked on the same file * there are no guarantees as to order in which those writes actually occur * <p> * The handler will be called when the write is complete, or if an error occurs. * @param buffer the buffer to write * @param position the position in the file to write it at * @return a reference to this, so the API can be used fluently */ public Single<Void> rxWrite(io.vertx.rxjava.core.buffer.Buffer buffer, long position) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { write(buffer, position, fut); })); }
/** * Close the file. The actual close happens asynchronously. * The handler will be called when the close is complete, or an error occurs. * @return */ public Single<Void> rxClose() { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { close(fut); })); }
/** * Write a {@link io.vertx.rxjava.core.buffer.Buffer} to the file at position <code>position</code> in the file, asynchronously. * <p> * If <code>position</code> lies outside of the current size * of the file, the file will be enlarged to encompass it. * <p> * When multiple writes are invoked on the same file * there are no guarantees as to order in which those writes actually occur * <p> * The handler will be called when the write is complete, or if an error occurs. * @param buffer the buffer to write * @param position the position in the file to write it at * @return a reference to this, so the API can be used fluently */ public Single<Void> rxWrite(io.vertx.rxjava.core.buffer.Buffer buffer, long position) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { write(buffer, position, fut); })); }
/** * Same as {@link io.vertx.rxjava.core.file.AsyncFile#flush} but the handler will be called when the flush is complete or if an error occurs * @return */ public Single<Void> rxFlush() { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { flush(fut); })); }
public synchronized io.vertx.rx.java.WriteStreamSubscriber<io.vertx.rxjava.core.buffer.Buffer> toSubscriber() { if (subscriber == null) { java.util.function.Function<io.vertx.rxjava.core.buffer.Buffer, io.vertx.core.buffer.Buffer> conv = io.vertx.rxjava.core.buffer.Buffer::getDelegate; subscriber = io.vertx.rx.java.RxHelper.toSubscriber(getDelegate(), conv); } return subscriber; }
public static AsyncFile newInstance(io.vertx.core.file.AsyncFile arg) { return arg != null ? new AsyncFile(arg) : null; } }
lastOutput[0] = read[0]; dest.write(buf); });
/** * Same as {@link io.vertx.rxjava.core.file.AsyncFile#flush} but the handler will be called when the flush is complete or if an error occurs * @return */ public Single<Void> rxFlush() { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { flush(fut); })); }