private void recover(final boolean lastExitOK) { long maxPhyOffsetOfConsumeQueue = this.recoverConsumeQueue(); if (lastExitOK) { this.commitLog.recoverNormally(maxPhyOffsetOfConsumeQueue); } else { this.commitLog.recoverAbnormally(maxPhyOffsetOfConsumeQueue); } this.recoverTopicQueueTable(); }
private void recover(final boolean lastExitOK) { long maxPhyOffsetOfConsumeQueue = this.recoverConsumeQueue(); if (lastExitOK) { this.commitLog.recoverNormally(maxPhyOffsetOfConsumeQueue); } else { this.commitLog.recoverAbnormally(maxPhyOffsetOfConsumeQueue); } this.recoverTopicQueueTable(); }
public boolean truncateNotSync() { if (BrokerRole.SLAVE != messageStoreConfig.getBrokerRole()) { log.warn("broker role is not slave, can not truncate data"); return true; } long phyOffsetSync = getInSyncOffsetSaved(); if (phyOffsetSync == -1) { log.info("no offset save, do not check and truncate"); return true; } long startTime = getSystemClock().now(); long phyOffsetCur = getMaxPhyOffset(); if (phyOffsetSync > phyOffsetCur) { log.warn("offset:{} > current offset:{}, no need to truncate", phyOffsetSync, phyOffsetCur); return false; } else if ((phyOffsetCur - phyOffsetSync) > COMMIT_LOG_TRUNCATE_COUNT_MAX * messageStoreConfig.getMapedFileSizeCommitLog()) { log.warn("truncate size({}) exceeded the threshold({}), do not truncate", phyOffsetCur - phyOffsetSync, COMMIT_LOG_TRUNCATE_COUNT_MAX * messageStoreConfig.getMapedFileSizeCommitLog()); return false; } indexService.deleteExpiredFile(phyOffsetSync); log.info("truncate index file to offset:{}", phyOffsetSync); //truncate commit log and consumer queue file commitLog.truncate(phyOffsetSync); log.info("truncate commit log to offset:{}", phyOffsetSync); this.recoverTopicQueueTable(); log.info("update topic queue tables"); log.info("truncate completely, from {} back to {}, cost:{} ms", phyOffsetCur, phyOffsetSync, getSystemClock().now() - startTime); return true; }
public boolean onRoleChange() { if (this.scheduleMessageService == null) { log.warn("scheduleMessageService is null"); return false; } scheduleMessageService.load(); if (BrokerRole.SLAVE != messageStoreConfig.getBrokerRole()) { this.scheduleMessageService.start(); this.recoverTopicQueueTable(); this.haService.initInSyncOffset(getMaxPhyOffset()); } else { this.scheduleMessageService.shutdown(); truncateNotSync(); if (this.getMessageStoreConfig().isDuplicationEnable()) { this.reputMessageService.setReputFromOffset(this.commitLog.getConfirmOffset()); } else { this.reputMessageService.setReputFromOffset(this.commitLog.getMaxOffset()); } } log.info("role change, current role:{}", messageStoreConfig.getBrokerRole()); return true; }
private void recover(final boolean lastExitOK) { long maxPhyOffsetOfConsumeQueue = this.recoverConsumeQueue(); if (lastExitOK) { this.commitLog.recoverNormally(maxPhyOffsetOfConsumeQueue); } else { this.commitLog.recoverAbnormally(maxPhyOffsetOfConsumeQueue); } this.recoverTopicQueueTable(); }