当END_OF_FILE时刷新Broker

在CommitLog.java中 当msgLen+END_FILE_MIN_BLANK_LENGTH)>maxBlank时,它将放入总大小、magiccode来标记空白

if ((msgLen + END_FILE_MIN_BLANK_LENGTH) > maxBlank) { this.resetByteBuffer(this.msgStoreItemMemory, maxBlank); // 1 TOTALSIZE this.msgStoreItemMemory.putInt(maxBlank); // 2 MAGICCODE this.msgStoreItemMemory.putInt(CommitLog.BLANK_MAGIC_CODE); // 3 The remaining space may be any value // Here the length of the specially set maxBlank final long beginTimeMills = CommitLog.this.defaultMessageStore.now(); byteBuffer.put(this.msgStoreItemMemory.array(), 0, maxBlank); return new AppendMessageResult(AppendMessageStatus.END_OF_FILE, wroteOffset, maxBlank, msgId, msgInner.getStoreTimestamp(), queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills); }

解析结果时

case END_OF_FILE: unlockMappedFile = mappedFile; // Create a new file, re-write the message mappedFile = this.mappedFileQueue.getLastMappedFile(0); if (null == mappedFile) { // XXX: warn and notify me log.error("create mapped file2 error, topic: " + msg.getTopic() + " clientAddr: " + msg.getBornHostString()); beginTimeInLock = 0; return new PutMessageResult(PutMessageStatus.CREATE_MAPEDFILE_FAILED, result); } result = mappedFile.appendMessage(msg, this.appendMessageCallback); break;

它会创建一个新文件,放入消息并刷新它,但标记为空白的数据不会刷新,如何处理?

原提问者GitHub用户Crearns

展开
收起
芬奇福贵 2023-05-26 11:58:39 108 分享 版权
1 条回答
写回答
取消 提交回答
  • AppendMessage方法只将消息写入内存(通常是页面缓存,但如果transientStorePoolEnable为true,则写入直接缓冲区),其他线程将数据刷新到磁盘,因此标记为空的数据最终将被刷新。

    原回答者GitHub用户RongtongJin

    2023-05-26 17:42:48
    赞同 展开评论
问答分类:
问答地址:

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

还有其他疑问?
咨询AI助理