use of org.apache.rocketmq.common.protocol.body.TopicList in project rocketmq by apache.
the class BrokerLiveInfo method getHasUnitSubTopicList.
public byte[] getHasUnitSubTopicList() {
TopicList topicList = new TopicList();
try {
try {
this.lock.readLock().lockInterruptibly();
Iterator<Entry<String, List<QueueData>>> topicTableIt = this.topicQueueTable.entrySet().iterator();
while (topicTableIt.hasNext()) {
Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
String topic = topicEntry.getKey();
List<QueueData> queueDatas = topicEntry.getValue();
if (queueDatas != null && queueDatas.size() > 0 && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
topicList.getTopicList().add(topic);
}
}
} finally {
this.lock.readLock().unlock();
}
} catch (Exception e) {
log.error("getAllTopicList Exception", e);
}
return topicList.encode();
}
use of org.apache.rocketmq.common.protocol.body.TopicList in project rocketmq by apache.
the class BrokerLiveInfo method getUnitTopics.
public byte[] getUnitTopics() {
TopicList topicList = new TopicList();
try {
try {
this.lock.readLock().lockInterruptibly();
Iterator<Entry<String, List<QueueData>>> topicTableIt = this.topicQueueTable.entrySet().iterator();
while (topicTableIt.hasNext()) {
Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
String topic = topicEntry.getKey();
List<QueueData> queueDatas = topicEntry.getValue();
if (queueDatas != null && queueDatas.size() > 0 && TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())) {
topicList.getTopicList().add(topic);
}
}
} finally {
this.lock.readLock().unlock();
}
} catch (Exception e) {
log.error("getAllTopicList Exception", e);
}
return topicList.encode();
}
use of org.apache.rocketmq.common.protocol.body.TopicList in project rocketmq by apache.
the class MQClientAPIImpl method getUnitTopicList.
public TopicList getUnitTopicList(final boolean containRetry, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_UNIT_TOPIC_LIST, null);
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(response.getBody(), TopicList.class);
if (!containRetry) {
Iterator<String> it = topicList.getTopicList().iterator();
while (it.hasNext()) {
String topic = it.next();
if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
it.remove();
}
}
return topicList;
}
}
default:
break;
}
throw new MQClientException(response.getCode(), response.getRemark());
}
use of org.apache.rocketmq.common.protocol.body.TopicList in project rocketmq by apache.
the class MQClientAPIImpl method getHasUnitSubTopicList.
public TopicList getHasUnitSubTopicList(final boolean containRetry, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_HAS_UNIT_SUB_TOPIC_LIST, null);
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(response.getBody(), TopicList.class);
if (!containRetry) {
Iterator<String> it = topicList.getTopicList().iterator();
while (it.hasNext()) {
String topic = it.next();
if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
it.remove();
}
}
return topicList;
}
}
default:
break;
}
throw new MQClientException(response.getCode(), response.getRemark());
}
use of org.apache.rocketmq.common.protocol.body.TopicList 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());
}
Aggregations