Skip to content

Commit 1cb2eb0

Browse files
author
Inigo Goiri
committed
HDFS-14353. Erasure Coding: metrics xmitsInProgress become to negative. Contributed by maobaolong.
1 parent 05db2a5 commit 1cb2eb0

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/ErasureCodingWorker.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,8 @@ public void shutDown() {
170170
stripedReconstructionPool.shutdown();
171171
stripedReadPool.shutdown();
172172
}
173+
174+
public float getXmitWeight() {
175+
return xmitWeight;
176+
}
173177
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockReconstructor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ public void run() {
6767
LOG.warn("Failed to reconstruct striped block: {}", getBlockGroup(), e);
6868
getDatanode().getMetrics().incrECFailedReconstructionTasks();
6969
} finally {
70-
getDatanode().decrementXmitsInProgress(getXmits());
70+
float xmitWeight = getErasureCodingWorker().getXmitWeight();
71+
// if the xmits is smaller than 1, the xmitsSubmitted should be set to 1
72+
// because if it set to zero, we cannot to measure the xmits submitted
73+
int xmitsSubmitted = Math.max((int) (getXmits() * xmitWeight), 1);
74+
getDatanode().decrementXmitsInProgress(xmitsSubmitted);
7175
final DataNodeMetrics metrics = getDatanode().getMetrics();
7276
metrics.incrECReconstructionTasks();
7377
metrics.incrECReconstructionBytesRead(getBytesRead());

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedReconstructor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,8 @@ Configuration getConf() {
275275
DataNode getDatanode() {
276276
return datanode;
277277
}
278+
279+
public ErasureCodingWorker getErasureCodingWorker() {
280+
return erasureCodingWorker;
281+
}
278282
}

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestReconstructStripedFile.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ private void testNNSendsErasureCodingTasks(int deadDN) throws Exception {
514514

515515
@Test(timeout = 180000)
516516
public void testErasureCodingWorkerXmitsWeight() throws Exception {
517+
testErasureCodingWorkerXmitsWeight(0.5f,
518+
(int) (ecPolicy.getNumDataUnits() * 0.5f));
517519
testErasureCodingWorkerXmitsWeight(1f, ecPolicy.getNumDataUnits());
518520
testErasureCodingWorkerXmitsWeight(0f, 1);
519521
testErasureCodingWorkerXmitsWeight(10f, 10 * ecPolicy.getNumDataUnits());
@@ -567,6 +569,10 @@ public void stripedBlockReconstruction() throws IOException {
567569
} finally {
568570
barrier.await();
569571
DataNodeFaultInjector.set(oldInjector);
572+
for (final DataNode curDn : cluster.getDataNodes()) {
573+
GenericTestUtils.waitFor(() -> curDn.getXceiverCount() > 1, 10, 60000);
574+
assertEquals(0, curDn.getXmitsInProgress());
575+
}
570576
}
571577
}
572578
}

0 commit comments

Comments
 (0)