Search in sources :

Example 1 with DFSStripedOutputStream

use of org.apache.hadoop.hdfs.DFSStripedOutputStream in project hadoop by apache.

the class TestAddStripedBlocks method testBlockScheduledUpdate.

/**
   * Check if the scheduled block size on each DN storage is correctly updated
   */
@Test
public void testBlockScheduledUpdate() throws Exception {
    final FSNamesystem fsn = cluster.getNamesystem();
    final Path foo = new Path("/foo");
    try (FSDataOutputStream out = dfs.create(foo, true)) {
        DFSStripedOutputStream sout = (DFSStripedOutputStream) out.getWrappedStream();
        writeAndFlushStripedOutputStream(sout, DFS_BYTES_PER_CHECKSUM_DEFAULT);
        // make sure the scheduled block size has been updated for each DN storage
        // in NN
        final List<DatanodeDescriptor> dnList = new ArrayList<>();
        fsn.getBlockManager().getDatanodeManager().fetchDatanodes(dnList, null, false);
        for (DatanodeDescriptor dn : dnList) {
            Assert.assertEquals(1, dn.getBlocksScheduled());
        }
    }
    // we have completed the file, force the DN to flush IBR
    for (DataNode dn : cluster.getDataNodes()) {
        DataNodeTestUtils.triggerBlockReport(dn);
    }
    // check the scheduled block size again
    final List<DatanodeDescriptor> dnList = new ArrayList<>();
    fsn.getBlockManager().getDatanodeManager().fetchDatanodes(dnList, null, false);
    for (DatanodeDescriptor dn : dnList) {
        Assert.assertEquals(0, dn.getBlocksScheduled());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) DatanodeDescriptor(org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor) DFSStripedOutputStream(org.apache.hadoop.hdfs.DFSStripedOutputStream) DataNode(org.apache.hadoop.hdfs.server.datanode.DataNode) ArrayList(java.util.ArrayList) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 Path (org.apache.hadoop.fs.Path)1 DFSStripedOutputStream (org.apache.hadoop.hdfs.DFSStripedOutputStream)1 DatanodeDescriptor (org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor)1 DataNode (org.apache.hadoop.hdfs.server.datanode.DataNode)1 Test (org.junit.Test)1