zoukankan      html  css  js  c++  java
  • rocketMQ 删除过期文件

    commitLog 删除文件的策略
    指定时间到了,磁盘不足,人工删除,满足任一条件,判断文件是否过期或者磁盘严重不足(超过 85%),是则删除,一批次最多删除 10 个文件。

    有个地方需要注意,mmap 写文件,windows 观察,发现文件的修改时间戳一直不变,linux 还未验证。

    commitLog,consumeQueue,indexFile 的删除策略如下图:

    commitLog 尾部是有空洞的,当一个消息在当前文件放不下时,rocketmq 认为下一个文件一定能放下该消息,消息不会分隔保存。

    commitLog 文件尾部存在至少 8 字节的空洞。

    一般情况的尾部组成:maxBlank,BLANK_MAGIC_CODE,随机的内容

    // org.apache.rocketmq.store.CommitLog.DefaultAppendMessageCallback#doAppend
    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);
    }
  • 相关阅读:
    pytest-html报告自定义字段
    Python SMTP发送邮件
    IE浏览器兼容测试工具 IETester
    全局ID生成--雪花算法改进版
    全局ID生成--雪花算法
    spring-cloud-sleuth/zipkin
    14.跑批到某个点突然所有批都断批
    13.分布式锁在不同环境引发的坑
    spring-cloud-gateway
    spring-cloud-netflix-config
  • 原文地址:https://www.cnblogs.com/allenwas3/p/12404169.html
Copyright © 2011-2022 走看看