use of org.apache.rocketmq.common.protocol.route.QueueData in project rocketmq by apache.
the class BrokerLiveInfo method wipeWritePermOfBroker.
private int wipeWritePermOfBroker(final String brokerName) {
int wipeTopicCnt = 0;
Iterator<Entry<String, List<QueueData>>> itTopic = this.topicQueueTable.entrySet().iterator();
while (itTopic.hasNext()) {
Entry<String, List<QueueData>> entry = itTopic.next();
List<QueueData> qdList = entry.getValue();
Iterator<QueueData> it = qdList.iterator();
while (it.hasNext()) {
QueueData qd = it.next();
if (qd.getBrokerName().equals(brokerName)) {
int perm = qd.getPerm();
perm &= ~PermName.PERM_WRITE;
qd.setPerm(perm);
wipeTopicCnt++;
}
}
}
return wipeTopicCnt;
}
use of org.apache.rocketmq.common.protocol.route.QueueData in project rocketmq by apache.
the class DefaultMQAdminExtImpl method resetOffsetByTimestampOld.
@Override
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
List<RollbackStats> rollbackStatsList = new ArrayList<RollbackStats>();
Map<String, Integer> topicRouteMap = new HashMap<String, Integer>();
for (BrokerData bd : topicRouteData.getBrokerDatas()) {
for (QueueData queueData : topicRouteData.getQueueDatas()) {
topicRouteMap.put(bd.selectBrokerAddr(), queueData.getReadQueueNums());
}
}
for (BrokerData bd : topicRouteData.getBrokerDatas()) {
String addr = bd.selectBrokerAddr();
if (addr != null) {
ConsumeStats consumeStats = this.mqClientInstance.getMQClientAPIImpl().getConsumeStats(addr, consumerGroup, timeoutMillis);
boolean hasConsumed = false;
for (Map.Entry<MessageQueue, OffsetWrapper> entry : consumeStats.getOffsetTable().entrySet()) {
MessageQueue queue = entry.getKey();
OffsetWrapper offsetWrapper = entry.getValue();
if (topic.equals(queue.getTopic())) {
hasConsumed = true;
RollbackStats rollbackStats = resetOffsetConsumeOffset(addr, consumerGroup, queue, offsetWrapper, timestamp, force);
rollbackStatsList.add(rollbackStats);
}
}
if (!hasConsumed) {
HashMap<MessageQueue, TopicOffset> topicStatus = this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis).getOffsetTable();
for (int i = 0; i < topicRouteMap.get(addr); i++) {
MessageQueue queue = new MessageQueue(topic, bd.getBrokerName(), i);
OffsetWrapper offsetWrapper = new OffsetWrapper();
offsetWrapper.setBrokerOffset(topicStatus.get(queue).getMaxOffset());
offsetWrapper.setConsumerOffset(topicStatus.get(queue).getMinOffset());
RollbackStats rollbackStats = resetOffsetConsumeOffset(addr, consumerGroup, queue, offsetWrapper, timestamp, force);
rollbackStatsList.add(rollbackStats);
}
}
}
}
return rollbackStatsList;
}
Aggregations