This is an automated email from the ASF dual-hosted git repository.
zhaoc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new a7bf006 Use BackendStatus to show BE's infomation in `show backends;`
(#3713)
a7bf006 is described below
commit a7bf006b51a28a702aeb2d331e3c7aa8014b0cbc
Author: WingC <[email protected]>
AuthorDate: Fri Jun 5 22:37:48 2020 -0500
Use BackendStatus to show BE's infomation in `show backends;` (#3713)
The infomation is displayed in JSON format.For example:
{"lastTabletReportTime":"2020-05-28 15:29:01"}
---
.../sql-statements/Administration/SHOW BACKENDS.md | 1 +
.../sql-statements/Administration/SHOW BACKENDS.md | 1 +
.../apache/doris/common/proc/BackendsProcDir.java | 4 +++-
.../org/apache/doris/master/ReportHandler.java | 11 ++++++++-
.../main/java/org/apache/doris/system/Backend.java | 26 ++++++++++++++++++----
5 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/docs/en/sql-reference/sql-statements/Administration/SHOW
BACKENDS.md b/docs/en/sql-reference/sql-statements/Administration/SHOW
BACKENDS.md
index 8d414e6..e89adc9 100644
--- a/docs/en/sql-reference/sql-statements/Administration/SHOW BACKENDS.md
+++ b/docs/en/sql-reference/sql-statements/Administration/SHOW BACKENDS.md
@@ -42,6 +42,7 @@ Explain:
9. Total Capacity represents total disk space. Total Capacity = AvailCapacity
+ DataUsedCapacity + other non-user data files take up space.
10. UsedPct represents the percentage of disk usage.
11. ErrMsg is used to display error messages when a heartbeat fails.
+12. Status is used to display some Status information about BE in JSON format,
including the last time that BE reported it's tablet.
## keyword
SHOW, BACKENDS
diff --git a/docs/zh-CN/sql-reference/sql-statements/Administration/SHOW
BACKENDS.md b/docs/zh-CN/sql-reference/sql-statements/Administration/SHOW
BACKENDS.md
index 495c2ed..5cdbdeb 100644
--- a/docs/zh-CN/sql-reference/sql-statements/Administration/SHOW BACKENDS.md
+++ b/docs/zh-CN/sql-reference/sql-statements/Administration/SHOW BACKENDS.md
@@ -42,6 +42,7 @@ under the License.
9. TotalCapacity 表示总磁盘空间。TotalCapacity = AvailCapacity +
DataUsedCapacity + 其他非用户数据文件占用空间。
10. UsedPct 表示磁盘已使用量百分比。
11. ErrMsg 用于显示心跳失败时的错误信息。
+ 12. Status 用于以 JSON 格式显示BE的一些状态信息, 目前包括最后一次BE汇报其tablet的时间信息。
## keyword
SHOW, BACKENDS
diff --git a/fe/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
b/fe/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
index 7cd2fee..559f1e0 100644
--- a/fe/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
+++ b/fe/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
@@ -17,6 +17,7 @@
package org.apache.doris.common.proc;
+import com.google.gson.Gson;
import org.apache.doris.alter.DecommissionBackendJob.DecommissionType;
import org.apache.doris.catalog.Catalog;
import org.apache.doris.cluster.Cluster;
@@ -51,7 +52,7 @@ public class BackendsProcDir implements ProcDirInterface {
.add("BePort").add("HttpPort").add("BrpcPort").add("LastStartTime").add("LastHeartbeat").add("Alive")
.add("SystemDecommissioned").add("ClusterDecommissioned").add("TabletNum")
.add("DataUsedCapacity").add("AvailCapacity").add("TotalCapacity").add("UsedPct")
- .add("MaxDiskUsedPct").add("ErrMsg").add("Version")
+ .add("MaxDiskUsedPct").add("ErrMsg").add("Version").add("Status")
.build();
public static final int IP_INDEX = 2;
@@ -167,6 +168,7 @@ public class BackendsProcDir implements ProcDirInterface {
backendInfo.add(backend.getHeartbeatErrMsg());
backendInfo.add(backend.getVersion());
+ backendInfo.add(new Gson().toJson(backend.getBackendStatus()));
comparableBackendInfos.add(backendInfo);
}
diff --git a/fe/src/main/java/org/apache/doris/master/ReportHandler.java
b/fe/src/main/java/org/apache/doris/master/ReportHandler.java
index b8448f5..6f13734 100644
--- a/fe/src/main/java/org/apache/doris/master/ReportHandler.java
+++ b/fe/src/main/java/org/apache/doris/master/ReportHandler.java
@@ -37,12 +37,14 @@ import org.apache.doris.common.Config;
import org.apache.doris.common.MetaNotFoundException;
import org.apache.doris.common.Pair;
import org.apache.doris.common.util.Daemon;
+import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.metric.GaugeMetric;
import org.apache.doris.metric.Metric.MetricUnit;
import org.apache.doris.metric.MetricRepo;
import org.apache.doris.persist.BackendTabletsInfo;
import org.apache.doris.persist.ReplicaPersistInfo;
import org.apache.doris.system.Backend;
+import org.apache.doris.system.Backend.BackendStatus;
import org.apache.doris.system.SystemInfoService;
import org.apache.doris.task.AgentBatchTask;
import org.apache.doris.task.AgentTask;
@@ -309,7 +311,14 @@ public class ReportHandler extends Daemon {
// 10. send set tablet in memory to be
handleSetTabletInMemory(backendId, backendTablets);
-
+
+ final SystemInfoService currentSystemInfo =
Catalog.getCurrentSystemInfo();
+ Backend reportBackend = currentSystemInfo.getBackend(backendId);
+ if (reportBackend != null) {
+ BackendStatus backendStatus = reportBackend.getBackendStatus();
+ backendStatus.lastSuccessReportTabletsTime =
TimeUtils.longToTimeString(start);
+ }
+
long end = System.currentTimeMillis();
LOG.info("tablet report from backend[{}] cost: {} ms", backendId, (end
- start));
}
diff --git a/fe/src/main/java/org/apache/doris/system/Backend.java
b/fe/src/main/java/org/apache/doris/system/Backend.java
index 24e236f..a95f7bb 100644
--- a/fe/src/main/java/org/apache/doris/system/Backend.java
+++ b/fe/src/main/java/org/apache/doris/system/Backend.java
@@ -94,6 +94,9 @@ public class Backend implements Writable {
// this field is set by tablet report, and just for metric monitor, no
need to persist.
private AtomicLong tabletMaxCompactionScore = new AtomicLong(0);
+ // additional backendStatus information for BE, display in JSON format
+ private BackendStatus backendStatus = new BackendStatus();
+
public Backend() {
this.host = "";
this.version = "";
@@ -105,9 +108,9 @@ public class Backend implements Writable {
this.bePort = new AtomicInteger();
this.httpPort = new AtomicInteger();
this.beRpcPort = new AtomicInteger();
- this.disksRef = new AtomicReference<ImmutableMap<String,
DiskInfo>>(ImmutableMap.<String, DiskInfo> of());
+ this.disksRef = new AtomicReference<>(ImmutableMap.of());
- this.ownerClusterName = new AtomicReference<String>("");
+ this.ownerClusterName = new AtomicReference<>("");
this.backendState = new AtomicInteger(BackendState.free.ordinal());
this.decommissionType = new
AtomicInteger(DecommissionType.SystemDecommission.ordinal());
@@ -123,12 +126,12 @@ public class Backend implements Writable {
this.beRpcPort = new AtomicInteger(-1);
this.lastUpdateMs = new AtomicLong(-1L);
this.lastStartTime = new AtomicLong(-1L);
- this.disksRef = new AtomicReference<ImmutableMap<String,
DiskInfo>>(ImmutableMap.<String, DiskInfo> of());
+ this.disksRef = new AtomicReference<>(ImmutableMap.of());
this.isAlive = new AtomicBoolean(false);
this.isDecommissioned = new AtomicBoolean(false);
- this.ownerClusterName = new AtomicReference<String>("");
+ this.ownerClusterName = new AtomicReference<>("");
this.backendState = new AtomicInteger(BackendState.free.ordinal());
this.decommissionType = new
AtomicInteger(DecommissionType.SystemDecommission.ordinal());
}
@@ -262,6 +265,10 @@ public class Backend implements Writable {
this.disksRef.set(disks);
}
+ public BackendStatus getBackendStatus() {
+ return backendStatus;
+ }
+
/**
* backend belong to some cluster
*
@@ -631,5 +638,16 @@ public class Backend implements Writable {
public long getTabletMaxCompactionScore() {
return tabletMaxCompactionScore.get();
}
+
+ /**
+ * Note: This class must be a POJO in order to display in JSON format
+ * Add additional information in the class to show in `show backends`
+ * if just change new added backendStatus, you can do like following
+ * BackendStatus status = Backend.getBackendStatus();
+ * status.newItem = xxx;
+ */
+ public class BackendStatus {
+ public String lastSuccessReportTabletsTime = "N/A";
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]