org.apache.rocketmq.store.DefaultMessageStore Java Examples

The following examples show how to use org.apache.rocketmq.store.DefaultMessageStore. 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: AdminBrokerProcessor.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private RemotingCommand getAllDelayOffset(ChannelHandlerContext ctx, RemotingCommand request) {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    String content = ((DefaultMessageStore) this.brokerController.getMessageStore()).getScheduleMessageService().encode();
    if (content != null && content.length() > 0) {
        try {
            response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
        } catch (UnsupportedEncodingException e) {
            log.error("get all delay offset from master error.", e);

            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark("UnsupportedEncodingException " + e);
            return response;
        }
    } else {
        log.error("No delay offset in this broker, client: {} ", ctx.channel().remoteAddress());
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark("No delay offset in this broker");
        return response;
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);

    return response;
}
 
Example #2
Source File: AdminBrokerProcessor.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
private RemotingCommand getAllDelayOffset(ChannelHandlerContext ctx, RemotingCommand request) {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    String content = ((DefaultMessageStore) this.brokerController.getMessageStore()).getScheduleMessageService().encode();
    if (content != null && content.length() > 0) {
        try {
            response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
        } catch (UnsupportedEncodingException e) {
            log.error("get all delay offset from master error.", e);

            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark("UnsupportedEncodingException " + e);
            return response;
        }
    } else {
        log.error("No delay offset in this broker, client: {} ", ctx.channel().remoteAddress());
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark("No delay offset in this broker");
        return response;
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);

    return response;
}
 
Example #3
Source File: MessageStoreWithFilterTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount, int msgCountPerTopic) throws Exception {
    List<MessageExtBrokerInner> msgs = new ArrayList<MessageExtBrokerInner>();
    for (int i = 0; i < topicCount; i++) {
        String realTopic = topic + i;
        for (int j = 0; j < msgCountPerTopic; j++) {
            MessageExtBrokerInner msg = buildMessage();
            msg.setTopic(realTopic);
            msg.putUserProperty("a", String.valueOf(j * 10 + 5));
            msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties()));

            PutMessageResult result = master.putMessage(msg);

            msg.setMsgId(result.getAppendMessageResult().getMsgId());

            msgs.add(msg);
        }
    }

    return msgs;
}
 
Example #4
Source File: MessageStoreWithFilterTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount,
                                             int msgCountPerTopic) throws Exception {
    List<MessageExtBrokerInner> msgs = new ArrayList<MessageExtBrokerInner>();
    for (int i = 0; i < topicCount; i++) {
        String realTopic = topic + i;
        for (int j = 0; j < msgCountPerTopic; j++) {
            MessageExtBrokerInner msg = buildMessage();
            msg.setTopic(realTopic);
            msg.putUserProperty("a", String.valueOf(j * 10 + 5));
            msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties()));

            PutMessageResult result = master.putMessage(msg);

            msg.setMsgId(result.getAppendMessageResult().getMsgId());

            msgs.add(msg);
        }
    }

    return msgs;
}
 
Example #5
Source File: MessageStoreWithFilterTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount,
                                             int msgCountPerTopic) throws Exception {
    List<MessageExtBrokerInner> msgs = new ArrayList<MessageExtBrokerInner>();
    for (int i = 0; i < topicCount; i++) {
        String realTopic = topic + i;
        for (int j = 0; j < msgCountPerTopic; j++) {
            MessageExtBrokerInner msg = buildMessage();
            msg.setTopic(realTopic);
            msg.putUserProperty("a", String.valueOf(j * 10 + 5));
            msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties()));

            PutMessageResult result = master.putMessage(msg);

            msg.setMsgId(result.getAppendMessageResult().getMsgId());

            msgs.add(msg);
        }
    }

    return msgs;
}
 
Example #6
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 #7
Source File: MessageStoreWithFilterTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount,
                                             int msgCountPerTopic) throws Exception {
    List<MessageExtBrokerInner> msgs = new ArrayList<MessageExtBrokerInner>();
    for (int i = 0; i < topicCount; i++) {
        String realTopic = topic + i;
        for (int j = 0; j < msgCountPerTopic; j++) {
            MessageExtBrokerInner msg = buildMessage();
            msg.setTopic(realTopic);
            msg.putUserProperty("a", String.valueOf(j * 10 + 5));
            msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties()));

            PutMessageResult result = master.putMessage(msg);

            msg.setMsgId(result.getAppendMessageResult().getMsgId());

            msgs.add(msg);
        }
    }

    return msgs;
}
 
Example #8
Source File: AdminBrokerProcessor.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private RemotingCommand getAllMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    DefaultMessageStore messageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
    ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable = new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>();
    ConcurrentMap<String, ConcurrentMap<Integer, ConsumeQueue>> consumeQueueTable = messageStore.getConsumeQueueTable();
    for (Map.Entry<String, ConcurrentMap<Integer, ConsumeQueue>> entry : consumeQueueTable.entrySet()) {
        String topic = entry.getKey();
        for (Map.Entry<Integer, ConsumeQueue> entry1 : entry.getValue().entrySet()) {
            Integer qid = entry1.getKey();
            long maxOffset = entry1.getValue().getMaxOffsetInQueue();
            if (!offsetTable.containsKey(topic)) {
                offsetTable.put(topic, new ConcurrentHashMap<Integer, Long>());
            }
            offsetTable.get(topic).put(qid, maxOffset);
        }
    }
    AllMaxOffset allMaxOffset = new AllMaxOffset();
    allMaxOffset.setOffsetTable(offsetTable);
    response.setBody(allMaxOffset.encode());
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
Example #9
Source File: AdminBrokerProcessor.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private RemotingCommand getAllDelayOffset(ChannelHandlerContext ctx, RemotingCommand request) {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    String content = ((DefaultMessageStore) this.brokerController.getMessageStore()).getScheduleMessageService().encode();
    if (content != null && content.length() > 0) {
        try {
            response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
        } catch (UnsupportedEncodingException e) {
            log.error("get all delay offset from master error.", e);

            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark("UnsupportedEncodingException " + e);
            return response;
        }
    } else {
        log.error("No delay offset in this broker, client: {} ", ctx.channel().remoteAddress());
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark("No delay offset in this broker");
        return response;
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);

    return response;
}
 
Example #10
Source File: DLedgerCommitLog.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public DLedgerCommitLog(final DefaultMessageStore defaultMessageStore) {
    super(defaultMessageStore);
    dLedgerConfig = new DLedgerConfig();
    dLedgerConfig.setEnableDiskForceClean(defaultMessageStore.getMessageStoreConfig().isCleanFileForciblyEnable());
    dLedgerConfig.setStoreType(DLedgerConfig.FILE);
    dLedgerConfig.setSelfId(defaultMessageStore.getMessageStoreConfig().getdLegerSelfId());
    dLedgerConfig.setGroup(defaultMessageStore.getMessageStoreConfig().getdLegerGroup());
    dLedgerConfig.setPeers(defaultMessageStore.getMessageStoreConfig().getdLegerPeers());
    dLedgerConfig.setStoreBaseDir(defaultMessageStore.getMessageStoreConfig().getStorePathRootDir());
    dLedgerConfig.setMappedFileSizeForEntryData(defaultMessageStore.getMessageStoreConfig().getMappedFileSizeCommitLog());
    dLedgerConfig.setDeleteWhen(defaultMessageStore.getMessageStoreConfig().getDeleteWhen());
    dLedgerConfig.setFileReservedHours(defaultMessageStore.getMessageStoreConfig().getFileReservedTime() + 1);
    id = Integer.valueOf(dLedgerConfig.getSelfId().substring(1)) + 1;
    dLedgerServer = new DLedgerServer(dLedgerConfig);
    dLedgerFileStore = (DLedgerMmapFileStore) dLedgerServer.getdLedgerStore();
    DLedgerMmapFileStore.AppendHook appendHook = (entry, buffer, bodyOffset) -> {
        assert bodyOffset == DLedgerEntry.BODY_OFFSET;
        buffer.position(buffer.position() + bodyOffset + MessageDecoder.PHY_POS_POSITION);
        buffer.putLong(entry.getPos() + bodyOffset);
    };
    dLedgerFileStore.addAppendHook(appendHook);
    dLedgerFileList = dLedgerFileStore.getDataFileList();
    this.messageSerializer = new MessageSerializer(defaultMessageStore.getMessageStoreConfig().getMaxMessageSize());

}
 
Example #11
Source File: AdminBrokerProcessor.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private RemotingCommand getAllDelayOffset(ChannelHandlerContext ctx, RemotingCommand request) {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    String content = ((DefaultMessageStore)this.brokerController.getMessageStore()).getScheduleMessageService().encode();
    if (content != null && content.length() > 0) {
        try {
            response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
        } catch (UnsupportedEncodingException e) {
            log.error("get all delay offset from master error.", e);

            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark("UnsupportedEncodingException " + e);
            return response;
        }
    } else {
        log.error("No delay offset in this broker, client: {} ", ctx.channel().remoteAddress());
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark("No delay offset in this broker");
        return response;
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);

    return response;
}
 
Example #12
Source File: MessageStoreWithFilterTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount,
                                             int msgCountPerTopic) throws Exception {
    List<MessageExtBrokerInner> msgs = new ArrayList<MessageExtBrokerInner>();
    for (int i = 0; i < topicCount; i++) {
        String realTopic = topic + i;
        for (int j = 0; j < msgCountPerTopic; j++) {
            MessageExtBrokerInner msg = buildMessage();
            msg.setTopic(realTopic);
            msg.putUserProperty("a", String.valueOf(j * 10 + 5));
            msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties()));

            PutMessageResult result = master.putMessage(msg);

            msg.setMsgId(result.getAppendMessageResult().getMsgId());

            msgs.add(msg);
        }
    }

    return msgs;
}
 
Example #13
Source File: MessageStoreTestBase.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
protected DefaultMessageStore createMessageStore(String base, boolean createAbort) throws Exception {
    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);
    DefaultMessageStore defaultMessageStore = new DefaultMessageStore(storeConfig,  new BrokerStatsManager("CommitlogTest"), (topic, queueId, logicOffset, tagsCode, msgStoreTime, filterBitMap, properties) -> {

    }, new BrokerConfig());

    if (createAbort) {
        String fileName = StorePathConfigHelper.getAbortFile(storeConfig.getStorePathRootDir());
        makeSureFileExists(fileName);
    }
    Assert.assertTrue(defaultMessageStore.load());
    defaultMessageStore.start();
    return defaultMessageStore;
}
 
Example #14
Source File: AdminBrokerProcessor.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private RemotingCommand getAllMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    DefaultMessageStore messageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
    ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable = new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>();
    ConcurrentMap<String, ConcurrentMap<Integer, ConsumeQueue>> consumeQueueTable = messageStore.getConsumeQueueTable();
    for (Map.Entry<String, ConcurrentMap<Integer, ConsumeQueue>> entry : consumeQueueTable.entrySet()) {
        String topic = entry.getKey();
        for (Map.Entry<Integer, ConsumeQueue> entry1 : entry.getValue().entrySet()) {
            Integer qid = entry1.getKey();
            long maxOffset = entry1.getValue().getMaxOffsetInQueue();
            if (!offsetTable.containsKey(topic)) {
                offsetTable.put(topic, new ConcurrentHashMap<Integer, Long>());
            }
            offsetTable.get(topic).put(qid, maxOffset);
        }
    }
    AllMaxOffset allMaxOffset = new AllMaxOffset();
    allMaxOffset.setOffsetTable(offsetTable);
    response.setBody(allMaxOffset.encode());
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
Example #15
Source File: MessageStoreWithFilterTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount,
                                             int msgCountPerTopic) throws Exception {
    List<MessageExtBrokerInner> msgs = new ArrayList<MessageExtBrokerInner>();
    for (int i = 0; i < topicCount; i++) {
        String realTopic = topic + i;
        for (int j = 0; j < msgCountPerTopic; j++) {
            MessageExtBrokerInner msg = buildMessage();
            msg.setTopic(realTopic);
            msg.putUserProperty("a", String.valueOf(j * 10 + 5));
            msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties()));

            PutMessageResult result = master.putMessage(msg);

            msg.setMsgId(result.getAppendMessageResult().getMsgId());

            msgs.add(msg);
        }
    }

    return msgs;
}
 
Example #16
Source File: DLedgerCommitlogTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutAndGetMessage() throws Exception {
    String base =  createBaseDir();
    String peers = String.format("n0-localhost:%d", nextPort());
    String group = UUID.randomUUID().toString();
    DefaultMessageStore messageStore = createDledgerMessageStore(base, group, "n0", peers, null, false, 0);
    Thread.sleep(1000);
    String topic = UUID.randomUUID().toString();

    List<PutMessageResult> results = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        MessageExtBrokerInner msgInner =
            i < 5 ? buildMessage() : buildIPv6HostMessage();
        msgInner.setTopic(topic);
        msgInner.setQueueId(0);
        PutMessageResult putMessageResult = messageStore.putMessage(msgInner);
        results.add(putMessageResult);
        Assert.assertEquals(PutMessageStatus.PUT_OK, putMessageResult.getPutMessageStatus());
        Assert.assertEquals(i, putMessageResult.getAppendMessageResult().getLogicsOffset());
    }
    Thread.sleep(100);
    Assert.assertEquals(0, messageStore.getMinOffsetInQueue(topic, 0));
    Assert.assertEquals(10, messageStore.getMaxOffsetInQueue(topic, 0));
    Assert.assertEquals(0, messageStore.dispatchBehindBytes());
    GetMessageResult getMessageResult =  messageStore.getMessage("group", topic, 0, 0, 32, null);
    Assert.assertEquals(GetMessageStatus.FOUND, getMessageResult.getStatus());

    Assert.assertEquals(10, getMessageResult.getMessageBufferList().size());
    Assert.assertEquals(10, getMessageResult.getMessageMapedList().size());

    for (int i = 0; i < results.size(); i++) {
        ByteBuffer buffer = getMessageResult.getMessageBufferList().get(i);
        MessageExt messageExt = MessageDecoder.decode(buffer);
        Assert.assertEquals(i, messageExt.getQueueOffset());
        Assert.assertEquals(results.get(i).getAppendMessageResult().getMsgId(), messageExt.getMsgId());
        Assert.assertEquals(results.get(i).getAppendMessageResult().getWroteOffset(), messageExt.getCommitLogOffset());
    }
    messageStore.destroy();
    messageStore.shutdown();
}
 
Example #17
Source File: IndexService.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public IndexService(final DefaultMessageStore store) {
    this.defaultMessageStore = store;
    this.hashSlotNum = store.getMessageStoreConfig().getMaxHashSlotNum();
    this.indexNum = store.getMessageStoreConfig().getMaxIndexNum();
    this.storePath =
        StorePathConfigHelper.getStorePathIndex(store.getMessageStoreConfig().getStorePathRootDir());
}
 
Example #18
Source File: HAService.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public HAService(final DefaultMessageStore defaultMessageStore) throws IOException {
    this.defaultMessageStore = defaultMessageStore;
    this.acceptSocketService =
        new AcceptSocketService(defaultMessageStore.getMessageStoreConfig().getHaListenPort());
    this.groupTransferService = new GroupTransferService();
    this.haClient = new HAClient();
}
 
Example #19
Source File: DLedgerCommitlogTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testIPv6HostMsgCommittedPos() throws Exception {
    String peers = String.format("n0-localhost:%d;n1-localhost:%d", nextPort(), nextPort());
    String group = UUID.randomUUID().toString();
    DefaultMessageStore leaderStore = createDledgerMessageStore(createBaseDir(), group,"n0", peers, "n0", false, 0);

    String topic = UUID.randomUUID().toString();
    MessageExtBrokerInner msgInner =  buildIPv6HostMessage();
    msgInner.setTopic(topic);
    msgInner.setQueueId(0);
    PutMessageResult putMessageResult = leaderStore.putMessage(msgInner);
    Assert.assertEquals(PutMessageStatus.OS_PAGECACHE_BUSY, putMessageResult.getPutMessageStatus());

    Thread.sleep(1000);

    Assert.assertEquals(0, leaderStore.getCommitLog().getMaxOffset());
    Assert.assertEquals(0, leaderStore.getMaxOffsetInQueue(topic, 0));


    DefaultMessageStore followerStore = createDledgerMessageStore(createBaseDir(), group,"n1", peers, "n0", false, 0);
    Thread.sleep(2000);

    Assert.assertEquals(1, leaderStore.getMaxOffsetInQueue(topic, 0));
    Assert.assertEquals(1, followerStore.getMaxOffsetInQueue(topic, 0));
    Assert.assertTrue(leaderStore.getCommitLog().getMaxOffset() > 0);


    leaderStore.destroy();
    followerStore.destroy();

    leaderStore.shutdown();
    followerStore.shutdown();
}
 
Example #20
Source File: AdminBrokerProcessor.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private RemotingCommand getAllDelayOffset(ChannelHandlerContext ctx, RemotingCommand request) {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);

    if (!(this.brokerController.getMessageStore() instanceof DefaultMessageStore)) {
        log.error("Delay offset not supported in this messagetore, client: {} ", ctx.channel().remoteAddress());
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark("Delay offset not supported in this messagetore");
        return response;
    }

    String content = ((DefaultMessageStore) this.brokerController.getMessageStore()).getScheduleMessageService().encode();
    if (content != null && content.length() > 0) {
        try {
            response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
        } catch (UnsupportedEncodingException e) {
            log.error("Get all delay offset from master error.", e);

            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark("UnsupportedEncodingException " + e);
            return response;
        }
    } else {
        log.error("No delay offset in this broker, client: {} ", ctx.channel().remoteAddress());
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark("No delay offset in this broker");
        return response;
    }

    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);

    return response;
}
 
Example #21
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 #22
Source File: HAService.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public HAService(final DefaultMessageStore defaultMessageStore) throws IOException {
    this.defaultMessageStore = defaultMessageStore;
    this.acceptSocketService =
        new AcceptSocketService(defaultMessageStore.getMessageStoreConfig().getHaListenPort());
    this.groupTransferService = new GroupTransferService();
    this.haClient = new HAClient();
}
 
Example #23
Source File: IndexService.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public IndexService(final DefaultMessageStore store) {
    this.defaultMessageStore = store;
    this.hashSlotNum = store.getMessageStoreConfig().getMaxHashSlotNum();
    this.indexNum = store.getMessageStoreConfig().getMaxIndexNum();
    this.storePath =
        StorePathConfigHelper.getStorePathIndex(store.getMessageStoreConfig().getStorePathRootDir());
}
 
Example #24
Source File: BrokerController.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private void shutdownOldMaster() {
    if (masterAndSlaveDiffPrintFuture != null) {
        masterAndSlaveDiffPrintFuture.cancel(false);
        masterAndSlaveDiffPrintFuture = null;
    }
    if (messageStore instanceof DefaultMessageStore) {
        ((DefaultMessageStore) messageStore).getHaService().destroyConnections();
    }

    log.info("shutdown the master role");
}
 
Example #25
Source File: IndexService.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public IndexService(final DefaultMessageStore store) {
    this.defaultMessageStore = store;
    this.hashSlotNum = store.getMessageStoreConfig().getMaxHashSlotNum();
    this.indexNum = store.getMessageStoreConfig().getMaxIndexNum();
    this.storePath =
        StorePathConfigHelper.getStorePathIndex(store.getMessageStoreConfig().getStorePathRootDir());
}
 
Example #26
Source File: HAService.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public HAService(final DefaultMessageStore defaultMessageStore) throws IOException {
    this.defaultMessageStore = defaultMessageStore;
    this.acceptSocketService =
        new AcceptSocketService(defaultMessageStore.getMessageStoreConfig().getHaListenPort());
    this.groupTransferService = new GroupTransferService();
    this.haClient = new HAClient();
}
 
Example #27
Source File: HAService.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public HAService(final DefaultMessageStore defaultMessageStore) throws IOException {
    this.defaultMessageStore = defaultMessageStore;
    this.acceptSocketService =
        new AcceptSocketService(defaultMessageStore.getMessageStoreConfig().getHaListenPort());
    this.groupTransferService = new GroupTransferService();
    this.haClient = new HAClient();
}
 
Example #28
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 #29
Source File: IndexService.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public IndexService(final DefaultMessageStore store) {
    this.defaultMessageStore = store;
    this.hashSlotNum = store.getMessageStoreConfig().getMaxHashSlotNum();
    this.indexNum = store.getMessageStoreConfig().getMaxIndexNum();
    this.storePath =
        StorePathConfigHelper.getStorePathIndex(store.getMessageStoreConfig().getStorePathRootDir());
}
 
Example #30
Source File: BrokerController.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private void shutdownOldMaster() {
    if (masterAndSlaveDiffPrintFuture != null) {
        masterAndSlaveDiffPrintFuture.cancel(false);
        masterAndSlaveDiffPrintFuture = null;
    }
    if (messageStore instanceof DefaultMessageStore) {
        ((DefaultMessageStore) messageStore).getHaService().destroyConnections();
    }

    log.info("shutdown the master role");
}