本文整理汇总了Java中org.apache.rocketmq.store.MappedFile类的典型用法代码示例。如果您正苦于以下问题:Java MappedFile类的具体用法?Java MappedFile怎么用?Java MappedFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MappedFile类属于org.apache.rocketmq.store包,在下文中一共展示了MappedFile类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IndexFile
import org.apache.rocketmq.store.MappedFile; //导入依赖的package包/类
public IndexFile(final String fileName, final int hashSlotNum, final int indexNum,
final long endPhyOffset, final long endTimestamp) throws IOException {
int fileTotalSize =
IndexHeader.INDEX_HEADER_SIZE + (hashSlotNum * hashSlotSize) + (indexNum * indexSize);
this.mappedFile = new MappedFile(fileName, fileTotalSize);
this.fileChannel = this.mappedFile.getFileChannel();
this.mappedByteBuffer = this.mappedFile.getMappedByteBuffer();
this.hashSlotNum = hashSlotNum;
this.indexNum = indexNum;
ByteBuffer byteBuffer = this.mappedByteBuffer.slice();
this.indexHeader = new IndexHeader(byteBuffer);
if (endPhyOffset > 0) {
this.indexHeader.setBeginPhyOffset(endPhyOffset);
this.indexHeader.setEndPhyOffset(endPhyOffset);
}
if (endTimestamp > 0) {
this.indexHeader.setBeginTimestamp(endTimestamp);
this.indexHeader.setEndTimestamp(endTimestamp);
}
}
示例2: IndexFile
import org.apache.rocketmq.store.MappedFile; //导入依赖的package包/类
/**
*
* @param fileName userRootPath/index/YYMMDDhhmmss + mmm(毫秒)
* @param hashSlotNum default value = 5000000
* @param indexNum default value = 5000000 * 4
*
* 如果IndexFile 在IndexService.indexFileList.isEmpty()空时创建,则 endPhyOffset = endTimestamp = 0;
* 否则, endPhyOffset = IndexService.indexFileList.last().endPhyOffset
* endTimestamp = IndexService.indexFileList.last().endTimestamp
* @param endPhyOffset
* @param endTimestamp
* @throws IOException
*/
public IndexFile(final String fileName, final int hashSlotNum, final int indexNum,
final long endPhyOffset, final long endTimestamp) throws IOException {
//fileTotalSize = 40 + (5,000,000[hashSlotNum] * 4[hashSlotSize]) + ((4 * 5,000,000)[indexNum] * 20[indexSize])
//1G = 1024 * 1024 * 1024 = 1,073,741,824 (10亿级)
int fileTotalSize =
IndexHeader.INDEX_HEADER_SIZE + (hashSlotNum * hashSlotSize) + (indexNum * indexSize);
this.mappedFile = new MappedFile(fileName, fileTotalSize);
this.fileChannel = this.mappedFile.getFileChannel();
this.mappedByteBuffer = this.mappedFile.getMappedByteBuffer();
this.hashSlotNum = hashSlotNum;
this.indexNum = indexNum;
ByteBuffer byteBuffer = this.mappedByteBuffer.slice();
this.indexHeader = new IndexHeader(byteBuffer);
if (endPhyOffset > 0) {
this.indexHeader.setBeginPhyOffset(endPhyOffset);
this.indexHeader.setEndPhyOffset(endPhyOffset);
}
if (endTimestamp > 0) {
this.indexHeader.setBeginTimestamp(endTimestamp);
this.indexHeader.setEndTimestamp(endTimestamp);
}
}