StandBy NameNode 合并并回传FSImage

启动StandbyCheckpointer

// 接上篇
StandbyState public void enterState(HAContext context)
NameNodeHAContext public void startStandbyServices()
FSNamesystem void startStandbyServices(final Configuration conf)
standbyCheckpointer = new StandbyCheckpointer(conf, this);
this.thread = new CheckpointerThread()

StandbyCheckpointer 启动 CheckpointerThread 线程,进行周期性检查;
如果满足条件 uncheckpointed >= checkpointConf.getTxnCount() 或者 secsSinceLast >= checkpointConf.getPeriod() 则执行 StandbyCheckpointerdoCheckpoint()方法。

doCheckpoint

doCheckpoint() 先将所有FSImage 持久化为文件,然后再通过HTTP PUT方法传送到NN中

save FSImage文件

StandbyCheckpointer private void doCheckpoint()
FSImage public synchronized void saveNamespace()
FSImage private synchronized void saveFSImageInAllDirs() {
    List<Thread> saveThreads = new ArrayList<Thread>();
      // save images into current
      for (Iterator<StorageDirectory> it
             = storage.dirIterator(NameNodeDirType.IMAGE); it.hasNext();) {
        StorageDirectory sd = it.next();
        FSImageSaver saver = new FSImageSaver(ctx, sd, nnf);
        Thread saveThread = new Thread(saver, saver.toString());
        saveThreads.add(saveThread);
        saveThread.start();
      }
      waitForThreads(saveThreads);
}

// Storage 

  /**
   * Write all data storage files.
   * @throws IOException
   */
  public void writeAll() throws IOException {
    this.layoutVersion = getServiceLayoutVersion();
    for (Iterator<StorageDirectory> it = storageDirs.iterator(); it.hasNext();) {
      writeProperties(it.next());
    }
  }

启动独立线程,SNN 向NN PUT FSImage

        TransferFsImage.uploadImageFromStorage(activeNNAddress, conf,
            namesystem.getFSImage().getStorage(), imageType, txid, canceler);
            
// TransferFsImage
public static void uploadImageFromStorage()
// Uploads the imagefile using HTTP PUT method
private static void uploadImage(private static void writeFileToPutRequest()

ImageServlet 接收 FSImage

标准 HTTPServlet,通过doPut() 方法接收FSImage文件

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值