org.apache.rocketmq.store.config.MessageStoreConfig Java Examples

The following examples show how to use org.apache.rocketmq.store.config.MessageStoreConfig. 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: DefaultMessageStoreTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test(expected = OverlappingFileLockException.class)
public void test_repate_restart() throws Exception {
    QUEUE_TOTAL = 1;
    MessageBody = StoreMessage.getBytes();

    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    messageStoreConfig.setMapedFileSizeCommitLog(1024 * 8);
    messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 4);
    messageStoreConfig.setMaxHashSlotNum(100);
    messageStoreConfig.setMaxIndexNum(100 * 10);
    MessageStore master = new DefaultMessageStore(messageStoreConfig, null, new MyMessageArrivingListener(), new BrokerConfig());

    boolean load = master.load();
    assertTrue(load);

    try {
        master.start();
        master.start();
    } finally {
        master.shutdown();
        master.destroy();
    }
}
 
Example #2
Source File: ConsumeQueueTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
protected DefaultMessageStore gen() throws Exception {
    MessageStoreConfig messageStoreConfig = buildStoreConfig(
        commitLogFileSize, cqFileSize, true, cqExtFileSize
    );

    BrokerConfig brokerConfig = new BrokerConfig();

    DefaultMessageStore master = new DefaultMessageStore(
        messageStoreConfig,
        new BrokerStatsManager(brokerConfig.getBrokerClusterName()),
        new MessageArrivingListener() {
            @Override
            public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
                long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
            }
        }
        , brokerConfig);

    assertThat(master.load()).isTrue();

    master.start();

    return master;
}
 
Example #3
Source File: ConsumeQueueTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
protected DefaultMessageStore gen() throws Exception {
    MessageStoreConfig messageStoreConfig = buildStoreConfig(
        commitLogFileSize, cqFileSize, true, cqExtFileSize
    );

    BrokerConfig brokerConfig = new BrokerConfig();

    DefaultMessageStore master = new DefaultMessageStore(
        messageStoreConfig,
        new BrokerStatsManager(brokerConfig.getBrokerClusterName()),
        new MessageArrivingListener() {
            @Override
            public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
                                 long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
            }
        }
        , brokerConfig);

    assertThat(master.load()).isTrue();

    master.start();

    return master;
}
 
Example #4
Source File: DefaultMessageStoreTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private void damageCommitlog(long offset) throws Exception {
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    File file = new File(messageStoreConfig.getStorePathCommitLog() + File.separator + "00000000000000000000");

    FileChannel fileChannel = new RandomAccessFile(file, "rw").getChannel();
    MappedByteBuffer mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, 1024 * 1024 * 10);

    int bodyLen = mappedByteBuffer.getInt((int) offset + 84);
    int topicLenIndex = (int) offset + 84 + bodyLen + 4;
    mappedByteBuffer.position(topicLenIndex);
    mappedByteBuffer.putInt(0);
    mappedByteBuffer.putInt(0);
    mappedByteBuffer.putInt(0);
    mappedByteBuffer.putInt(0);

    mappedByteBuffer.force();
    fileChannel.force(true);
    fileChannel.close();
}
 
Example #5
Source File: TransactionRecordFlush2DBService.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
public TransactionRecordFlush2DBService(DefaultMessageStore defaultMessageStore) {
    MessageStoreConfig messageStoreConfig = defaultMessageStore.getMessageStoreConfig();
    this.transactionOffsetConifgService = new TransactionOffsetConifgService(defaultMessageStore);
    TransactionTableDefConfigService transactionTableDefConfigService = new TransactionTableDefConfigService(defaultMessageStore);
    transactionTableDefConfigService.load();
    int retry = 0;
    boolean isCheckTable = false;
    this.transactionStore = new JDBCTransactionStore(messageStoreConfig);
    this.transactionStore.load();
    do {
        int tableSuffix = transactionTableDefConfigService.getTableSuffix(messageStoreConfig);
        this.transactionStore.setTableSuffix(tableSuffix);
        log.info("loadTableStoreConfig tableSuffix={}", tableSuffix);
    } while (!(isCheckTable = transactionStore.createTableIfNotExists()) && ++retry < 5);

    if (!isCheckTable) {
        throw new RuntimeException("check db info error!");
    } else {
        transactionTableDefConfigService.persist();
    }

    for (int i = 0; i < REQUEST_BUFFER_IN_QUEUE; i++) {
        dispatchRequestBufferQueue.add(new DispatchRequestCollections(new AtomicInteger(0), new ArrayList<>()));
    }
}
 
Example #6
Source File: DefaultMessageStoreTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test(expected = OverlappingFileLockException.class)
public void test_repate_restart() throws Exception {
    QUEUE_TOTAL = 1;
    MessageBody = StoreMessage.getBytes();

    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    messageStoreConfig.setMapedFileSizeCommitLog(1024 * 8);
    messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 4);
    messageStoreConfig.setMaxHashSlotNum(100);
    messageStoreConfig.setMaxIndexNum(100 * 10);
    MessageStore master = new DefaultMessageStore(messageStoreConfig, null, new MyMessageArrivingListener(), new BrokerConfig());

    boolean load = master.load();
    assertTrue(load);

    try {
        master.start();
        master.start();
    } finally {
        master.shutdown();
        master.destroy();
    }
}
 
Example #7
Source File: DefaultMessageStoreTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private void damageCommitlog(long offset) throws Exception {
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    File file = new File(messageStoreConfig.getStorePathCommitLog() + File.separator + "00000000000000000000");

    FileChannel fileChannel = new RandomAccessFile(file, "rw").getChannel();
    MappedByteBuffer mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, 1024 * 1024 * 10);

    int bodyLen = mappedByteBuffer.getInt((int) offset + 84);
    int topicLenIndex = (int) offset + 84 + bodyLen + 4;
    mappedByteBuffer.position(topicLenIndex);
    mappedByteBuffer.putInt(0);
    mappedByteBuffer.putInt(0);
    mappedByteBuffer.putInt(0);
    mappedByteBuffer.putInt(0);

    mappedByteBuffer.force();
    fileChannel.force(true);
    fileChannel.close();
}
 
Example #8
Source File: ConsumeQueueTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
protected DefaultMessageStore gen() throws Exception {
    MessageStoreConfig messageStoreConfig = buildStoreConfig(
        commitLogFileSize, cqFileSize, true, cqExtFileSize
    );

    BrokerConfig brokerConfig = new BrokerConfig();

    DefaultMessageStore master = new DefaultMessageStore(
        messageStoreConfig,
        new BrokerStatsManager(brokerConfig.getBrokerClusterName()),
        new MessageArrivingListener() {
            @Override
            public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
                long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
            }
        }
        , brokerConfig);

    assertThat(master.load()).isTrue();

    master.start();

    return master;
}
 
Example #9
Source File: ConsumeQueueTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
protected DefaultMessageStore gen() throws Exception {
    MessageStoreConfig messageStoreConfig = buildStoreConfig(
        commitLogFileSize, cqFileSize, true, cqExtFileSize
    );

    BrokerConfig brokerConfig = new BrokerConfig();

    DefaultMessageStore master = new DefaultMessageStore(
        messageStoreConfig,
        new BrokerStatsManager(brokerConfig.getBrokerClusterName()),
        new MessageArrivingListener() {
            @Override
            public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
                long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
            }
        }
        , brokerConfig);

    assertThat(master.load()).isTrue();

    master.start();

    return master;
}
 
Example #10
Source File: DeFiReplyMessageProcessorTest.java    From DeFiBus with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    deFiBrokerController = spy(new DeFiBrokerController(new BrokerConfig(), new NettyServerConfig(), new NettyClientConfig(), new MessageStoreConfig(), deFiBusBrokerConfig));
    channelHandlerContext = mock(ChannelHandlerContext.class);
    messageStore = mock(MessageStore.class);
    DeFiBusBroker2Client broker2Client = mock(DeFiBusBroker2Client.class);
    when(this.deFiBrokerController.getDeFiBusBroker2Client()).thenReturn(broker2Client);
    when(broker2Client.pushRRReplyMessageToClient(any(), any(), any())).thenReturn(true);
    Channel channel = mock(Channel.class);
    when(channel.isActive()).thenReturn(true);
    ClientChannelInfo channelInfo = mock(ClientChannelInfo.class);
    when(channelInfo.getChannel()).thenReturn(channel);
    DeFiProducerManager mockProducer = mock(DeFiProducerManager.class);
    when(mockProducer.getClientChannel(anyString())).thenReturn(channelInfo);
    when(this.deFiBrokerController.getProducerManager()).thenReturn(mockProducer);
    this.deFiBrokerController.setMessageStore(this.messageStore);
    when(this.messageStore.now()).thenReturn(System.currentTimeMillis());
    AppendMessageResult appendMessageResult = new AppendMessageResult(AppendMessageStatus.PUT_OK, 0, 0, "00000000000000000000000000000000", messageStore.now(), 0L, 0);
    when(this.messageStore.putMessage(any())).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, appendMessageResult));
    when(channel.remoteAddress()).thenReturn(new InetSocketAddress(1024));
    when(channelHandlerContext.channel()).thenReturn(channel);
    deFiReplyMessageProcessor = new DeFiReplyMessageProcessor(this.deFiBrokerController);
}
 
Example #11
Source File: ConsumeQueueTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
protected DefaultMessageStore gen() throws Exception {
    MessageStoreConfig messageStoreConfig = buildStoreConfig(
        commitLogFileSize, cqFileSize, true, cqExtFileSize
    );

    BrokerConfig brokerConfig = new BrokerConfig();

    DefaultMessageStore master = new DefaultMessageStore(
        messageStoreConfig,
        new BrokerStatsManager(brokerConfig.getBrokerClusterName()),
        new MessageArrivingListener() {
            @Override
            public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
                long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
            }
        }
        , brokerConfig);

    assertThat(master.load()).isTrue();

    master.start();

    return master;
}
 
Example #12
Source File: AbstractTestCase.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
/**
 * Start rocketmq broker service
 * @throws Exception
 */
private static void startBroker() throws Exception {

    System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));

    BrokerConfig brokerConfig = new BrokerConfig();
    brokerConfig.setNamesrvAddr(nameServer);
    brokerConfig.setBrokerId(MixAll.MASTER_ID);
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    nettyServerConfig.setListenPort(10911);
    NettyClientConfig nettyClientConfig = new NettyClientConfig();
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();

    brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, messageStoreConfig);
    boolean initResult = brokerController.initialize();
    if (!initResult) {
        brokerController.shutdown();
        throw new Exception();
    }
    brokerController.start();
}
 
Example #13
Source File: IntegrationTestBase.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
public static BrokerController createAndStartBroker(String nsAddr) {
    String baseDir = createBaseDir();
    BrokerConfig brokerConfig = new BrokerConfig();
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    NettyClientConfig nettyClientConfig = new NettyClientConfig();
    MessageStoreConfig storeConfig = new MessageStoreConfig();
    brokerConfig.setBrokerName(BROKER_NAME_PREFIX + BROKER_INDEX.getAndIncrement());
    brokerConfig.setBrokerIP1("127.0.0.1");
    brokerConfig.setNamesrvAddr(nsAddr);
    storeConfig.setStorePathRootDir(baseDir);
    storeConfig.setStorePathCommitLog(baseDir + SEP + "commitlog");
    storeConfig.setHaListenPort(8000 + random.nextInt(1000));
    nettyServerConfig.setListenPort(10000 + random.nextInt(1000));
    BrokerController brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, storeConfig);
    try {
        Assert.assertTrue(brokerController.initialize());
        logger.info("Broker Start name:{} addr:{}", brokerConfig.getBrokerName(), brokerController.getBrokerAddr());
        brokerController.start();
    } catch (Exception e) {
        logger.info("Broker start failed");
        System.exit(1);
    }
    BROKER_CONTROLLERS.add(brokerController);
    return brokerController;
}
 
Example #14
Source File: IntegrationTestBase.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public static BrokerController createAndStartBroker(String nsAddr) {
    String baseDir = createBaseDir();
    BrokerConfig brokerConfig = new BrokerConfig();
    MessageStoreConfig storeConfig = new MessageStoreConfig();
    brokerConfig.setBrokerName(BROKER_NAME_PREFIX + BROKER_INDEX.getAndIncrement());
    brokerConfig.setBrokerIP1("127.0.0.1");
    brokerConfig.setNamesrvAddr(nsAddr);
    brokerConfig.setEnablePropertyFilter(true);
    storeConfig.setStorePathRootDir(baseDir);
    storeConfig.setStorePathCommitLog(baseDir + SEP + "commitlog");
    storeConfig.setMappedFileSizeCommitLog(COMMIT_LOG_SIZE);
    storeConfig.setMaxIndexNum(INDEX_NUM);
    storeConfig.setMaxHashSlotNum(INDEX_NUM * 4);
    return createAndStartBroker(storeConfig, brokerConfig);

}
 
Example #15
Source File: IntegrationTestBase.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public static BrokerController createAndStartBroker(String nsAddr) {
    String baseDir = createBaseDir();
    BrokerConfig brokerConfig = new BrokerConfig();
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    NettyClientConfig nettyClientConfig = new NettyClientConfig();
    MessageStoreConfig storeConfig = new MessageStoreConfig();
    brokerConfig.setBrokerName(BROKER_NAME_PREFIX + BROKER_INDEX.getAndIncrement());
    brokerConfig.setBrokerIP1("127.0.0.1");
    brokerConfig.setNamesrvAddr(nsAddr);
    storeConfig.setStorePathRootDir(baseDir);
    storeConfig.setStorePathCommitLog(baseDir + SEP + "commitlog");
    storeConfig.setHaListenPort(8000 + random.nextInt(1000));
    nettyServerConfig.setListenPort(10000 + random.nextInt(1000));
    BrokerController brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, storeConfig);
    try {
        Assert.assertTrue(brokerController.initialize());
        logger.info("Broker Start name:{} addr:{}", brokerConfig.getBrokerName(), brokerController.getBrokerAddr());
        brokerController.start();
    } catch (Exception e) {
        logger.info("Broker start failed");
        System.exit(1);
    }
    BROKER_CONTROLLERS.add(brokerController);
    return brokerController;
}
 
Example #16
Source File: DefaultMessageStoreTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private void damageCommitlog(long offset) throws Exception {
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    File file = new File(messageStoreConfig.getStorePathCommitLog() + File.separator + "00000000000000000000");

    FileChannel fileChannel = new RandomAccessFile(file, "rw").getChannel();
    MappedByteBuffer mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, 1024 * 1024 * 10);

    int bodyLen = mappedByteBuffer.getInt((int) offset + 84);
    int topicLenIndex = (int) offset + 84 + bodyLen + 4;
    mappedByteBuffer.position(topicLenIndex);
    mappedByteBuffer.putInt(0);
    mappedByteBuffer.putInt(0);
    mappedByteBuffer.putInt(0);
    mappedByteBuffer.putInt(0);

    mappedByteBuffer.force();
    fileChannel.force(true);
    fileChannel.close();
}
 
Example #17
Source File: DefaultMessageStoreTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@After
public void destory() {
    messageStore.shutdown();
    messageStore.destroy();

    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    File file = new File(messageStoreConfig.getStorePathRootDir());
    UtilAll.deleteFile(file);
}
 
Example #18
Source File: MessageStoreWithFilterTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
protected DefaultMessageStore gen(ConsumerFilterManager filterManager) throws Exception {
    MessageStoreConfig messageStoreConfig = buildStoreConfig(
        commitLogFileSize, cqFileSize, true, cqExtFileSize
    );

    BrokerConfig brokerConfig = new BrokerConfig();
    brokerConfig.setEnableCalcFilterBitMap(true);
    brokerConfig.setMaxErrorRateOfBloomFilter(20);
    brokerConfig.setExpectConsumerNumUseFilter(64);

    DefaultMessageStore master = new DefaultMessageStore(
        messageStoreConfig,
        new BrokerStatsManager(brokerConfig.getBrokerClusterName()),
        new MessageArrivingListener() {
            @Override
            public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
                                 long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
            }
        }
        , brokerConfig);

    master.getDispatcherList().addFirst(new CommitLogDispatcher() {
        @Override
        public void dispatch(DispatchRequest request) {
            try {
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    });
    master.getDispatcherList().addFirst(new CommitLogDispatcherCalcBitMap(brokerConfig, filterManager));

    assertThat(master.load()).isTrue();

    master.start();

    return master;
}
 
Example #19
Source File: MessageStoreWithFilterTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
protected DefaultMessageStore gen(ConsumerFilterManager filterManager) throws Exception {
    MessageStoreConfig messageStoreConfig = buildStoreConfig(
        commitLogFileSize, cqFileSize, true, cqExtFileSize
    );

    BrokerConfig brokerConfig = new BrokerConfig();
    brokerConfig.setEnableCalcFilterBitMap(true);
    brokerConfig.setMaxErrorRateOfBloomFilter(20);
    brokerConfig.setExpectConsumerNumUseFilter(64);

    DefaultMessageStore master = new DefaultMessageStore(
        messageStoreConfig,
        new BrokerStatsManager(brokerConfig.getBrokerClusterName()),
        new MessageArrivingListener() {
            @Override
            public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
                                 long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
            }
        }
        , brokerConfig);

    master.getDispatcherList().addFirst(new CommitLogDispatcher() {
        @Override
        public void dispatch(DispatchRequest request) {
            try {
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    });
    master.getDispatcherList().addFirst(new CommitLogDispatcherCalcBitMap(brokerConfig, filterManager));

    assertThat(master.load()).isTrue();

    master.start();

    return master;
}
 
Example #20
Source File: AppendCallbackTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Before
public void init() throws Exception{
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    messageStoreConfig.setMapedFileSizeCommitLog(1024 * 8);
    messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 4);
    messageStoreConfig.setMaxHashSlotNum(100);
    messageStoreConfig.setMaxIndexNum(100 * 10);
    messageStoreConfig.setStorePathRootDir(System.getProperty("user.home") + File.separator + "unitteststore");
    messageStoreConfig.setStorePathCommitLog(System.getProperty("user.home") + File.separator + "unitteststore" + File.separator + "commitlog");
    //too much reference
    DefaultMessageStore messageStore = new DefaultMessageStore(messageStoreConfig, null, null, null);
    CommitLog commitLog = new CommitLog(messageStore);
    callback = commitLog.new DefaultAppendMessageCallback(1024);
}
 
Example #21
Source File: MessageStorePluginContext.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
public MessageStorePluginContext(MessageStoreConfig messageStoreConfig,
    BrokerStatsManager brokerStatsManager, MessageArrivingListener messageArrivingListener,
    BrokerConfig brokerConfig) {
    super();
    this.messageStoreConfig = messageStoreConfig;
    this.brokerStatsManager = brokerStatsManager;
    this.messageArrivingListener = messageArrivingListener;
    this.brokerConfig = brokerConfig;
}
 
Example #22
Source File: DefaultMessageStoreShutDownTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
public DefaultMessageStore buildMessageStore() throws Exception {
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    messageStoreConfig.setMapedFileSizeCommitLog(1024 * 1024 * 10);
    messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 1024 * 10);
    messageStoreConfig.setMaxHashSlotNum(10000);
    messageStoreConfig.setMaxIndexNum(100 * 100);
    messageStoreConfig.setFlushDiskType(FlushDiskType.SYNC_FLUSH);
    return new DefaultMessageStore(messageStoreConfig, new BrokerStatsManager("simpleTest"), null, new BrokerConfig());
}
 
Example #23
Source File: BrokerStartupTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
// 设置版本号
        System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
        // NettyServerConfig 配置
        final NettyServerConfig nettyServerConfig = new NettyServerConfig();
        nettyServerConfig.setListenPort(10911);
        // BrokerConfig 配置
        final BrokerConfig brokerConfig = new BrokerConfig();
        brokerConfig.setBrokerName("broker-a");
        brokerConfig.setNamesrvAddr("127.0.0.1:9876");
        // MessageStoreConfig 配置
        final MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
        messageStoreConfig.setDeleteWhen("04");
        messageStoreConfig.setFileReservedTime(48);
        messageStoreConfig.setFlushDiskType(FlushDiskType.ASYNC_FLUSH);
        messageStoreConfig.setDuplicationEnable(false);

//        BrokerPathConfigHelper.setBrokerConfigPath("/Users/yunai/百度云同步盘/开发/Javascript/Story/incubator-rocketmq/conf/broker.conf");
        // 创建 BrokerController 对象,并启动
        BrokerController brokerController = new BrokerController(//
                brokerConfig, //
                nettyServerConfig, //
                new NettyClientConfig(), //
                messageStoreConfig);
        brokerController.initialize();
        brokerController.start();
        // 睡觉,就不起来
        System.out.println("你猜");
        Thread.sleep(DateUtils.MILLIS_PER_DAY);
    }
 
Example #24
Source File: MessageStoreWithFilterTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
protected DefaultMessageStore gen(ConsumerFilterManager filterManager) throws Exception {
    MessageStoreConfig messageStoreConfig = buildStoreConfig(
        commitLogFileSize, cqFileSize, true, cqExtFileSize
    );

    BrokerConfig brokerConfig = new BrokerConfig();
    brokerConfig.setEnableCalcFilterBitMap(true);
    brokerConfig.setMaxErrorRateOfBloomFilter(20);
    brokerConfig.setExpectConsumerNumUseFilter(64);

    DefaultMessageStore master = new DefaultMessageStore(
        messageStoreConfig,
        new BrokerStatsManager(brokerConfig.getBrokerClusterName()),
        new MessageArrivingListener() {
            @Override
            public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
                                 long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
            }
        }
        , brokerConfig);

    master.getDispatcherList().addFirst(new CommitLogDispatcher() {
        @Override
        public void dispatch(DispatchRequest request) {
            try {
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    });
    master.getDispatcherList().addFirst(new CommitLogDispatcherCalcBitMap(brokerConfig, filterManager));

    assertThat(master.load()).isTrue();

    master.start();

    return master;
}
 
Example #25
Source File: DefaultMessageStoreTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private MessageStore buildMessageStore() throws Exception {
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    messageStoreConfig.setMapedFileSizeCommitLog(1024 * 1024 * 10);
    messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 1024 * 10);
    messageStoreConfig.setMaxHashSlotNum(10000);
    messageStoreConfig.setMaxIndexNum(100 * 100);
    messageStoreConfig.setFlushDiskType(FlushDiskType.SYNC_FLUSH);
    messageStoreConfig.setFlushIntervalConsumeQueue(1);
    return new DefaultMessageStore(messageStoreConfig, new BrokerStatsManager("simpleTest"), new MyMessageArrivingListener(), new BrokerConfig());
}
 
Example #26
Source File: DefaultMessageStoreShutDownTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
public DefaultMessageStore buildMessageStore() throws Exception {
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    messageStoreConfig.setMapedFileSizeCommitLog(1024 * 1024 * 10);
    messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 1024 * 10);
    messageStoreConfig.setMaxHashSlotNum(10000);
    messageStoreConfig.setMaxIndexNum(100 * 100);
    messageStoreConfig.setFlushDiskType(FlushDiskType.SYNC_FLUSH);
    return new DefaultMessageStore(messageStoreConfig, new BrokerStatsManager("simpleTest"), null, new BrokerConfig());
}
 
Example #27
Source File: DefaultMessageStoreTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private MessageStore buildMessageStore() throws Exception {
    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    messageStoreConfig.setMapedFileSizeCommitLog(1024 * 1024 * 10);
    messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 1024 * 10);
    messageStoreConfig.setMaxHashSlotNum(10000);
    messageStoreConfig.setMaxIndexNum(100 * 100);
    messageStoreConfig.setFlushDiskType(FlushDiskType.SYNC_FLUSH);
    messageStoreConfig.setFlushIntervalConsumeQueue(1);
    return new DefaultMessageStore(messageStoreConfig, new BrokerStatsManager("simpleTest"), new MyMessageArrivingListener(), new BrokerConfig());
}
 
Example #28
Source File: BrokerControllerTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
/**
     * broker 启动
     */
    @Test
    public void testBrokerRestart() throws Exception {
        // 设置版本号
        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.setNamesrvAddr("127.0.0.1:9876");
        //
        final MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
        messageStoreConfig.setDeleteWhen("04");
        messageStoreConfig.setFileReservedTime(48);
        messageStoreConfig.setFlushDiskType(FlushDiskType.ASYNC_FLUSH);

        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);
    }
 
Example #29
Source File: DefaultMessageStoreTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@After
public void destory() {
    messageStore.shutdown();
    messageStore.destroy();

    MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    File file = new File(messageStoreConfig.getStorePathRootDir());
    UtilAll.deleteFile(file);
}
 
Example #30
Source File: BrokerControllerTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
/**
 * Tests if the controller can be properly stopped and started.
 *
 * @throws Exception If fails.
 */
@Test
public void testBrokerRestart() throws Exception {
    for (int i = 0; i < 2; i++) {
        BrokerController brokerController = new BrokerController(//
            new BrokerConfig(), //
            new NettyServerConfig(), //
            new NettyClientConfig(), //
            new MessageStoreConfig());
        assertThat(brokerController.initialize());
        brokerController.start();
        brokerController.shutdown();
    }
}