コード例 #1
0
ファイル: CommitLog.java プロジェクト: xiexingguang/RocketMQ
  public SelectMapedBufferResult getData(final long offset, final boolean returnFirstOnNotFound) {
    int mapedFileSize =
        this.defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog();
    MapedFile mapedFile = this.mapedFileQueue.findMapedFileByOffset(offset, returnFirstOnNotFound);
    if (mapedFile != null) {
      int pos = (int) (offset % mapedFileSize);
      SelectMapedBufferResult result = mapedFile.selectMapedBuffer(pos);
      return result;
    }

    return null;
  }
コード例 #2
0
ファイル: CommitLog.java プロジェクト: xiexingguang/RocketMQ
  /** 读取消息 */
  public SelectMapedBufferResult getMessage(final long offset, final int size) {
    int mapedFileSize =
        this.defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog();
    MapedFile mapedFile =
        this.mapedFileQueue.findMapedFileByOffset(offset, (0 == offset ? true : false));
    if (mapedFile != null) {
      int pos = (int) (offset % mapedFileSize);
      SelectMapedBufferResult result = mapedFile.selectMapedBuffer(pos, size);
      return result;
    }

    return null;
  }