Search in sources :

Example 1 with GetTopicsByClusterRequestHeader

use of org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MQClientAPIImpl method getTopicsByCluster.

public TopicList getTopicsByCluster(final String cluster, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
    GetTopicsByClusterRequestHeader requestHeader = new GetTopicsByClusterRequestHeader();
    requestHeader.setCluster(cluster);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPICS_BY_CLUSTER, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                byte[] body = response.getBody();
                if (body != null) {
                    TopicList topicList = TopicList.decode(body, TopicList.class);
                    return topicList;
                }
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetTopicsByClusterRequestHeader(org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader) TopicList(org.apache.rocketmq.common.protocol.body.TopicList) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 2 with GetTopicsByClusterRequestHeader

use of org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader in project rocketmq by apache.

the class DefaultRequestProcessor method getTopicsByCluster.

private RemotingCommand getTopicsByCluster(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetTopicsByClusterRequestHeader requestHeader = (GetTopicsByClusterRequestHeader) request.decodeCommandCustomHeader(GetTopicsByClusterRequestHeader.class);
    byte[] body = this.namesrvController.getRouteInfoManager().getTopicsByCluster(requestHeader.getCluster());
    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetTopicsByClusterRequestHeader(org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader)

Example 3 with GetTopicsByClusterRequestHeader

use of org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader in project rocketmq by apache.

the class MQClientAPIImpl method getTopicsByCluster.

public TopicList getTopicsByCluster(final String cluster, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
    GetTopicsByClusterRequestHeader requestHeader = new GetTopicsByClusterRequestHeader();
    requestHeader.setCluster(cluster);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPICS_BY_CLUSTER, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                byte[] body = response.getBody();
                if (body != null) {
                    TopicList topicList = TopicList.decode(body, TopicList.class);
                    return topicList;
                }
            }
        default:
            break;
    }
    throw new MQClientException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetTopicsByClusterRequestHeader(org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader) TopicList(org.apache.rocketmq.common.protocol.body.TopicList) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 4 with GetTopicsByClusterRequestHeader

use of org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class DefaultRequestProcessor method getTopicsByCluster.

/**
 * 获取指定集群下的全部Topic列表
 */
private RemotingCommand getTopicsByCluster(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetTopicsByClusterRequestHeader requestHeader = (GetTopicsByClusterRequestHeader) request.decodeCommandCustomHeader(GetTopicsByClusterRequestHeader.class);
    byte[] body = this.namesrvController.getRouteInfoManager().getTopicsByCluster(requestHeader.getCluster());
    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetTopicsByClusterRequestHeader(org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader)

Aggregations

GetTopicsByClusterRequestHeader (org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader)4 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)4 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2 TopicList (org.apache.rocketmq.common.protocol.body.TopicList)2