HDFS-8255. Rename getBlockReplication to getPreferredBlockReplication. (Contributed by Zhe Zhang)
This commit is contained in:
parent
f887243f88
commit
c31c6fbda7
|
@ -210,6 +210,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HDFS-8357. Consolidate parameters of INode.CleanSubtree() into a parameter
|
HDFS-8357. Consolidate parameters of INode.CleanSubtree() into a parameter
|
||||||
objects. (Li Lu via wheat9)
|
objects. (Li Lu via wheat9)
|
||||||
|
|
||||||
|
HDFS-8255. Rename getBlockReplication to getPreferredBlockReplication.
|
||||||
|
(Contributed by Zhe Zhang)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
||||||
|
|
|
@ -58,7 +58,7 @@ public interface BlockCollection {
|
||||||
* Get block replication for the collection
|
* Get block replication for the collection
|
||||||
* @return block replication value
|
* @return block replication value
|
||||||
*/
|
*/
|
||||||
public short getBlockReplication();
|
public short getPreferredBlockReplication();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the storage policy ID.
|
* @return the storage policy ID.
|
||||||
|
|
|
@ -383,7 +383,7 @@ public class BlockInfoContiguous extends Block
|
||||||
if(isComplete()) {
|
if(isComplete()) {
|
||||||
BlockInfoContiguousUnderConstruction ucBlock =
|
BlockInfoContiguousUnderConstruction ucBlock =
|
||||||
new BlockInfoContiguousUnderConstruction(this,
|
new BlockInfoContiguousUnderConstruction(this,
|
||||||
getBlockCollection().getBlockReplication(), s, targets);
|
getBlockCollection().getPreferredBlockReplication(), s, targets);
|
||||||
ucBlock.setBlockCollection(getBlockCollection());
|
ucBlock.setBlockCollection(getBlockCollection());
|
||||||
return ucBlock;
|
return ucBlock;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1172,7 +1172,7 @@ public class BlockManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
short expectedReplicas =
|
short expectedReplicas =
|
||||||
b.corrupted.getBlockCollection().getBlockReplication();
|
b.corrupted.getBlockCollection().getPreferredBlockReplication();
|
||||||
|
|
||||||
// Add replica to the data-node if it is not already there
|
// Add replica to the data-node if it is not already there
|
||||||
if (storageInfo != null) {
|
if (storageInfo != null) {
|
||||||
|
@ -1346,7 +1346,7 @@ public class BlockManager {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
requiredReplication = bc.getBlockReplication();
|
requiredReplication = bc.getPreferredBlockReplication();
|
||||||
|
|
||||||
// get a source data-node
|
// get a source data-node
|
||||||
containingNodes = new ArrayList<DatanodeDescriptor>();
|
containingNodes = new ArrayList<DatanodeDescriptor>();
|
||||||
|
@ -1432,7 +1432,7 @@ public class BlockManager {
|
||||||
neededReplications.decrementReplicationIndex(priority);
|
neededReplications.decrementReplicationIndex(priority);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
requiredReplication = bc.getBlockReplication();
|
requiredReplication = bc.getPreferredBlockReplication();
|
||||||
|
|
||||||
// do not schedule more if enough replicas is already pending
|
// do not schedule more if enough replicas is already pending
|
||||||
NumberReplicas numReplicas = countNodes(block);
|
NumberReplicas numReplicas = countNodes(block);
|
||||||
|
@ -2586,7 +2586,7 @@ public class BlockManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle underReplication/overReplication
|
// handle underReplication/overReplication
|
||||||
short fileReplication = bc.getBlockReplication();
|
short fileReplication = bc.getPreferredBlockReplication();
|
||||||
if (!isNeededReplication(storedBlock, fileReplication, numCurrentReplica)) {
|
if (!isNeededReplication(storedBlock, fileReplication, numCurrentReplica)) {
|
||||||
neededReplications.remove(storedBlock, numCurrentReplica,
|
neededReplications.remove(storedBlock, numCurrentReplica,
|
||||||
num.decommissionedAndDecommissioning(), fileReplication);
|
num.decommissionedAndDecommissioning(), fileReplication);
|
||||||
|
@ -2817,7 +2817,7 @@ public class BlockManager {
|
||||||
}
|
}
|
||||||
// calculate current replication
|
// calculate current replication
|
||||||
short expectedReplication =
|
short expectedReplication =
|
||||||
block.getBlockCollection().getBlockReplication();
|
block.getBlockCollection().getPreferredBlockReplication();
|
||||||
NumberReplicas num = countNodes(block);
|
NumberReplicas num = countNodes(block);
|
||||||
int numCurrentReplica = num.liveReplicas();
|
int numCurrentReplica = num.liveReplicas();
|
||||||
// add to under-replicated queue if need to be
|
// add to under-replicated queue if need to be
|
||||||
|
@ -3318,7 +3318,7 @@ public class BlockManager {
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
final Block block = it.next();
|
final Block block = it.next();
|
||||||
BlockCollection bc = blocksMap.getBlockCollection(block);
|
BlockCollection bc = blocksMap.getBlockCollection(block);
|
||||||
short expectedReplication = bc.getBlockReplication();
|
short expectedReplication = bc.getPreferredBlockReplication();
|
||||||
NumberReplicas num = countNodes(block);
|
NumberReplicas num = countNodes(block);
|
||||||
int numCurrentReplica = num.liveReplicas();
|
int numCurrentReplica = num.liveReplicas();
|
||||||
if (numCurrentReplica > expectedReplication) {
|
if (numCurrentReplica > expectedReplication) {
|
||||||
|
@ -3432,7 +3432,7 @@ public class BlockManager {
|
||||||
* process it as an over replicated block.
|
* process it as an over replicated block.
|
||||||
*/
|
*/
|
||||||
public void checkReplication(BlockCollection bc) {
|
public void checkReplication(BlockCollection bc) {
|
||||||
final short expected = bc.getBlockReplication();
|
final short expected = bc.getPreferredBlockReplication();
|
||||||
for (Block block : bc.getBlocks()) {
|
for (Block block : bc.getBlocks()) {
|
||||||
final NumberReplicas n = countNodes(block);
|
final NumberReplicas n = countNodes(block);
|
||||||
if (isNeededReplication(block, expected, n.liveReplicas())) {
|
if (isNeededReplication(block, expected, n.liveReplicas())) {
|
||||||
|
@ -3471,7 +3471,7 @@ public class BlockManager {
|
||||||
*/
|
*/
|
||||||
private int getReplication(Block block) {
|
private int getReplication(Block block) {
|
||||||
final BlockCollection bc = blocksMap.getBlockCollection(block);
|
final BlockCollection bc = blocksMap.getBlockCollection(block);
|
||||||
return bc == null? 0: bc.getBlockReplication();
|
return bc == null? 0: bc.getPreferredBlockReplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,7 @@ public class DecommissionManager {
|
||||||
private boolean isSufficientlyReplicated(BlockInfoContiguous block,
|
private boolean isSufficientlyReplicated(BlockInfoContiguous block,
|
||||||
BlockCollection bc,
|
BlockCollection bc,
|
||||||
NumberReplicas numberReplicas) {
|
NumberReplicas numberReplicas) {
|
||||||
final int numExpected = bc.getBlockReplication();
|
final int numExpected = bc.getPreferredBlockReplication();
|
||||||
final int numLive = numberReplicas.liveReplicas();
|
final int numLive = numberReplicas.liveReplicas();
|
||||||
if (!blockManager.isNeededReplication(block, numExpected, numLive)) {
|
if (!blockManager.isNeededReplication(block, numExpected, numLive)) {
|
||||||
// Block doesn't need replication. Skip.
|
// Block doesn't need replication. Skip.
|
||||||
|
@ -288,7 +288,7 @@ public class DecommissionManager {
|
||||||
DatanodeDescriptor srcNode, NumberReplicas num,
|
DatanodeDescriptor srcNode, NumberReplicas num,
|
||||||
Iterable<DatanodeStorageInfo> storages) {
|
Iterable<DatanodeStorageInfo> storages) {
|
||||||
int curReplicas = num.liveReplicas();
|
int curReplicas = num.liveReplicas();
|
||||||
int curExpectedReplicas = bc.getBlockReplication();
|
int curExpectedReplicas = bc.getPreferredBlockReplication();
|
||||||
StringBuilder nodeList = new StringBuilder();
|
StringBuilder nodeList = new StringBuilder();
|
||||||
for (DatanodeStorageInfo storage : storages) {
|
for (DatanodeStorageInfo storage : storages) {
|
||||||
final DatanodeDescriptor node = storage.getDatanodeDescriptor();
|
final DatanodeDescriptor node = storage.getDatanodeDescriptor();
|
||||||
|
@ -564,8 +564,8 @@ public class DecommissionManager {
|
||||||
|
|
||||||
// Schedule under-replicated blocks for replication if not already
|
// Schedule under-replicated blocks for replication if not already
|
||||||
// pending
|
// pending
|
||||||
if (blockManager.isNeededReplication(block, bc.getBlockReplication(),
|
if (blockManager.isNeededReplication(block,
|
||||||
liveReplicas)) {
|
bc.getPreferredBlockReplication(), liveReplicas)) {
|
||||||
if (!blockManager.neededReplications.contains(block) &&
|
if (!blockManager.neededReplications.contains(block) &&
|
||||||
blockManager.pendingReplications.getNumReplicas(block) == 0 &&
|
blockManager.pendingReplications.getNumReplicas(block) == 0 &&
|
||||||
namesystem.isPopulatingReplQueues()) {
|
namesystem.isPopulatingReplQueues()) {
|
||||||
|
@ -573,7 +573,7 @@ public class DecommissionManager {
|
||||||
blockManager.neededReplications.add(block,
|
blockManager.neededReplications.add(block,
|
||||||
curReplicas,
|
curReplicas,
|
||||||
num.decommissionedAndDecommissioning(),
|
num.decommissionedAndDecommissioning(),
|
||||||
bc.getBlockReplication());
|
bc.getPreferredBlockReplication());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ public class FSDirAttrOp {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
INodeFile file = inode.asFile();
|
INodeFile file = inode.asFile();
|
||||||
final short oldBR = file.getBlockReplication();
|
final short oldBR = file.getPreferredBlockReplication();
|
||||||
|
|
||||||
// before setFileReplication, check for increasing block replication.
|
// before setFileReplication, check for increasing block replication.
|
||||||
// if replication > oldBR, then newBR == replication.
|
// if replication > oldBR, then newBR == replication.
|
||||||
|
@ -399,7 +399,7 @@ public class FSDirAttrOp {
|
||||||
|
|
||||||
file.setFileReplication(replication, iip.getLatestSnapshotId());
|
file.setFileReplication(replication, iip.getLatestSnapshotId());
|
||||||
|
|
||||||
final short newBR = file.getBlockReplication();
|
final short newBR = file.getPreferredBlockReplication();
|
||||||
// check newBR < oldBR case.
|
// check newBR < oldBR case.
|
||||||
if (newBR < oldBR) {
|
if (newBR < oldBR) {
|
||||||
long dsDelta = file.storagespaceConsumed(null).getStorageSpace() / newBR;
|
long dsDelta = file.storagespaceConsumed(null).getStorageSpace() / newBR;
|
||||||
|
|
|
@ -167,9 +167,9 @@ class FSDirConcatOp {
|
||||||
private static QuotaCounts computeQuotaDeltas(FSDirectory fsd,
|
private static QuotaCounts computeQuotaDeltas(FSDirectory fsd,
|
||||||
INodeFile target, INodeFile[] srcList) {
|
INodeFile target, INodeFile[] srcList) {
|
||||||
QuotaCounts deltas = new QuotaCounts.Builder().build();
|
QuotaCounts deltas = new QuotaCounts.Builder().build();
|
||||||
final short targetRepl = target.getBlockReplication();
|
final short targetRepl = target.getPreferredBlockReplication();
|
||||||
for (INodeFile src : srcList) {
|
for (INodeFile src : srcList) {
|
||||||
short srcRepl = src.getBlockReplication();
|
short srcRepl = src.getPreferredBlockReplication();
|
||||||
long fileSize = src.computeFileSize();
|
long fileSize = src.computeFileSize();
|
||||||
if (targetRepl != srcRepl) {
|
if (targetRepl != srcRepl) {
|
||||||
deltas.addStorageSpace(fileSize * (targetRepl - srcRepl));
|
deltas.addStorageSpace(fileSize * (targetRepl - srcRepl));
|
||||||
|
|
|
@ -489,7 +489,7 @@ public class FSDirectory implements Closeable {
|
||||||
|
|
||||||
// check quota limits and updated space consumed
|
// check quota limits and updated space consumed
|
||||||
updateCount(inodesInPath, 0, fileINode.getPreferredBlockSize(),
|
updateCount(inodesInPath, 0, fileINode.getPreferredBlockSize(),
|
||||||
fileINode.getBlockReplication(), true);
|
fileINode.getPreferredBlockReplication(), true);
|
||||||
|
|
||||||
// associate new last block for the file
|
// associate new last block for the file
|
||||||
BlockInfoContiguousUnderConstruction blockInfo =
|
BlockInfoContiguousUnderConstruction blockInfo =
|
||||||
|
@ -546,7 +546,7 @@ public class FSDirectory implements Closeable {
|
||||||
|
|
||||||
// update space consumed
|
// update space consumed
|
||||||
updateCount(iip, 0, -fileNode.getPreferredBlockSize(),
|
updateCount(iip, 0, -fileNode.getPreferredBlockSize(),
|
||||||
fileNode.getBlockReplication(), true);
|
fileNode.getPreferredBlockReplication(), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -975,7 +975,7 @@ public class FSEditLogLoader {
|
||||||
}
|
}
|
||||||
// add the new block
|
// add the new block
|
||||||
BlockInfoContiguous newBI = new BlockInfoContiguousUnderConstruction(
|
BlockInfoContiguous newBI = new BlockInfoContiguousUnderConstruction(
|
||||||
newBlock, file.getBlockReplication());
|
newBlock, file.getPreferredBlockReplication());
|
||||||
fsNamesys.getBlockManager().addBlockCollection(newBI, file);
|
fsNamesys.getBlockManager().addBlockCollection(newBI, file);
|
||||||
file.addBlock(newBI);
|
file.addBlock(newBI);
|
||||||
fsNamesys.getBlockManager().processQueuedMessagesForBlock(newBlock);
|
fsNamesys.getBlockManager().processQueuedMessagesForBlock(newBlock);
|
||||||
|
@ -1054,13 +1054,14 @@ public class FSEditLogLoader {
|
||||||
// what about an old-version fsync() where fsync isn't called
|
// what about an old-version fsync() where fsync isn't called
|
||||||
// until several blocks in?
|
// until several blocks in?
|
||||||
newBI = new BlockInfoContiguousUnderConstruction(
|
newBI = new BlockInfoContiguousUnderConstruction(
|
||||||
newBlock, file.getBlockReplication());
|
newBlock, file.getPreferredBlockReplication());
|
||||||
} else {
|
} else {
|
||||||
// OP_CLOSE should add finalized blocks. This code path
|
// OP_CLOSE should add finalized blocks. This code path
|
||||||
// is only executed when loading edits written by prior
|
// is only executed when loading edits written by prior
|
||||||
// versions of Hadoop. Current versions always log
|
// versions of Hadoop. Current versions always log
|
||||||
// OP_ADD operations as each block is allocated.
|
// OP_ADD operations as each block is allocated.
|
||||||
newBI = new BlockInfoContiguous(newBlock, file.getBlockReplication());
|
newBI = new BlockInfoContiguous(newBlock,
|
||||||
|
file.getPreferredBlockReplication());
|
||||||
}
|
}
|
||||||
fsNamesys.getBlockManager().addBlockCollection(newBI, file);
|
fsNamesys.getBlockManager().addBlockCollection(newBI, file);
|
||||||
file.addBlock(newBI);
|
file.addBlock(newBI);
|
||||||
|
|
|
@ -2160,7 +2160,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
// Add new truncateBlock into blocksMap and
|
// Add new truncateBlock into blocksMap and
|
||||||
// use oldBlock as a source for copy-on-truncate recovery
|
// use oldBlock as a source for copy-on-truncate recovery
|
||||||
truncatedBlockUC = new BlockInfoContiguousUnderConstruction(newBlock,
|
truncatedBlockUC = new BlockInfoContiguousUnderConstruction(newBlock,
|
||||||
file.getBlockReplication());
|
file.getPreferredBlockReplication());
|
||||||
truncatedBlockUC.setNumBytes(oldBlock.getNumBytes() - lastBlockDelta);
|
truncatedBlockUC.setNumBytes(oldBlock.getNumBytes() - lastBlockDelta);
|
||||||
truncatedBlockUC.setTruncateBlock(oldBlock);
|
truncatedBlockUC.setTruncateBlock(oldBlock);
|
||||||
file.setLastBlock(truncatedBlockUC, blockManager.getStorages(oldBlock));
|
file.setLastBlock(truncatedBlockUC, blockManager.getStorages(oldBlock));
|
||||||
|
@ -2797,7 +2797,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
final BlockInfoContiguous lastBlock = file.getLastBlock();
|
final BlockInfoContiguous lastBlock = file.getLastBlock();
|
||||||
if (lastBlock != null) {
|
if (lastBlock != null) {
|
||||||
final long diff = file.getPreferredBlockSize() - lastBlock.getNumBytes();
|
final long diff = file.getPreferredBlockSize() - lastBlock.getNumBytes();
|
||||||
final short repl = file.getBlockReplication();
|
final short repl = file.getPreferredBlockReplication();
|
||||||
delta.addStorageSpace(diff * repl);
|
delta.addStorageSpace(diff * repl);
|
||||||
final BlockStoragePolicy policy = dir.getBlockStoragePolicySuite()
|
final BlockStoragePolicy policy = dir.getBlockStoragePolicySuite()
|
||||||
.getPolicy(file.getStoragePolicyID());
|
.getPolicy(file.getStoragePolicyID());
|
||||||
|
|
|
@ -355,7 +355,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // BlockCollection
|
@Override // BlockCollection
|
||||||
public short getBlockReplication() {
|
public short getPreferredBlockReplication() {
|
||||||
short max = getFileReplication(CURRENT_STATE_ID);
|
short max = getFileReplication(CURRENT_STATE_ID);
|
||||||
FileWithSnapshotFeature sf = this.getFileWithSnapshotFeature();
|
FileWithSnapshotFeature sf = this.getFileWithSnapshotFeature();
|
||||||
if (sf != null) {
|
if (sf != null) {
|
||||||
|
@ -728,7 +728,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
blocks = allBlocks;
|
blocks = allBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
final short replication = getBlockReplication();
|
final short replication = getPreferredBlockReplication();
|
||||||
for (BlockInfoContiguous b : blocks) {
|
for (BlockInfoContiguous b : blocks) {
|
||||||
long blockSize = b.isComplete() ? b.getNumBytes() :
|
long blockSize = b.isComplete() ? b.getNumBytes() :
|
||||||
getPreferredBlockSize();
|
getPreferredBlockSize();
|
||||||
|
@ -850,10 +850,10 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
truncatedBytes -= bi.getNumBytes();
|
truncatedBytes -= bi.getNumBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
delta.addStorageSpace(-truncatedBytes * getBlockReplication());
|
delta.addStorageSpace(-truncatedBytes * getPreferredBlockReplication());
|
||||||
if (bsps != null) {
|
if (bsps != null) {
|
||||||
List<StorageType> types = bsps.chooseStorageTypes(
|
List<StorageType> types = bsps.chooseStorageTypes(
|
||||||
getBlockReplication());
|
getPreferredBlockReplication());
|
||||||
for (StorageType t : types) {
|
for (StorageType t : types) {
|
||||||
if (t.supportTypeQuota()) {
|
if (t.supportTypeQuota()) {
|
||||||
delta.addTypeSpace(t, -truncatedBytes);
|
delta.addTypeSpace(t, -truncatedBytes);
|
||||||
|
|
|
@ -255,15 +255,18 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
|
||||||
NumberReplicas numberReplicas= bm.countNodes(block);
|
NumberReplicas numberReplicas= bm.countNodes(block);
|
||||||
out.println("Block Id: " + blockId);
|
out.println("Block Id: " + blockId);
|
||||||
out.println("Block belongs to: "+iNode.getFullPathName());
|
out.println("Block belongs to: "+iNode.getFullPathName());
|
||||||
out.println("No. of Expected Replica: " + bc.getBlockReplication());
|
out.println("No. of Expected Replica: " +
|
||||||
|
bc.getPreferredBlockReplication());
|
||||||
out.println("No. of live Replica: " + numberReplicas.liveReplicas());
|
out.println("No. of live Replica: " + numberReplicas.liveReplicas());
|
||||||
out.println("No. of excess Replica: " + numberReplicas.excessReplicas());
|
out.println("No. of excess Replica: " + numberReplicas.excessReplicas());
|
||||||
out.println("No. of stale Replica: " + numberReplicas.replicasOnStaleNodes());
|
out.println("No. of stale Replica: " +
|
||||||
|
numberReplicas.replicasOnStaleNodes());
|
||||||
out.println("No. of decommissioned Replica: "
|
out.println("No. of decommissioned Replica: "
|
||||||
+ numberReplicas.decommissioned());
|
+ numberReplicas.decommissioned());
|
||||||
out.println("No. of decommissioning Replica: "
|
out.println("No. of decommissioning Replica: "
|
||||||
+ numberReplicas.decommissioning());
|
+ numberReplicas.decommissioning());
|
||||||
out.println("No. of corrupted Replica: " + numberReplicas.corruptReplicas());
|
out.println("No. of corrupted Replica: " +
|
||||||
|
numberReplicas.corruptReplicas());
|
||||||
//record datanodes that have corrupted block replica
|
//record datanodes that have corrupted block replica
|
||||||
Collection<DatanodeDescriptor> corruptionRecord = null;
|
Collection<DatanodeDescriptor> corruptionRecord = null;
|
||||||
if (bm.getCorruptReplicas(block) != null) {
|
if (bm.getCorruptReplicas(block) != null) {
|
||||||
|
|
|
@ -151,11 +151,12 @@ public class FileWithSnapshotFeature implements INode.Feature {
|
||||||
long oldStoragespace;
|
long oldStoragespace;
|
||||||
if (removed.snapshotINode != null) {
|
if (removed.snapshotINode != null) {
|
||||||
short replication = removed.snapshotINode.getFileReplication();
|
short replication = removed.snapshotINode.getFileReplication();
|
||||||
short currentRepl = file.getBlockReplication();
|
short currentRepl = file.getPreferredBlockReplication();
|
||||||
if (replication > currentRepl) {
|
if (replication > currentRepl) {
|
||||||
long oldFileSizeNoRep = currentRepl == 0
|
long oldFileSizeNoRep = currentRepl == 0
|
||||||
? file.computeFileSize(true, true)
|
? file.computeFileSize(true, true)
|
||||||
: oldCounts.getStorageSpace() / file.getBlockReplication();
|
: oldCounts.getStorageSpace() /
|
||||||
|
file.getPreferredBlockReplication();
|
||||||
oldStoragespace = oldFileSizeNoRep * replication;
|
oldStoragespace = oldFileSizeNoRep * replication;
|
||||||
oldCounts.setStorageSpace(oldStoragespace);
|
oldCounts.setStorageSpace(oldStoragespace);
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,7 @@ public class TestBlockManager {
|
||||||
|
|
||||||
private BlockInfoContiguous addBlockOnNodes(long blockId, List<DatanodeDescriptor> nodes) {
|
private BlockInfoContiguous addBlockOnNodes(long blockId, List<DatanodeDescriptor> nodes) {
|
||||||
BlockCollection bc = Mockito.mock(BlockCollection.class);
|
BlockCollection bc = Mockito.mock(BlockCollection.class);
|
||||||
Mockito.doReturn((short)3).when(bc).getBlockReplication();
|
Mockito.doReturn((short)3).when(bc).getPreferredBlockReplication();
|
||||||
BlockInfoContiguous blockInfo = blockOnNodes(blockId, nodes);
|
BlockInfoContiguous blockInfo = blockOnNodes(blockId, nodes);
|
||||||
|
|
||||||
bm.blocksMap.addBlockCollection(blockInfo, bc);
|
bm.blocksMap.addBlockCollection(blockInfo, bc);
|
||||||
|
@ -740,7 +740,7 @@ public class TestBlockManager {
|
||||||
BlockInfoContiguous blockInfo =
|
BlockInfoContiguous blockInfo =
|
||||||
new BlockInfoContiguous(block, (short) 3);
|
new BlockInfoContiguous(block, (short) 3);
|
||||||
BlockCollection bc = Mockito.mock(BlockCollection.class);
|
BlockCollection bc = Mockito.mock(BlockCollection.class);
|
||||||
Mockito.doReturn((short) 3).when(bc).getBlockReplication();
|
Mockito.doReturn((short) 3).when(bc).getPreferredBlockReplication();
|
||||||
bm.blocksMap.addBlockCollection(blockInfo, bc);
|
bm.blocksMap.addBlockCollection(blockInfo, bc);
|
||||||
return blockInfo;
|
return blockInfo;
|
||||||
}
|
}
|
||||||
|
@ -750,7 +750,7 @@ public class TestBlockManager {
|
||||||
BlockInfoContiguousUnderConstruction blockInfo =
|
BlockInfoContiguousUnderConstruction blockInfo =
|
||||||
new BlockInfoContiguousUnderConstruction(block, (short) 3);
|
new BlockInfoContiguousUnderConstruction(block, (short) 3);
|
||||||
BlockCollection bc = Mockito.mock(BlockCollection.class);
|
BlockCollection bc = Mockito.mock(BlockCollection.class);
|
||||||
Mockito.doReturn((short) 3).when(bc).getBlockReplication();
|
Mockito.doReturn((short) 3).when(bc).getPreferredBlockReplication();
|
||||||
bm.blocksMap.addBlockCollection(blockInfo, bc);
|
bm.blocksMap.addBlockCollection(blockInfo, bc);
|
||||||
return blockInfo;
|
return blockInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class TestFileWithSnapshotFeature {
|
||||||
|
|
||||||
// INode only exists in the snapshot
|
// INode only exists in the snapshot
|
||||||
INodeFile snapshotINode = mock(INodeFile.class);
|
INodeFile snapshotINode = mock(INodeFile.class);
|
||||||
when(file.getBlockReplication()).thenReturn(REPL_1);
|
when(file.getPreferredBlockReplication()).thenReturn(REPL_1);
|
||||||
Whitebox.setInternalState(snapshotINode, "header", (long) REPL_3 << 48);
|
Whitebox.setInternalState(snapshotINode, "header", (long) REPL_3 << 48);
|
||||||
Whitebox.setInternalState(diff, "snapshotINode", snapshotINode);
|
Whitebox.setInternalState(diff, "snapshotINode", snapshotINode);
|
||||||
when(diff.getSnapshotINode()).thenReturn(snapshotINode);
|
when(diff.getSnapshotINode()).thenReturn(snapshotINode);
|
||||||
|
|
|
@ -841,12 +841,12 @@ public class TestSnapshotDeletion {
|
||||||
}
|
}
|
||||||
|
|
||||||
INodeFile nodeFile13 = (INodeFile) fsdir.getINode(file13.toString());
|
INodeFile nodeFile13 = (INodeFile) fsdir.getINode(file13.toString());
|
||||||
assertEquals(REPLICATION_1, nodeFile13.getBlockReplication());
|
assertEquals(REPLICATION_1, nodeFile13.getPreferredBlockReplication());
|
||||||
TestSnapshotBlocksMap.assertBlockCollection(file13.toString(), 1, fsdir,
|
TestSnapshotBlocksMap.assertBlockCollection(file13.toString(), 1, fsdir,
|
||||||
blockmanager);
|
blockmanager);
|
||||||
|
|
||||||
INodeFile nodeFile12 = (INodeFile) fsdir.getINode(file12_s1.toString());
|
INodeFile nodeFile12 = (INodeFile) fsdir.getINode(file12_s1.toString());
|
||||||
assertEquals(REPLICATION_1, nodeFile12.getBlockReplication());
|
assertEquals(REPLICATION_1, nodeFile12.getPreferredBlockReplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test deleting snapshots with modification on the metadata of directory */
|
/** Test deleting snapshots with modification on the metadata of directory */
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.junit.Test;
|
||||||
/**
|
/**
|
||||||
* This class tests the replication handling/calculation of snapshots. In
|
* This class tests the replication handling/calculation of snapshots. In
|
||||||
* particular, {@link INodeFile#getFileReplication()} and
|
* particular, {@link INodeFile#getFileReplication()} and
|
||||||
* {@link INodeFile#getBlockReplication()} are tested to make sure
|
* {@link INodeFile#getPreferredBlockReplication()} are tested to make sure
|
||||||
* the number of replication is calculated correctly with/without snapshots.
|
* the number of replication is calculated correctly with/without snapshots.
|
||||||
*/
|
*/
|
||||||
public class TestSnapshotReplication {
|
public class TestSnapshotReplication {
|
||||||
|
@ -81,7 +81,7 @@ public class TestSnapshotReplication {
|
||||||
/**
|
/**
|
||||||
* Check the replication of a given file. We test both
|
* Check the replication of a given file. We test both
|
||||||
* {@link INodeFile#getFileReplication()} and
|
* {@link INodeFile#getFileReplication()} and
|
||||||
* {@link INodeFile#getBlockReplication()}.
|
* {@link INodeFile#getPreferredBlockReplication()}.
|
||||||
*
|
*
|
||||||
* @param file The given file
|
* @param file The given file
|
||||||
* @param replication The expected replication number
|
* @param replication The expected replication number
|
||||||
|
@ -95,10 +95,11 @@ public class TestSnapshotReplication {
|
||||||
// INodeFile#getFileReplication().
|
// INodeFile#getFileReplication().
|
||||||
short fileReplication = hdfs.getFileStatus(file1).getReplication();
|
short fileReplication = hdfs.getFileStatus(file1).getReplication();
|
||||||
assertEquals(replication, fileReplication);
|
assertEquals(replication, fileReplication);
|
||||||
// Check the correctness of getBlockReplication()
|
// Check the correctness of getPreferredBlockReplication()
|
||||||
INode inode = fsdir.getINode(file1.toString());
|
INode inode = fsdir.getINode(file1.toString());
|
||||||
assertTrue(inode instanceof INodeFile);
|
assertTrue(inode instanceof INodeFile);
|
||||||
assertEquals(blockReplication, ((INodeFile) inode).getBlockReplication());
|
assertEquals(blockReplication,
|
||||||
|
((INodeFile) inode).getPreferredBlockReplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,16 +138,19 @@ public class TestSnapshotReplication {
|
||||||
*/
|
*/
|
||||||
private void checkSnapshotFileReplication(Path currentFile,
|
private void checkSnapshotFileReplication(Path currentFile,
|
||||||
Map<Path, Short> snapshotRepMap, short expectedBlockRep) throws Exception {
|
Map<Path, Short> snapshotRepMap, short expectedBlockRep) throws Exception {
|
||||||
// First check the getBlockReplication for the INode of the currentFile
|
// First check the getPreferredBlockReplication for the INode of
|
||||||
|
// the currentFile
|
||||||
final INodeFile inodeOfCurrentFile = getINodeFile(currentFile);
|
final INodeFile inodeOfCurrentFile = getINodeFile(currentFile);
|
||||||
assertEquals(expectedBlockRep, inodeOfCurrentFile.getBlockReplication());
|
assertEquals(expectedBlockRep,
|
||||||
|
inodeOfCurrentFile.getPreferredBlockReplication());
|
||||||
// Then check replication for every snapshot
|
// Then check replication for every snapshot
|
||||||
for (Path ss : snapshotRepMap.keySet()) {
|
for (Path ss : snapshotRepMap.keySet()) {
|
||||||
final INodesInPath iip = fsdir.getINodesInPath(ss.toString(), true);
|
final INodesInPath iip = fsdir.getINodesInPath(ss.toString(), true);
|
||||||
final INodeFile ssInode = iip.getLastINode().asFile();
|
final INodeFile ssInode = iip.getLastINode().asFile();
|
||||||
// The replication number derived from the
|
// The replication number derived from the
|
||||||
// INodeFileWithLink#getBlockReplication should always == expectedBlockRep
|
// INodeFileWithLink#getPreferredBlockReplication should
|
||||||
assertEquals(expectedBlockRep, ssInode.getBlockReplication());
|
// always == expectedBlockRep
|
||||||
|
assertEquals(expectedBlockRep, ssInode.getPreferredBlockReplication());
|
||||||
// Also check the number derived from INodeFile#getFileReplication
|
// Also check the number derived from INodeFile#getFileReplication
|
||||||
assertEquals(snapshotRepMap.get(ss).shortValue(),
|
assertEquals(snapshotRepMap.get(ss).shortValue(),
|
||||||
ssInode.getFileReplication(iip.getPathSnapshotId()));
|
ssInode.getFileReplication(iip.getPathSnapshotId()));
|
||||||
|
@ -218,8 +222,9 @@ public class TestSnapshotReplication {
|
||||||
for (Path ss : snapshotRepMap.keySet()) {
|
for (Path ss : snapshotRepMap.keySet()) {
|
||||||
final INodeFile ssInode = getINodeFile(ss);
|
final INodeFile ssInode = getINodeFile(ss);
|
||||||
// The replication number derived from the
|
// The replication number derived from the
|
||||||
// INodeFileWithLink#getBlockReplication should always == expectedBlockRep
|
// INodeFileWithLink#getPreferredBlockReplication should
|
||||||
assertEquals(REPLICATION, ssInode.getBlockReplication());
|
// always == expectedBlockRep
|
||||||
|
assertEquals(REPLICATION, ssInode.getPreferredBlockReplication());
|
||||||
// Also check the number derived from INodeFile#getFileReplication
|
// Also check the number derived from INodeFile#getFileReplication
|
||||||
assertEquals(snapshotRepMap.get(ss).shortValue(),
|
assertEquals(snapshotRepMap.get(ss).shortValue(),
|
||||||
ssInode.getFileReplication());
|
ssInode.getFileReplication());
|
||||||
|
|
Loading…
Reference in New Issue