Skip to content

Commit f8d26b2

Browse files
committed
HDFS-16582. Expose aggregate latency of slow node as perceived by the reporting node
1 parent 3ecdf39 commit f8d26b2

File tree

8 files changed

+334
-125
lines changed

8 files changed

+334
-125
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,8 +1901,9 @@ public DatanodeCommand[] handleHeartbeat(DatanodeRegistration nodeReg,
19011901
if (LOG.isDebugEnabled()) {
19021902
LOG.debug("DataNode " + nodeReg + " reported slow peers: " + slowPeersMap);
19031903
}
1904-
for (String slowNodeId : slowPeersMap.keySet()) {
1905-
slowPeerTracker.addReport(slowNodeId, nodeReg.getIpcAddr(false));
1904+
for (Map.Entry<String, Double> slowNodeId : slowPeersMap.entrySet()) {
1905+
slowPeerTracker.addReport(slowNodeId.getKey(), nodeReg.getIpcAddr(false),
1906+
slowNodeId.getValue());
19061907
}
19071908
}
19081909
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/SlowPeerDisabledTracker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@ public boolean isSlowPeerTrackerEnabled() {
5858
}
5959

6060
@Override
61-
public void addReport(String slowNode, String reportingNode) {
61+
public void addReport(String slowNode, String reportingNode, Double slowNodeLatency) {
6262
LOG.trace("Adding slow peer report is disabled. To enable it, please enable config {}.",
6363
DFSConfigKeys.DFS_DATANODE_PEER_STATS_ENABLED_KEY);
6464
}
6565

6666
@Override
67-
public Set<String> getReportsForNode(String slowNode) {
67+
public Set<SlowPeerLatencyWithReportingNode> getReportsForNode(String slowNode) {
6868
LOG.trace("Retrieval of slow peer report is disabled. To enable it, please enable config {}.",
6969
DFSConfigKeys.DFS_DATANODE_PEER_STATS_ENABLED_KEY);
7070
return ImmutableSet.of();
7171
}
7272

7373
@Override
74-
public Map<String, SortedSet<String>> getReportsForAllDataNodes() {
74+
public Map<String, SortedSet<SlowPeerLatencyWithReportingNode>> getReportsForAllDataNodes() {
7575
LOG.trace("Retrieval of slow peer report for all nodes is disabled. "
7676
+ "To enable it, please enable config {}.",
7777
DFSConfigKeys.DFS_DATANODE_PEER_STATS_ENABLED_KEY);
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.hdfs.server.blockmanagement;
20+
21+
import java.util.SortedSet;
22+
23+
import com.fasterxml.jackson.annotation.JsonProperty;
24+
25+
import org.apache.commons.lang3.builder.EqualsBuilder;
26+
import org.apache.commons.lang3.builder.HashCodeBuilder;
27+
import org.apache.hadoop.classification.InterfaceAudience;
28+
29+
/**
30+
* This structure is a thin wrapper over slow peer reports to make Json
31+
* [de]serialization easy.
32+
*/
33+
@InterfaceAudience.Private
34+
final class SlowPeerJsonReport {
35+
36+
@JsonProperty("SlowNode")
37+
private final String slowNode;
38+
39+
@JsonProperty("SlowPeerLatencyWithReportingNodes")
40+
private final SortedSet<SlowPeerLatencyWithReportingNode> slowPeerLatencyWithReportingNodes;
41+
42+
public SlowPeerJsonReport(
43+
@JsonProperty("SlowNode")
44+
String slowNode,
45+
@JsonProperty("SlowPeerLatencyWithReportingNodes")
46+
SortedSet<SlowPeerLatencyWithReportingNode> slowPeerLatencyWithReportingNodes) {
47+
this.slowNode = slowNode;
48+
this.slowPeerLatencyWithReportingNodes = slowPeerLatencyWithReportingNodes;
49+
}
50+
51+
public String getSlowNode() {
52+
return slowNode;
53+
}
54+
55+
public SortedSet<SlowPeerLatencyWithReportingNode> getSlowPeerLatencyWithReportingNodes() {
56+
return slowPeerLatencyWithReportingNodes;
57+
}
58+
59+
@Override
60+
public boolean equals(Object o) {
61+
if (this == o) {
62+
return true;
63+
}
64+
65+
if (o == null || getClass() != o.getClass()) {
66+
return false;
67+
}
68+
69+
SlowPeerJsonReport that = (SlowPeerJsonReport) o;
70+
71+
return new EqualsBuilder()
72+
.append(slowNode, that.slowNode)
73+
.append(slowPeerLatencyWithReportingNodes, that.slowPeerLatencyWithReportingNodes)
74+
.isEquals();
75+
}
76+
77+
@Override
78+
public int hashCode() {
79+
return new HashCodeBuilder(17, 37)
80+
.append(slowNode)
81+
.append(slowPeerLatencyWithReportingNodes)
82+
.toHashCode();
83+
}
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.hdfs.server.blockmanagement;
20+
21+
import com.fasterxml.jackson.annotation.JsonProperty;
22+
23+
import org.apache.commons.lang3.builder.EqualsBuilder;
24+
import org.apache.commons.lang3.builder.HashCodeBuilder;
25+
import org.apache.hadoop.classification.InterfaceAudience;
26+
27+
/**
28+
* This class represents the reporting node and the slow node's latency as observed by the
29+
* reporting node. This class is used by SlowPeerJsonReport class.
30+
*/
31+
@InterfaceAudience.Private
32+
final class SlowPeerLatencyWithReportingNode
33+
implements Comparable<SlowPeerLatencyWithReportingNode> {
34+
35+
@JsonProperty("ReportingNode")
36+
private final String reportingNode;
37+
38+
@JsonProperty("ReportedLatency")
39+
private final Double reportedLatency;
40+
41+
public SlowPeerLatencyWithReportingNode(
42+
@JsonProperty("ReportingNode")
43+
String reportingNode,
44+
@JsonProperty("ReportedLatency")
45+
Double reportedLatency) {
46+
this.reportingNode = reportingNode;
47+
this.reportedLatency = reportedLatency;
48+
}
49+
50+
public String getReportingNode() {
51+
return reportingNode;
52+
}
53+
54+
public Double getReportedLatency() {
55+
return reportedLatency;
56+
}
57+
58+
@Override
59+
public int compareTo(SlowPeerLatencyWithReportingNode o) {
60+
return this.reportingNode.compareTo(o.getReportingNode());
61+
}
62+
63+
@Override
64+
public boolean equals(Object o) {
65+
if (this == o) {
66+
return true;
67+
}
68+
69+
if (o == null || getClass() != o.getClass()) {
70+
return false;
71+
}
72+
73+
SlowPeerLatencyWithReportingNode that = (SlowPeerLatencyWithReportingNode) o;
74+
75+
return new EqualsBuilder()
76+
.append(reportingNode, that.reportingNode)
77+
.append(reportedLatency, that.reportedLatency)
78+
.isEquals();
79+
}
80+
81+
@Override
82+
public int hashCode() {
83+
return new HashCodeBuilder(17, 37)
84+
.append(reportingNode)
85+
.append(reportedLatency)
86+
.toHashCode();
87+
}
88+
}

0 commit comments

Comments
 (0)