public class DefaultMmapFile extends ReferenceResource implements MmapFile
| 限定符和类型 | 字段和说明 |
|---|---|
protected java.io.File |
file |
protected static org.slf4j.Logger |
logger |
static int |
OS_PAGE_SIZE |
available, cleanupOver, refCount| 构造器和说明 |
|---|
DefaultMmapFile(java.lang.String fileName,
int fileSize) |
| 限定符和类型 | 方法和说明 |
|---|---|
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)
Content of data from offset to offset + length will be wrote to file.
|
static void |
clean(java.nio.ByteBuffer buffer) |
boolean |
cleanup(long currentRef) |
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.
|
static void |
ensureDirOK(java.lang.String dirName) |
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
|
static int |
getTotalMappedFiles() |
static long |
getTotalMappedVirtualMemory() |
int |
getWrotePosition()
Returns the wrote position of this mapped file.
|
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. |
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 pos)
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 pos)
Sets the flushed position of this mapped file.
|
void |
setStartPosition(int startPosition)
Sets the start position of this mapped file.
|
void |
setWrotePosition(int pos)
Sets the wrote position of this mapped file.
|
java.nio.ByteBuffer |
sliceByteBuffer()
Returns a slice of the mapped byte buffer behind the mapped file.
|
java.lang.String |
toString() |
getRefCount, hold, isAvailable, isCleanupOver, release, shutdownclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithold, isAvailable, release, shutdownpublic static final int OS_PAGE_SIZE
protected static org.slf4j.Logger logger
protected java.io.File file
public DefaultMmapFile(java.lang.String fileName,
int fileSize)
throws java.io.IOException
java.io.IOExceptionpublic static int getTotalMappedFiles()
public static long getTotalMappedVirtualMemory()
public static void ensureDirOK(java.lang.String dirName)
public static void clean(java.nio.ByteBuffer buffer)
public long getLastModifiedTimestamp()
MmapFilegetLastModifiedTimestamp 在接口中 MmapFilepublic int getFileSize()
MmapFileMappedFile.getFileSize 在接口中 MmapFilepublic java.nio.channels.FileChannel getFileChannel()
MmapFileFileChannel behind the MappedFile.getFileChannel 在接口中 MmapFilepublic long getFileFromOffset()
MmapFilegetFileFromOffset 在接口中 MmapFilepublic boolean appendMessage(byte[] data)
MmapFileMappedFile.appendMessage 在接口中 MmapFiledata - the byte array to appendpublic boolean appendMessage(byte[] data,
int offset,
int length)
appendMessage 在接口中 MmapFileoffset - The offset of the subarray to be used.length - The length of the subarray to be used.data - the byte array to appendpublic int flush(int flushLeastPages)
MmapFilepublic int commit(int commitLeastPages)
MmapFilepublic int getFlushedPosition()
MmapFilegetFlushedPosition 在接口中 MmapFilepublic void setFlushedPosition(int pos)
MmapFilesetFlushedPosition 在接口中 MmapFilepos - the specific flushed positionpublic int getStartPosition()
MmapFilegetStartPosition 在接口中 MmapFilepublic void setStartPosition(int startPosition)
MmapFilesetStartPosition 在接口中 MmapFilestartPosition - the specific start positionpublic boolean isFull()
MmapFileMappedFile is full and no new messages can be added.public SelectMmapBufferResult selectMappedBuffer(int pos, int size)
MmapFileselectMappedBuffer 在接口中 MmapFilepos - the given positionsize - the size of the returned sub-regionSelectMappedBufferResult instance contains the selected slicepublic SelectMmapBufferResult selectMappedBuffer(int pos)
MmapFileselectMappedBuffer 在接口中 MmapFilepos - the given positionSelectMappedBufferResult instance contains the selected slicepublic boolean getData(int pos,
int size,
java.nio.ByteBuffer byteBuffer)
MmapFilepublic boolean cleanup(long currentRef)
cleanup 在类中 ReferenceResourcepublic boolean destroy(long intervalForcibly)
MmapFilepublic int getWrotePosition()
MmapFilegetWrotePosition 在接口中 MmapFilepublic void setWrotePosition(int pos)
MmapFilesetWrotePosition 在接口中 MmapFilepos - the specific wrote positionpublic int getReadPosition()
MmapFilegetReadPosition 在接口中 MmapFilepublic void setCommittedPosition(int pos)
MmapFilesetCommittedPosition 在接口中 MmapFilepos - the specific committed positionpublic java.lang.String getFileName()
MmapFileMappedFile.getFileName 在接口中 MmapFilepublic java.nio.MappedByteBuffer getMappedByteBuffer()
MmapFilegetMappedByteBuffer 在接口中 MmapFilepublic java.nio.ByteBuffer sliceByteBuffer()
MmapFilesliceByteBuffer 在接口中 MmapFilepublic boolean isFirstCreateInQueue()
MmapFileisFirstCreateInQueue 在接口中 MmapFilepublic void setFirstCreateInQueue(boolean firstCreateInQueue)
MmapFilesetFirstCreateInQueue 在接口中 MmapFilefirstCreateInQueue - true or falsepublic java.lang.String toString()
toString 在类中 java.lang.ObjectCopyright © 2019. All Rights Reserved.