
0. 简介

1. Driver Conductor - add[Exclusive]Publication


创建IpcPublication,核心就是 "${aeronDirectory}/${correlationId}.logbuffer" 共享内存文件;
返回ON_[EXCLUSIVE_]PUBLICATION_READY消息;
向所有相关的 subscribers 发送ON_AVAILABLE_IMAGE消息。(subscribers 收到该消息就会读取共享内存进行消费,具体逻辑下篇分析)
1.1 ${correlationId}.logbuffer 共享内存文件


2. Client Conductor - onNew[Exclusive]Publication


从 Log Meta Data 中取出 Active Term Count (termCount)
termCount按照PARTITION_COUNT(3)取余得到当前的 Term 索引 (index)
从 Log Meta Data 中获取对应的的 Tail Counter #index (rawTail)
rawTail的高 32 位是 termId,低 32 位是termOffset
termBeginPosition = (termId - initialTermId) << positionBitsToShift,其中positionBitsToShift这步操作本质上就是乘 Term 的长度
3. ExclusivePublication - offer


3.1 termAppender.append[Un]fragmentedMessage 写入数据


3.2 newPosition 更新位置


4. tryClaim




文章转载自BUG侦探,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




