Search in sources :

Example 1 with LockBatchResponseBody

use of org.apache.rocketmq.common.protocol.body.LockBatchResponseBody in project rocketmq by apache.

the class MQClientAPIImpl method lockBatchMQ.

public Set<MessageQueue> lockBatchMQ(final String addr, final LockBatchRequestBody requestBody, final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.LOCK_BATCH_MQ, null);
    request.setBody(requestBody.encode());
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                LockBatchResponseBody responseBody = LockBatchResponseBody.decode(response.getBody(), LockBatchResponseBody.class);
                Set<MessageQueue> messageQueues = responseBody.getLockOKMQSet();
                return messageQueues;
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) Set(java.util.Set) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) LockBatchResponseBody(org.apache.rocketmq.common.protocol.body.LockBatchResponseBody)

Example 2 with LockBatchResponseBody

use of org.apache.rocketmq.common.protocol.body.LockBatchResponseBody in project rocketmq by apache.

the class AdminBrokerProcessor method lockBatchMQ.

private RemotingCommand lockBatchMQ(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    LockBatchRequestBody requestBody = LockBatchRequestBody.decode(request.getBody(), LockBatchRequestBody.class);
    Set<MessageQueue> lockOKMQSet = this.brokerController.getRebalanceLockManager().tryLockBatch(requestBody.getConsumerGroup(), requestBody.getMqSet(), requestBody.getClientId());
    LockBatchResponseBody responseBody = new LockBatchResponseBody();
    responseBody.setLockOKMQSet(lockOKMQSet);
    response.setBody(responseBody.encode());
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) LockBatchResponseBody(org.apache.rocketmq.common.protocol.body.LockBatchResponseBody) LockBatchRequestBody(org.apache.rocketmq.common.protocol.body.LockBatchRequestBody)

Example 3 with LockBatchResponseBody

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

the class AdminBrokerProcessor method lockBatchMQ.

private RemotingCommand lockBatchMQ(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    LockBatchRequestBody requestBody = LockBatchRequestBody.decode(request.getBody(), LockBatchRequestBody.class);
    Set<MessageQueue> lockOKMQSet = // 
    this.brokerController.getRebalanceLockManager().tryLockBatch(// 
    requestBody.getConsumerGroup(), // 
    requestBody.getMqSet(), requestBody.getClientId());
    LockBatchResponseBody responseBody = new LockBatchResponseBody();
    responseBody.setLockOKMQSet(lockOKMQSet);
    response.setBody(responseBody.encode());
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) LockBatchResponseBody(org.apache.rocketmq.common.protocol.body.LockBatchResponseBody) LockBatchRequestBody(org.apache.rocketmq.common.protocol.body.LockBatchRequestBody)

Example 4 with LockBatchResponseBody

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

the class MQClientAPIImpl method lockBatchMQ.

public // 
Set<MessageQueue> lockBatchMQ(// 
final String addr, // 
final LockBatchRequestBody requestBody, final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.LOCK_BATCH_MQ, null);
    request.setBody(requestBody.encode());
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                LockBatchResponseBody responseBody = LockBatchResponseBody.decode(response.getBody(), LockBatchResponseBody.class);
                Set<MessageQueue> messageQueues = responseBody.getLockOKMQSet();
                return messageQueues;
            }
        default:
            break;
    }
    throw new MQBrokerException(response.getCode(), response.getRemark());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) Set(java.util.Set) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) LockBatchResponseBody(org.apache.rocketmq.common.protocol.body.LockBatchResponseBody)

Aggregations

LockBatchResponseBody (org.apache.rocketmq.common.protocol.body.LockBatchResponseBody)4 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)4 Set (java.util.Set)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)2 LockBatchRequestBody (org.apache.rocketmq.common.protocol.body.LockBatchRequestBody)2