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

字段摘要
static int OS_PAGE_SIZE
           
 
从类 com.alibaba.rocketmq.store.ReferenceResource 继承的字段
available, cleanupOver, refCount
 
构造方法摘要
MapedFile(String fileName, int fileSize)
           
 
方法摘要
 boolean appendMessage(byte[] data)
          向存储层追加数据,一般在SLAVE存储结构中使用
 AppendMessageResult appendMessage(Object msg, AppendMessageCallback cb)
          向MapedBuffer追加消息
static void clean(ByteBuffer buffer)
           
 boolean cleanup(long currentRef)
           
 int commit(int flushLeastPages)
          消息刷盘
 boolean destroy(long intervalForcibly)
          清理资源,destroy与调用shutdown的线程必须是同一个
static void ensureDirOK(String dirName)
           
 int getCommittedPosition()
           
 FileChannel getFileChannel()
           
 long getFileFromOffset()
          文件起始偏移量
 String getFileName()
           
 int getFileSize()
          获取文件大小
 long getLastModifiedTimestamp()
           
 MappedByteBuffer getMappedByteBuffer()
           
 long getStoreTimestamp()
           
static int getTotalmapedfiles()
           
static long getTotalMapedVitualMemory()
           
 int getWrotePostion()
           
 boolean isFirstCreateInQueue()
           
 boolean isFull()
           
 SelectMapedBufferResult selectMapedBuffer(int pos)
          读逻辑分区
 SelectMapedBufferResult selectMapedBuffer(int pos, int size)
           
 void setCommittedPosition(int pos)
           
 void setFirstCreateInQueue(boolean firstCreateInQueue)
           
 void setWrotePostion(int pos)
           
 ByteBuffer sliceByteBuffer()
          方法不能在运行时调用,不安全。
 
从类 com.alibaba.rocketmq.store.ReferenceResource 继承的方法
getRefCount, hold, isAvailable, isCleanupOver, release, shutdown
 
从类 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.