Skip to content

Commit

Permalink
HDFS-7907. Erasure Coding: track invalid, corrupt, and under-recovery…
Browse files Browse the repository at this point in the history
… striped blocks in NameNode. Contributed by Jing Zhao.
  • Loading branch information
Jing9 authored and Zhe Zhang committed May 26, 2015
1 parent 97378e4 commit abf833a
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 155 deletions.
Expand Up @@ -18,11 +18,13 @@
package org.apache.hadoop.hdfs.server.blockmanagement; package org.apache.hadoop.hdfs.server.blockmanagement;


import org.apache.hadoop.hdfs.protocol.Block; import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;

import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;


import static org.apache.hadoop.hdfs.protocol.HdfsConstants.BLOCK_STRIPED_CHUNK_SIZE;

/** /**
* Subclass of {@link BlockInfo}, presenting a block group in erasure coding. * Subclass of {@link BlockInfo}, presenting a block group in erasure coding.
* *
Expand All @@ -37,7 +39,6 @@
* array to record the block index for each triplet. * array to record the block index for each triplet.
*/ */
public class BlockInfoStriped extends BlockInfo { public class BlockInfoStriped extends BlockInfo {
private final int chunkSize = HdfsConstants.BLOCK_STRIPED_CHUNK_SIZE;
private final short dataBlockNum; private final short dataBlockNum;
private final short parityBlockNum; private final short parityBlockNum;
/** /**
Expand Down Expand Up @@ -132,6 +133,22 @@ int getStorageBlockIndex(DatanodeStorageInfo storage) {
return i == -1 ? -1 : indices[i]; return i == -1 ? -1 : indices[i];
} }


/**
* Identify the block stored in the given datanode storage. Note that
* the returned block has the same block Id with the one seen/reported by the
* DataNode.
*/
Block getBlockOnStorage(DatanodeStorageInfo storage) {
int index = getStorageBlockIndex(storage);
if (index < 0) {
return null;
} else {
Block block = new Block(this);
block.setBlockId(this.getBlockId() + index);
return block;
}
}

@Override @Override
boolean removeStorage(DatanodeStorageInfo storage) { boolean removeStorage(DatanodeStorageInfo storage) {
int dnIndex = findStorageInfoFromEnd(storage); int dnIndex = findStorageInfoFromEnd(storage);
Expand Down Expand Up @@ -186,8 +203,8 @@ public long spaceConsumed() {
// In case striped blocks, total usage by this striped blocks should // In case striped blocks, total usage by this striped blocks should
// be the total of data blocks and parity blocks because // be the total of data blocks and parity blocks because
// `getNumBytes` is the total of actual data block size. // `getNumBytes` is the total of actual data block size.
return ((getNumBytes() - 1) / (dataBlockNum * chunkSize) + 1) return ((getNumBytes() - 1) / (dataBlockNum * BLOCK_STRIPED_CHUNK_SIZE) + 1)
* chunkSize * parityBlockNum + getNumBytes(); * BLOCK_STRIPED_CHUNK_SIZE * parityBlockNum + getNumBytes();
} }


@Override @Override
Expand Down

0 comments on commit abf833a

Please sign in to comment.