首页 > 其他 > 详细

RocketMQ之broker读取本地文件数据

时间:2017-04-06 22:02:17      阅读:331      评论:0      收藏:0      [点我收藏+]

这个load操作发生在启动broker的时候。

技术分享

所以我们直接进入DefaultMessageStore的load()方法:

   /**
     * 加载数据
     *
     * @throws IOException
     */
    public boolean load() {
        boolean result = true;

        try {
            boolean lastExitOK = !this.isTempFileExist();
            log.info("last shutdown {}", (lastExitOK ? "normally" : "abnormally"));

            // load 定时进度
            // 这个步骤要放置到最前面,从CommitLog里Recover定时消息需要依赖加载的定时级别参数
            // slave依赖scheduleMessageService做定时消息的恢复
            if (null != scheduleMessageService) {
                result = result && this.scheduleMessageService.load();
            }

            // load Commit Log
            result = result && this.commitLog.load();

            // load Consume Queue
            result = result && this.loadConsumeQueue();

            if (result) {
                this.storeCheckpoint =
                        new StoreCheckpoint(StorePathConfigHelper.getStoreCheckpoint(this.messageStoreConfig.getStorePathRootDir()));

                this.indexService.load(lastExitOK);

                // 尝试恢复数据
                this.recover(lastExitOK);

                log.info("load over, and the max phy offset = {}", this.getMaxPhyOffset());
            }
        } catch (Exception e) {
            log.error("load exception", e);
            result = false;
        }

        if (!result) {
            this.allocateMapedFileService.shutdown();
        }

        return result;
    }

待续。。。

 

RocketMQ之broker读取本地文件数据

原文:http://www.cnblogs.com/guazi/p/6675541.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!