org.apache.rocketmq.common.constant.PermName Java Examples

The following examples show how to use org.apache.rocketmq.common.constant.PermName. 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: RouteInfoManager.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
/**
 * //去除该broker上所有topic的写权限
 * @param brokerName brokerName
 * @return ;
 */
private int wipeWritePermOfBroker(final String brokerName) {
    int wipeTopicCnt = 0;
    Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator();
    while (itTopic.hasNext()) {
        Entry<String, List<QueueData>> entry = itTopic.next();
        List<QueueData> qdList = entry.getValue();

        Iterator<QueueData> it = qdList.iterator();
        while (it.hasNext()) {
            QueueData qd = it.next();
            if (qd.getBrokerName().equals(brokerName)) {
                int perm = qd.getPerm();
                perm &= ~PermName.PERM_WRITE;
                qd.setPerm(perm);
                wipeTopicCnt++;
            }
        }
    }
    return wipeTopicCnt;
}
 
Example #2
Source File: DeFiBrokerController.java    From DeFiBus with Apache License 2.0 6 votes vote down vote up
@Override
public boolean initialize() throws CloneNotSupportedException {
    boolean result = super.initialize();

    result = result && this.extTopicConfigManager.load();

    //reset the lastDeliverOffsetTable as offsetTable of consumer
    consumeQueueManager.load();

    String rrTopic = this.getBrokerConfig().getBrokerClusterName() + "-" + DeFiBusConstant.RR_REPLY_TOPIC;
    if (getTopicConfigManager().selectTopicConfig(rrTopic) == null) {
        TopicConfig topicConfig = new TopicConfig(rrTopic);
        topicConfig.setWriteQueueNums(1);
        topicConfig.setReadQueueNums(1);
        topicConfig.setPerm(PermName.PERM_INHERIT | PermName.PERM_READ | PermName.PERM_WRITE);
        this.getTopicConfigManager().updateTopicConfig(topicConfig);
    }
    this.getTopicConfigManager().getSystemTopic().add(rrTopic);

    return result;
}
 
Example #3
Source File: RouteInfoManager.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
private int wipeWritePermOfBroker(final String brokerName) {
    int wipeTopicCnt = 0;
    Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator();
    while (itTopic.hasNext()) {
        Entry<String, List<QueueData>> entry = itTopic.next();
        List<QueueData> qdList = entry.getValue();

        Iterator<QueueData> it = qdList.iterator();
        while (it.hasNext()) {
            QueueData qd = it.next();
            if (qd.getBrokerName().equals(brokerName)) {
                int perm = qd.getPerm();
                perm &= ~PermName.PERM_WRITE;
                qd.setPerm(perm);
                wipeTopicCnt++;
            }
        }
    }

    return wipeTopicCnt;
}
 
Example #4
Source File: RouteInfoManager.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
private int wipeWritePermOfBroker(final String brokerName) {
    int wipeTopicCnt = 0;
    Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator();
    while (itTopic.hasNext()) {
        Entry<String, List<QueueData>> entry = itTopic.next();
        List<QueueData> qdList = entry.getValue();

        Iterator<QueueData> it = qdList.iterator();
        while (it.hasNext()) {
            QueueData qd = it.next();
            if (qd.getBrokerName().equals(brokerName)) {
                int perm = qd.getPerm();
                perm &= ~PermName.PERM_WRITE;
                qd.setPerm(perm);
                wipeTopicCnt++;
            }
        }
    }

    return wipeTopicCnt;
}
 
Example #5
Source File: RouteInfoManager.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private int wipeWritePermOfBroker(final String brokerName) {
    int wipeTopicCnt = 0;
    Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator();
    while (itTopic.hasNext()) {
        Entry<String, List<QueueData>> entry = itTopic.next();
        List<QueueData> qdList = entry.getValue();

        Iterator<QueueData> it = qdList.iterator();
        while (it.hasNext()) {
            QueueData qd = it.next();
            if (qd.getBrokerName().equals(brokerName)) {
                int perm = qd.getPerm();
                perm &= ~PermName.PERM_WRITE;
                qd.setPerm(perm);
                wipeTopicCnt++;
            }
        }
    }

    return wipeTopicCnt;
}
 
Example #6
Source File: RouteInfoManager.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
private int wipeWritePermOfBroker(final String brokerName) {
    int wipeTopicCnt = 0;
    Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator();
    while (itTopic.hasNext()) {
        Entry<String, List<QueueData>> entry = itTopic.next();
        List<QueueData> qdList = entry.getValue();

        Iterator<QueueData> it = qdList.iterator();
        while (it.hasNext()) {
            QueueData qd = it.next();
            if (qd.getBrokerName().equals(brokerName)) {
                int perm = qd.getPerm();
                perm &= ~PermName.PERM_WRITE;
                qd.setPerm(perm);
                wipeTopicCnt++;
            }
        }
    }

    return wipeTopicCnt;
}
 
Example #7
Source File: BrokerController.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public synchronized void registerBrokerAll(final boolean checkOrderConfig, boolean oneway, boolean forceRegister) {
    TopicConfigSerializeWrapper topicConfigWrapper = this.getTopicConfigManager().buildTopicConfigSerializeWrapper();

    if (!PermName.isWriteable(this.getBrokerConfig().getBrokerPermission())
        || !PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) {
        ConcurrentHashMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>();
        for (TopicConfig topicConfig : topicConfigWrapper.getTopicConfigTable().values()) {
            TopicConfig tmp =
                new TopicConfig(topicConfig.getTopicName(), topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(),
                    this.brokerConfig.getBrokerPermission());
            topicConfigTable.put(topicConfig.getTopicName(), tmp);
        }
        topicConfigWrapper.setTopicConfigTable(topicConfigTable);
    }

    if (forceRegister || needRegister(this.brokerConfig.getBrokerClusterName(),
        this.getBrokerAddr(),
        this.brokerConfig.getBrokerName(),
        this.brokerConfig.getBrokerId(),
        this.brokerConfig.getRegisterBrokerTimeoutMills())) {
        doRegisterBrokerAll(checkOrderConfig, oneway, topicConfigWrapper);
    }
}
 
Example #8
Source File: RouteInfoManager.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private int wipeWritePermOfBroker(final String brokerName) {
    int wipeTopicCnt = 0;
    Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator();
    while (itTopic.hasNext()) {
        Entry<String, List<QueueData>> entry = itTopic.next();
        List<QueueData> qdList = entry.getValue();

        Iterator<QueueData> it = qdList.iterator();
        while (it.hasNext()) {
            QueueData qd = it.next();
            if (qd.getBrokerName().equals(brokerName)) {
                int perm = qd.getPerm();
                perm &= ~PermName.PERM_WRITE;
                qd.setPerm(perm);
                wipeTopicCnt++;
            }
        }
    }

    return wipeTopicCnt;
}
 
Example #9
Source File: DefaultTransactionalMessageCheckListener.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private MessageExtBrokerInner toMessageExtBrokerInner(MessageExt msgExt) {
    TopicConfig topicConfig = this.getBrokerController().getTopicConfigManager().createTopicOfTranCheckMaxTime(TCMT_QUEUE_NUMS, PermName.PERM_READ | PermName.PERM_WRITE);
    int queueId = Math.abs(random.nextInt() % 99999999) % TCMT_QUEUE_NUMS;
    MessageExtBrokerInner inner = new MessageExtBrokerInner();
    inner.setTopic(topicConfig.getTopicName());
    inner.setBody(msgExt.getBody());
    inner.setFlag(msgExt.getFlag());
    MessageAccessor.setProperties(inner, msgExt.getProperties());
    inner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties()));
    inner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(msgExt.getTags()));
    inner.setQueueId(queueId);
    inner.setSysFlag(msgExt.getSysFlag());
    inner.setBornHost(msgExt.getBornHost());
    inner.setBornTimestamp(msgExt.getBornTimestamp());
    inner.setStoreHost(msgExt.getStoreHost());
    inner.setReconsumeTimes(msgExt.getReconsumeTimes());
    inner.setMsgId(msgExt.getMsgId());
    inner.setWaitStoreMsgOK(false);
    return inner;
}
 
Example #10
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private int wipeWritePermOfBroker(final String brokerName) {
    int wipeTopicCnt = 0;
    Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator();
    while (itTopic.hasNext()) {
        Entry<String, List<QueueData>> entry = itTopic.next();
        List<QueueData> qdList = entry.getValue();

        Iterator<QueueData> it = qdList.iterator();
        while (it.hasNext()) {
            QueueData qd = it.next();
            if (qd.getBrokerName().equals(brokerName)) {
                int perm = qd.getPerm();
                perm &= ~PermName.PERM_WRITE;
                qd.setPerm(perm);
                wipeTopicCnt++;
            }
        }
    }

    return wipeTopicCnt;
}
 
Example #11
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private int wipeWritePermOfBroker(final String brokerName) {
    int wipeTopicCnt = 0;
    Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator();
    while (itTopic.hasNext()) {
        Entry<String, List<QueueData>> entry = itTopic.next();
        List<QueueData> qdList = entry.getValue();

        Iterator<QueueData> it = qdList.iterator();
        while (it.hasNext()) {
            QueueData qd = it.next();
            if (qd.getBrokerName().equals(brokerName)) {
                int perm = qd.getPerm();
                perm &= ~PermName.PERM_WRITE;
                qd.setPerm(perm);
                wipeTopicCnt++;
            }
        }
    }

    return wipeTopicCnt;
}
 
Example #12
Source File: TopicConfig.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
        + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
        + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
        + order + "]";
}
 
Example #13
Source File: MQClientInstance.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public static Set<MessageQueue> topicRouteData2TopicSubscribeInfo(final String topic, final TopicRouteData route) {
    Set<MessageQueue> mqList = new HashSet<MessageQueue>();
    List<QueueData> qds = route.getQueueDatas();
    for (QueueData qd : qds) {
        if (PermName.isReadable(qd.getPerm())) {
            for (int i = 0; i < qd.getReadQueueNums(); i++) {
                MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
                mqList.add(mq);
            }
        }
    }

    return mqList;
}
 
Example #14
Source File: Utils.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public static boolean isBrokerTopicWritable(String cluster, String nameSvr, String address/* broker Address */) {

        try {
            DefaultMQAdminExt adminExt = getMQAdminExt(nameSvr, cluster);
            String brokerPermission = adminExt.getBrokerConfig(address).getProperty("brokerPermission");
            if (!PermName.isWriteable(Integer.parseInt(brokerPermission))) {
                logger.info("skip send because of broker brokerPermission={}. cluster={}, namesvr={}, address={}",
                        brokerPermission, cluster, nameSvr, address);
                return false;
            }
            TopicRouteData topicRouteInfo = adminExt.examineTopicRouteInfo("SELF_TEST_TOPIC");

            String brokerName = null;
            for (BrokerData brokerData : topicRouteInfo.getBrokerDatas()) {
                if (StringUtils.equals(brokerData.getBrokerAddrs().get(0L), address)) {
                    brokerName = brokerData.getBrokerName();
                    break;
                }
            }
            if (brokerName != null) {
                for (QueueData queueData : topicRouteInfo.getQueueDatas()) {
                    if (StringUtils.equals(queueData.getBrokerName(), brokerName)) {
                        if (queueData.getWriteQueueNums() == 0 || !PermName.isWriteable(queueData.getPerm())) {
                            logger.info("skip send because of queue.Permission={},queue.writeQNuum={}. cluster={}, namesvr={}, address={}",
                                    queueData.getPerm(), queueData.getWriteQueueNums(), cluster, nameSvr, address);
                            return false;
                        }
                        break;
                    }
                }
            }
        } catch (Exception e) {
            logger.error("exception in isBrokerTopicWritable, cluster={}, namesvr={}, address={}", cluster, nameSvr, address, e);
        }
        return true;
    }
 
Example #15
Source File: SendMessageProcessor.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private RemotingCommand msgCheckWithMultiTopic(ChannelHandlerContext ctx, SendMessageRequestHeader requestHeader,
    RemotingCommand response, String[] topics) {
    for (String topic : topics) {
        if (!PermName.isWriteable(this.brokerController.getBrokerConfig().getBrokerPermission())
            && this.brokerController.getTopicConfigManager().isOrderTopic(topic)) {
            response.setCode(ResponseCode.NO_PERMISSION);
            response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1()
                + "] sending message is forbidden");
            return response;
        }
        if (!this.brokerController.getTopicConfigManager().isTopicCanSendMessage(topic)) {
            String errorMsg = "the topic[" + topic + "] is conflict with system reserved words.";
            log.warn(errorMsg);
            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark(errorMsg);
            return response;
        }

        TopicConfig topicConfig =
            this.brokerController.getTopicConfigManager().selectTopicConfig(topic);

        if (null == topicConfig) {
            response.setCode(ResponseCode.TOPIC_NOT_EXIST);
            response.setRemark("topic[" + requestHeader.getTopic() + "] not exist, apply first please!"
                + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
            return response;
        }

    }
    return response;
}
 
Example #16
Source File: TopicConfig.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
        + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
        + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
        + order + "]";
}
 
Example #17
Source File: TopicConfig.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
        + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
        + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
        + order + "]";
}
 
Example #18
Source File: MQClientInstance.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public static Set<MessageQueue> topicRouteData2TopicSubscribeInfo(final String topic, final TopicRouteData route) {
    Set<MessageQueue> mqList = new HashSet<MessageQueue>();
    List<QueueData> qds = route.getQueueDatas();
    for (QueueData qd : qds) {
        if (PermName.isReadable(qd.getPerm())) {
            for (int i = 0; i < qd.getReadQueueNums(); i++) {
                MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
                mqList.add(mq);
            }
        }
    }

    return mqList;
}
 
Example #19
Source File: Utils.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public static boolean isBrokerTopicWritable(String cluster, String nameSvr, String address/* broker Address */) {

        try {
            DefaultMQAdminExt adminExt = getMQAdminExt(nameSvr, cluster);
            String brokerPermission = adminExt.getBrokerConfig(address).getProperty("brokerPermission");
            if (!PermName.isWriteable(Integer.parseInt(brokerPermission))) {
                logger.info("skip send because of broker brokerPermission={}. cluster={}, namesvr={}, address={}",
                        brokerPermission, cluster, nameSvr, address);
                return false;
            }
            TopicRouteData topicRouteInfo = adminExt.examineTopicRouteInfo("SELF_TEST_TOPIC");

            String brokerName = null;
            for (BrokerData brokerData : topicRouteInfo.getBrokerDatas()) {
                if (StringUtils.equals(brokerData.getBrokerAddrs().get(0L), address)) {
                    brokerName = brokerData.getBrokerName();
                    break;
                }
            }
            if (brokerName != null) {
                for (QueueData queueData : topicRouteInfo.getQueueDatas()) {
                    if (StringUtils.equals(queueData.getBrokerName(), brokerName)) {
                        if (queueData.getWriteQueueNums() == 0 || !PermName.isWriteable(queueData.getPerm())) {
                            logger.info("skip send because of queue.Permission={},queue.writeQNuum={}. cluster={}, namesvr={}, address={}",
                                    queueData.getPerm(), queueData.getWriteQueueNums(), cluster, nameSvr, address);
                            return false;
                        }
                        break;
                    }
                }
            }
        } catch (Exception e) {
            logger.error("exception in isBrokerTopicWritable, cluster={}, namesvr={}, address={}", cluster, nameSvr, address, e);
        }
        return true;
    }
 
Example #20
Source File: MQClientInstance.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public static Set<MessageQueue> topicRouteData2TopicSubscribeInfo(final String topic, final TopicRouteData route) {
    Set<MessageQueue> mqList = new HashSet<MessageQueue>();
    List<QueueData> qds = route.getQueueDatas();
    for (QueueData qd : qds) {
        if (PermName.isReadable(qd.getPerm())) {
            for (int i = 0; i < qd.getReadQueueNums(); i++) {
                MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
                mqList.add(mq);
            }
        }
    }

    return mqList;
}
 
Example #21
Source File: BrokerController.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public synchronized void registerBrokerAll(final boolean checkOrderConfig, boolean oneway) {
    TopicConfigSerializeWrapper topicConfigWrapper = this.getTopicConfigManager().buildTopicConfigSerializeWrapper();

    if (!PermName.isWriteable(this.getBrokerConfig().getBrokerPermission())
            || !PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) {
        ConcurrentHashMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>();
        for (TopicConfig topicConfig : topicConfigWrapper.getTopicConfigTable().values()) {
            TopicConfig tmp =
                    new TopicConfig(topicConfig.getTopicName(), topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(),
                            this.brokerConfig.getBrokerPermission());
            topicConfigTable.put(topicConfig.getTopicName(), tmp);
        }
        topicConfigWrapper.setTopicConfigTable(topicConfigTable);
    }

    RegisterBrokerResult registerBrokerResult = this.brokerOuterAPI.registerBrokerAll(
            this.brokerConfig.getBrokerClusterName(),
            this.getBrokerAddr(),
            this.brokerConfig.getBrokerName(),
            this.brokerConfig.getBrokerId(),
            this.getHAServerAddr(),
            topicConfigWrapper,
            this.filterServerManager.buildNewFilterServerList(),
            oneway,
            this.brokerConfig.getRegisterBrokerTimeoutMills());

    if (registerBrokerResult != null) {
        if (this.updateMasterHAServerAddrPeriodically && registerBrokerResult.getHaServerAddr() != null) {
            this.messageStore.updateHaMasterAddress(registerBrokerResult.getHaServerAddr());
        }

        this.slaveSynchronize.setMasterAddr(registerBrokerResult.getMasterAddr());

        if (checkOrderConfig) {
            this.getTopicConfigManager().updateOrderTopicConfig(registerBrokerResult.getKvTable());
        }
    }
}
 
Example #22
Source File: TopicConfig.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
        + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
        + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
        + order + "]";
}
 
Example #23
Source File: MQClientInstance.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public static Set<MessageQueue> topicRouteData2TopicSubscribeInfo(final String topic, final TopicRouteData route) {
    Set<MessageQueue> mqList = new HashSet<MessageQueue>();
    List<QueueData> qds = route.getQueueDatas();
    for (QueueData qd : qds) {
        if (PermName.isReadable(qd.getPerm())) {
            for (int i = 0; i < qd.getReadQueueNums(); i++) {
                MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
                mqList.add(mq);
            }
        }
    }

    return mqList;
}
 
Example #24
Source File: TransactionalMessageBridge.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private TopicConfig selectTopicConfig(String topic) {
    TopicConfig topicConfig = brokerController.getTopicConfigManager().selectTopicConfig(topic);
    if (topicConfig == null) {
        topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(
            topic, 1, PermName.PERM_WRITE | PermName.PERM_READ, 0);
    }
    return topicConfig;
}
 
Example #25
Source File: AdminBrokerProcessorTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private RemotingCommand buildCreateTopicRequest(String topic) {
    CreateTopicRequestHeader requestHeader = new CreateTopicRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setTopicFilterType(TopicFilterType.SINGLE_TAG.name());
    requestHeader.setReadQueueNums(8);
    requestHeader.setWriteQueueNums(8);
    requestHeader.setPerm(PermName.PERM_READ | PermName.PERM_WRITE);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC, requestHeader);
    request.makeCustomHeaderToNet();
    return request;
}
 
Example #26
Source File: TopicConfig.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
        + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
        + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
        + order + "]";
}
 
Example #27
Source File: TopicConfig.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
        + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
        + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
        + order + "]";
}
 
Example #28
Source File: MQClientInstance.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public static Set<MessageQueue> topicRouteData2TopicSubscribeInfo(final String topic, final TopicRouteData route) {
    Set<MessageQueue> mqList = new HashSet<MessageQueue>();
    List<QueueData> qds = route.getQueueDatas();
    for (QueueData qd : qds) {
        if (PermName.isReadable(qd.getPerm())) {
            for (int i = 0; i < qd.getReadQueueNums(); i++) {
                MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
                mqList.add(mq);
            }
        }
    }

    return mqList;
}
 
Example #29
Source File: SendMessageProcessor.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private RemotingCommand msgCheckWithMultiTopic(ChannelHandlerContext ctx, SendMessageRequestHeader requestHeader,
    RemotingCommand response, String[] topics) {
    for (String topic : topics) {
        if (!PermName.isWriteable(this.brokerController.getBrokerConfig().getBrokerPermission())
            && this.brokerController.getTopicConfigManager().isOrderTopic(topic)) {
            response.setCode(ResponseCode.NO_PERMISSION);
            response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1()
                + "] sending message is forbidden");
            return response;
        }
        if (!this.brokerController.getTopicConfigManager().isTopicCanSendMessage(topic)) {
            String errorMsg = "the topic[" + topic + "] is conflict with system reserved words.";
            log.warn(errorMsg);
            response.setCode(ResponseCode.SYSTEM_ERROR);
            response.setRemark(errorMsg);
            return response;
        }

        TopicConfig topicConfig =
            this.brokerController.getTopicConfigManager().selectTopicConfig(topic);

        if (null == topicConfig) {
            response.setCode(ResponseCode.TOPIC_NOT_EXIST);
            response.setRemark("topic[" + requestHeader.getTopic() + "] not exist, apply first please!"
                + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
            return response;
        }

    }
    return response;
}
 
Example #30
Source File: TopicConfig.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
        + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
        + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
        + order + "]";
}