public interface MmapFile
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
appendMessage(byte[] data)
Appends a raw message data represents by a byte array to the current
MappedFile. |
boolean |
appendMessage(byte[] data,
int offset,
int length)
Appends a raw message data represents by a byte array to the current
MappedFile,
starting at the given offset in the array. |
int |
commit(int commitLeastPages)
Flushes the data in the secondary cache to page cache or disk immediately.
|
boolean |
destroy(long intervalForcibly)
Destroys the file and delete it from the file system.
|
int |
flush(int flushLeastPages)
Flushes the data in cache to disk immediately.
|
boolean |
getData(int pos,
int size,
java.nio.ByteBuffer byteBuffer)
get the data from file channel
|
java.nio.channels.FileChannel |
getFileChannel()
Returns the
FileChannel behind the MappedFile. |
long |
getFileFromOffset()
Returns the global offset of the current {code MappedFile}, it's a long value of the file name.
|
java.lang.String |
getFileName()
Returns the file name of the
MappedFile. |
int |
getFileSize()
Returns the file size of the
MappedFile. |
int |
getFlushedPosition()
Returns the flushed position of this mapped file.
|
long |
getLastModifiedTimestamp()
Returns the last modified timestamp of the file.
|
java.nio.MappedByteBuffer |
getMappedByteBuffer()
Returns the mapped byte buffer behind the mapped file.
|
int |
getReadPosition()
Returns the current max readable position of this mapped file.
|
int |
getStartPosition()
Returns the start position of this mapped file, before which the data is truncated
|
int |
getWrotePosition()
Returns the wrote position of this mapped file.
|
boolean |
hold()
Increases the reference count by
1. |
boolean |
isAvailable()
Returns true if this
MappedFile is available. |
boolean |
isFirstCreateInQueue()
Returns true if the current file is first mapped file of some consume queue.
|
boolean |
isFull()
Returns true if this
MappedFile is full and no new messages can be added. |
void |
release()
Decreases the reference count by
1 and clean up the mapped file if the reference count reaches at
0. |
SelectMmapBufferResult |
selectMappedBuffer(int pos)
Selects a slice of the mapped byte buffer's sub-region behind the mapped file,
starting at the given position.
|
SelectMmapBufferResult |
selectMappedBuffer(int pos,
int size)
Selects a slice of the mapped byte buffer's sub-region behind the mapped file,
starting at the given position.
|
void |
setCommittedPosition(int committedPosition)
Sets the committed position of this mapped file.
|
void |
setFirstCreateInQueue(boolean firstCreateInQueue)
Sets the flag whether the current file is first mapped file of some consume queue.
|
void |
setFlushedPosition(int flushedPosition)
Sets the flushed position of this mapped file.
|
void |
setStartPosition(int startPosition)
Sets the start position of this mapped file.
|
void |
setWrotePosition(int wrotePosition)
Sets the wrote position of this mapped file.
|
void |
shutdown(long intervalForcibly)
Shutdowns the file and mark it unavailable.
|
java.nio.ByteBuffer |
sliceByteBuffer()
Returns a slice of the mapped byte buffer behind the mapped file.
|
java.lang.String getFileName()
MappedFile.int getFileSize()
MappedFile.java.nio.channels.FileChannel getFileChannel()
FileChannel behind the MappedFile.boolean isFull()
MappedFile is full and no new messages can be added.boolean isAvailable()
MappedFile is available.
The mapped file will be not available if it's shutdown or destroyed.
boolean appendMessage(byte[] data)
MappedFile.data - the byte array to appendboolean appendMessage(byte[] data,
int offset,
int length)
MappedFile,
starting at the given offset in the array.data - the byte array to appendoffset - the offset within the array of the first byte to be readlength - the number of bytes to be read from the given arraylong getFileFromOffset()
int flush(int flushLeastPages)
flushLeastPages - the least pages to flushint commit(int commitLeastPages)
commitLeastPages - the least pages to commitSelectMmapBufferResult selectMappedBuffer(int pos, int size)
pos - the given positionsize - the size of the returned sub-regionSelectMappedBufferResult instance contains the selected sliceSelectMmapBufferResult selectMappedBuffer(int pos)
pos - the given positionSelectMappedBufferResult instance contains the selected slicejava.nio.MappedByteBuffer getMappedByteBuffer()
java.nio.ByteBuffer sliceByteBuffer()
long getLastModifiedTimestamp()
boolean destroy(long intervalForcibly)
intervalForcibly - If true then this method will destroy the file forcibly and ignore the referencevoid shutdown(long intervalForcibly)
intervalForcibly - If true then this method will shutdown the file forcibly and ignore the
referencevoid release()
1 and clean up the mapped file if the reference count reaches at
0.boolean hold()
1.boolean isFirstCreateInQueue()
void setFirstCreateInQueue(boolean firstCreateInQueue)
firstCreateInQueue - true or falseint getFlushedPosition()
void setFlushedPosition(int flushedPosition)
flushedPosition - the specific flushed positionint getStartPosition()
void setStartPosition(int startPosition)
startPosition - the specific start positionint getWrotePosition()
void setWrotePosition(int wrotePosition)
wrotePosition - the specific wrote positionint getReadPosition()
void setCommittedPosition(int committedPosition)
committedPosition - the specific committed positionboolean getData(int pos,
int size,
java.nio.ByteBuffer byteBuffer)
pos - size - byteBuffer - Copyright © 2020. All Rights Reserved.