public static interface StateMachine.DataChannel extends WritableByteChannel
| 限定符和类型 | 方法和说明 |
|---|---|
void |
force(boolean metadata)
Similar to
FileChannel.force(boolean),
the underlying implementation should force writing the data and/or metadata to the underlying storage. |
default int |
write(ByteBuffer buffer)
This method is the same as
WritableByteChannel.write(ByteBuffer). |
default int |
write(ReferenceCountedObject<ByteBuffer> referenceCountedBuffer)
Similar to
write(ByteBuffer)
except that the parameter is a ReferenceCountedObject. |
default int write(ByteBuffer buffer) throws IOException
WritableByteChannel.write(ByteBuffer).
If the implementation has overridden write(ReferenceCountedObject),
then it does not have to override this method.write 在接口中 WritableByteChannelIOExceptiondefault int write(ReferenceCountedObject<ByteBuffer> referenceCountedBuffer) throws IOException
write(ByteBuffer)
except that the parameter is a ReferenceCountedObject.
This is an optional method.
The default implementation is the same as write(referenceCountedBuffer.get()).
The implementation may choose to override this method in order to retain the buffer for later use.
- If the buffer is retained, it must be released afterward.
Otherwise, the buffer will not be returned, and it will cause a memory leak.
- If the buffer is retained multiple times, it must be released the same number of time.
- It is safe to access the buffer before this method returns with or without retaining it.
- If the buffer is not retained but is accessed after this method returns,
the content of the buffer could possibly be changed unexpectedly, and it will cause data corruption.IOExceptionvoid force(boolean metadata)
throws IOException
FileChannel.force(boolean),
the underlying implementation should force writing the data and/or metadata to the underlying storage.metadata - Should the metadata be forced?IOException - If there are IO errors.Copyright © 2017–2025 The Apache Software Foundation. All rights reserved.