org.apache.rocketmq.store.config.StorePathConfigHelper Java Examples
The following examples show how to use
org.apache.rocketmq.store.config.StorePathConfigHelper.
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: MappedFileQueue.java From DDMQ with Apache License 2.0 | 6 votes |
public void backupFiles(long offset, String backupPath) { for (MappedFile file : this.mappedFiles) { long fileTailOffset = file.getFileFromOffset() + this.mappedFileSize; if (fileTailOffset > offset) { file.flush(0); try { Path source = Paths.get(file.getFileName()); Path target = Paths.get(StorePathConfigHelper.getBackupStoreFilePath(backupPath, new File(file.getFileName()).getName())); Files.copy(source, target); log.info("backup file:{} to {}", file.getFileName(), target); } catch (Exception ex) { log.error("backup file failed", ex); } } } }
Example #2
Source File: HAService.java From DDMQ with Apache License 2.0 | 6 votes |
public void saveInSyncOffset() { if (this.defaultMessageStore.getMessageStoreConfig().getBrokerRole() == BrokerRole.SLAVE) { return; } long minInSyncOffset = getMinOffsetInSync(); if (minInSyncOffset == -1) { return; } String fileName = StorePathConfigHelper.getOffsetInSyncStorePath(this.defaultMessageStore.getMessageStoreConfig().getStorePathRootDir()); try { MixAll.string2File(String.valueOf(minInSyncOffset), fileName); } catch (IOException e) { log.error("save phy offset slave reported [{}] exception", fileName, e); } log.info("save slave min offset in sync:{}", minInSyncOffset); }
Example #3
Source File: HAService.java From DDMQ with Apache License 2.0 | 6 votes |
public void initInSyncOffset(long offset) { if (this.defaultMessageStore.getMessageStoreConfig().getBrokerRole() == BrokerRole.SLAVE) { return; } String fileName = StorePathConfigHelper.getOffsetInSyncStorePath(this.defaultMessageStore.getMessageStoreConfig().getStorePathRootDir()); File file = new File(fileName); if (file.exists()) { log.info("as master before, no need to sync offset"); return; } try { MixAll.string2File(String.valueOf(offset), fileName); } catch (IOException e) { log.error("save phy offset slave reported [{}] exception", fileName, e); } }
Example #4
Source File: DefaultMessageStoreTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testTruncate() throws Exception { String topic = "truncateTopic"; for (int i = 0; i < 1000; i++) { MessageExtBrokerInner messageExtBrokerInner = buildMessage(); messageExtBrokerInner.setTopic(topic); messageExtBrokerInner.setQueueId(0); messageStore.putMessage(messageExtBrokerInner); } if (messageStore instanceof DefaultMessageStore) { DefaultMessageStore defaultMessageStore = (DefaultMessageStore) messageStore; long maxPhyOffset = defaultMessageStore.getMaxPhyOffset(); String fileName = StorePathConfigHelper.getOffsetInSyncStorePath(defaultMessageStore.getMessageStoreConfig().getStorePathRootDir()); MixAll.string2File(String.valueOf(defaultMessageStore.getMaxPhyOffset() - 100), fileName); defaultMessageStore.getMessageStoreConfig().setBrokerRole(BrokerRole.SLAVE); defaultMessageStore.truncateNotSync(); assertThat(defaultMessageStore.getMaxPhyOffset()).isEqualTo(maxPhyOffset - 100); } }
Example #5
Source File: HAService.java From DDMQ with Apache License 2.0 | 6 votes |
public void saveInSyncOffset() { if (this.defaultMessageStore.getMessageStoreConfig().getBrokerRole() == BrokerRole.SLAVE) { return; } long minInSyncOffset = getMinOffsetInSync(); if (minInSyncOffset == -1) { return; } String fileName = StorePathConfigHelper.getOffsetInSyncStorePath(this.defaultMessageStore.getMessageStoreConfig().getStorePathRootDir()); try { MixAll.string2File(String.valueOf(minInSyncOffset), fileName); } catch (IOException e) { log.error("save phy offset slave reported [{}] exception", fileName, e); } log.info("save slave min offset in sync:{}", minInSyncOffset); }
Example #6
Source File: CommitLog.java From DDMQ with Apache License 2.0 | 6 votes |
public void truncate(long phyOffset) { String backupDirPath = StorePathConfigHelper.getBackupStoreSubDirPath(defaultMessageStore.getMessageStoreConfig().getStorePathRootDir(), String.valueOf(defaultMessageStore.getSystemClock().now())); File dir = new File(backupDirPath); if (!dir.exists()) { dir.mkdirs(); } this.mappedFileQueue.backupFiles(phyOffset, backupDirPath); this.mappedFileQueue.setFlushedWhere(phyOffset); this.mappedFileQueue.setCommittedWhere(phyOffset); this.mappedFileQueue.truncateDirtyFiles(phyOffset); // Clear ConsumeQueue redundant data this.defaultMessageStore.truncateDirtyLogicFiles(phyOffset); }
Example #7
Source File: CommitLog.java From DDMQ with Apache License 2.0 | 6 votes |
public void truncate(long phyOffset) { String backupDirPath = StorePathConfigHelper.getBackupStoreSubDirPath(defaultMessageStore.getMessageStoreConfig().getStorePathRootDir(), String.valueOf(defaultMessageStore.getSystemClock().now())); File dir = new File(backupDirPath); if (!dir.exists()) { dir.mkdirs(); } this.mappedFileQueue.backupFiles(phyOffset, backupDirPath); this.mappedFileQueue.setFlushedWhere(phyOffset); this.mappedFileQueue.setCommittedWhere(phyOffset); this.mappedFileQueue.truncateDirtyFiles(phyOffset); // Clear ConsumeQueue redundant data this.defaultMessageStore.truncateDirtyLogicFiles(phyOffset); }
Example #8
Source File: DefaultMessageStore.java From DDMQ with Apache License 2.0 | 6 votes |
private long getInSyncOffsetSaved() { long offset = -1; String fileName = StorePathConfigHelper.getOffsetInSyncStorePath(this.messageStoreConfig.getStorePathRootDir()); try { File file = new File(fileName); if (file.exists()) { String offsetStr = MixAll.file2String(fileName); if (offsetStr != null) { offset = Long.valueOf(offsetStr); } file.delete(); } } catch (Exception ex) { log.error("get offset in sync failed", ex); } return offset; }
Example #9
Source File: DefaultMessageStore.java From DDMQ with Apache License 2.0 | 6 votes |
private long getInSyncOffsetSaved() { long offset = -1; String fileName = StorePathConfigHelper.getOffsetInSyncStorePath(this.messageStoreConfig.getStorePathRootDir()); try { File file = new File(fileName); if (file.exists()) { String offsetStr = MixAll.file2String(fileName); if (offsetStr != null) { offset = Long.valueOf(offsetStr); } file.delete(); } } catch (Exception ex) { log.error("get offset in sync failed", ex); } return offset; }
Example #10
Source File: DefaultMessageStore.java From DDMQ with Apache License 2.0 | 5 votes |
/** * @throws IOException */ private void createTempFile() throws IOException { String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir()); File file = new File(fileName); MappedFile.ensureDirOK(file.getParent()); boolean result = file.createNewFile(); log.info(fileName + (result ? " create OK" : " already exists")); }
Example #11
Source File: DefaultMessageStore.java From rocketmq with Apache License 2.0 | 5 votes |
/** * @throws IOException */ public boolean load() { boolean result = true; try { boolean lastExitOK = !this.isTempFileExist(); log.info("last shutdown {}", lastExitOK ? "normally" : "abnormally"); if (null != scheduleMessageService) { //解析延迟级别,加载delayOffset.json result = result && this.scheduleMessageService.load(); } // load Commit Log result = result && this.commitLog.load(); // load Consume Queue result = result && this.loadConsumeQueue(); // TODO 待读 if (result) { this.storeCheckpoint = new StoreCheckpoint(StorePathConfigHelper.getStoreCheckpoint(this.messageStoreConfig.getStorePathRootDir())); this.indexService.load(lastExitOK); this.recover(lastExitOK); log.info("load over, and the max phy offset = {}", this.getMaxPhyOffset()); } } catch (Exception e) { log.error("load exception", e); result = false; } if (!result) { this.allocateMappedFileService.shutdown(); } return result; }
Example #12
Source File: DefaultMessageStore.java From rocketmq with Apache License 2.0 | 5 votes |
/** */ public void shutdown() { if (!this.shutdown) { this.shutdown = true; this.scheduledExecutorService.shutdown(); try { Thread.sleep(1000 * 3); } catch (InterruptedException e) { log.error("shutdown Exception, ", e); } if (this.scheduleMessageService != null) { this.scheduleMessageService.shutdown(); } this.haService.shutdown(); this.storeStatsService.shutdown(); this.indexService.shutdown(); this.commitLog.shutdown(); this.reputMessageService.shutdown(); this.flushConsumeQueueService.shutdown(); this.allocateMappedFileService.shutdown(); this.storeCheckpoint.flush(); this.storeCheckpoint.shutdown(); if (this.runningFlags.isWriteable()) { this.deleteFile(StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir())); } else { log.warn("the store may be wrong, so shutdown abnormally, and keep abort file."); } } this.transientStorePool.destroy(); }
Example #13
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 #14
Source File: DefaultMessageStore.java From rocketmq with Apache License 2.0 | 5 votes |
private boolean loadConsumeQueue() { File dirLogic = new File(StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir())); 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; try { queueId = Integer.parseInt(fileQueueId.getName()); } catch (NumberFormatException e) { continue; } ConsumeQueue logic = new ConsumeQueue( topic, queueId, StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()), this.getMessageStoreConfig().getMappedFileSizeConsumeQueue(), this); this.putConsumeQueue(topic, queueId, logic); if (!logic.load()) { return false; } } } } } log.info("load logics queue all over, OK"); return true; }
Example #15
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 #16
Source File: DefaultMessageStore.java From DDMQ with Apache License 2.0 | 5 votes |
public void destroy() { this.destroyLogics(); this.commitLog.destroy(); this.indexService.destroy(); this.deleteFile(StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir())); this.deleteFile(StorePathConfigHelper.getStoreCheckpoint(this.messageStoreConfig.getStorePathRootDir())); }
Example #17
Source File: DefaultMessageStore.java From DDMQ with Apache License 2.0 | 5 votes |
@Override public HashMap<String, String> getRuntimeInfo() { HashMap<String, String> result = this.storeStatsService.getRuntimeInfo(); { String storePathPhysic = DefaultMessageStore.this.getMessageStoreConfig().getStorePathCommitLog(); double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic); result.put(RunningStats.commitLogDiskRatio.name(), String.valueOf(physicRatio)); } { String storePathLogics = StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()); double logicsRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogics); result.put(RunningStats.consumeQueueDiskRatio.name(), String.valueOf(logicsRatio)); } { if (this.scheduleMessageService != null) { this.scheduleMessageService.buildRunningStats(result); } } result.put(RunningStats.commitLogMinOffset.name(), String.valueOf(DefaultMessageStore.this.getMinPhyOffset())); result.put(RunningStats.commitLogMaxOffset.name(), String.valueOf(DefaultMessageStore.this.getMaxPhyOffset())); return result; }
Example #18
Source File: DefaultMessageStore.java From DDMQ with Apache License 2.0 | 5 votes |
public ConsumeQueue findConsumeQueue(String topic, int queueId) { ConcurrentMap<Integer, ConsumeQueue> map = consumeQueueTable.get(topic); if (null == map) { ConcurrentMap<Integer, ConsumeQueue> newMap = new ConcurrentHashMap<Integer, ConsumeQueue>(128); ConcurrentMap<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(this.messageStoreConfig.getStorePathRootDir()), this.getMessageStoreConfig().getMapedFileSizeConsumeQueue(), this); ConsumeQueue oldLogic = map.putIfAbsent(queueId, newLogic); if (oldLogic != null) { logic = oldLogic; } else { logic = newLogic; } } return logic; }
Example #19
Source File: DefaultMessageStore.java From DDMQ with Apache License 2.0 | 5 votes |
public DefaultMessageStore(final MessageStoreConfig messageStoreConfig, final BrokerStatsManager brokerStatsManager, final MessageArrivingListener messageArrivingListener, final BrokerConfig brokerConfig) throws IOException { this.messageArrivingListener = messageArrivingListener; this.brokerConfig = brokerConfig; this.messageStoreConfig = messageStoreConfig; this.brokerStatsManager = brokerStatsManager; this.allocateMappedFileService = new AllocateMappedFileService(this); this.commitLog = new CommitLog(this); this.consumeQueueTable = new ConcurrentHashMap<>(32); this.flushConsumeQueueService = new FlushConsumeQueueService(); this.cleanCommitLogService = new CleanCommitLogService(); this.cleanConsumeQueueService = new CleanConsumeQueueService(); this.storeStatsService = new StoreStatsService(); this.indexService = new IndexService(this); this.haService = new HAService(this); this.reputMessageService = new ReputMessageService(); this.scheduleMessageService = new ScheduleMessageService(this); this.transientStorePool = new TransientStorePool(messageStoreConfig); if (messageStoreConfig.isTransientStorePoolEnable()) { this.transientStorePool.init(); } this.allocateMappedFileService.start(); this.indexService.start(); this.dispatcherList = new LinkedList<>(); this.dispatcherList.addLast(new CommitLogDispatcherBuildConsumeQueue()); this.dispatcherList.addLast(new CommitLogDispatcherBuildIndex()); File file = new File(StorePathConfigHelper.getLockFile(messageStoreConfig.getStorePathRootDir())); MappedFile.ensureDirOK(file.getParent()); lockFile = new RandomAccessFile(file, "rw"); }
Example #20
Source File: DefaultMessageStore.java From DDMQ with Apache License 2.0 | 5 votes |
private boolean loadConsumeQueue() { File dirLogic = new File(StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir())); 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; try { queueId = Integer.parseInt(fileQueueId.getName()); } catch (NumberFormatException e) { continue; } ConsumeQueue logic = new ConsumeQueue( topic, queueId, StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()), this.getMessageStoreConfig().getMapedFileSizeConsumeQueue(), this); this.putConsumeQueue(topic, queueId, logic); if (!logic.load()) { return false; } } } } } log.info("load logics queue all over, OK"); return true; }
Example #21
Source File: MixCommitlogTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testFallBehindCQ() throws Exception { String base = createBaseDir(); String topic = UUID.randomUUID().toString(); String peers = String.format("n0-localhost:%d", nextPort()); String group = UUID.randomUUID().toString(); { DefaultMessageStore originalStore = createMessageStore(base, false); doPutMessages(originalStore, topic, 0, 1000, 0); Assert.assertEquals(11, originalStore.getMaxPhyOffset()/originalStore.getMessageStoreConfig().getMappedFileSizeCommitLog()); Thread.sleep(500); Assert.assertEquals(0, originalStore.getMinOffsetInQueue(topic, 0)); Assert.assertEquals(1000, originalStore.getMaxOffsetInQueue(topic, 0)); Assert.assertEquals(0, originalStore.dispatchBehindBytes()); doGetMessages(originalStore, topic, 0, 1000, 0); originalStore.shutdown(); } //delete the cq files { StoreTestBase.deleteFile(StorePathConfigHelper.getStorePathConsumeQueue(base)); } { DefaultMessageStore dledgerStore = createDledgerMessageStore(base, group, "n0", peers, null, true, 0); Thread.sleep(2000); Assert.assertEquals(0, dledgerStore.getMinOffsetInQueue(topic, 0)); Assert.assertEquals(1000, dledgerStore.getMaxOffsetInQueue(topic, 0)); Assert.assertEquals(0, dledgerStore.dispatchBehindBytes()); doGetMessages(dledgerStore, topic, 0, 1000, 0); doPutMessages(dledgerStore, topic, 0, 1000, 1000); Thread.sleep(500); Assert.assertEquals(0, dledgerStore.getMinOffsetInQueue(topic, 0)); Assert.assertEquals(2000, dledgerStore.getMaxOffsetInQueue(topic, 0)); Assert.assertEquals(0, dledgerStore.dispatchBehindBytes()); doGetMessages(dledgerStore, topic, 0, 2000, 0); dledgerStore.shutdown(); } }
Example #22
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 #23
Source File: DefaultMessageStore.java From rocketmq with Apache License 2.0 | 5 votes |
public ConsumeQueue findConsumeQueue(String topic, int queueId) { ConcurrentMap<Integer, ConsumeQueue> map = consumeQueueTable.get(topic); if (null == map) { ConcurrentMap<Integer, ConsumeQueue> newMap = new ConcurrentHashMap<Integer, ConsumeQueue>(128); ConcurrentMap<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(this.messageStoreConfig.getStorePathRootDir()), this.getMessageStoreConfig().getMappedFileSizeConsumeQueue(), this); ConsumeQueue oldLogic = map.putIfAbsent(queueId, newLogic); if (oldLogic != null) { logic = oldLogic; } else { logic = newLogic; } } return logic; }
Example #24
Source File: SendMessageProcessor.java From rocketmq with Apache License 2.0 | 5 votes |
private String diskUtil() { String storePathPhysic = this.brokerController.getMessageStoreConfig().getStorePathCommitLog(); double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic); String storePathLogis = StorePathConfigHelper.getStorePathConsumeQueue(this.brokerController.getMessageStoreConfig().getStorePathRootDir()); double logisRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogis); String storePathIndex = StorePathConfigHelper.getStorePathIndex(this.brokerController.getMessageStoreConfig().getStorePathRootDir()); double indexRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathIndex); return String.format("CL: %5.2f CQ: %5.2f INDEX: %5.2f", physicRatio, logisRatio, indexRatio); }
Example #25
Source File: DefaultMessageStoreShutDownTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testDispatchBehindWhenShutdown() { messageStore.shutdown(); assertTrue(!messageStore.shutDownNormal); File file = new File(StorePathConfigHelper.getAbortFile(messageStore.getMessageStoreConfig().getStorePathRootDir())); assertTrue(file.exists()); }
Example #26
Source File: DefaultMessageStore.java From rocketmq-read with Apache License 2.0 | 5 votes |
private boolean loadConsumeQueue() { File dirLogic = new File(StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir())); 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; try { queueId = Integer.parseInt(fileQueueId.getName()); } catch (NumberFormatException e) { continue; } ConsumeQueue logic = new ConsumeQueue( topic, queueId, StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()), this.getMessageStoreConfig().getMapedFileSizeConsumeQueue(), this); this.putConsumeQueue(topic, queueId, logic); if (!logic.load()) { return false; } } } } } log.info("load logics queue all over, OK"); return true; }
Example #27
Source File: SendMessageProcessor.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
private String diskUtil() { String storePathPhysic = this.brokerController.getMessageStoreConfig().getStorePathCommitLog(); double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic); String storePathLogis = StorePathConfigHelper.getStorePathConsumeQueue(this.brokerController.getMessageStoreConfig().getStorePathRootDir()); double logisRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogis); String storePathIndex = StorePathConfigHelper.getStorePathIndex(this.brokerController.getMessageStoreConfig().getStorePathRootDir()); double indexRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathIndex); return String.format("CL: %5.2f CQ: %5.2f INDEX: %5.2f", physicRatio, logisRatio, indexRatio); }
Example #28
Source File: DefaultMessageStore.java From rocketmq-read with Apache License 2.0 | 5 votes |
/** * 找到消费队列 * @param topic topic * @param queueId 队列id * @return ; */ public ConsumeQueue findConsumeQueue(String topic, int queueId) { ConcurrentMap<Integer, ConsumeQueue> map = consumeQueueTable.get(topic); if (null == map) { ConcurrentMap<Integer, ConsumeQueue> newMap = new ConcurrentHashMap<Integer, ConsumeQueue>(128); ConcurrentMap<Integer, ConsumeQueue> oldMap = consumeQueueTable.putIfAbsent(topic, newMap); if (oldMap != null) { map = oldMap; } else { map = newMap; } } //根据队列id获取逻辑队列 ConsumeQueue logic = map.get(queueId); if (null == logic) { //构造逻辑队列 ConsumeQueue newLogic = new ConsumeQueue( topic, queueId, StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()), this.getMessageStoreConfig().getMapedFileSizeConsumeQueue(), this); ConsumeQueue oldLogic = map.putIfAbsent(queueId, newLogic); if (oldLogic != null) { logic = oldLogic; } else { logic = newLogic; } } return logic; }
Example #29
Source File: DefaultMessageStore.java From rocketmq-read with Apache License 2.0 | 5 votes |
/** * 获取运行时信息 * @return ; */ @Override public HashMap<String, String> getRuntimeInfo() { HashMap<String, String> result = this.storeStatsService.getRuntimeInfo(); { String storePathPhysic = DefaultMessageStore.this.getMessageStoreConfig().getStorePathCommitLog(); double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic); result.put(RunningStats.commitLogDiskRatio.name(), String.valueOf(physicRatio)); } { String storePathLogics = StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()); double logicsRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogics); result.put(RunningStats.consumeQueueDiskRatio.name(), String.valueOf(logicsRatio)); } { if (this.scheduleMessageService != null) { this.scheduleMessageService.buildRunningStats(result); } } result.put(RunningStats.commitLogMinOffset.name(), String.valueOf(DefaultMessageStore.this.getMinPhyOffset())); result.put(RunningStats.commitLogMaxOffset.name(), String.valueOf(DefaultMessageStore.this.getMaxPhyOffset())); return result; }
Example #30
Source File: DefaultMessageStore.java From rocketmq-read with Apache License 2.0 | 5 votes |
/** * 销毁持久化文件 */ @Override public void destroy() { this.destroyLogics(); this.commitLog.destroy(); this.indexService.destroy(); this.deleteFile(StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir())); this.deleteFile(StorePathConfigHelper.getStoreCheckpoint(this.messageStoreConfig.getStorePathRootDir())); }