Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-9902][Manager] Data preview supports pulsar multi cluster #9903

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
Expand Down Expand Up @@ -304,11 +305,11 @@ public List<BriefMQMessage> queryLatestMessages(InlongGroupInfo groupInfo,
InlongStreamInfo streamInfo, Integer messageCount) throws Exception {
String groupId = streamInfo.getInlongGroupId();
InlongPulsarInfo inlongPulsarInfo = ((InlongPulsarInfo) groupInfo);
PulsarClusterInfo pulsarCluster = (PulsarClusterInfo) clusterService.getOne(groupInfo.getInlongClusterTag(),
null, ClusterType.PULSAR);
List<ClusterInfo> pulsarClusterList =
clusterService.listByTagAndType(groupInfo.getInlongClusterTag(), ClusterType.PULSAR);
String tenant = inlongPulsarInfo.getPulsarTenant();
if (StringUtils.isBlank(tenant)) {
tenant = pulsarCluster.getPulsarTenant();
if (StringUtils.isBlank(tenant) && CollectionUtils.isNotEmpty(pulsarClusterList)) {
tenant = ((PulsarClusterInfo) pulsarClusterList.get(0)).getPulsarTenant();
}

String namespace = groupInfo.getMqResource();
Expand All @@ -317,8 +318,14 @@ public List<BriefMQMessage> queryLatestMessages(InlongGroupInfo groupInfo,
String clusterTag = inlongPulsarInfo.getInlongClusterTag();
String subs = String.format(PULSAR_SUBSCRIPTION_REALTIME_REVIEW, clusterTag, topicName);
boolean serial = InlongConstants.PULSAR_QUEUE_TYPE_SERIAL.equals(inlongPulsarInfo.getQueueModule());
List<BriefMQMessage> briefMQMessages = pulsarOperator.queryLatestMessage(pulsarCluster, fullTopicName, subs,
messageCount, streamInfo, serial);
List<BriefMQMessage> briefMQMessages = new ArrayList<>();
for (ClusterInfo clusterInfo : pulsarClusterList) {
briefMQMessages = pulsarOperator.queryLatestMessage((PulsarClusterInfo) clusterInfo, fullTopicName, subs,
messageCount, streamInfo, serial);
if (CollectionUtils.isNotEmpty(briefMQMessages)) {
break;
}
}

// insert the consumer group info into the inlong_consume table
Integer id = consumeService.saveBySystem(groupInfo, topicName, subs);
Expand Down
Loading