com.alibaba.rocketmq.store
类 MapedFile
java.lang.Object
com.alibaba.rocketmq.store.ReferenceResource
com.alibaba.rocketmq.store.MapedFile
public class MapedFile
- extends ReferenceResource
Pagecache文件访问封装
- 从以下版本开始:
- 2013-7-21
- 作者:
- shijia.wxr
| 从类 java.lang.Object 继承的方法 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OS_PAGE_SIZE
public static final int OS_PAGE_SIZE
- 另请参见:
- 常量字段值
MapedFile
public MapedFile(String fileName,
int fileSize)
throws IOException
- 抛出:
IOException
ensureDirOK
public static void ensureDirOK(String dirName)
clean
public static void clean(ByteBuffer buffer)
getTotalmapedfiles
public static int getTotalmapedfiles()
getTotalMapedVitualMemory
public static long getTotalMapedVitualMemory()
getLastModifiedTimestamp
public long getLastModifiedTimestamp()
getFileName
public String getFileName()
getFileSize
public int getFileSize()
- 获取文件大小
getFileChannel
public FileChannel getFileChannel()
appendMessage
public AppendMessageResult appendMessage(Object msg,
AppendMessageCallback cb)
- 向MapedBuffer追加消息
- 参数:
msg - 要追加的消息cb - 用来对消息进行序列化,尤其对于依赖MapedFile Offset的属性进行动态序列化
- 返回:
- 是否成功,写入多少数据
getFileFromOffset
public long getFileFromOffset()
- 文件起始偏移量
appendMessage
public boolean appendMessage(byte[] data)
- 向存储层追加数据,一般在SLAVE存储结构中使用
- 返回:
- 返回写入了多少数据
commit
public int commit(int flushLeastPages)
- 消息刷盘
- 参数:
flushLeastPages - 至少刷几个page
- 返回:
getCommittedPosition
public int getCommittedPosition()
setCommittedPosition
public void setCommittedPosition(int pos)
isFull
public boolean isFull()
selectMapedBuffer
public SelectMapedBufferResult selectMapedBuffer(int pos,
int size)
selectMapedBuffer
public SelectMapedBufferResult selectMapedBuffer(int pos)
- 读逻辑分区
cleanup
public boolean cleanup(long currentRef)
- 指定者:
- 类
ReferenceResource 中的 cleanup
destroy
public boolean destroy(long intervalForcibly)
- 清理资源,destroy与调用shutdown的线程必须是同一个
- 返回:
- 是否被destory成功,上层调用需要对失败情况处理,失败后尝试重试
getWrotePostion
public int getWrotePostion()
setWrotePostion
public void setWrotePostion(int pos)
getMappedByteBuffer
public MappedByteBuffer getMappedByteBuffer()
sliceByteBuffer
public ByteBuffer sliceByteBuffer()
- 方法不能在运行时调用,不安全。只在启动时,reload已有数据时调用
getStoreTimestamp
public long getStoreTimestamp()
isFirstCreateInQueue
public boolean isFirstCreateInQueue()
setFirstCreateInQueue
public void setFirstCreateInQueue(boolean firstCreateInQueue)
Copyright © 2012–2015. All rights reserved.