org.apache.rocketmq.store.ConsumeQueue Java Examples
The following examples show how to use
org.apache.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: AdminBrokerProcessor.java From DDMQ with Apache License 2.0 | 6 votes |
private RemotingCommand getAllMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) { final RemotingCommand response = RemotingCommand.createResponseCommand(null); DefaultMessageStore messageStore = (DefaultMessageStore) this.brokerController.getMessageStore(); ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable = new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(); ConcurrentMap<String, ConcurrentMap<Integer, ConsumeQueue>> consumeQueueTable = messageStore.getConsumeQueueTable(); for (Map.Entry<String, ConcurrentMap<Integer, ConsumeQueue>> entry : consumeQueueTable.entrySet()) { String topic = entry.getKey(); for (Map.Entry<Integer, ConsumeQueue> entry1 : entry.getValue().entrySet()) { Integer qid = entry1.getKey(); long maxOffset = entry1.getValue().getMaxOffsetInQueue(); if (!offsetTable.containsKey(topic)) { offsetTable.put(topic, new ConcurrentHashMap<Integer, Long>()); } offsetTable.get(topic).put(qid, maxOffset); } } AllMaxOffset allMaxOffset = new AllMaxOffset(); allMaxOffset.setOffsetTable(offsetTable); response.setBody(allMaxOffset.encode()); response.setCode(ResponseCode.SUCCESS); response.setRemark(null); return response; }
Example #2
Source File: AdminBrokerProcessor.java From DDMQ with Apache License 2.0 | 6 votes |
private RemotingCommand getAllMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) { final RemotingCommand response = RemotingCommand.createResponseCommand(null); DefaultMessageStore messageStore = (DefaultMessageStore) this.brokerController.getMessageStore(); ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable = new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(); ConcurrentMap<String, ConcurrentMap<Integer, ConsumeQueue>> consumeQueueTable = messageStore.getConsumeQueueTable(); for (Map.Entry<String, ConcurrentMap<Integer, ConsumeQueue>> entry : consumeQueueTable.entrySet()) { String topic = entry.getKey(); for (Map.Entry<Integer, ConsumeQueue> entry1 : entry.getValue().entrySet()) { Integer qid = entry1.getKey(); long maxOffset = entry1.getValue().getMaxOffsetInQueue(); if (!offsetTable.containsKey(topic)) { offsetTable.put(topic, new ConcurrentHashMap<Integer, Long>()); } offsetTable.get(topic).put(qid, maxOffset); } } AllMaxOffset allMaxOffset = new AllMaxOffset(); allMaxOffset.setOffsetTable(offsetTable); response.setBody(allMaxOffset.encode()); response.setCode(ResponseCode.SUCCESS); response.setRemark(null); return response; }
Example #3
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 MappedFileQueue(cStorePath, cSize, null); consumeQueueTable = new ConcurrentHashMap<String/* topic */, ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>>(); }
Example #4
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.printf("load logics queue all over, OK"); return true; }
Example #5
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 #6
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 #7
Source File: Store.java From rocketmq_trans_message 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_trans_message 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_trans_message 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.printf("load logics queue all over, OK"); return true; }
Example #10
Source File: Store.java From rocketmq_trans_message 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 MappedFileQueue(cStorePath, cSize, null); consumeQueueTable = new ConcurrentHashMap<String/* topic */, ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>>(); }
Example #11
Source File: MessageStoreConfig.java From DDMQ with Apache License 2.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0)); return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE); }
Example #12
Source File: MessageStoreConfig.java From rocketmq with Apache License 2.0 | 4 votes |
public int getMappedFileSizeConsumeQueue() { int factor = (int) Math.ceil(this.mappedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0)); return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE); }
Example #13
Source File: AbstractPluginMessageStore.java From rocketmq with Apache License 2.0 | 4 votes |
@Override public ConsumeQueue getConsumeQueue(String topic, int queueId) { return next.getConsumeQueue(topic, queueId); }
Example #14
Source File: MessageStoreConfig.java From rocketmq_trans_message with Apache License 2.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0)); return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE); }
Example #15
Source File: TransactionStateDBService.java From rocketmq_trans_message with Apache License 2.0 | 4 votes |
@Override public ConsumeQueue getTranRedoLog() { return null; }
Example #16
Source File: MessageStoreConfig.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { // 此处需要向上取整 int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0)); return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE); }
Example #17
Source File: AbstractPluginMessageStore.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 4 votes |
@Override public ConsumeQueue getConsumeQueue(String topic, int queueId) { return next.getConsumeQueue(topic, queueId); }
Example #18
Source File: MessageStoreConfig.java From DDMQ with Apache License 2.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0)); return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE); }
Example #19
Source File: AbstractPluginMessageStore.java From DDMQ with Apache License 2.0 | 4 votes |
@Override public ConsumeQueue getConsumeQueue(String topic, int queueId) { return next.getConsumeQueue(topic, queueId); }
Example #20
Source File: AbstractPluginMessageStore.java From DDMQ with Apache License 2.0 | 4 votes |
@Override public ConsumeQueue getConsumeQueue(String topic, int queueId) { return next.getConsumeQueue(topic, queueId); }
Example #21
Source File: MessageStoreConfig.java From rocketmq with Apache License 2.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0)); return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE); }
Example #22
Source File: MessageStoreConfig.java From rocketmq-read with Apache License 2.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0)); return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE); }
Example #23
Source File: AbstractPluginMessageStore.java From rocketmq-read with Apache License 2.0 | 4 votes |
@Override public ConsumeQueue getConsumeQueue(String topic, int queueId) { return next.getConsumeQueue(topic, queueId); }
Example #24
Source File: MessageStoreConfig.java From rocketmq-4.3.0 with Apache License 2.0 | 4 votes |
public int getMapedFileSizeConsumeQueue() { int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0)); return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE); }
Example #25
Source File: AbstractPluginMessageStore.java From rocketmq-4.3.0 with Apache License 2.0 | 4 votes |
@Override public ConsumeQueue getConsumeQueue(String topic, int queueId) { return next.getConsumeQueue(topic, queueId); }
Example #26
Source File: TransactionStateService.java From rocketmq_trans_message with Apache License 2.0 | votes |
ConsumeQueue getTranRedoLog();