Search in sources :

Example 6 with MaterializedReplica

use of org.apache.hadoop.hdfs.server.datanode.FsDatasetTestUtils.MaterializedReplica in project hadoop by apache.

the class MiniDFSCluster method corruptBlockOnDataNodesHelper.

private int corruptBlockOnDataNodesHelper(ExtendedBlock block, boolean deleteBlockFile) throws IOException {
    int blocksCorrupted = 0;
    for (DataNode dn : getDataNodes()) {
        try {
            MaterializedReplica replica = getFsDatasetTestUtils(dn).getMaterializedReplica(block);
            if (deleteBlockFile) {
                replica.deleteData();
            } else {
                replica.corruptData();
            }
            blocksCorrupted++;
        } catch (ReplicaNotFoundException e) {
        // Ignore.
        }
    }
    return blocksCorrupted;
}
Also used : DataNode(org.apache.hadoop.hdfs.server.datanode.DataNode) MaterializedReplica(org.apache.hadoop.hdfs.server.datanode.FsDatasetTestUtils.MaterializedReplica) ReplicaNotFoundException(org.apache.hadoop.hdfs.server.datanode.ReplicaNotFoundException)

Example 7 with MaterializedReplica

use of org.apache.hadoop.hdfs.server.datanode.FsDatasetTestUtils.MaterializedReplica in project hadoop by apache.

the class TestDFSShell method corrupt.

private static void corrupt(List<MaterializedReplica> replicas, String content) throws IOException {
    StringBuilder sb = new StringBuilder(content);
    char c = content.charAt(0);
    sb.setCharAt(0, ++c);
    for (MaterializedReplica replica : replicas) {
        replica.corruptData(sb.toString().getBytes("UTF8"));
    }
}
Also used : MaterializedReplica(org.apache.hadoop.hdfs.server.datanode.FsDatasetTestUtils.MaterializedReplica)

Aggregations

MaterializedReplica (org.apache.hadoop.hdfs.server.datanode.FsDatasetTestUtils.MaterializedReplica)7 Configuration (org.apache.hadoop.conf.Configuration)4 ExtendedBlock (org.apache.hadoop.hdfs.protocol.ExtendedBlock)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)2 Path (org.apache.hadoop.fs.Path)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 OutputStream (java.io.OutputStream)1 InetSocketAddress (java.net.InetSocketAddress)1 Map (java.util.Map)1 Semaphore (java.util.concurrent.Semaphore)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)1 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)1 Block (org.apache.hadoop.hdfs.protocol.Block)1 BlockListAsLongs (org.apache.hadoop.hdfs.protocol.BlockListAsLongs)1 DataNode (org.apache.hadoop.hdfs.server.datanode.DataNode)1 ReplicaNotFoundException (org.apache.hadoop.hdfs.server.datanode.ReplicaNotFoundException)1 FSNamesystem (org.apache.hadoop.hdfs.server.namenode.FSNamesystem)1