Class AsyncFile
- All Implemented Interfaces:
MutinyDelegate,ReadStream<io.vertx.core.buffer.Buffer>,StreamBase,WriteStream<io.vertx.core.buffer.Buffer>
This class also implements ReadStream and
WriteStream. This allows the data to be piped to and from
other streams, e.g. an HttpClientRequest instance,
using the Pipe class
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- Author:
- Tim Fox
- See Also:
-
AsyncFile
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.ReadStream
ReadStream.ReadStreamImpl<T>Nested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.StreamBase
StreamBase.StreamBaseImplNested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.WriteStream
WriteStream.WriteStreamImpl<T> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.smallrye.mutiny.Uni<Void>close()Close the file.voidClose the file.Close the file.drainHandler(Runnable handler) Set a drain handler on the stream.io.smallrye.mutiny.Uni<Void>end()Ends the stream.io.smallrye.mutiny.Uni<Void>end(io.vertx.core.buffer.Buffer arg0) Same asend()but writes some data to the stream before ending.voidEnds the stream.voidendAndAwait(io.vertx.core.buffer.Buffer arg0) Same asend()but writes some data to the stream before ending.Ends the stream.endAndForget(io.vertx.core.buffer.Buffer arg0) Same asend()but writes some data to the stream before ending.endHandler(Runnable endHandler) Set an end handler.booleanexceptionHandler(Consumer<Throwable> handler) Set an exception handler on the read stream and on the write stream.fetch(long amount) Fetch the specifiedamountof elements.io.smallrye.mutiny.Uni<Void>flush()Flush any writes made to this file to underlying persistent storage.voidFlush any writes made to this file to underlying persistent storage.Flush any writes made to this file to underlying persistent storage.io.vertx.core.file.AsyncFileGet the delegate instance.longlongSet a data handler.inthashCode()io.smallrye.mutiny.Uni<AsyncFileLock>lock()Acquire a non-shared lock on the entire file.io.smallrye.mutiny.Uni<AsyncFileLock>lock(long position, long size, boolean shared) Acquire a lock on a portion of this file.Acquire a non-shared lock on the entire file.lockAndAwait(long position, long size, boolean shared) Acquire a lock on a portion of this file.Acquire a non-shared lock on the entire file.lockAndForget(long position, long size, boolean shared) Acquire a lock on a portion of this file.static AsyncFilenewInstance(io.vertx.core.file.AsyncFile delegate) Creates a new instance of theAsyncFile.pause()Pause theReadStream, it sets the buffer infetchmode and clears the actual demand.Pipe<io.vertx.core.buffer.Buffer>pipe()Pause this stream and return aPipeto transfer the elements of this stream to a destinationWriteStream.io.smallrye.mutiny.Uni<Void>pipeTo(WriteStream<io.vertx.core.buffer.Buffer> arg0) Pipe thisReadStreamto theWriteStream.voidpipeToAndAwait(WriteStream<io.vertx.core.buffer.Buffer> arg0) Pipe thisReadStreamto theWriteStream.pipeToAndForget(WriteStream<io.vertx.core.buffer.Buffer> arg0) Pipe thisReadStreamto theWriteStream.io.smallrye.mutiny.Uni<io.vertx.core.buffer.Buffer>read(io.vertx.core.buffer.Buffer buffer, int offset, long position, int length) Readslengthbytes of data from the file at positionpositionin the file, asynchronously.io.vertx.core.buffer.BufferreadAndAwait(io.vertx.core.buffer.Buffer buffer, int offset, long position, int length) Readslengthbytes of data from the file at positionpositionin the file, asynchronously.readAndForget(io.vertx.core.buffer.Buffer buffer, int offset, long position, int length) Readslengthbytes of data from the file at positionpositionin the file, asynchronously.resume()Resume reading, and sets the buffer inflowingmode.setReadBufferSize(int readBufferSize) Sets the buffer size that will be used to read the data from the file.setReadLength(long readLength) Sets the number of bytes that will be read when using the file as aReadStream.setReadPos(long readPos) Sets the position from which data will be read from when using the file as aReadStream.setWritePos(long writePos) Sets the position from which data will be written when using the file as aWriteStream.setWriteQueueMaxSize(int maxSize) Set the maximum size of the write queue tomaxSize.io.smallrye.mutiny.Uni<Long>size()Unlike the bare Vert.x variant, this method returns aUni.Unlike the bare Vert.x variant, this method returns aLong.Unlike the bare Vert.x variant, this method ignores theLongresult or any failure.longLikesize()but blocking.Iterable<io.vertx.core.buffer.Buffer>Stream<io.vertx.core.buffer.Buffer>io.smallrye.mutiny.Multi<io.vertx.core.buffer.Buffer>toMulti()toString()Flow.Subscriber<io.vertx.core.buffer.Buffer>Converts the current write stream to a subscriber.tryLock()Try to acquire a non-shared lock on the entire file.tryLock(long position, long size, boolean shared) Try to acquire a lock on a portion of this file.<T> io.smallrye.mutiny.Uni<T>Acquire a lock on a portion of this file.<T> io.smallrye.mutiny.Uni<T>Acquire a non-shared lock on the entire file.<T> TwithLockAndAwait(long position, long size, boolean shared, Supplier<io.smallrye.mutiny.Uni<T>> block) Acquire a lock on a portion of this file.<T> TwithLockAndAwait(Supplier<io.smallrye.mutiny.Uni<T>> block) Acquire a non-shared lock on the entire file.<T> AsyncFilewithLockAndForget(long position, long size, boolean shared, Supplier<io.smallrye.mutiny.Uni<T>> block) Acquire a lock on a portion of this file.<T> AsyncFilewithLockAndForget(Supplier<io.smallrye.mutiny.Uni<T>> block) Acquire a non-shared lock on the entire file.io.smallrye.mutiny.Uni<Void>write(io.vertx.core.buffer.Buffer arg0) Write some data to the stream.io.smallrye.mutiny.Uni<Void>write(io.vertx.core.buffer.Buffer buffer, long position) Write aBufferto the file at positionpositionin the file, asynchronously.voidwriteAndAwait(io.vertx.core.buffer.Buffer arg0) Write some data to the stream.voidwriteAndAwait(io.vertx.core.buffer.Buffer buffer, long position) Write aBufferto the file at positionpositionin the file, asynchronously.writeAndForget(io.vertx.core.buffer.Buffer arg0) Write some data to the stream.writeAndForget(io.vertx.core.buffer.Buffer buffer, long position) Write aBufferto the file at positionpositionin the file, asynchronously.booleanThis will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
AsyncFile
public AsyncFile(io.vertx.core.file.AsyncFile delegate) Create a new instance ofAsyncFiledelegating to the given (non-null) instance ofAsyncFile. -
AsyncFile
-
-
Method Details
-
getDelegate
public io.vertx.core.file.AsyncFile getDelegate()Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceReadStream<io.vertx.core.buffer.Buffer>- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<io.vertx.core.buffer.Buffer>- Returns:
- the delegate instance
-
close
Close the file. The actual close happens asynchronously.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
AsyncFile.close()
-
closeAndAwait
public void closeAndAwait()Close the file. The actual close happens asynchronously.Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
AsyncFile.close()
-
closeAndForget
Close the file. The actual close happens asynchronously.Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
AsyncFile.close()
-
write
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> write(io.vertx.core.buffer.Buffer buffer, long position) Write aBufferto the file at positionpositionin the file, asynchronously.If
positionlies outside of the current size of the file, the file will be enlarged to encompass it.When multiple writes are invoked on the same file there are no guarantees as to order in which those writes actually occur
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
buffer- the buffer to writeposition- the position in the file to write it at- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
AsyncFile.write(Buffer, long)
-
writeAndAwait
public void writeAndAwait(io.vertx.core.buffer.Buffer buffer, long position) Write aBufferto the file at positionpositionin the file, asynchronously.If
positionlies outside of the current size of the file, the file will be enlarged to encompass it.When multiple writes are invoked on the same file there are no guarantees as to order in which those writes actually occur
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
buffer- the buffer to writeposition- the position in the file to write it at- See Also:
-
AsyncFile.write(Buffer, long)
-
writeAndForget
Write aBufferto the file at positionpositionin the file, asynchronously.If
positionlies outside of the current size of the file, the file will be enlarged to encompass it.When multiple writes are invoked on the same file there are no guarantees as to order in which those writes actually occur
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
buffer- the buffer to writeposition- the position in the file to write it at- Returns:
- The current instance to chain operations if needed.
- See Also:
-
AsyncFile.write(Buffer, long)
-
read
@CheckReturnValue public io.smallrye.mutiny.Uni<io.vertx.core.buffer.Buffer> read(io.vertx.core.buffer.Buffer buffer, int offset, long position, int length) Readslengthbytes of data from the file at positionpositionin the file, asynchronously.The read data will be written into the specified
Buffer bufferat positionoffset.If data is read past the end of the file then zero bytes will be read.
When multiple reads are invoked on the same file there are no guarantees as to order in which those reads actually occur.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
buffer- the buffer to read intooffset- the offset into the buffer where the data will be readposition- the position in the file where to start readinglength- the number of bytes to read- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
AsyncFile.read(Buffer, int, long, int)
-
readAndAwait
public io.vertx.core.buffer.Buffer readAndAwait(io.vertx.core.buffer.Buffer buffer, int offset, long position, int length) Readslengthbytes of data from the file at positionpositionin the file, asynchronously.The read data will be written into the specified
Buffer bufferat positionoffset.If data is read past the end of the file then zero bytes will be read.
When multiple reads are invoked on the same file there are no guarantees as to order in which those reads actually occur.
Unlike the bare Vert.x variant, this method returns a
Buffer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
buffer- the buffer to read intooffset- the offset into the buffer where the data will be readposition- the position in the file where to start readinglength- the number of bytes to read- Returns:
- The operation result
- See Also:
-
AsyncFile.read(Buffer, int, long, int)
-
readAndForget
public AsyncFile readAndForget(io.vertx.core.buffer.Buffer buffer, int offset, long position, int length) Readslengthbytes of data from the file at positionpositionin the file, asynchronously.The read data will be written into the specified
Buffer bufferat positionoffset.If data is read past the end of the file then zero bytes will be read.
When multiple reads are invoked on the same file there are no guarantees as to order in which those reads actually occur.
Unlike the bare Vert.x variant, this method ignores the
Bufferresult or any failure.- Parameters:
buffer- the buffer to read intooffset- the offset into the buffer where the data will be readposition- the position in the file where to start readinglength- the number of bytes to read- Returns:
- The current instance to chain operations if needed.
- See Also:
-
AsyncFile.read(Buffer, int, long, int)
-
flush
Flush any writes made to this file to underlying persistent storage.If the file was opened with
flushset totruethen calling this method will have no effect.The actual flush will happen asynchronously.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
AsyncFile.flush()
-
flushAndAwait
public void flushAndAwait()Flush any writes made to this file to underlying persistent storage.If the file was opened with
flushset totruethen calling this method will have no effect.The actual flush will happen asynchronously.
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
AsyncFile.flush()
-
flushAndForget
Flush any writes made to this file to underlying persistent storage.If the file was opened with
flushset totruethen calling this method will have no effect.The actual flush will happen asynchronously.
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
AsyncFile.flush()
-
size
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
AsyncFile.size()
-
sizeAndAwait
Unlike the bare Vert.x variant, this method returns a
Long. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Returns:
- The operation result
- See Also:
-
AsyncFile.size()
-
sizeAndForget
Unlike the bare Vert.x variant, this method ignores the
Longresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
AsyncFile.size()
-
lock
Acquire a non-shared lock on the entire file.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
AsyncFile.lock()
-
lockAndAwait
Acquire a non-shared lock on the entire file.Unlike the bare Vert.x variant, this method returns a
AsyncFileLock. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Returns:
- The operation result
- See Also:
-
AsyncFile.lock()
-
lockAndForget
Acquire a non-shared lock on the entire file.Unlike the bare Vert.x variant, this method ignores the
AsyncFileLockresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
AsyncFile.lock()
-
lock
@CheckReturnValue public io.smallrye.mutiny.Uni<AsyncFileLock> lock(long position, long size, boolean shared) Acquire a lock on a portion of this file.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
position- where the region startssize- the size of the regionshared- whether the lock should be shared- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
AsyncFile.lock(long, long, boolean)
-
lockAndAwait
Acquire a lock on a portion of this file.Unlike the bare Vert.x variant, this method returns a
AsyncFileLock. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
position- where the region startssize- the size of the regionshared- whether the lock should be shared- Returns:
- The operation result
- See Also:
-
AsyncFile.lock(long, long, boolean)
-
lockAndForget
Acquire a lock on a portion of this file.Unlike the bare Vert.x variant, this method ignores the
AsyncFileLockresult or any failure.- Parameters:
position- where the region startssize- the size of the regionshared- whether the lock should be shared- Returns:
- The current instance to chain operations if needed.
- See Also:
-
AsyncFile.lock(long, long, boolean)
-
withLock
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> withLock(Supplier<io.smallrye.mutiny.Uni<T>> block) Acquire a non-shared lock on the entire file.When the
blockis called, the lock is already acquired, it will be released when theFuture<T>returned by the block completes.When the
blockfails, the lock is released and the returned uni is failed with the cause of the failure.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
block- the code block called after lock acquisition- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
AsyncFile.withLock(Supplier)
-
withLockAndAwait
Acquire a non-shared lock on the entire file.When the
blockis called, the lock is already acquired, it will be released when theFuture<T>returned by the block completes.When the
blockfails, the lock is released and the returned underlying uni is failed with the cause of the failure.Unlike the bare Vert.x variant, this method returns a
AsyncFile. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
block- the code block called after lock acquisition- Returns:
- The operation result
- See Also:
-
AsyncFile.withLock(Supplier)
-
withLockAndForget
Acquire a non-shared lock on the entire file.When the
blockis called, the lock is already acquired, it will be released when theFuture<T>returned by the block completes.When the
blockfails, the lock is released and the returned underlying uni is failed with the cause of the failure.Unlike the bare Vert.x variant, this method ignores the
AsyncFileresult or any failure.- Parameters:
block- the code block called after lock acquisition- Returns:
- The current instance to chain operations if needed.
- See Also:
-
AsyncFile.withLock(Supplier)
-
withLock
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> withLock(long position, long size, boolean shared, Supplier<io.smallrye.mutiny.Uni<T>> block) Acquire a lock on a portion of this file.When the
blockis called, the lock is already acquired , it will be released when theFuture<T>returned by the block completes.When the
blockfails, the lock is released and the returned uni is failed with the cause of the failure.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
position- where the region startssize- the size of the regionshared- whether the lock should be sharedblock- the code block called after lock acquisition- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
AsyncFile.withLock(long, long, boolean, Supplier)
-
withLockAndAwait
public <T> T withLockAndAwait(long position, long size, boolean shared, Supplier<io.smallrye.mutiny.Uni<T>> block) Acquire a lock on a portion of this file.When the
blockis called, the lock is already acquired , it will be released when theFuture<T>returned by the block completes.When the
blockfails, the lock is released and the returned underlying uni is failed with the cause of the failure.Unlike the bare Vert.x variant, this method returns a
AsyncFile. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
position- where the region startssize- the size of the regionshared- whether the lock should be sharedblock- the code block called after lock acquisition- Returns:
- The operation result
- See Also:
-
AsyncFile.withLock(long, long, boolean, Supplier)
-
withLockAndForget
public <T> AsyncFile withLockAndForget(long position, long size, boolean shared, Supplier<io.smallrye.mutiny.Uni<T>> block) Acquire a lock on a portion of this file.When the
blockis called, the lock is already acquired , it will be released when theFuture<T>returned by the block completes.When the
blockfails, the lock is released and the returned underlying uni is failed with the cause of the failure.Unlike the bare Vert.x variant, this method ignores the
AsyncFileresult or any failure.- Parameters:
position- where the region startssize- the size of the regionshared- whether the lock should be sharedblock- the code block called after lock acquisition- Returns:
- The current instance to chain operations if needed.
- See Also:
-
AsyncFile.withLock(long, long, boolean, Supplier)
-
end
Ends the stream.Once the stream has ended, it cannot be used any more.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
endin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
WriteStream.end()
-
endAndAwait
public void endAndAwait()Ends the stream.Once the stream has ended, it cannot be used any more.
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
WriteStream.end()
-
endAndForget
Ends the stream.Once the stream has ended, it cannot be used any more.
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
WriteStream.end()
-
end
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
endin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
WriteStream.end(T)
-
endAndAwait
public void endAndAwait(io.vertx.core.buffer.Buffer arg0) Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
data- the data to write- See Also:
-
WriteStream.end(T)
-
endAndForget
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
data- the data to write- Returns:
- The current instance to chain operations if needed.
- See Also:
-
WriteStream.end(T)
-
write
Write some data to the stream.The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the
writeQueueFull()method before writing. This is done automatically if using aPipe.When the
datais moved from the queue to the actual medium, the returnedFuturewill be completed with the write result, e.g the uni is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
writein interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
WriteStream.write(T)
-
writeAndAwait
public void writeAndAwait(io.vertx.core.buffer.Buffer arg0) Write some data to the stream.The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the
writeQueueFull()method before writing. This is done automatically if using aPipe.When the
datais moved from the queue to the actual medium, the returnedFuturewill be completed with the write result, e.g the underlying uni is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
data- the data to write- See Also:
-
WriteStream.write(T)
-
writeAndForget
Write some data to the stream.The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the
writeQueueFull()method before writing. This is done automatically if using aPipe.When the
datais moved from the queue to the actual medium, the returnedFuturewill be completed with the write result, e.g the underlying uni is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
data- the data to write- Returns:
- The current instance to chain operations if needed.
- See Also:
-
WriteStream.write(T)
-
pipeTo
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<io.vertx.core.buffer.Buffer> arg0) Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
pipeToin interfaceReadStream<io.vertx.core.buffer.Buffer>- Parameters:
dst- the destination write stream- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
io.vertx.core.file.AsyncFile#pipeTo(WriteStream)
-
pipeToAndAwait
Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
dst- the destination write stream- See Also:
-
io.vertx.core.file.AsyncFile#pipeTo(WriteStream)
-
pipeToAndForget
Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
dst- the destination write stream- Returns:
- The current instance to chain operations if needed.
- See Also:
-
io.vertx.core.file.AsyncFile#pipeTo(WriteStream)
-
handler
Description copied from interface:ReadStreamSet a data handler. As data is read, the handler will be called with the data.- Specified by:
handlerin interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
pause
Description copied from interface:ReadStreamPause theReadStream, it sets the buffer infetchmode and clears the actual demand.While it's paused, no data will be sent to the data
handler.- Specified by:
pausein interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
resume
Description copied from interface:ReadStreamResume reading, and sets the buffer inflowingmode. If theReadStreamhas been paused, reading will recommence on it.- Specified by:
resumein interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
Description copied from interface:ReadStreamSet an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.- Specified by:
endHandlerin interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
setWriteQueueMaxSize
Description copied from interface:WriteStreamSet the maximum size of the write queue tomaxSize. You will still be able to write to the stream even if there is more thanmaxSizeitems in the write queue. This is used as an indicator by classes such asPipeto provide flow control. The value is defined by the implementation of the stream, e.g in bytes for aNetSocket, etc...- Specified by:
setWriteQueueMaxSizein interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
maxSize- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
Description copied from interface:WriteStreamSet a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. SeePipefor an example of this being used.The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to
maxSize / 2.- Specified by:
drainHandlerin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
handler- the handler. Can benull.- Returns:
- a reference to this, so the API can be used fluently
-
exceptionHandler
Set an exception handler on the read stream and on the write stream.- Specified by:
exceptionHandlerin interfaceReadStream<io.vertx.core.buffer.Buffer>- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
fetch
Description copied from interface:ReadStreamFetch the specifiedamountof elements. If theReadStreamhas been paused, reading will recommence with the specifiedamountof items, otherwise the specifiedamountwill be added to the current stream demand.- Specified by:
fetchin interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
setReadPos
Sets the position from which data will be read from when using the file as aReadStream.- Parameters:
readPos- the position in the file- Returns:
- a reference to this, so the API can be used fluently
-
setReadLength
Sets the number of bytes that will be read when using the file as aReadStream.- Parameters:
readLength- the bytes that will be read from the file- Returns:
- a reference to this, so the API can be used fluently
-
getReadLength
public long getReadLength()- Returns:
- the number of bytes that will be read when using the file as a
ReadStream
-
setWritePos
Sets the position from which data will be written when using the file as aWriteStream.- Parameters:
writePos- the position in the file- Returns:
- a reference to this, so the API can be used fluently
-
getWritePos
public long getWritePos()- Returns:
- the current write position the file is at
-
setReadBufferSize
Sets the buffer size that will be used to read the data from the file. Changing this value will impact how much the data will be read at a time from the file system.- Parameters:
readBufferSize- the buffer size- Returns:
- a reference to this, so the API can be used fluently
-
sizeBlocking
public long sizeBlocking()Likesize()but blocking. -
tryLock
Try to acquire a non-shared lock on the entire file.- Returns:
- the lock if it can be acquired immediately, otherwise
null
-
tryLock
Try to acquire a lock on a portion of this file.- Parameters:
position- where the region startssize- the size of the regionshared- whether the lock should be shared- Returns:
- the lock if it can be acquired immediately, otherwise
null
-
pipe
Pause this stream and return aPipeto transfer the elements of this stream to a destinationWriteStream. The stream will be resumed when the pipe will be wired to aWriteStream.- Specified by:
pipein interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a pipe
-
writeQueueFull
public boolean writeQueueFull()This will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)- Specified by:
writeQueueFullin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Returns:
trueif write queue is full
-
newInstance
Creates a new instance of theAsyncFile. -
hashCode
public int hashCode() -
equals
-
toString
-
toMulti
@CheckReturnValue public io.smallrye.mutiny.Multi<io.vertx.core.buffer.Buffer> toMulti() -
toBlockingIterable
-
toBlockingStream
-
toSubscriber
Converts the current write stream to a subscriber.
-