|
@@ -49,11 +49,15 @@ import org.mockito.Mockito;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
|
|
+import java.lang.management.ManagementFactory;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
import java.util.concurrent.TimeoutException;
|
|
import java.util.concurrent.TimeoutException;
|
|
|
|
|
|
|
|
+import javax.management.MBeanServer;
|
|
|
|
+import javax.management.ObjectName;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Ensure that the DN reserves disk space equivalent to a full block for
|
|
* Ensure that the DN reserves disk space equivalent to a full block for
|
|
* replica being written (RBW).
|
|
* replica being written (RBW).
|
|
@@ -324,6 +328,30 @@ public class TestRbwSpaceReservation {
|
|
fsVolumeImpl.getReservedForRbw() == 0);
|
|
fsVolumeImpl.getReservedForRbw() == 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Test(timeout = 30000)
|
|
|
|
+ public void testRBWInJMXBean() throws Exception {
|
|
|
|
+
|
|
|
|
+ final short replication = 1;
|
|
|
|
+ startCluster(BLOCK_SIZE, replication, -1);
|
|
|
|
+
|
|
|
|
+ final String methodName = GenericTestUtils.getMethodName();
|
|
|
|
+ final Path file = new Path("/" + methodName + ".01.dat");
|
|
|
|
+
|
|
|
|
+ try (FSDataOutputStream os = fs.create(file, replication)) {
|
|
|
|
+ // Write 1 byte to the file
|
|
|
|
+ os.write(new byte[1]);
|
|
|
|
+ os.hsync();
|
|
|
|
+
|
|
|
|
+ final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
|
|
|
+ final ObjectName mxbeanName = new ObjectName(
|
|
|
|
+ "Hadoop:service=DataNode,name=DataNodeInfo");
|
|
|
|
+ final String volumeInfo = (String) mbs.getAttribute(mxbeanName,
|
|
|
|
+ "VolumeInfo");
|
|
|
|
+
|
|
|
|
+ assertTrue(volumeInfo.contains("reservedSpaceForRBW"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Stress test to ensure we are not leaking reserved space.
|
|
* Stress test to ensure we are not leaking reserved space.
|
|
* @throws IOException
|
|
* @throws IOException
|