com.alibaba.rocketmq.store.MapedFileQueue Java Examples

The following examples show how to use com.alibaba.rocketmq.store.MapedFileQueue. 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: Store.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public Store(String cStorePath, int cSize, String lStorePath, int lSize) {
    this.cStorePath = cStorePath;
    this.cSize = cSize;
    this.lStorePath = lStorePath;
    this.lSize = lSize;
    mapedFileQueue = new MapedFileQueue(cStorePath, cSize, null);
    consumeQueueTable =
            new ConcurrentHashMap<String/* topic */, ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>>();
}
 
Example #2
Source File: Store.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public Store(String cStorePath, int cSize, String lStorePath, int lSize) {
    this.cStorePath = cStorePath;
    this.cSize = cSize;
    this.lStorePath = lStorePath;
    this.lSize = lSize;
    mapedFileQueue = new MapedFileQueue(cStorePath, cSize, null);
    consumeQueueTable =
            new ConcurrentHashMap<String/* topic */, ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>>();
}
 
Example #3
Source File: TransactionStateService.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public TransactionStateService(final DefaultMessageStore defaultMessageStore) {
    this.defaultMessageStore = defaultMessageStore;
    this.tranStateTable =
            new MapedFileQueue(defaultMessageStore.getMessageStoreConfig().getTranStateTableStorePath(),
                defaultMessageStore.getMessageStoreConfig().getTranStateTableMapedFileSize(), null);

    this.tranRedoLog = new ConsumeQueue(//
        TRANSACTION_REDOLOG_TOPIC,//
        TRANSACTION_REDOLOG_TOPIC_QUEUEID,//
        defaultMessageStore.getMessageStoreConfig().getTranRedoLogStorePath(),//
        defaultMessageStore.getMessageStoreConfig().getTranRedoLogMapedFileSize(),//
        defaultMessageStore);
}
 
Example #4
Source File: Store.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
public Store(String cStorePath, int cSize, String lStorePath, int lSize) {
    this.cStorePath = cStorePath;
    this.cSize = cSize;
    this.lStorePath = lStorePath;
    this.lSize = lSize;
    mapedFileQueue = new MapedFileQueue(cStorePath, cSize, null);
    consumeQueueTable =
            new ConcurrentHashMap<String/* topic */, ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>>();
}
 
Example #5
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();
        }
    }
}