Search in sources :

Example 1 with UnlockBatchRequestBody

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

the class RebalanceImpl method unlock.

public void unlock(final MessageQueue mq, final boolean oneway) {
    FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(), MixAll.MASTER_ID, true);
    if (findBrokerResult != null) {
        UnlockBatchRequestBody requestBody = new UnlockBatchRequestBody();
        requestBody.setConsumerGroup(this.consumerGroup);
        requestBody.setClientId(this.mQClientFactory.getClientId());
        requestBody.getMqSet().add(mq);
        try {
            this.mQClientFactory.getMQClientAPIImpl().unlockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000, oneway);
            // 
            log.warn(// 
            "unlock messageQueue. group:{}, clientId:{}, mq:{}", // 
            this.consumerGroup, // 
            this.mQClientFactory.getClientId(), mq);
        } catch (Exception e) {
            log.error("unlockBatchMQ exception, " + mq, e);
        }
    }
}
Also used : FindBrokerResult(org.apache.rocketmq.client.impl.FindBrokerResult) UnlockBatchRequestBody(org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody)

Example 2 with UnlockBatchRequestBody

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

the class AdminBrokerProcessor method unlockBatchMQ.

private RemotingCommand unlockBatchMQ(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    UnlockBatchRequestBody requestBody = UnlockBatchRequestBody.decode(request.getBody(), UnlockBatchRequestBody.class);
    // 
    this.brokerController.getRebalanceLockManager().unlockBatch(// 
    requestBody.getConsumerGroup(), // 
    requestBody.getMqSet(), requestBody.getClientId());
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) UnlockBatchRequestBody(org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody)

Example 3 with UnlockBatchRequestBody

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

the class RebalanceImpl method unlockAll.

public void unlockAll(final boolean oneway) {
    HashMap<String, Set<MessageQueue>> brokerMqs = this.buildProcessQueueTableByBrokerName();
    for (final Map.Entry<String, Set<MessageQueue>> entry : brokerMqs.entrySet()) {
        final String brokerName = entry.getKey();
        final Set<MessageQueue> mqs = entry.getValue();
        if (mqs.isEmpty())
            continue;
        FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(brokerName, MixAll.MASTER_ID, true);
        if (findBrokerResult != null) {
            UnlockBatchRequestBody requestBody = new UnlockBatchRequestBody();
            requestBody.setConsumerGroup(this.consumerGroup);
            requestBody.setClientId(this.mQClientFactory.getClientId());
            requestBody.setMqSet(mqs);
            try {
                this.mQClientFactory.getMQClientAPIImpl().unlockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000, oneway);
                for (MessageQueue mq : mqs) {
                    ProcessQueue processQueue = this.processQueueTable.get(mq);
                    if (processQueue != null) {
                        processQueue.setLocked(false);
                        log.info("the message queue unlock OK, Group: {} {}", this.consumerGroup, mq);
                    }
                }
            } catch (Exception e) {
                log.error("unlockBatchMQ exception, " + mqs, e);
            }
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) FindBrokerResult(org.apache.rocketmq.client.impl.FindBrokerResult) UnlockBatchRequestBody(org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody)

Example 4 with UnlockBatchRequestBody

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

the class RebalanceImpl method unlockAll.

public void unlockAll(final boolean oneway) {
    HashMap<String, Set<MessageQueue>> brokerMqs = this.buildProcessQueueTableByBrokerName();
    for (final Map.Entry<String, Set<MessageQueue>> entry : brokerMqs.entrySet()) {
        final String brokerName = entry.getKey();
        final Set<MessageQueue> mqs = entry.getValue();
        if (mqs.isEmpty())
            continue;
        FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(brokerName, MixAll.MASTER_ID, true);
        if (findBrokerResult != null) {
            UnlockBatchRequestBody requestBody = new UnlockBatchRequestBody();
            requestBody.setConsumerGroup(this.consumerGroup);
            requestBody.setClientId(this.mQClientFactory.getClientId());
            requestBody.setMqSet(mqs);
            try {
                this.mQClientFactory.getMQClientAPIImpl().unlockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000, oneway);
                for (MessageQueue mq : mqs) {
                    ProcessQueue processQueue = this.processQueueTable.get(mq);
                    if (processQueue != null) {
                        processQueue.setLocked(false);
                        log.info("the message queue unlock OK, Group: {} {}", this.consumerGroup, mq);
                    }
                }
            } catch (Exception e) {
                log.error("unlockBatchMQ exception, " + mqs, e);
            }
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) FindBrokerResult(org.apache.rocketmq.client.impl.FindBrokerResult) UnlockBatchRequestBody(org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody)

Example 5 with UnlockBatchRequestBody

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

the class RebalanceImpl method unlock.

public void unlock(final MessageQueue mq, final boolean oneway) {
    FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(), MixAll.MASTER_ID, true);
    if (findBrokerResult != null) {
        UnlockBatchRequestBody requestBody = new UnlockBatchRequestBody();
        requestBody.setConsumerGroup(this.consumerGroup);
        requestBody.setClientId(this.mQClientFactory.getClientId());
        requestBody.getMqSet().add(mq);
        try {
            this.mQClientFactory.getMQClientAPIImpl().unlockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000, oneway);
            log.warn("unlock messageQueue. group:{}, clientId:{}, mq:{}", this.consumerGroup, this.mQClientFactory.getClientId(), mq);
        } catch (Exception e) {
            log.error("unlockBatchMQ exception, " + mq, e);
        }
    }
}
Also used : FindBrokerResult(org.apache.rocketmq.client.impl.FindBrokerResult) UnlockBatchRequestBody(org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody)

Aggregations

UnlockBatchRequestBody (org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody)6 FindBrokerResult (org.apache.rocketmq.client.impl.FindBrokerResult)4 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)2 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)2