zoukankan      html  css  js  c++  java
  • Apache Kafka源码分析 – ReplicaManager

    如果说controller作为master,负责全局的事情,比如选取leader,reassignment等
    那么ReplicaManager就是worker,负责完成replica的管理工作

    主要工作包含,

    stopReplica
    getOrCreatePartition
    getLeaderReplicaIfLocal
    getReplica
    readMessageSets
    becomeLeaderOrFollower

     

    StopReplicaCommand

    处理很简单,主要就是停止fetcher线程,并删除partition目录

    stopReplicas

    stopReplica

    LeaderAndISRCommand

    becomeLeaderOrFollower
    做些epoch和valid的检查,然后区分出leader和follows,分别调用makeLeaders,makeFollowers


    makeLeaders
    停止Fetcher,调用partition.makeLeader,把这些partition加到leaderPartitions中


    makeFollowers
    除了修改leaderPartitions和Mark as followers以外
    作为followers,需要truncated log到highWatermark,然后启动fetcher去catch leader


    checkpointHighWatermarks
    对于每个replica而已,HighWatermarks是很重要的,因为只有通过它可以知道到底哪些数据是一致的,这样就算broker crash,恢复的时候只需要基于HighWatermarks继续catch就可以
    所以对于HighWatermarks,需要做cp

  • 相关阅读:
    【leetcode】ZigZag——easy
    联合
    AddChildViewController
    imageWithRender(图片的渲染模式)
    13.范型函数的使用:将字典合并到当前字典
    12.代码获取命名空间名称,并创建相应的类(anyClass 应用)
    13.static 面向对象
    11.swift 单例
    swift String 扩展
    swift UIView 扩展
  • 原文地址:https://www.cnblogs.com/fxjwind/p/3578417.html
Copyright © 2011-2022 走看看