Java Code Examples for org.apache.rocketmq.common.protocol.route.QueueData#getWriteQueueNums()

The following examples show how to use org.apache.rocketmq.common.protocol.route.QueueData#getWriteQueueNums() . 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: 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 2
Source File: TopicPublishInfo.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public int getQueueIdByBroker(final String brokerName) {
    for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
        final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
        if (queueData.getBrokerName().equals(brokerName)) {
            return queueData.getWriteQueueNums();
        }
    }

    return -1;
}
 
Example 3
Source File: TopicPublishInfo.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
public int getQueueIdByBroker(final String brokerName) {
    for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
        final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
        if (queueData.getBrokerName().equals(brokerName)) {
            return queueData.getWriteQueueNums();
        }
    }

    return -1;
}
 
Example 4
Source File: TopicPublishInfo.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
public int getQueueIdByBroker(final String brokerName) {
    for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
        final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
        if (queueData.getBrokerName().equals(brokerName)) {
            return queueData.getWriteQueueNums();
        }
    }

    return -1;
}
 
Example 5
Source File: TopicPublishInfo.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public int getQueueIdByBroker(final String brokerName) {
    for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
        final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
        if (queueData.getBrokerName().equals(brokerName)) {
            return queueData.getWriteQueueNums();
        }
    }

    return -1;
}
 
Example 6
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 7
Source File: TopicPublishInfo.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public int getQueueIdByBroker(final String brokerName) {
    for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
        final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
        if (queueData.getBrokerName().equals(brokerName)) {
            return queueData.getWriteQueueNums();
        }
    }

    return -1;
}
 
Example 8
Source File: TopicPublishInfo.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public int getQueueIdByBroker(final String brokerName) {
    for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
        final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
        if (queueData.getBrokerName().equals(brokerName)) {
            return queueData.getWriteQueueNums();
        }
    }

    return -1;
}
 
Example 9
Source File: TopicPublishInfo.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public int getQueueIdByBroker(final String brokerName) {
    for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
        final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
        if (queueData.getBrokerName().equals(brokerName)) {
            return queueData.getWriteQueueNums();
        }
    }

    return -1;
}
 
Example 10
Source File: TopicPublishInfo.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public int getQueueIdByBroker(final String brokerName) {
    for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
        final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
        if (queueData.getBrokerName().equals(brokerName)) {
            return queueData.getWriteQueueNums();
        }
    }

    return -1;
}