Skip to content

Commit 67a62da

Browse files
committed
HDFS-8640. Make reserved RBW space visible through JMX. (Contributed by kanaka kumar avvaru)
1 parent bc43390 commit 67a62da

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,9 @@ Release 2.8.0 - UNRELEASED
669669
HDFS-8462. Implement GETXATTRS and LISTXATTRS operations for WebImageViewer.
670670
(Jagadesh Kiran N via aajisaka)
671671

672+
HDFS-8640. Make reserved RBW space visible through JMX. (kanaka kumar
673+
avvaru via Arpit Agarwal)
674+
672675
OPTIMIZATIONS
673676

674677
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,13 +2559,15 @@ private static class VolumeInfo {
25592559
final String directory;
25602560
final long usedSpace; // size of space used by HDFS
25612561
final long freeSpace; // size of free space excluding reserved space
2562-
final long reservedSpace; // size of space reserved for non-HDFS and RBW
2562+
final long reservedSpace; // size of space reserved for non-HDFS
2563+
final long reservedSpaceForRBW; // size of space reserved RBW
25632564

25642565
VolumeInfo(FsVolumeImpl v, long usedSpace, long freeSpace) {
25652566
this.directory = v.toString();
25662567
this.usedSpace = usedSpace;
25672568
this.freeSpace = freeSpace;
25682569
this.reservedSpace = v.getReserved();
2570+
this.reservedSpaceForRBW = v.getReservedForRbw();
25692571
}
25702572
}
25712573

@@ -2599,6 +2601,7 @@ public Map<String, Object> getVolumeInfoMap() {
25992601
innerInfo.put("usedSpace", v.usedSpace);
26002602
innerInfo.put("freeSpace", v.freeSpace);
26012603
innerInfo.put("reservedSpace", v.reservedSpace);
2604+
innerInfo.put("reservedSpaceForRBW", v.reservedSpaceForRBW);
26022605
info.put(v.directory, innerInfo);
26032606
}
26042607
return info;

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestRbwSpaceReservation.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@
4949

5050
import java.io.IOException;
5151
import java.io.OutputStream;
52+
import java.lang.management.ManagementFactory;
5253
import java.lang.reflect.Field;
5354
import java.util.Map;
5455
import java.util.Random;
5556
import java.util.concurrent.TimeoutException;
5657

58+
import javax.management.MBeanServer;
59+
import javax.management.ObjectName;
60+
5761
/**
5862
* Ensure that the DN reserves disk space equivalent to a full block for
5963
* replica being written (RBW).
@@ -324,6 +328,30 @@ public void testRBWFileCreationError() throws Exception {
324328
fsVolumeImpl.getReservedForRbw() == 0);
325329
}
326330

331+
@Test(timeout = 30000)
332+
public void testRBWInJMXBean() throws Exception {
333+
334+
final short replication = 1;
335+
startCluster(BLOCK_SIZE, replication, -1);
336+
337+
final String methodName = GenericTestUtils.getMethodName();
338+
final Path file = new Path("/" + methodName + ".01.dat");
339+
340+
try (FSDataOutputStream os = fs.create(file, replication)) {
341+
// Write 1 byte to the file
342+
os.write(new byte[1]);
343+
os.hsync();
344+
345+
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
346+
final ObjectName mxbeanName = new ObjectName(
347+
"Hadoop:service=DataNode,name=DataNodeInfo");
348+
final String volumeInfo = (String) mbs.getAttribute(mxbeanName,
349+
"VolumeInfo");
350+
351+
assertTrue(volumeInfo.contains("reservedSpaceForRBW"));
352+
}
353+
}
354+
327355
/**
328356
* Stress test to ensure we are not leaking reserved space.
329357
* @throws IOException

0 commit comments

Comments
 (0)