Java Code Examples for com.alibaba.rocketmq.store.ConsumeQueue#CQStoreUnitSize

The following examples show how to use com.alibaba.rocketmq.store.ConsumeQueue#CQStoreUnitSize . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageStoreConfig.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 4 votes vote down vote up
public int getMapedFileSizeConsumeQueue() {
    int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQStoreUnitSize * 1.0));
    return factor * ConsumeQueue.CQStoreUnitSize;
}
 
Example 2
Source File: TransactionStateService.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
private void recreateStateTable() {
    this.tranStateTable =
            new MapedFileQueue(defaultMessageStore.getMessageStoreConfig().getTranStateTableStorePath(),
                defaultMessageStore.getMessageStoreConfig().getTranStateTableMapedFileSize(), null);

    final TreeSet<Long> preparedItemSet = new TreeSet<Long>();

    final long minOffset = this.tranRedoLog.getMinOffsetInQuque();
    long processOffset = minOffset;
    while (true) {
        SelectMapedBufferResult bufferConsumeQueue = this.tranRedoLog.getIndexBuffer(processOffset);
        if (bufferConsumeQueue != null) {
            try {
                long i = 0;
                for (; i < bufferConsumeQueue.getSize(); i += ConsumeQueue.CQStoreUnitSize) {
                    long offsetMsg = bufferConsumeQueue.getByteBuffer().getLong();
                    int sizeMsg = bufferConsumeQueue.getByteBuffer().getInt();
                    long tagsCode = bufferConsumeQueue.getByteBuffer().getLong();

                    // Prepared
                    if (TransactionStateService.PreparedMessageTagsCode == tagsCode) {
                        preparedItemSet.add(offsetMsg);
                    }
                    // Commit/Rollback
                    else {
                        preparedItemSet.remove(tagsCode);
                    }
                }

                processOffset += i;
            }
            finally {
                bufferConsumeQueue.release();
            }
        }
        else {
            break;
        }
    }

    log.info("scan transaction redolog over, End offset: {},  Prepared Transaction Count: {}",
        processOffset, preparedItemSet.size());

    Iterator<Long> it = preparedItemSet.iterator();
    while (it.hasNext()) {
        Long offset = it.next();

        MessageExt msgExt = this.defaultMessageStore.lookMessageByOffset(offset);
        if (msgExt != null) {

            this.appendPreparedTransaction(msgExt.getCommitLogOffset(), msgExt.getStoreSize(),
                (int) (msgExt.getStoreTimestamp() / 1000),
                msgExt.getProperty(MessageConst.PROPERTY_PRODUCER_GROUP).hashCode());
            this.tranStateTableOffset.incrementAndGet();
        }
    }
}
 
Example 3
Source File: MessageStoreConfig.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public int getMapedFileSizeConsumeQueue() {

        int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQStoreUnitSize * 1.0));
        return (int) (factor * ConsumeQueue.CQStoreUnitSize);
    }
 
Example 4
Source File: MessageStoreConfig.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public int getMapedFileSizeConsumeQueue() {
    // 此处需要向上取整
    int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQStoreUnitSize * 1.0));
    return (int) (factor * ConsumeQueue.CQStoreUnitSize);
}