com.alibaba.rocketmq.store.ConsumeQueue Java Examples
The following examples show how to use
com.alibaba.rocketmq.store.ConsumeQueue.
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 |
private boolean loadConsumeQueue() { File dirLogic = new File(StorePathConfigHelper.getStorePathConsumeQueue(lStorePath)); File[] fileTopicList = dirLogic.listFiles(); if (fileTopicList != null) { for (File fileTopic : fileTopicList) { String topic = fileTopic.getName(); File[] fileQueueIdList = fileTopic.listFiles(); if (fileQueueIdList != null) { for (File fileQueueId : fileQueueIdList) { int queueId = Integer.parseInt(fileQueueId.getName()); ConsumeQueue logic = new ConsumeQueue(// topic,// queueId,// StorePathConfigHelper.getStorePathConsumeQueue(lStorePath),// lSize,// null); this.putConsumeQueue(topic, queueId, logic); if (!logic.load()) { return false; } } } } } System.out.println("load logics queue all over, OK"); return true; }
Example #2
Source File: Store.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
public ConsumeQueue findConsumeQueue(String topic, int queueId) { ConcurrentHashMap<Integer, ConsumeQueue> map = consumeQueueTable.get(topic); if (null == map) { ConcurrentHashMap<Integer, ConsumeQueue> newMap = new ConcurrentHashMap<Integer, ConsumeQueue>(128); ConcurrentHashMap<Integer, ConsumeQueue> oldMap = consumeQueueTable.putIfAbsent(topic, newMap); if (oldMap != null) { map = oldMap; } else { map = newMap; } } ConsumeQueue logic = map.get(queueId); if (null == logic) { ConsumeQueue newLogic = new ConsumeQueue(// topic, // queueId, // StorePathConfigHelper.getStorePathConsumeQueue(lStorePath), // lSize, // null); ConsumeQueue oldLogic = map.putIfAbsent(queueId, newLogic); if (oldLogic != null) { logic = oldLogic; } else { logic = newLogic; } } return logic; }
Example #3
Source File: Store.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
private void putConsumeQueue(final String topic, final int queueId, final ConsumeQueue consumeQueue) { ConcurrentHashMap<Integer/* queueId */, ConsumeQueue> map = this.consumeQueueTable.get(topic); if (null == map) { map = new ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>(); map.put(queueId, consumeQueue); this.consumeQueueTable.put(topic, map); } else { map.put(queueId, consumeQueue); } }
Example #4
Source File: Store.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
private boolean loadConsumeQueue() { File dirLogic = new File(StorePathConfigHelper.getStorePathConsumeQueue(lStorePath)); File[] fileTopicList = dirLogic.listFiles(); if (fileTopicList != null) { // TOPIC 遍历 for (File fileTopic : fileTopicList) { String topic = fileTopic.getName(); // TOPIC 下队列遍历 File[] fileQueueIdList = fileTopic.listFiles(); if (fileQueueIdList != null) { for (File fileQueueId : fileQueueIdList) { int queueId = Integer.parseInt(fileQueueId.getName()); ConsumeQueue logic = new ConsumeQueue(// topic, // queueId, // StorePathConfigHelper.getStorePathConsumeQueue(lStorePath), // lSize, // null); this.putConsumeQueue(topic, queueId, logic); if (!logic.load()) { return false; } } } } } System.out.println("load logics queue all over, OK"); return true; }
Example #5
Source File: Store.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
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 #6
Source File: TransactionStateService.java From rocketmq with Apache License 2.0 | 5 votes |
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 #7
Source File: Store.java From rocketmq with Apache License 2.0 | 5 votes |
public ConsumeQueue findConsumeQueue(String topic, int queueId) { ConcurrentHashMap<Integer, ConsumeQueue> map = consumeQueueTable.get(topic); if (null == map) { ConcurrentHashMap<Integer, ConsumeQueue> newMap = new ConcurrentHashMap<Integer, ConsumeQueue>(128); ConcurrentHashMap<Integer, ConsumeQueue> oldMap = consumeQueueTable.putIfAbsent(topic, newMap); if (oldMap != null) { map = oldMap; } else { map = newMap; } } ConsumeQueue logic = map.get(queueId); if (null == logic) { ConsumeQueue newLogic = new ConsumeQueue(// topic,// queueId,// StorePathConfigHelper.getStorePathConsumeQueue(lStorePath),// lSize,// null); ConsumeQueue oldLogic = map.putIfAbsent(queueId, newLogic); if (oldLogic != null) { logic = oldLogic; } else { logic = newLogic; } } return logic; }
Example #8
Source File: Store.java From rocketmq with Apache License 2.0 | 5 votes |
private void putConsumeQueue(final String topic, final int queueId, final ConsumeQueue consumeQueue) { ConcurrentHashMap<Integer/* queueId */, ConsumeQueue> map = this.consumeQueueTable.get(topic); if (null == map) { map = new ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>(); map.put(queueId, consumeQueue); this.consumeQueueTable.put(topic, map); } else { map.put(queueId, consumeQueue); } }
Example #9
Source File: Store.java From rocketmq with Apache License 2.0 | 5 votes |
private boolean loadConsumeQueue() { File dirLogic = new File(StorePathConfigHelper.getStorePathConsumeQueue(lStorePath)); File[] fileTopicList = dirLogic.listFiles(); if (fileTopicList != null) { for (File fileTopic : fileTopicList) { String topic = fileTopic.getName(); File[] fileQueueIdList = fileTopic.listFiles(); if (fileQueueIdList != null) { for (File fileQueueId : fileQueueIdList) { int queueId = Integer.parseInt(fileQueueId.getName()); ConsumeQueue logic = new ConsumeQueue(// topic,// queueId,// StorePathConfigHelper.getStorePathConsumeQueue(lStorePath),// lSize,// null); this.putConsumeQueue(topic, queueId, logic); if (!logic.load()) { return false; } } } } } System.out.println("load logics queue all over, OK"); return true; }
Example #10
Source File: Store.java From rocketmq with Apache License 2.0 | 5 votes |
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 #11
Source File: Store.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
public ConsumeQueue findConsumeQueue(String topic, int queueId) { ConcurrentHashMap<Integer, ConsumeQueue> map = consumeQueueTable.get(topic); if (null == map) { ConcurrentHashMap<Integer, ConsumeQueue> newMap = new ConcurrentHashMap<Integer, ConsumeQueue>(128); ConcurrentHashMap<Integer, ConsumeQueue> oldMap = consumeQueueTable.putIfAbsent(topic, newMap); if (oldMap != null) { map = oldMap; } else { map = newMap; } } ConsumeQueue logic = map.get(queueId); if (null == logic) { ConsumeQueue newLogic = new ConsumeQueue(// topic,// queueId,// StorePathConfigHelper.getStorePathConsumeQueue(lStorePath),// lSize,// null); ConsumeQueue oldLogic = map.putIfAbsent(queueId, newLogic); if (oldLogic != null) { logic = oldLogic; } else { logic = newLogic; } } return logic; }
Example #12
Source File: Store.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
private void putConsumeQueue(final String topic, final int queueId, final ConsumeQueue consumeQueue) { ConcurrentHashMap<Integer/* queueId */, ConsumeQueue> map = this.consumeQueueTable.get(topic); if (null == map) { map = new ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>(); map.put(queueId, consumeQueue); this.consumeQueueTable.put(topic, map); } else { map.put(queueId, consumeQueue); } }
Example #13
Source File: Store.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
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 #14
Source File: TransactionStateService.java From rocketmq with Apache License 2.0 | 4 votes |
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 #15
Source File: TransactionStateService.java From rocketmq with Apache License 2.0 | 4 votes |
public ConsumeQueue getTranRedoLog() { return tranRedoLog; }
Example #16
Source File: MessageStoreConfig.java From rocketmq with Apache License 2.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQStoreUnitSize * 1.0)); return (int) (factor * ConsumeQueue.CQStoreUnitSize); }
Example #17
Source File: MessageStoreConfig.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQStoreUnitSize * 1.0)); return factor * ConsumeQueue.CQStoreUnitSize; }
Example #18
Source File: MessageStoreConfig.java From RocketMQ-Master-analyze with Apache License 2.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { // 此处需要向上取整 int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQStoreUnitSize * 1.0)); return (int) (factor * ConsumeQueue.CQStoreUnitSize); }