Search in sources :

Example 1 with GetProducerConnectionListRequestHeader

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

the class AdminBrokerProcessor method getProducerConnectionList.

private RemotingCommand getProducerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetProducerConnectionListRequestHeader requestHeader = (GetProducerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);
    ProducerConnection bodydata = new ProducerConnection();
    HashMap<Channel, ClientChannelInfo> channelInfoHashMap = this.brokerController.getProducerManager().getGroupChannelTable().get(requestHeader.getProducerGroup());
    if (channelInfoHashMap != null) {
        Iterator<Map.Entry<Channel, ClientChannelInfo>> it = channelInfoHashMap.entrySet().iterator();
        while (it.hasNext()) {
            ClientChannelInfo info = it.next().getValue();
            Connection connection = new Connection();
            connection.setClientId(info.getClientId());
            connection.setLanguage(info.getLanguage());
            connection.setVersion(info.getVersion());
            connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));
            bodydata.getConnectionSet().add(connection);
        }
        byte[] body = bodydata.encode();
        response.setBody(body);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }
    response.setCode(ResponseCode.SYSTEM_ERROR);
    response.setRemark("the producer group[" + requestHeader.getProducerGroup() + "] not exist");
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ClientChannelInfo(org.apache.rocketmq.broker.client.ClientChannelInfo) GetProducerConnectionListRequestHeader(org.apache.rocketmq.common.protocol.header.GetProducerConnectionListRequestHeader) Channel(io.netty.channel.Channel) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) Connection(org.apache.rocketmq.common.protocol.body.Connection) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection)

Example 2 with GetProducerConnectionListRequestHeader

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

the class AdminBrokerProcessor method getProducerConnectionList.

private RemotingCommand getProducerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetProducerConnectionListRequestHeader requestHeader = (GetProducerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);
    ProducerConnection bodydata = new ProducerConnection();
    HashMap<Channel, ClientChannelInfo> channelInfoHashMap = this.brokerController.getProducerManager().getGroupChannelTable().get(requestHeader.getProducerGroup());
    if (channelInfoHashMap != null) {
        Iterator<Map.Entry<Channel, ClientChannelInfo>> it = channelInfoHashMap.entrySet().iterator();
        while (it.hasNext()) {
            ClientChannelInfo info = it.next().getValue();
            Connection connection = new Connection();
            connection.setClientId(info.getClientId());
            connection.setLanguage(info.getLanguage());
            connection.setVersion(info.getVersion());
            connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));
            bodydata.getConnectionSet().add(connection);
        }
        byte[] body = bodydata.encode();
        response.setBody(body);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }
    response.setCode(ResponseCode.SYSTEM_ERROR);
    response.setRemark("the producer group[" + requestHeader.getProducerGroup() + "] not exist");
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) ClientChannelInfo(org.apache.rocketmq.broker.client.ClientChannelInfo) GetProducerConnectionListRequestHeader(org.apache.rocketmq.common.protocol.header.GetProducerConnectionListRequestHeader) Channel(io.netty.channel.Channel) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) Connection(org.apache.rocketmq.common.protocol.body.Connection) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection)

Example 3 with GetProducerConnectionListRequestHeader

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

the class MQClientAPIImpl method getProducerConnectionList.

public ProducerConnection getProducerConnectionList(final String addr, final String producerGroup, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
    GetProducerConnectionListRequestHeader requestHeader = new GetProducerConnectionListRequestHeader();
    requestHeader.setProducerGroup(producerGroup);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_PRODUCER_CONNECTION_LIST, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                return ProducerConnection.decode(response.getBody(), ProducerConnection.class);
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetProducerConnectionListRequestHeader(org.apache.rocketmq.common.protocol.header.GetProducerConnectionListRequestHeader) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection)

Example 4 with GetProducerConnectionListRequestHeader

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

the class MQClientAPIImpl method getProducerConnectionList.

public ProducerConnection getProducerConnectionList(final String addr, final String producerGroup, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
    GetProducerConnectionListRequestHeader requestHeader = new GetProducerConnectionListRequestHeader();
    requestHeader.setProducerGroup(producerGroup);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_PRODUCER_CONNECTION_LIST, requestHeader);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                return ProducerConnection.decode(response.getBody(), ProducerConnection.class);
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetProducerConnectionListRequestHeader(org.apache.rocketmq.common.protocol.header.GetProducerConnectionListRequestHeader) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) ProducerConnection(org.apache.rocketmq.common.protocol.body.ProducerConnection)

Aggregations

ProducerConnection (org.apache.rocketmq.common.protocol.body.ProducerConnection)4 GetProducerConnectionListRequestHeader (org.apache.rocketmq.common.protocol.header.GetProducerConnectionListRequestHeader)4 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)4 Channel (io.netty.channel.Channel)2 ClientChannelInfo (org.apache.rocketmq.broker.client.ClientChannelInfo)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 Connection (org.apache.rocketmq.common.protocol.body.Connection)2 ConsumerConnection (org.apache.rocketmq.common.protocol.body.ConsumerConnection)2