Search in sources :

Example 26 with MessageStoreConfig

use of org.apache.rocketmq.store.config.MessageStoreConfig in project rocketmq by apache.

the class DefaultMessageStoreTest method test_repate_restart.

@Test(expected = OverlappingFileLockException.class)
public void test_repate_restart() throws Exception {
    long totalMsgs = 100;
    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();
    }
}
Also used : MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) BrokerConfig(org.apache.rocketmq.common.BrokerConfig) Test(org.junit.Test)

Example 27 with MessageStoreConfig

use of org.apache.rocketmq.store.config.MessageStoreConfig in project rocketmq by apache.

the class DefaultMessageStoreTest method buildMessageStore.

public 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);
    return new DefaultMessageStore(messageStoreConfig, new BrokerStatsManager("simpleTest"), new MyMessageArrivingListener(), new BrokerConfig());
}
Also used : BrokerStatsManager(org.apache.rocketmq.store.stats.BrokerStatsManager) MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) BrokerConfig(org.apache.rocketmq.common.BrokerConfig)

Example 28 with MessageStoreConfig

use of org.apache.rocketmq.store.config.MessageStoreConfig in project rocketmq by apache.

the class IntegrationTestBase method createAndStartBroker.

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);
    brokerConfig.setEnablePropertyFilter(true);
    storeConfig.setStorePathRootDir(baseDir);
    storeConfig.setStorePathCommitLog(baseDir + SEP + "commitlog");
    storeConfig.setHaListenPort(8000 + random.nextInt(1000));
    storeConfig.setMapedFileSizeCommitLog(COMMIT_LOG_SIZE);
    storeConfig.setMaxIndexNum(INDEX_NUM);
    storeConfig.setMaxHashSlotNum(INDEX_NUM * 4);
    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;
}
Also used : MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) BrokerConfig(org.apache.rocketmq.common.BrokerConfig) NettyClientConfig(org.apache.rocketmq.remoting.netty.NettyClientConfig) BrokerController(org.apache.rocketmq.broker.BrokerController) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig)

Example 29 with MessageStoreConfig

use of org.apache.rocketmq.store.config.MessageStoreConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class AppendCallbackTest method init.

@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);
}
Also used : MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) Before(org.junit.Before)

Example 30 with MessageStoreConfig

use of org.apache.rocketmq.store.config.MessageStoreConfig in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class DefaultMessageStoreTest method testWriteAndRead.

@Test
public void testWriteAndRead() throws Exception {
    long totalMsgs = 100;
    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);
    master.start();
    try {
        for (long i = 0; i < totalMsgs; i++) {
            master.putMessage(buildMessage());
        }
        for (long i = 0; i < totalMsgs; i++) {
            GetMessageResult result = master.getMessage("GROUP_A", "TOPIC_A", 0, i, 1024 * 1024, null);
            assertThat(result).isNotNull();
            result.release();
        }
    } finally {
        master.shutdown();
        master.destroy();
    }
}
Also used : MessageStoreConfig(org.apache.rocketmq.store.config.MessageStoreConfig) BrokerConfig(org.apache.rocketmq.common.BrokerConfig) Test(org.junit.Test)

Aggregations

MessageStoreConfig (org.apache.rocketmq.store.config.MessageStoreConfig)33 BrokerConfig (org.apache.rocketmq.common.BrokerConfig)26 NettyClientConfig (org.apache.rocketmq.remoting.netty.NettyClientConfig)17 NettyServerConfig (org.apache.rocketmq.remoting.netty.NettyServerConfig)17 BrokerController (org.apache.rocketmq.broker.BrokerController)13 MQClientException (org.apache.rocketmq.client.exception.MQClientException)8 BrokerStatsManager (org.apache.rocketmq.store.stats.BrokerStatsManager)6 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)5 Test (org.junit.Test)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)4 EventDeliveryException (org.apache.flume.EventDeliveryException)3 LoggerContext (ch.qos.logback.classic.LoggerContext)2 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)2 BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Properties (java.util.Properties)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2