Java Code Examples for org.apache.rocketmq.store.config.MessageStoreConfig#setBrokerRole()
The following examples show how to use
org.apache.rocketmq.store.config.MessageStoreConfig#setBrokerRole() .
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: HATest.java From rocketmq with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { StoreHost = new InetSocketAddress(InetAddress.getLocalHost(), 8123); BornHost = new InetSocketAddress(InetAddress.getByName("127.0.0.1"), 0); masterMessageStoreConfig = new MessageStoreConfig(); masterMessageStoreConfig.setBrokerRole(BrokerRole.SYNC_MASTER); masterMessageStoreConfig.setStorePathRootDir(storePathRootDir+File.separator+"master"); masterMessageStoreConfig.setStorePathCommitLog(storePathRootDir+File.separator+"master"+ File.separator+"commitlog"); buildMessageStoreConfig(masterMessageStoreConfig); slaveStoreConfig = new MessageStoreConfig(); slaveStoreConfig.setBrokerRole(BrokerRole.SLAVE); slaveStoreConfig.setStorePathRootDir(storePathRootDir+File.separator+"slave"); slaveStoreConfig.setStorePathCommitLog(storePathRootDir+File.separator+"slave"+ File.separator+"commitlog"); slaveStoreConfig.setHaListenPort(10943); buildMessageStoreConfig(slaveStoreConfig); messageStore = buildMessageStore(masterMessageStoreConfig,0L); slaveMessageStore = buildMessageStore(slaveStoreConfig,1L); boolean load = messageStore.load(); boolean slaveLoad = slaveMessageStore.load(); slaveMessageStore.updateHaMasterAddress("127.0.0.1:10912"); assertTrue(load); assertTrue(slaveLoad); messageStore.start(); slaveMessageStore.start(); Thread.sleep(6000L);//because the haClient will wait 5s after the first connectMaster failed,sleep 6s }
Example 2
Source File: BrokerControllerSlaveTest.java From rocketmq with Apache License 2.0 | 5 votes |
/** * broker 启动 */ @Test public void testBrokerRestart() throws Exception { System.setProperty("user.home", System.getProperty("user.home") + File.separator + "broker" + File.separator + "slave"); // 设置版本号 System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION)); // final NettyServerConfig nettyServerConfig = new NettyServerConfig(); nettyServerConfig.setListenPort(20911); // final BrokerConfig brokerConfig = new BrokerConfig(); brokerConfig.setBrokerName("broker-a"); brokerConfig.setBrokerId(1L); // 1 brokerConfig.setNamesrvAddr("127.0.0.1:9876"); // final MessageStoreConfig messageStoreConfig = new MessageStoreConfig(); messageStoreConfig.setDeleteWhen("04"); messageStoreConfig.setFileReservedTime(48); messageStoreConfig.setFlushDiskType(FlushDiskType.ASYNC_FLUSH); messageStoreConfig.setBrokerRole(BrokerRole.SLAVE); messageStoreConfig.setDuplicationEnable(false); messageStoreConfig.setHaListenPort(nettyServerConfig.getListenPort() + 1); // BrokerPathConfigHelper.setBrokerConfigPath("/Users/yunai/百度云同步盘/开发/Javascript/Story/incubator-rocketmq/conf/broker.conf"); // broker 启动 BrokerController brokerController = new BrokerController(// brokerConfig, // nettyServerConfig, // new NettyClientConfig(), // messageStoreConfig); brokerController.initialize(); brokerController.start(); // brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod() Thread.sleep(DateUtils.MILLIS_PER_DAY); }
Example 3
Source File: BrokerControllerMasterTest2.java From rocketmq with Apache License 2.0 | 4 votes |
/** * broker 启动 */ @Test public void testBrokerRestart() throws Exception { System.setProperty("user.home", System.getProperty("user.home") + File.separator + "broker" + File.separator + "master-b"); // 设置版本号 System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION)); // final NettyServerConfig nettyServerConfig = new NettyServerConfig(); nettyServerConfig.setListenPort(10911 + 100); // final BrokerConfig brokerConfig = new BrokerConfig(); brokerConfig.setBrokerName("broker-b"); brokerConfig.setBrokerId(MixAll.MASTER_ID); brokerConfig.setNamesrvAddr("127.0.0.1:9876"); // final MessageStoreConfig messageStoreConfig = new MessageStoreConfig(); messageStoreConfig.setDeleteWhen("04"); messageStoreConfig.setFileReservedTime(48); messageStoreConfig.setFlushDiskType(FlushDiskType.ASYNC_FLUSH); if (true) { messageStoreConfig.setBrokerRole(BrokerRole.ASYNC_MASTER); } else { messageStoreConfig.setBrokerRole(BrokerRole.SYNC_MASTER); } messageStoreConfig.setDuplicationEnable(false); messageStoreConfig.setHaListenPort(nettyServerConfig.getListenPort() + 1); // BrokerPathConfigHelper.setBrokerConfigPath("/Users/yunai/百度云同步盘/开发/Javascript/Story/incubator-rocketmq/conf/broker.conf"); // broker 启动 BrokerController brokerController = new BrokerController(// brokerConfig, // nettyServerConfig, // new NettyClientConfig(), // messageStoreConfig); brokerController.initialize(); brokerController.start(); // brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod() Thread.sleep(DateUtils.MILLIS_PER_DAY); }
Example 4
Source File: BrokerControllerMasterTest.java From rocketmq with Apache License 2.0 | 4 votes |
/** * broker 启动 */ @Test public void testBrokerRestart() throws Exception { System.setProperty("user.home", System.getProperty("user.home") + File.separator + "broker" + File.separator + "master"); // 设置版本号 System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION)); // final NettyServerConfig nettyServerConfig = new NettyServerConfig(); nettyServerConfig.setListenPort(10911); // final BrokerConfig brokerConfig = new BrokerConfig(); brokerConfig.setBrokerName("broker-a"); brokerConfig.setBrokerId(MixAll.MASTER_ID); brokerConfig.setNamesrvAddr("127.0.0.1:9876"); // final MessageStoreConfig messageStoreConfig = new MessageStoreConfig(); messageStoreConfig.setDeleteWhen("04"); messageStoreConfig.setFileReservedTime(48); messageStoreConfig.setFlushDiskType(FlushDiskType.ASYNC_FLUSH); if (true) { messageStoreConfig.setBrokerRole(BrokerRole.ASYNC_MASTER); } else { messageStoreConfig.setBrokerRole(BrokerRole.SYNC_MASTER); } messageStoreConfig.setDuplicationEnable(false); // BrokerPathConfigHelper.setBrokerConfigPath("/Users/yunai/百度云同步盘/开发/Javascript/Story/incubator-rocketmq/conf/broker.conf"); // broker 启动 BrokerController brokerController = new BrokerController(// brokerConfig, // nettyServerConfig, // new NettyClientConfig(), // messageStoreConfig); brokerController.initialize(); brokerController.start(); // brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod() Thread.sleep(DateUtils.MILLIS_PER_DAY); }