Skip to content
Open
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 @@ -45,8 +45,10 @@
import org.apache.doris.catalog.TableIf.TableType;
import org.apache.doris.catalog.Tablet;
import org.apache.doris.catalog.TabletMeta;
import org.apache.doris.cloud.catalog.CloudReplica;
import org.apache.doris.cloud.catalog.CloudTablet;
import org.apache.doris.cloud.proto.Cloud.CommitTxnResponse;
import org.apache.doris.cloud.system.CloudSystemInfoService;
import org.apache.doris.cluster.ClusterNamespace;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.AuthenticationException;
Expand Down Expand Up @@ -2302,6 +2304,19 @@ private String getClientAddrAsString() {
return addr == null ? "unknown" : addr.hostname;
}

private List<Backend> getAllCloudPrimaryBackends(CloudReplica cloudReplica) {
CloudSystemInfoService cloudSystemInfoService = (CloudSystemInfoService) Env.getCurrentSystemInfo();
List<Backend> backends = Lists.newArrayList();
Set<Long> backendIds = new HashSet<>();
for (String cloudClusterId : cloudSystemInfoService.getCloudClusterIds()) {
Backend primaryBackend = cloudReplica.getPrimaryBackend(cloudClusterId, true);
if (primaryBackend != null && backendIds.add(primaryBackend.getId())) {
backends.add(primaryBackend);
}
}
return backends;
}

@Override
public TWaitingTxnStatusResult waitingTxnStatus(TWaitingTxnStatusRequest request) throws TException {
TWaitingTxnStatusResult result = new TWaitingTxnStatusResult();
Expand Down Expand Up @@ -2668,15 +2683,24 @@ public TGetTabletReplicaInfosResult getTabletReplicaInfos(TGetTabletReplicaInfos
LOG.warn("replica {} not normal", replica.getId());
continue;
}
Backend backend = Env.getCurrentEnv().getCurrentSystemInfo().getBackend(replica.getBackendId());
if (backend != null) {
TReplicaInfo replicaInfo = new TReplicaInfo();
replicaInfo.setHost(backend.getHost());
replicaInfo.setBePort(backend.getBePort());
replicaInfo.setHttpPort(backend.getHttpPort());
replicaInfo.setBrpcPort(backend.getBrpcPort());
replicaInfo.setReplicaId(replica.getId());
replicaInfos.add(replicaInfo);
List<Backend> backends;
if (Config.isCloudMode()) {
CloudReplica cloudReplica = (CloudReplica) replica;
backends = getAllCloudPrimaryBackends(cloudReplica);
} else {
Backend backend = Env.getCurrentEnv().getCurrentSystemInfo().getBackend(replica.getBackendId());
backends = Lists.newArrayList(backend);
}
for (Backend backend : backends) {
if (backend != null) {
TReplicaInfo replicaInfo = new TReplicaInfo();
replicaInfo.setHost(backend.getHost());
replicaInfo.setBePort(backend.getBePort());
replicaInfo.setHttpPort(backend.getHttpPort());
replicaInfo.setBrpcPort(backend.getBrpcPort());
replicaInfo.setReplicaId(replica.getId());
replicaInfos.add(replicaInfo);
}
}
}
tabletReplicaInfos.put(tabletId, replicaInfos);
Expand Down
Loading