@Override public long getMaxPhyOffset() { return this.commitLog.getMaxOffset(); }
public long behind() { return DefaultMessageStore.this.commitLog.getMaxOffset() - this.reputFromOffset; }
private boolean isCommitLogAvailable() { return this.reputFromOffset < DefaultMessageStore.this.commitLog.getMaxOffset(); }
@Override public long slaveFallBehindMuch() { return this.commitLog.getMaxOffset() - this.haService.getPush2SlaveMaxOffset().get(); }
@Override public void shutdown() { for (int i = 0; i < 50 && this.isCommitLogAvailable(); i++) { try { Thread.sleep(100); } catch (InterruptedException ignored) { } } if (this.isCommitLogAvailable()) { log.warn("shutdown ReputMessageService, but commitlog have not finish to be dispatched, CL: {} reputFromOffset: {}", DefaultMessageStore.this.commitLog.getMaxOffset(), this.reputFromOffset); } super.shutdown(); }
/** * @throws Exception */ public void start() throws Exception { lock = lockFile.getChannel().tryLock(0, 1, false); if (lock == null || lock.isShared() || !lock.isValid()) { throw new RuntimeException("Lock failed,MQ already started"); } lockFile.getChannel().write(ByteBuffer.wrap("lock".getBytes())); lockFile.getChannel().force(true); this.flushConsumeQueueService.start(); this.commitLog.start(); this.storeStatsService.start(); if (this.scheduleMessageService != null && SLAVE != messageStoreConfig.getBrokerRole()) { this.scheduleMessageService.start(); } if (this.getMessageStoreConfig().isDuplicationEnable()) { this.reputMessageService.setReputFromOffset(this.commitLog.getConfirmOffset()); } else { this.reputMessageService.setReputFromOffset(this.commitLog.getMaxOffset()); } this.reputMessageService.start(); this.haService.start(); this.createTempFile(); this.addScheduleTask(); this.shutdown = false; }
@Override public boolean checkInDiskByConsumeOffset(final String topic, final int queueId, long consumeOffset) { final long maxOffsetPy = this.commitLog.getMaxOffset(); ConsumeQueue consumeQueue = findConsumeQueue(topic, queueId); if (consumeQueue != null) { SelectMappedBufferResult bufferConsumeQueue = consumeQueue.getIndexBuffer(consumeOffset); if (bufferConsumeQueue != null) { try { for (int i = 0; i < bufferConsumeQueue.getSize(); ) { i += ConsumeQueue.CQ_STORE_UNIT_SIZE; long offsetPy = bufferConsumeQueue.getByteBuffer().getLong(); return checkInDiskByCommitOffset(offsetPy, maxOffsetPy); } } finally { bufferConsumeQueue.release(); } } else { return false; } } return false; }
long masterOffset = HAConnection.this.haService.getDefaultMessageStore().getCommitLog().getMaxOffset(); masterOffset = masterOffset
@Override public long getMaxPhyOffset() { return this.commitLog.getMaxOffset(); }
private boolean isCommitLogAvailable() { return this.reputFromOffset < DefaultMessageStore.this.commitLog.getMaxOffset(); }
public long behind() { return DefaultMessageStore.this.commitLog.getMaxOffset() - this.reputFromOffset; }
@Override public long slaveFallBehindMuch() { return this.commitLog.getMaxOffset() - this.haService.getPush2SlaveMaxOffset().get(); }
final long maxOffsetPy = this.commitLog.getMaxOffset();
@Override public void shutdown() { for (int i = 0; i < 50 && this.isCommitLogAvailable(); i++) { try { Thread.sleep(100); } catch (InterruptedException ignored) { } } if (this.isCommitLogAvailable()) { log.warn("shutdown ReputMessageService, but commitlog have not finish to be dispatched, CL: {} reputFromOffset: {}", DefaultMessageStore.this.commitLog.getMaxOffset(), this.reputFromOffset); } super.shutdown(); }
@Override public boolean checkInDiskByConsumeOffset(final String topic, final int queueId, long consumeOffset) { final long maxOffsetPy = this.commitLog.getMaxOffset(); ConsumeQueue consumeQueue = findConsumeQueue(topic, queueId); if (consumeQueue != null) { SelectMappedBufferResult bufferConsumeQueue = consumeQueue.getIndexBuffer(consumeOffset); if (bufferConsumeQueue != null) { try { for (int i = 0; i < bufferConsumeQueue.getSize(); ) { i += ConsumeQueue.CQ_STORE_UNIT_SIZE; long offsetPy = bufferConsumeQueue.getByteBuffer().getLong(); return checkInDiskByCommitOffset(offsetPy, maxOffsetPy); } } finally { bufferConsumeQueue.release(); } } else { return false; } } return false; }
/** * @throws Exception */ public void start() throws Exception { lock = lockFile.getChannel().tryLock(0, 1, false); if (lock == null || lock.isShared() || !lock.isValid()) { throw new RuntimeException("Lock failed,MQ already started"); } lockFile.getChannel().write(ByteBuffer.wrap("lock".getBytes())); lockFile.getChannel().force(true); this.flushConsumeQueueService.start(); this.commitLog.start(); this.storeStatsService.start(); if (this.scheduleMessageService != null && BrokerRole.SLAVE != messageStoreConfig.getBrokerRole()) { this.scheduleMessageService.start(); } if (this.getMessageStoreConfig().isDuplicationEnable()) { this.reputMessageService.setReputFromOffset(this.commitLog.getConfirmOffset()); } else { this.reputMessageService.setReputFromOffset(this.commitLog.getMaxOffset()); } this.reputMessageService.start(); this.haService.start(); this.createTempFile(); this.addScheduleTask(); if (BrokerRole.SLAVE != messageStoreConfig.getBrokerRole()) { this.haService.initInSyncOffset(getMaxPhyOffset()); } this.shutdown = false; }
long masterOffset = HAConnection.this.haService.getDefaultMessageStore().getCommitLog().getMaxOffset(); masterOffset = masterOffset
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; }
final long maxOffsetPy = this.commitLog.getMaxOffset();
@Override public long slaveFallBehindMuch() { return this.commitLog.getMaxOffset() - this.haService.getPush2SlaveMaxOffset().get(); }