Java Code Examples for org.apache.rocketmq.store.config.MessageStoreConfig#setdLegerPeers()
The following examples show how to use
org.apache.rocketmq.store.config.MessageStoreConfig#setdLegerPeers() .
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: DLedgerProduceAndConsumeIT.java From rocketmq with Apache License 2.0 | 5 votes |
public MessageStoreConfig buildStoreConfig(String brokerName, String peers, String selfId) { MessageStoreConfig storeConfig = new MessageStoreConfig(); String baseDir = IntegrationTestBase.createBaseDir(); storeConfig.setStorePathRootDir(baseDir); storeConfig.setStorePathCommitLog(baseDir + SEP + "commitlog"); storeConfig.setHaListenPort(nextPort()); storeConfig.setMappedFileSizeCommitLog(10 * 1024 * 1024); storeConfig.setEnableDLegerCommitLog(true); storeConfig.setdLegerGroup(brokerName); storeConfig.setdLegerSelfId(selfId); storeConfig.setdLegerPeers(peers); return storeConfig; }
Example 2
Source File: MessageStoreTestBase.java From rocketmq with Apache License 2.0 | 4 votes |
protected DefaultMessageStore createDledgerMessageStore(String base, String group, String selfId, String peers, String leaderId, boolean createAbort, int deleteFileNum) throws Exception { System.setProperty("dledger.disk.ratio.check", "0.95"); System.setProperty("dledger.disk.ratio.clean", "0.95"); baseDirs.add(base); MessageStoreConfig storeConfig = new MessageStoreConfig(); storeConfig.setMappedFileSizeCommitLog(1024 * 100); storeConfig.setMappedFileSizeConsumeQueue(1024); storeConfig.setMaxHashSlotNum(100); storeConfig.setMaxIndexNum(100 * 10); storeConfig.setStorePathRootDir(base); storeConfig.setStorePathCommitLog(base + File.separator + "commitlog"); storeConfig.setFlushDiskType(FlushDiskType.ASYNC_FLUSH); storeConfig.setEnableDLegerCommitLog(true); storeConfig.setdLegerGroup(group); storeConfig.setdLegerPeers(peers); storeConfig.setdLegerSelfId(selfId); DefaultMessageStore defaultMessageStore = new DefaultMessageStore(storeConfig, new BrokerStatsManager("DLedgerCommitlogTest"), (topic, queueId, logicOffset, tagsCode, msgStoreTime, filterBitMap, properties) -> { }, new BrokerConfig()); DLedgerServer dLegerServer = ((DLedgerCommitLog) defaultMessageStore.getCommitLog()).getdLedgerServer(); if (leaderId != null) { dLegerServer.getdLedgerConfig().setEnableLeaderElector(false); if (selfId.equals(leaderId)) { dLegerServer.getMemberState().changeToLeader(-1); } else { dLegerServer.getMemberState().changeToFollower(-1, leaderId); } } if (createAbort) { String fileName = StorePathConfigHelper.getAbortFile(storeConfig.getStorePathRootDir()); makeSureFileExists(fileName); } if (deleteFileNum > 0) { DLedgerConfig config = dLegerServer.getdLedgerConfig(); if (deleteFileNum > 0) { File dir = new File(config.getDataStorePath()); File[] files = dir.listFiles(); if (files != null) { Arrays.sort(files); for (int i = files.length - 1; i >= 0; i--) { File file = files[i]; file.delete(); if (files.length - i >= deleteFileNum) { break; } } } } } Assert.assertTrue(defaultMessageStore.load()); defaultMessageStore.start(); return defaultMessageStore; }