You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by to...@apache.org on 2023/02/03 02:07:20 UTC
[hadoop] branch branch-3.3 updated: HDFS-16902. Add Namenode status to BPServiceActor metrics and improve logging in offerservice (#5334)
This is an automated email from the ASF dual-hosted git repository.
tomscut pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new 10b42e93063 HDFS-16902. Add Namenode status to BPServiceActor metrics and improve logging in offerservice (#5334)
10b42e93063 is described below
commit 10b42e9306368ab7506200615e7ea4fd5278f8cb
Author: Tao Li <to...@apache.org>
AuthorDate: Fri Feb 3 10:02:45 2023 +0800
HDFS-16902. Add Namenode status to BPServiceActor metrics and improve logging in offerservice (#5334)
Reviewed-by: Mingliang Liu <li...@apache.org>
Reviewed-by: Shilun Fan <sl...@apache.org>
Signed-off-by: Tao Li <to...@apache.org>
---
.../hadoop/hdfs/server/datanode/BPServiceActor.java | 15 ++++++++++++++-
.../hadoop/hdfs/server/datanode/ErrorReportAction.java | 9 +++++++++
.../hadoop/hdfs/server/datanode/ReportBadBlockAction.java | 10 ++++++++++
.../hadoop-hdfs/src/main/webapps/datanode/datanode.html | 2 ++
4 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java
index 06c2c681c34..362edd1cace 100755
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java
@@ -200,6 +200,7 @@ class BPServiceActor implements Runnable {
Map<String, String> getActorInfoMap() {
final Map<String, String> info = new HashMap<String, String>();
info.put("NamenodeAddress", getNameNodeAddress());
+ info.put("NamenodeHaState", state != null ? state.toString() : "Unknown");
info.put("BlockPoolID", bpos.getBlockPoolId());
info.put("ActorState", getRunningState());
info.put("LastHeartbeat",
@@ -685,6 +686,8 @@ class BPServiceActor implements Runnable {
// Every so often, send heartbeat or block-report
//
final boolean sendHeartbeat = scheduler.isHeartbeatDue(startTime);
+ LOG.debug("BP offer service run start time: {}, sendHeartbeat: {}", startTime,
+ sendHeartbeat);
HeartbeatResponse resp = null;
if (sendHeartbeat) {
//
@@ -697,6 +700,8 @@ class BPServiceActor implements Runnable {
boolean requestBlockReportLease = (fullBlockReportLeaseId == 0) &&
scheduler.isBlockReportDue(startTime);
if (!dn.areHeartbeatsDisabledForTests()) {
+ LOG.debug("Before sending heartbeat to namenode {}, the state of the namenode known"
+ + " to datanode so far is {}", this.getNameNodeAddress(), state);
resp = sendHeartBeat(requestBlockReportLease);
assert resp != null;
if (resp.getFullBlockReportLeaseId() != 0) {
@@ -721,7 +726,12 @@ class BPServiceActor implements Runnable {
// that we should actually process.
bpos.updateActorStatesFromHeartbeat(
this, resp.getNameNodeHaState());
- state = resp.getNameNodeHaState().getState();
+ HAServiceState stateFromResp = resp.getNameNodeHaState().getState();
+ if (state != stateFromResp) {
+ LOG.info("After receiving heartbeat response, updating state of namenode {} to {}",
+ this.getNameNodeAddress(), stateFromResp);
+ }
+ state = stateFromResp;
if (state == HAServiceState.ACTIVE) {
handleRollingUpgradeStatus(resp);
@@ -781,6 +791,7 @@ class BPServiceActor implements Runnable {
long sleepTime = Math.min(1000, dnConf.heartBeatInterval);
Thread.sleep(sleepTime);
} catch (InterruptedException ie) {
+ LOG.info("BPServiceActor {} is interrupted", this);
Thread.currentThread().interrupt();
}
}
@@ -983,6 +994,8 @@ class BPServiceActor implements Runnable {
while (!duplicateQueue.isEmpty()) {
BPServiceActorAction actionItem = duplicateQueue.remove();
try {
+ LOG.debug("BPServiceActor ( {} ) processing queued messages. Action item: {}", this,
+ actionItem);
actionItem.reportTo(bpNamenode, bpRegistration);
} catch (BPServiceActorActionException baae) {
LOG.warn(baae.getMessage() + nnAddr , baae);
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ErrorReportAction.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ErrorReportAction.java
index 26498d4a0fc..38581bee228 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ErrorReportAction.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ErrorReportAction.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs.server.datanode;
import java.io.IOException;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.hadoop.hdfs.protocolPB.DatanodeProtocolClientSideTranslatorPB;
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
import org.apache.hadoop.ipc.RemoteException;
@@ -84,4 +85,12 @@ public class ErrorReportAction implements BPServiceActorAction {
}
return true;
}
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("errorCode", errorCode)
+ .append("errorMessage", errorMessage)
+ .toString();
+ }
}
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java
index 2946358a5cb..d525d9f7822 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs.server.datanode;
import java.io.IOException;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.hadoop.fs.StorageType;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
@@ -111,4 +112,13 @@ public class ReportBadBlockAction implements BPServiceActorAction {
}
return true;
}
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("block", block)
+ .append("storageUuid", storageUuid)
+ .append("storageType", storageType)
+ .toString();
+ }
}
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/datanode.html b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/datanode.html
index caab81ef686..b491d5a04e3 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/datanode.html
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/datanode.html
@@ -81,6 +81,7 @@
<thead>
<tr>
<th>Namenode Address</th>
+ <th>Namenode HA State</th>
<th>Block Pool ID</th>
<th>Actor State</th>
<th>Last Heartbeat</th>
@@ -91,6 +92,7 @@
{#dn.BPServiceActorInfo}
<tr>
<td>{NamenodeAddress}</td>
+ <td>{NamenodeHaState}</td>
<td>{BlockPoolID}</td>
<td>{ActorState}</td>
<td>{LastHeartbeat}s</td>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org