Skip to content
Open
Show file tree
Hide file tree
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 @@ -29,6 +29,7 @@
import org.apache.doris.common.util.NetUtils;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.nereids.trees.plans.commands.info.ModifyBrokerOp;
import org.apache.doris.nereids.util.HostUtils;
import org.apache.doris.persist.gson.GsonUtils;

import com.google.common.collect.ArrayListMultimap;
Expand All @@ -52,7 +53,7 @@
*/
public class BrokerMgr {
public static final ImmutableList<String> BROKER_PROC_NODE_TITLE_NAMES = new ImmutableList.Builder<String>()
.add("Name").add("Host").add("Port").add("Alive")
.add("Name").add("Host").add("IP").add("Port").add("Alive")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better append new column to the end for better compatibility.
it is the same for the other similar occurrences

Copy link
Contributor Author

@heguanhui heguanhui Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#60211
#60210
Because of this two bugs in these two PRs, if I put this IP field to the end, it will result in display incorrectly, or you can merge these two PRs firstly, then I can rebase and adjust this field to the end.

.add("LastStartTime").add("LastUpdateTime").add("ErrMsg")
.build();

Expand Down Expand Up @@ -387,6 +388,7 @@ public ProcResult fetchResult() {
List<String> row = Lists.newArrayList();
row.add(brokerName);
row.add(broker.host);
row.add(HostUtils.resolveHostToIp(broker.host));
row.add(String.valueOf(broker.port));
row.add(String.valueOf(broker.isAlive));
row.add(TimeUtils.longToTimeString(broker.lastStartTime));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.doris.common.util.DebugUtil;
import org.apache.doris.common.util.ListComparator;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.nereids.util.HostUtils;
import org.apache.doris.system.Backend;
import org.apache.doris.system.SystemInfoService;
import org.apache.doris.thrift.TUnit;
Expand All @@ -47,10 +48,10 @@ public class BackendsProcDir implements ProcDirInterface {

public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>().add("BackendId")
.add("Host").add("HeartbeatPort").add("BePort").add("HttpPort").add("BrpcPort").add("ArrowFlightSqlPort")
.add("LastStartTime").add("LastHeartbeat").add("Alive").add("SystemDecommissioned").add("TabletNum")
.add("DataUsedCapacity").add("TrashUsedCapacity").add("AvailCapacity").add("TotalCapacity").add("UsedPct")
.add("MaxDiskUsedPct").add("RemoteUsedCapacity").add("Tag").add("ErrMsg").add("Version").add("Status")
.add("HeartbeatFailureCounter").add("NodeRole").add("CpuCores").add("Memory").add("LiveSince")
.add("LastStartTime").add("LastHeartbeat").add("Alive").add("IP").add("SystemDecommissioned")
.add("TabletNum").add("DataUsedCapacity").add("TrashUsedCapacity").add("AvailCapacity").add("TotalCapacity")
.add("UsedPct").add("MaxDiskUsedPct").add("RemoteUsedCapacity").add("Tag").add("ErrMsg").add("Version")
.add("Status").add("HeartbeatFailureCounter").add("NodeRole").add("CpuCores").add("Memory").add("LiveSince")
.add("RunningTasks").build();

public static final ImmutableList<String> DISK_TITLE_NAMES = new ImmutableList.Builder<String>()
Expand Down Expand Up @@ -116,6 +117,7 @@ public static List<List<String>> getBackendInfos() {
backendInfo.add(TimeUtils.longToTimeString(backend.getLastStartTime()));
backendInfo.add(TimeUtils.longToTimeString(backend.getLastUpdateMs()));
backendInfo.add(String.valueOf(backend.isAlive()));
backendInfo.add(HostUtils.resolveHostToIp(backend.getHost()));
backendInfo.add(String.valueOf(backend.isDecommissioned()));
backendInfo.add(tabletNum.toString());

Expand Down Expand Up @@ -229,5 +231,4 @@ public ProcNodeInterface lookup(String beIdStr) throws AnalysisException {

return new BackendProcNode(backend);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.doris.common.Pair;
import org.apache.doris.common.io.DiskUtils;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.nereids.util.HostUtils;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.service.FeDiskInfo;
import org.apache.doris.system.Frontend;
Expand All @@ -47,13 +48,13 @@ public class FrontendsProcNode implements ProcNodeInterface {

public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>()
.add("Name").add("Host").add("EditLogPort").add("HttpPort").add("QueryPort").add("RpcPort")
.add("ArrowFlightSqlPort").add("Role").add("IsMaster").add("ClusterId").add("Join").add("Alive")
.add("ArrowFlightSqlPort").add("Role").add("IsMaster").add("ClusterId").add("Join").add("Alive").add("IP")
.add("ReplayedJournalId").add("LastStartTime").add("LastHeartbeat").add("IsHelper").add("ErrMsg")
.add("Version").add("CurrentConnected").add("LiveSince")
.build();

public static final ImmutableList<String> DISK_TITLE_NAMES = new ImmutableList.Builder<String>()
.add("Name").add("Host").add("DirType").add("Dir").add("Filesystem")
.add("Name").add("Host").add("IP").add("DirType").add("Dir").add("Filesystem")
.add("Capacity").add("Used").add("Available").add("UseRate").add("MountOn")
.build();

Expand Down Expand Up @@ -155,9 +156,11 @@ public static void getFrontendsInfo(Env env, List<List<String>> infos) {

if (fe.getHost().equals(env.getSelfNode().getHost())) {
info.add("true");
info.add(HostUtils.resolveHostToIp(fe.getHost()));
info.add(Long.toString(env.getEditLog().getMaxJournalId()));
} else {
info.add(String.valueOf(fe.isAlive()));
info.add(HostUtils.resolveHostToIp(fe.getHost()));
info.add(Long.toString(fe.getReplayedJournalId()));
}
info.add(TimeUtils.longToTimeString(fe.getLastStartupTime()));
Expand Down Expand Up @@ -189,6 +192,7 @@ public static void getFrontendsDiskInfo(Env env, List<List<String>> infos) {
List<String> info = new ArrayList<String>();
info.add(fe.getNodeName());
info.add(fe.getHost());
info.add(HostUtils.resolveHostToIp(fe.getHost()));
info.add(disk.getDirType());
info.add(disk.getDir());
info.add(disk.getSpaceInfo().fileSystem);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.doris.nereids.util;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.net.InetAddress;

/**
* HostUtils
*/
public class HostUtils {

private static final Logger LOG = LogManager.getLogger(HostUtils.class);

/**
* resolve ip from hostname
*/
public static String resolveHostToIp(String host) {
try {
InetAddress address = InetAddress.getByName(host);
return address.getHostAddress();
} catch (Exception e) {
LOG.warn("Failed to resolve host {} to IP: {}", host, e.getMessage());
return "Unknown";
}
}

}
2 changes: 2 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/system/Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.doris.common.util.DebugPointUtil;
import org.apache.doris.common.util.PrintableMap;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.nereids.util.HostUtils;
import org.apache.doris.persist.gson.GsonUtils;
import org.apache.doris.qe.SimpleScheduler;
import org.apache.doris.resource.Tag;
Expand Down Expand Up @@ -370,6 +371,7 @@ public String getDetailsForCreateReplica() {
StringBuilder sb = new StringBuilder("[");
sb.append("backendId=").append(id);
sb.append(", host=").append(host);
sb.append(", ip=").append(HostUtils.resolveHostToIp(host));
if (!isAlive()) {
sb.append(", isAlive=false, exclude it");
} else if (isDecommissioned()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class BackendsTableValuedFunction extends MetadataTableValuedFunction {
new Column("LastStartTime", ScalarType.createStringType()),
new Column("LastHeartbeat", ScalarType.createStringType()),
new Column("Alive", ScalarType.createType(PrimitiveType.BOOLEAN)),
new Column("IP", ScalarType.createStringType()),
new Column("SystemDecommissioned", ScalarType.createType(PrimitiveType.BOOLEAN)),
new Column("TabletNum", ScalarType.createType(PrimitiveType.BIGINT)),
new Column("DataUsedCapacity", ScalarType.createType(PrimitiveType.BIGINT)),
Expand All @@ -69,7 +70,8 @@ public class BackendsTableValuedFunction extends MetadataTableValuedFunction {
new Column("Version", ScalarType.createStringType()),
new Column("Status", ScalarType.createStringType()),
new Column("HeartbeatFailureCounter", ScalarType.createType(PrimitiveType.INT)),
new Column("NodeRole", ScalarType.createStringType()));
new Column("NodeRole", ScalarType.createStringType())
);

private static final ImmutableMap<String, Integer> COLUMN_TO_INDEX;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class FrontendsDisksTableValuedFunction extends MetadataTableValuedFuncti
private static final ImmutableList<Column> SCHEMA = ImmutableList.of(
new Column("Name", ScalarType.createStringType()),
new Column("Host", ScalarType.createStringType()),
new Column("IP", ScalarType.createStringType()),
new Column("DirType", ScalarType.createStringType()),
new Column("Dir", ScalarType.createStringType()),
new Column("Filesystem", ScalarType.createStringType()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ public class FrontendsTableValuedFunction extends MetadataTableValuedFunction {
new Column("ClusterId", ScalarType.createStringType()),
new Column("Join", ScalarType.createStringType()),
new Column("Alive", ScalarType.createStringType()),
new Column("IP", ScalarType.createStringType()),
new Column("ReplayedJournalId", ScalarType.createStringType()),
new Column("LastStartTime", ScalarType.createStringType()),
new Column("LastHeartbeat", ScalarType.createStringType()),
new Column("IsHelper", ScalarType.createStringType()),
new Column("ErrMsg", ScalarType.createStringType()),
new Column("Version", ScalarType.createStringType()),
new Column("CurrentConnected", ScalarType.createStringType()));
new Column("CurrentConnected", ScalarType.createStringType())
);

private static final ImmutableMap<String, Integer> COLUMN_TO_INDEX;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.util.FrontendConjunctsUtils;
import org.apache.doris.nereids.util.HostUtils;
import org.apache.doris.nereids.util.PlanUtils;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.QeProcessorImpl;
Expand Down Expand Up @@ -457,6 +458,7 @@ private static TFetchSchemaTableDataResult backendsMetadataResult(TMetadataTable
trow.addToColumnValue(new TCell().setStringVal(TimeUtils.longToTimeString(backend.getLastStartTime())));
trow.addToColumnValue(new TCell().setStringVal(TimeUtils.longToTimeString(backend.getLastUpdateMs())));
trow.addToColumnValue(new TCell().setBoolVal(backend.isAlive()));
trow.addToColumnValue(new TCell().setStringVal(HostUtils.resolveHostToIp(backend.getHost())));
trow.addToColumnValue(new TCell().setBoolVal(backend.isDecommissioned()));
trow.addToColumnValue(new TCell().setLongVal(tabletNum));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
suite("test_backends_tvf","p0,external,tvf,external_docker") {
List<List<Object>> table = sql """ select * from backends(); """
assertTrue(table.size() > 0)
assertEquals(25, table[0].size())
assertEquals(26, table[0].size())

// filter columns
table = sql """ select BackendId, Host, Alive, TotalCapacity, Version, NodeRole from backends();"""
Expand Down Expand Up @@ -51,7 +51,7 @@ suite("test_backends_tvf","p0,external,tvf,external_docker") {
res = sql """ select count(*) from backends() where alive = true; """
assertTrue(res[0][0] > 0)

sql """ select BackendId, Host, HeartbeatPort,
sql """ select BackendId, Host, IP, HeartbeatPort,
BePort, HttpPort, BrpcPort, LastStartTime, LastHeartbeat, Alive
SystemDecommissioned, tabletnum
DataUsedCapacity, AvailCapacity, TotalCapacity, UsedPct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ suite("test_frontends_tvf","p0,external,tvf,external_docker") {
List<List<Object>> table = sql """ select * from `frontends`(); """
logger.info("${table}")
assertTrue(table.size() > 0)
assertTrue(table[0].size() == 19)
assertTrue(table[0].size() == 20)

// filter columns
table = sql """ select Name from `frontends`();"""
Expand All @@ -43,7 +43,7 @@ suite("test_frontends_tvf","p0,external,tvf,external_docker") {
def res = sql """ select count(*) from frontends() where alive = 'true'; """
assertTrue(res[0][0] > 0)

sql """ select Name, Host, EditLogPort
sql """ select Name, Host, IP, EditLogPort
HttpPort, QueryPort, RpcPort, ArrowFlightSqlPort, `Role`, IsMaster, ClusterId
`Join`, Alive, ReplayedJournalId, LastHeartbeat
IsHelper, ErrMsg, Version, CurrentConnected from frontends();
Expand Down