Revert "HDFS-8499. Refactor BlockInfo class hierarchy with static helper class. Contributed by Zhe Zhang."
This reverts commitc17439c2dd
. (cherry picked from commitf4c523b69b
)
This commit is contained in:
parent
2c694286b4
commit
d7d804623e
|
@ -289,9 +289,6 @@ Release 2.8.0 - UNRELEASED
|
||||||
HDFS-7923. The DataNodes should rate-limit their full block reports by
|
HDFS-7923. The DataNodes should rate-limit their full block reports by
|
||||||
asking the NN on heartbeat messages (cmccabe)
|
asking the NN on heartbeat messages (cmccabe)
|
||||||
|
|
||||||
HDFS-8499. Refactor BlockInfo class hierarchy with static helper class.
|
|
||||||
(Zhe Zhang via wang)
|
|
||||||
|
|
||||||
HDFS-8540. Mover should exit with NO_MOVE_BLOCK if no block can be moved.
|
HDFS-8540. Mover should exit with NO_MOVE_BLOCK if no block can be moved.
|
||||||
(surendra singh lilhore via szetszwo)
|
(surendra singh lilhore via szetszwo)
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public interface BlockCollection {
|
||||||
* Convert the last block of the collection to an under-construction block
|
* Convert the last block of the collection to an under-construction block
|
||||||
* and set the locations.
|
* and set the locations.
|
||||||
*/
|
*/
|
||||||
public BlockInfoUnderConstruction setLastBlock(BlockInfo lastBlock,
|
public BlockInfoContiguousUnderConstruction setLastBlock(BlockInfo lastBlock,
|
||||||
DatanodeStorageInfo[] targets) throws IOException;
|
DatanodeStorageInfo[] targets) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,7 +54,7 @@ public abstract class BlockInfo extends Block
|
||||||
* per replica is 42 bytes (LinkedList#Entry object per replica) versus 16
|
* per replica is 42 bytes (LinkedList#Entry object per replica) versus 16
|
||||||
* bytes using the triplets.
|
* bytes using the triplets.
|
||||||
*/
|
*/
|
||||||
Object[] triplets;
|
protected Object[] triplets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an entry for blocksmap
|
* Construct an entry for blocksmap
|
||||||
|
@ -298,7 +298,7 @@ public abstract class BlockInfo extends Block
|
||||||
/**
|
/**
|
||||||
* BlockInfo represents a block that is not being constructed.
|
* BlockInfo represents a block that is not being constructed.
|
||||||
* In order to start modifying the block, the BlockInfo should be converted
|
* In order to start modifying the block, the BlockInfo should be converted
|
||||||
* to {@link BlockInfoUnderConstruction}.
|
* to {@link BlockInfoContiguousUnderConstruction}.
|
||||||
* @return {@link BlockUCState#COMPLETE}
|
* @return {@link BlockUCState#COMPLETE}
|
||||||
*/
|
*/
|
||||||
public BlockUCState getBlockUCState() {
|
public BlockUCState getBlockUCState() {
|
||||||
|
@ -315,29 +315,27 @@ public abstract class BlockInfo extends Block
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a block to an under construction block.
|
* Convert a complete block to an under construction block.
|
||||||
* @return BlockInfoUnderConstruction - an under construction block.
|
* @return BlockInfoUnderConstruction - an under construction block.
|
||||||
*/
|
*/
|
||||||
public BlockInfoUnderConstruction convertToBlockUnderConstruction(
|
public BlockInfoContiguousUnderConstruction convertToBlockUnderConstruction(
|
||||||
BlockUCState s, DatanodeStorageInfo[] targets) {
|
BlockUCState s, DatanodeStorageInfo[] targets) {
|
||||||
if(isComplete()) {
|
if(isComplete()) {
|
||||||
return convertCompleteBlockToUC(s, targets);
|
BlockInfoContiguousUnderConstruction ucBlock =
|
||||||
|
new BlockInfoContiguousUnderConstruction(this,
|
||||||
|
getBlockCollection().getPreferredBlockReplication(), s, targets);
|
||||||
|
ucBlock.setBlockCollection(getBlockCollection());
|
||||||
|
return ucBlock;
|
||||||
}
|
}
|
||||||
// the block is already under construction
|
// the block is already under construction
|
||||||
BlockInfoUnderConstruction ucBlock =
|
BlockInfoContiguousUnderConstruction ucBlock =
|
||||||
(BlockInfoUnderConstruction)this;
|
(BlockInfoContiguousUnderConstruction)this;
|
||||||
ucBlock.setBlockUCState(s);
|
ucBlock.setBlockUCState(s);
|
||||||
ucBlock.setExpectedLocations(targets);
|
ucBlock.setExpectedLocations(targets);
|
||||||
ucBlock.setBlockCollection(getBlockCollection());
|
ucBlock.setBlockCollection(getBlockCollection());
|
||||||
return ucBlock;
|
return ucBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a complete block to an under construction block.
|
|
||||||
*/
|
|
||||||
abstract BlockInfoUnderConstruction convertCompleteBlockToUC(
|
|
||||||
BlockUCState s, DatanodeStorageInfo[] targets);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
// Super implementation is sufficient
|
// Super implementation is sufficient
|
||||||
|
|
|
@ -19,13 +19,13 @@ package org.apache.hadoop.hdfs.server.blockmanagement;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.hdfs.protocol.Block;
|
import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of {@link BlockInfo}, used for a block with replication scheme.
|
* Subclass of {@link BlockInfo}, used for a block with replication scheme.
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class BlockInfoContiguous extends BlockInfo {
|
public class BlockInfoContiguous extends BlockInfo {
|
||||||
|
public static final BlockInfoContiguous[] EMPTY_ARRAY = {};
|
||||||
|
|
||||||
public BlockInfoContiguous(short size) {
|
public BlockInfoContiguous(short size) {
|
||||||
super(size);
|
super(size);
|
||||||
|
@ -40,37 +40,84 @@ public class BlockInfoContiguous extends BlockInfo {
|
||||||
* This is used to convert BlockReplicationInfoUnderConstruction
|
* This is used to convert BlockReplicationInfoUnderConstruction
|
||||||
* @param from BlockReplicationInfo to copy from.
|
* @param from BlockReplicationInfo to copy from.
|
||||||
*/
|
*/
|
||||||
protected BlockInfoContiguous(BlockInfo from) {
|
protected BlockInfoContiguous(BlockInfoContiguous from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that there is enough space to include num more triplets.
|
||||||
|
* @return first free triplet index.
|
||||||
|
*/
|
||||||
|
private int ensureCapacity(int num) {
|
||||||
|
assert this.triplets != null : "BlockInfo is not initialized";
|
||||||
|
int last = numNodes();
|
||||||
|
if (triplets.length >= (last+num)*3) {
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
/* Not enough space left. Create a new array. Should normally
|
||||||
|
* happen only when replication is manually increased by the user. */
|
||||||
|
Object[] old = triplets;
|
||||||
|
triplets = new Object[(last+num)*3];
|
||||||
|
System.arraycopy(old, 0, triplets, 0, last * 3);
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean addStorage(DatanodeStorageInfo storage) {
|
boolean addStorage(DatanodeStorageInfo storage) {
|
||||||
return ContiguousBlockStorageOp.addStorage(this, storage);
|
// find the last null node
|
||||||
|
int lastNode = ensureCapacity(1);
|
||||||
|
setStorageInfo(lastNode, storage);
|
||||||
|
setNext(lastNode, null);
|
||||||
|
setPrevious(lastNode, null);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean removeStorage(DatanodeStorageInfo storage) {
|
boolean removeStorage(DatanodeStorageInfo storage) {
|
||||||
return ContiguousBlockStorageOp.removeStorage(this, storage);
|
int dnIndex = findStorageInfo(storage);
|
||||||
|
if (dnIndex < 0) { // the node is not found
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
assert getPrevious(dnIndex) == null && getNext(dnIndex) == null :
|
||||||
|
"Block is still in the list and must be removed first.";
|
||||||
|
// find the last not null node
|
||||||
|
int lastNode = numNodes()-1;
|
||||||
|
// replace current node triplet by the lastNode one
|
||||||
|
setStorageInfo(dnIndex, getStorageInfo(lastNode));
|
||||||
|
setNext(dnIndex, getNext(lastNode));
|
||||||
|
setPrevious(dnIndex, getPrevious(lastNode));
|
||||||
|
// set the last triplet to null
|
||||||
|
setStorageInfo(lastNode, null);
|
||||||
|
setNext(lastNode, null);
|
||||||
|
setPrevious(lastNode, null);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int numNodes() {
|
public int numNodes() {
|
||||||
return ContiguousBlockStorageOp.numNodes(this);
|
assert this.triplets != null : "BlockInfo is not initialized";
|
||||||
|
assert triplets.length % 3 == 0 : "Malformed BlockInfo";
|
||||||
|
|
||||||
|
for (int idx = getCapacity()-1; idx >= 0; idx--) {
|
||||||
|
if (getDatanode(idx) != null) {
|
||||||
|
return idx + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void replaceBlock(BlockInfo newBlock) {
|
void replaceBlock(BlockInfo newBlock) {
|
||||||
ContiguousBlockStorageOp.replaceBlock(this, newBlock);
|
assert newBlock instanceof BlockInfoContiguous;
|
||||||
}
|
for (int i = this.numNodes() - 1; i >= 0; i--) {
|
||||||
|
final DatanodeStorageInfo storage = this.getStorageInfo(i);
|
||||||
|
final boolean removed = storage.removeBlock(this);
|
||||||
|
assert removed : "currentBlock not found.";
|
||||||
|
|
||||||
@Override
|
final DatanodeStorageInfo.AddBlockResult result = storage.addBlock(
|
||||||
BlockInfoUnderConstruction convertCompleteBlockToUC(
|
newBlock);
|
||||||
HdfsServerConstants.BlockUCState s, DatanodeStorageInfo[] targets) {
|
assert result == DatanodeStorageInfo.AddBlockResult.ADDED :
|
||||||
BlockInfoUnderConstructionContiguous ucBlock =
|
"newBlock already exists.";
|
||||||
new BlockInfoUnderConstructionContiguous(this,
|
}
|
||||||
getBlockCollection().getPreferredBlockReplication(), s, targets);
|
|
||||||
ucBlock.setBlockCollection(getBlockCollection());
|
|
||||||
return ucBlock;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,11 @@
|
||||||
package org.apache.hadoop.hdfs.server.blockmanagement;
|
package org.apache.hadoop.hdfs.server.blockmanagement;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import org.apache.hadoop.hdfs.protocol.Block;
|
import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.ReplicaState;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.ReplicaState;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||||
|
@ -32,15 +31,15 @@ import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||||
* Represents a block that is currently being constructed.<br>
|
* Represents a block that is currently being constructed.<br>
|
||||||
* This is usually the last block of a file opened for write or append.
|
* This is usually the last block of a file opened for write or append.
|
||||||
*/
|
*/
|
||||||
public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
public class BlockInfoContiguousUnderConstruction extends BlockInfoContiguous {
|
||||||
/** Block state. See {@link BlockUCState} */
|
/** Block state. See {@link BlockUCState} */
|
||||||
protected BlockUCState blockUCState;
|
private BlockUCState blockUCState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block replicas as assigned when the block was allocated.
|
* Block replicas as assigned when the block was allocated.
|
||||||
* This defines the pipeline order.
|
* This defines the pipeline order.
|
||||||
*/
|
*/
|
||||||
protected List<ReplicaUnderConstruction> replicas;
|
private List<ReplicaUnderConstruction> replicas;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of the primary data node doing the recovery. Useful for log
|
* Index of the primary data node doing the recovery. Useful for log
|
||||||
|
@ -58,7 +57,7 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
/**
|
/**
|
||||||
* The block source to use in the event of copy-on-write truncate.
|
* The block source to use in the event of copy-on-write truncate.
|
||||||
*/
|
*/
|
||||||
protected Block truncateBlock;
|
private Block truncateBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReplicaUnderConstruction contains information about replicas while
|
* ReplicaUnderConstruction contains information about replicas while
|
||||||
|
@ -159,24 +158,45 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
* Create block and set its state to
|
* Create block and set its state to
|
||||||
* {@link BlockUCState#UNDER_CONSTRUCTION}.
|
* {@link BlockUCState#UNDER_CONSTRUCTION}.
|
||||||
*/
|
*/
|
||||||
public BlockInfoUnderConstruction(Block blk, short replication) {
|
public BlockInfoContiguousUnderConstruction(Block blk, short replication) {
|
||||||
this(blk, replication, BlockUCState.UNDER_CONSTRUCTION, null);
|
this(blk, replication, BlockUCState.UNDER_CONSTRUCTION, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a block that is currently being constructed.
|
* Create a block that is currently being constructed.
|
||||||
*/
|
*/
|
||||||
public BlockInfoUnderConstruction(Block blk, short replication,
|
public BlockInfoContiguousUnderConstruction(Block blk, short replication,
|
||||||
BlockUCState state, DatanodeStorageInfo[] targets) {
|
BlockUCState state, DatanodeStorageInfo[] targets) {
|
||||||
super(blk, replication);
|
super(blk, replication);
|
||||||
Preconditions.checkState(getBlockUCState() != BlockUCState.COMPLETE,
|
assert getBlockUCState() != BlockUCState.COMPLETE :
|
||||||
"BlockInfoUnderConstruction cannot be in COMPLETE state");
|
"BlockInfoUnderConstruction cannot be in COMPLETE state";
|
||||||
this.blockUCState = state;
|
this.blockUCState = state;
|
||||||
setExpectedLocations(targets);
|
setExpectedLocations(targets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set expected locations. */
|
/**
|
||||||
public abstract void setExpectedLocations(DatanodeStorageInfo[] targets);
|
* Convert an under construction block to a complete block.
|
||||||
|
*
|
||||||
|
* @return BlockInfo - a complete block.
|
||||||
|
* @throws IOException if the state of the block
|
||||||
|
* (the generation stamp and the length) has not been committed by
|
||||||
|
* the client or it does not have at least a minimal number of replicas
|
||||||
|
* reported from data-nodes.
|
||||||
|
*/
|
||||||
|
BlockInfo convertToCompleteBlock() throws IOException {
|
||||||
|
assert getBlockUCState() != BlockUCState.COMPLETE :
|
||||||
|
"Trying to convert a COMPLETE block";
|
||||||
|
return new BlockInfoContiguous(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set expected locations */
|
||||||
|
public void setExpectedLocations(DatanodeStorageInfo[] targets) {
|
||||||
|
int numLocations = targets == null ? 0 : targets.length;
|
||||||
|
this.replicas = new ArrayList<ReplicaUnderConstruction>(numLocations);
|
||||||
|
for(int i = 0; i < numLocations; i++)
|
||||||
|
replicas.add(
|
||||||
|
new ReplicaUnderConstruction(this, targets[i], ReplicaState.RBW));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create array of expected replica locations
|
* Create array of expected replica locations
|
||||||
|
@ -185,13 +205,12 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
public DatanodeStorageInfo[] getExpectedStorageLocations() {
|
public DatanodeStorageInfo[] getExpectedStorageLocations() {
|
||||||
int numLocations = replicas == null ? 0 : replicas.size();
|
int numLocations = replicas == null ? 0 : replicas.size();
|
||||||
DatanodeStorageInfo[] storages = new DatanodeStorageInfo[numLocations];
|
DatanodeStorageInfo[] storages = new DatanodeStorageInfo[numLocations];
|
||||||
for(int i = 0; i < numLocations; i++) {
|
for(int i = 0; i < numLocations; i++)
|
||||||
storages[i] = replicas.get(i).getExpectedStorageLocation();
|
storages[i] = replicas.get(i).getExpectedStorageLocation();
|
||||||
}
|
|
||||||
return storages;
|
return storages;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the number of expected locations. */
|
/** Get the number of expected locations */
|
||||||
public int getNumExpectedLocations() {
|
public int getNumExpectedLocations() {
|
||||||
return replicas == null ? 0 : replicas.size();
|
return replicas == null ? 0 : replicas.size();
|
||||||
}
|
}
|
||||||
|
@ -209,15 +228,19 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
blockUCState = s;
|
blockUCState = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get block recovery ID. */
|
/** Get block recovery ID */
|
||||||
public long getBlockRecoveryId() {
|
public long getBlockRecoveryId() {
|
||||||
return blockRecoveryId;
|
return blockRecoveryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get recover block. */
|
/** Get recover block */
|
||||||
public abstract Block getTruncateBlock();
|
public Block getTruncateBlock() {
|
||||||
|
return truncateBlock;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void setTruncateBlock(Block recoveryBlock);
|
public void setTruncateBlock(Block recoveryBlock) {
|
||||||
|
this.truncateBlock = recoveryBlock;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the recorded replicas. When about to commit or finish the
|
* Process the recorded replicas. When about to commit or finish the
|
||||||
|
@ -227,9 +250,8 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
public void setGenerationStampAndVerifyReplicas(long genStamp) {
|
public void setGenerationStampAndVerifyReplicas(long genStamp) {
|
||||||
// Set the generation stamp for the block.
|
// Set the generation stamp for the block.
|
||||||
setGenerationStamp(genStamp);
|
setGenerationStamp(genStamp);
|
||||||
if (replicas == null) {
|
if (replicas == null)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the replicas with wrong gen stamp.
|
// Remove the replicas with wrong gen stamp.
|
||||||
// The replica list is unchanged.
|
// The replica list is unchanged.
|
||||||
|
@ -249,10 +271,9 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
* @throws IOException if block ids are inconsistent.
|
* @throws IOException if block ids are inconsistent.
|
||||||
*/
|
*/
|
||||||
void commitBlock(Block block) throws IOException {
|
void commitBlock(Block block) throws IOException {
|
||||||
if(getBlockId() != block.getBlockId()) {
|
if(getBlockId() != block.getBlockId())
|
||||||
throw new IOException("Trying to commit inconsistent block: id = "
|
throw new IOException("Trying to commit inconsistent block: id = "
|
||||||
+ block.getBlockId() + ", expected id = " + getBlockId());
|
+ block.getBlockId() + ", expected id = " + getBlockId());
|
||||||
}
|
|
||||||
blockUCState = BlockUCState.COMMITTED;
|
blockUCState = BlockUCState.COMMITTED;
|
||||||
this.set(getBlockId(), block.getNumBytes(), block.getGenerationStamp());
|
this.set(getBlockId(), block.getNumBytes(), block.getGenerationStamp());
|
||||||
// Sort out invalid replicas.
|
// Sort out invalid replicas.
|
||||||
|
@ -268,17 +289,16 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
setBlockUCState(BlockUCState.UNDER_RECOVERY);
|
setBlockUCState(BlockUCState.UNDER_RECOVERY);
|
||||||
blockRecoveryId = recoveryId;
|
blockRecoveryId = recoveryId;
|
||||||
if (replicas.size() == 0) {
|
if (replicas.size() == 0) {
|
||||||
NameNode.blockStateChangeLog.warn("BLOCK* " +
|
NameNode.blockStateChangeLog.warn("BLOCK*"
|
||||||
"BlockInfoUnderConstruction.initLeaseRecovery: " +
|
+ " BlockInfoUnderConstruction.initLeaseRecovery:"
|
||||||
"No blocks found, lease removed.");
|
+ " No blocks found, lease removed.");
|
||||||
}
|
}
|
||||||
boolean allLiveReplicasTriedAsPrimary = true;
|
boolean allLiveReplicasTriedAsPrimary = true;
|
||||||
for (int i = 0; i < replicas.size(); i++) {
|
for (int i = 0; i < replicas.size(); i++) {
|
||||||
// Check if all replicas have been tried or not.
|
// Check if all replicas have been tried or not.
|
||||||
if (replicas.get(i).isAlive()) {
|
if (replicas.get(i).isAlive()) {
|
||||||
allLiveReplicasTriedAsPrimary =
|
allLiveReplicasTriedAsPrimary =
|
||||||
(allLiveReplicasTriedAsPrimary &&
|
(allLiveReplicasTriedAsPrimary && replicas.get(i).getChosenAsPrimary());
|
||||||
replicas.get(i).getChosenAsPrimary());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allLiveReplicasTriedAsPrimary) {
|
if (allLiveReplicasTriedAsPrimary) {
|
||||||
|
@ -292,8 +312,7 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
primaryNodeIndex = -1;
|
primaryNodeIndex = -1;
|
||||||
for(int i = 0; i < replicas.size(); i++) {
|
for(int i = 0; i < replicas.size(); i++) {
|
||||||
// Skip alive replicas which have been chosen for recovery.
|
// Skip alive replicas which have been chosen for recovery.
|
||||||
if (!(replicas.get(i).isAlive() &&
|
if (!(replicas.get(i).isAlive() && !replicas.get(i).getChosenAsPrimary())) {
|
||||||
!replicas.get(i).getChosenAsPrimary())) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final ReplicaUnderConstruction ruc = replicas.get(i);
|
final ReplicaUnderConstruction ruc = replicas.get(i);
|
||||||
|
@ -306,8 +325,7 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (primary != null) {
|
if (primary != null) {
|
||||||
primary.getExpectedStorageLocation().
|
primary.getExpectedStorageLocation().getDatanodeDescriptor().addBlockToBeRecovered(this);
|
||||||
getDatanodeDescriptor().addBlockToBeRecovered(this);
|
|
||||||
primary.setChosenAsPrimary(true);
|
primary.setChosenAsPrimary(true);
|
||||||
NameNode.blockStateChangeLog.debug(
|
NameNode.blockStateChangeLog.debug(
|
||||||
"BLOCK* {} recovery started, primary={}", this, primary);
|
"BLOCK* {} recovery started, primary={}", this, primary);
|
||||||
|
@ -340,25 +358,6 @@ public abstract class BlockInfoUnderConstruction extends BlockInfo {
|
||||||
replicas.add(new ReplicaUnderConstruction(block, storage, rState));
|
replicas.add(new ReplicaUnderConstruction(block, storage, rState));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an under construction block to a complete block.
|
|
||||||
*
|
|
||||||
* @return a complete block.
|
|
||||||
* @throws IOException
|
|
||||||
* if the state of the block (the generation stamp and the length)
|
|
||||||
* has not been committed by the client or it does not have at
|
|
||||||
* least a minimal number of replicas reported from data-nodes.
|
|
||||||
*/
|
|
||||||
public abstract BlockInfo convertToCompleteBlock();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
BlockInfoUnderConstruction convertCompleteBlockToUC
|
|
||||||
(HdfsServerConstants.BlockUCState s, DatanodeStorageInfo[] targets) {
|
|
||||||
BlockManager.LOG.error("convertCompleteBlockToUC should only be applied " +
|
|
||||||
"on complete blocks.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override // BlockInfo
|
@Override // BlockInfo
|
||||||
// BlockInfoUnderConstruction participates in maps the same way as BlockInfo
|
// BlockInfoUnderConstruction participates in maps the same way as BlockInfo
|
||||||
public int hashCode() {
|
public int hashCode() {
|
|
@ -1,110 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.apache.hadoop.hdfs.server.blockmanagement;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import org.apache.hadoop.hdfs.protocol.Block;
|
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subclass of {@link BlockInfoUnderConstruction}, representing a block under
|
|
||||||
* the contiguous (instead of striped) layout.
|
|
||||||
*/
|
|
||||||
public class BlockInfoUnderConstructionContiguous extends
|
|
||||||
BlockInfoUnderConstruction {
|
|
||||||
/**
|
|
||||||
* Create block and set its state to
|
|
||||||
* {@link HdfsServerConstants.BlockUCState#UNDER_CONSTRUCTION}.
|
|
||||||
*/
|
|
||||||
public BlockInfoUnderConstructionContiguous(Block blk, short replication) {
|
|
||||||
this(blk, replication, HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION,
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a block that is currently being constructed.
|
|
||||||
*/
|
|
||||||
public BlockInfoUnderConstructionContiguous(Block blk, short replication,
|
|
||||||
HdfsServerConstants.BlockUCState state, DatanodeStorageInfo[] targets) {
|
|
||||||
super(blk, replication);
|
|
||||||
Preconditions.checkState(getBlockUCState() !=
|
|
||||||
HdfsServerConstants.BlockUCState.COMPLETE,
|
|
||||||
"BlockInfoUnderConstructionContiguous cannot be in COMPLETE state");
|
|
||||||
this.blockUCState = state;
|
|
||||||
setExpectedLocations(targets);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an under construction block to a complete block.
|
|
||||||
*
|
|
||||||
* @return BlockInfo - a complete block.
|
|
||||||
* @throws IOException if the state of the block
|
|
||||||
* (the generation stamp and the length) has not been committed by
|
|
||||||
* the client or it does not have at least a minimal number of replicas
|
|
||||||
* reported from data-nodes.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public BlockInfoContiguous convertToCompleteBlock() {
|
|
||||||
Preconditions.checkState(getBlockUCState() !=
|
|
||||||
HdfsServerConstants.BlockUCState.COMPLETE,
|
|
||||||
"Trying to convert a COMPLETE block");
|
|
||||||
return new BlockInfoContiguous(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean addStorage(DatanodeStorageInfo storage) {
|
|
||||||
return ContiguousBlockStorageOp.addStorage(this, storage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean removeStorage(DatanodeStorageInfo storage) {
|
|
||||||
return ContiguousBlockStorageOp.removeStorage(this, storage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int numNodes() {
|
|
||||||
return ContiguousBlockStorageOp.numNodes(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void replaceBlock(BlockInfo newBlock) {
|
|
||||||
ContiguousBlockStorageOp.replaceBlock(this, newBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExpectedLocations(DatanodeStorageInfo[] targets) {
|
|
||||||
int numLocations = targets == null ? 0 : targets.length;
|
|
||||||
this.replicas = new ArrayList<>(numLocations);
|
|
||||||
for(int i = 0; i < numLocations; i++) {
|
|
||||||
replicas.add(
|
|
||||||
new ReplicaUnderConstruction(this, targets[i], HdfsServerConstants.ReplicaState.RBW));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Block getTruncateBlock() {
|
|
||||||
return truncateBlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTruncateBlock(Block recoveryBlock) {
|
|
||||||
this.truncateBlock = recoveryBlock;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -610,7 +610,7 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
* of replicas reported from data-nodes.
|
* of replicas reported from data-nodes.
|
||||||
*/
|
*/
|
||||||
private static boolean commitBlock(
|
private static boolean commitBlock(
|
||||||
final BlockInfoUnderConstruction block, final Block commitBlock)
|
final BlockInfoContiguousUnderConstruction block, final Block commitBlock)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (block.getBlockUCState() == BlockUCState.COMMITTED)
|
if (block.getBlockUCState() == BlockUCState.COMMITTED)
|
||||||
return false;
|
return false;
|
||||||
|
@ -642,7 +642,7 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
return false; // already completed (e.g. by syncBlock)
|
return false; // already completed (e.g. by syncBlock)
|
||||||
|
|
||||||
final boolean b = commitBlock(
|
final boolean b = commitBlock(
|
||||||
(BlockInfoUnderConstruction) lastBlock, commitBlock);
|
(BlockInfoContiguousUnderConstruction) lastBlock, commitBlock);
|
||||||
if(countNodes(lastBlock).liveReplicas() >= minReplication)
|
if(countNodes(lastBlock).liveReplicas() >= minReplication)
|
||||||
completeBlock(bc, bc.numBlocks()-1, false);
|
completeBlock(bc, bc.numBlocks()-1, false);
|
||||||
return b;
|
return b;
|
||||||
|
@ -662,8 +662,8 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
BlockInfo curBlock = bc.getBlocks()[blkIndex];
|
BlockInfo curBlock = bc.getBlocks()[blkIndex];
|
||||||
if(curBlock.isComplete())
|
if(curBlock.isComplete())
|
||||||
return curBlock;
|
return curBlock;
|
||||||
BlockInfoUnderConstruction ucBlock =
|
BlockInfoContiguousUnderConstruction ucBlock =
|
||||||
(BlockInfoUnderConstruction) curBlock;
|
(BlockInfoContiguousUnderConstruction) curBlock;
|
||||||
int numNodes = ucBlock.numNodes();
|
int numNodes = ucBlock.numNodes();
|
||||||
if (!force && numNodes < minReplication)
|
if (!force && numNodes < minReplication)
|
||||||
throw new IOException("Cannot complete block: " +
|
throw new IOException("Cannot complete block: " +
|
||||||
|
@ -705,7 +705,7 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
* when tailing edit logs as a Standby.
|
* when tailing edit logs as a Standby.
|
||||||
*/
|
*/
|
||||||
public BlockInfo forceCompleteBlock(final BlockCollection bc,
|
public BlockInfo forceCompleteBlock(final BlockCollection bc,
|
||||||
final BlockInfoUnderConstruction block) throws IOException {
|
final BlockInfoContiguousUnderConstruction block) throws IOException {
|
||||||
block.commitBlock(block);
|
block.commitBlock(block);
|
||||||
return completeBlock(bc, block, true);
|
return completeBlock(bc, block, true);
|
||||||
}
|
}
|
||||||
|
@ -736,7 +736,7 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
|
|
||||||
DatanodeStorageInfo[] targets = getStorages(oldBlock);
|
DatanodeStorageInfo[] targets = getStorages(oldBlock);
|
||||||
|
|
||||||
BlockInfoUnderConstruction ucBlock =
|
BlockInfoContiguousUnderConstruction ucBlock =
|
||||||
bc.setLastBlock(oldBlock, targets);
|
bc.setLastBlock(oldBlock, targets);
|
||||||
blocksMap.replaceBlock(ucBlock);
|
blocksMap.replaceBlock(ucBlock);
|
||||||
|
|
||||||
|
@ -838,14 +838,14 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
/** @return a LocatedBlock for the given block */
|
/** @return a LocatedBlock for the given block */
|
||||||
private LocatedBlock createLocatedBlock(final BlockInfo blk, final long pos
|
private LocatedBlock createLocatedBlock(final BlockInfo blk, final long pos
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
if (blk instanceof BlockInfoUnderConstruction) {
|
if (blk instanceof BlockInfoContiguousUnderConstruction) {
|
||||||
if (blk.isComplete()) {
|
if (blk.isComplete()) {
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
"blk instanceof BlockInfoUnderConstruction && blk.isComplete()"
|
"blk instanceof BlockInfoUnderConstruction && blk.isComplete()"
|
||||||
+ ", blk=" + blk);
|
+ ", blk=" + blk);
|
||||||
}
|
}
|
||||||
final BlockInfoUnderConstruction uc =
|
final BlockInfoContiguousUnderConstruction uc =
|
||||||
(BlockInfoUnderConstruction) blk;
|
(BlockInfoContiguousUnderConstruction) blk;
|
||||||
final DatanodeStorageInfo[] storages = uc.getExpectedStorageLocations();
|
final DatanodeStorageInfo[] storages = uc.getExpectedStorageLocations();
|
||||||
final ExtendedBlock eb = new ExtendedBlock(namesystem.getBlockPoolId(), blk);
|
final ExtendedBlock eb = new ExtendedBlock(namesystem.getBlockPoolId(), blk);
|
||||||
return newLocatedBlock(eb, storages, pos, false);
|
return newLocatedBlock(eb, storages, pos, false);
|
||||||
|
@ -1750,11 +1750,11 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
* reported by the datanode in the block report.
|
* reported by the datanode in the block report.
|
||||||
*/
|
*/
|
||||||
static class StatefulBlockInfo {
|
static class StatefulBlockInfo {
|
||||||
final BlockInfoUnderConstruction storedBlock;
|
final BlockInfoContiguousUnderConstruction storedBlock;
|
||||||
final Block reportedBlock;
|
final Block reportedBlock;
|
||||||
final ReplicaState reportedState;
|
final ReplicaState reportedState;
|
||||||
|
|
||||||
StatefulBlockInfo(BlockInfoUnderConstruction storedBlock,
|
StatefulBlockInfo(BlockInfoContiguousUnderConstruction storedBlock,
|
||||||
Block reportedBlock, ReplicaState reportedState) {
|
Block reportedBlock, ReplicaState reportedState) {
|
||||||
this.storedBlock = storedBlock;
|
this.storedBlock = storedBlock;
|
||||||
this.reportedBlock = reportedBlock;
|
this.reportedBlock = reportedBlock;
|
||||||
|
@ -1795,7 +1795,7 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
|
|
||||||
BlockToMarkCorrupt(BlockInfo stored, long gs, String reason,
|
BlockToMarkCorrupt(BlockInfo stored, long gs, String reason,
|
||||||
Reason reasonCode) {
|
Reason reasonCode) {
|
||||||
this(new BlockInfoContiguous(stored), stored,
|
this(new BlockInfoContiguous((BlockInfoContiguous)stored), stored,
|
||||||
reason, reasonCode);
|
reason, reasonCode);
|
||||||
//the corrupted block in datanode has a different generation stamp
|
//the corrupted block in datanode has a different generation stamp
|
||||||
corrupted.setGenerationStamp(gs);
|
corrupted.setGenerationStamp(gs);
|
||||||
|
@ -2154,13 +2154,13 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
|
|
||||||
// If block is under construction, add this replica to its list
|
// If block is under construction, add this replica to its list
|
||||||
if (isBlockUnderConstruction(storedBlock, ucState, reportedState)) {
|
if (isBlockUnderConstruction(storedBlock, ucState, reportedState)) {
|
||||||
((BlockInfoUnderConstruction)storedBlock)
|
((BlockInfoContiguousUnderConstruction)storedBlock)
|
||||||
.addReplicaIfNotPresent(storageInfo, iblk, reportedState);
|
.addReplicaIfNotPresent(storageInfo, iblk, reportedState);
|
||||||
// OpenFileBlocks only inside snapshots also will be added to safemode
|
// OpenFileBlocks only inside snapshots also will be added to safemode
|
||||||
// threshold. So we need to update such blocks to safemode
|
// threshold. So we need to update such blocks to safemode
|
||||||
// refer HDFS-5283
|
// refer HDFS-5283
|
||||||
BlockInfoUnderConstruction blockUC =
|
BlockInfoContiguousUnderConstruction blockUC =
|
||||||
(BlockInfoUnderConstruction) storedBlock;
|
(BlockInfoContiguousUnderConstruction) storedBlock;
|
||||||
if (namesystem.isInSnapshot(blockUC)) {
|
if (namesystem.isInSnapshot(blockUC)) {
|
||||||
int numOfReplicas = blockUC.getNumExpectedLocations();
|
int numOfReplicas = blockUC.getNumExpectedLocations();
|
||||||
namesystem.incrementSafeBlockCount(numOfReplicas);
|
namesystem.incrementSafeBlockCount(numOfReplicas);
|
||||||
|
@ -2315,7 +2315,7 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
|
|
||||||
if (isBlockUnderConstruction(storedBlock, ucState, reportedState)) {
|
if (isBlockUnderConstruction(storedBlock, ucState, reportedState)) {
|
||||||
toUC.add(new StatefulBlockInfo(
|
toUC.add(new StatefulBlockInfo(
|
||||||
(BlockInfoUnderConstruction) storedBlock,
|
(BlockInfoContiguousUnderConstruction) storedBlock,
|
||||||
new Block(block), reportedState));
|
new Block(block), reportedState));
|
||||||
return storedBlock;
|
return storedBlock;
|
||||||
}
|
}
|
||||||
|
@ -2506,7 +2506,7 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
|
|
||||||
void addStoredBlockUnderConstruction(StatefulBlockInfo ucBlock,
|
void addStoredBlockUnderConstruction(StatefulBlockInfo ucBlock,
|
||||||
DatanodeStorageInfo storageInfo) throws IOException {
|
DatanodeStorageInfo storageInfo) throws IOException {
|
||||||
BlockInfoUnderConstruction block = ucBlock.storedBlock;
|
BlockInfoContiguousUnderConstruction block = ucBlock.storedBlock;
|
||||||
block.addReplicaIfNotPresent(
|
block.addReplicaIfNotPresent(
|
||||||
storageInfo, ucBlock.reportedBlock, ucBlock.reportedState);
|
storageInfo, ucBlock.reportedBlock, ucBlock.reportedState);
|
||||||
|
|
||||||
|
@ -2567,7 +2567,7 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
assert block != null && namesystem.hasWriteLock();
|
assert block != null && namesystem.hasWriteLock();
|
||||||
BlockInfo storedBlock;
|
BlockInfo storedBlock;
|
||||||
DatanodeDescriptor node = storageInfo.getDatanodeDescriptor();
|
DatanodeDescriptor node = storageInfo.getDatanodeDescriptor();
|
||||||
if (block instanceof BlockInfoUnderConstruction) {
|
if (block instanceof BlockInfoContiguousUnderConstruction) {
|
||||||
//refresh our copy in case the block got completed in another thread
|
//refresh our copy in case the block got completed in another thread
|
||||||
storedBlock = blocksMap.getStoredBlock(block);
|
storedBlock = blocksMap.getStoredBlock(block);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3522,8 +3522,8 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
String src, BlockInfo[] blocks) {
|
String src, BlockInfo[] blocks) {
|
||||||
for (BlockInfo b: blocks) {
|
for (BlockInfo b: blocks) {
|
||||||
if (!b.isComplete()) {
|
if (!b.isComplete()) {
|
||||||
final BlockInfoUnderConstruction uc =
|
final BlockInfoContiguousUnderConstruction uc =
|
||||||
(BlockInfoUnderConstruction)b;
|
(BlockInfoContiguousUnderConstruction)b;
|
||||||
final int numNodes = b.numNodes();
|
final int numNodes = b.numNodes();
|
||||||
LOG.info("BLOCK* " + b + " is not COMPLETE (ucState = "
|
LOG.info("BLOCK* " + b + " is not COMPLETE (ucState = "
|
||||||
+ uc.getBlockUCState() + ", replication# = " + numNodes
|
+ uc.getBlockUCState() + ", replication# = " + numNodes
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.apache.hadoop.hdfs.server.blockmanagement;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility class with logic on managing storage locations shared between
|
|
||||||
* complete and under-construction blocks under the contiguous format --
|
|
||||||
* {@link BlockInfoContiguous} and
|
|
||||||
* {@link BlockInfoUnderConstructionContiguous}.
|
|
||||||
*/
|
|
||||||
class ContiguousBlockStorageOp {
|
|
||||||
/**
|
|
||||||
* Ensure that there is enough space to include num more triplets.
|
|
||||||
* @return first free triplet index.
|
|
||||||
*/
|
|
||||||
private static int ensureCapacity(BlockInfo b, int num) {
|
|
||||||
Preconditions.checkArgument(b.triplets != null,
|
|
||||||
"BlockInfo is not initialized");
|
|
||||||
int last = b.numNodes();
|
|
||||||
if (b.triplets.length >= (last+num)*3) {
|
|
||||||
return last;
|
|
||||||
}
|
|
||||||
/* Not enough space left. Create a new array. Should normally
|
|
||||||
* happen only when replication is manually increased by the user. */
|
|
||||||
Object[] old = b.triplets;
|
|
||||||
b.triplets = new Object[(last+num)*3];
|
|
||||||
System.arraycopy(old, 0, b.triplets, 0, last * 3);
|
|
||||||
return last;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean addStorage(BlockInfo b, DatanodeStorageInfo storage) {
|
|
||||||
// find the last null node
|
|
||||||
int lastNode = ensureCapacity(b, 1);
|
|
||||||
b.setStorageInfo(lastNode, storage);
|
|
||||||
b.setNext(lastNode, null);
|
|
||||||
b.setPrevious(lastNode, null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean removeStorage(BlockInfo b,
|
|
||||||
DatanodeStorageInfo storage) {
|
|
||||||
int dnIndex = b.findStorageInfo(storage);
|
|
||||||
if (dnIndex < 0) { // the node is not found
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Preconditions.checkArgument(b.getPrevious(dnIndex) == null &&
|
|
||||||
b.getNext(dnIndex) == null,
|
|
||||||
"Block is still in the list and must be removed first.");
|
|
||||||
// find the last not null node
|
|
||||||
int lastNode = b.numNodes()-1;
|
|
||||||
// replace current node triplet by the lastNode one
|
|
||||||
b.setStorageInfo(dnIndex, b.getStorageInfo(lastNode));
|
|
||||||
b.setNext(dnIndex, b.getNext(lastNode));
|
|
||||||
b.setPrevious(dnIndex, b.getPrevious(lastNode));
|
|
||||||
// set the last triplet to null
|
|
||||||
b.setStorageInfo(lastNode, null);
|
|
||||||
b.setNext(lastNode, null);
|
|
||||||
b.setPrevious(lastNode, null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int numNodes(BlockInfo b) {
|
|
||||||
Preconditions.checkArgument(b.triplets != null,
|
|
||||||
"BlockInfo is not initialized");
|
|
||||||
Preconditions.checkArgument(b.triplets.length % 3 == 0,
|
|
||||||
"Malformed BlockInfo");
|
|
||||||
|
|
||||||
for (int idx = b.getCapacity()-1; idx >= 0; idx--) {
|
|
||||||
if (b.getDatanode(idx) != null) {
|
|
||||||
return idx + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void replaceBlock(BlockInfo b, BlockInfo newBlock) {
|
|
||||||
for (int i = b.numNodes() - 1; i >= 0; i--) {
|
|
||||||
final DatanodeStorageInfo storage = b.getStorageInfo(i);
|
|
||||||
final boolean removed = storage.removeBlock(b);
|
|
||||||
Preconditions.checkState(removed, "currentBlock not found.");
|
|
||||||
|
|
||||||
final DatanodeStorageInfo.AddBlockResult result = storage.addBlock(
|
|
||||||
newBlock);
|
|
||||||
Preconditions.checkState(
|
|
||||||
result == DatanodeStorageInfo.AddBlockResult.ADDED,
|
|
||||||
"newBlock already exists.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -223,8 +223,8 @@ public class DatanodeDescriptor extends DatanodeInfo {
|
||||||
private final BlockQueue<BlockTargetPair> replicateBlocks =
|
private final BlockQueue<BlockTargetPair> replicateBlocks =
|
||||||
new BlockQueue<>();
|
new BlockQueue<>();
|
||||||
/** A queue of blocks to be recovered by this datanode */
|
/** A queue of blocks to be recovered by this datanode */
|
||||||
private final BlockQueue<BlockInfoUnderConstruction> recoverBlocks =
|
private final BlockQueue<BlockInfoContiguousUnderConstruction> recoverBlocks =
|
||||||
new BlockQueue<>();
|
new BlockQueue<BlockInfoContiguousUnderConstruction>();
|
||||||
/** A set of blocks to be invalidated by this datanode */
|
/** A set of blocks to be invalidated by this datanode */
|
||||||
private final LightWeightHashSet<Block> invalidateBlocks =
|
private final LightWeightHashSet<Block> invalidateBlocks =
|
||||||
new LightWeightHashSet<>();
|
new LightWeightHashSet<>();
|
||||||
|
@ -602,7 +602,7 @@ public class DatanodeDescriptor extends DatanodeInfo {
|
||||||
/**
|
/**
|
||||||
* Store block recovery work.
|
* Store block recovery work.
|
||||||
*/
|
*/
|
||||||
void addBlockToBeRecovered(BlockInfoUnderConstruction block) {
|
void addBlockToBeRecovered(BlockInfoContiguousUnderConstruction block) {
|
||||||
if(recoverBlocks.contains(block)) {
|
if(recoverBlocks.contains(block)) {
|
||||||
// this prevents adding the same block twice to the recovery queue
|
// this prevents adding the same block twice to the recovery queue
|
||||||
BlockManager.LOG.info(block + " is already in the recovery queue");
|
BlockManager.LOG.info(block + " is already in the recovery queue");
|
||||||
|
@ -644,12 +644,11 @@ public class DatanodeDescriptor extends DatanodeInfo {
|
||||||
return replicateBlocks.poll(maxTransfers);
|
return replicateBlocks.poll(maxTransfers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockInfoUnderConstruction[] getLeaseRecoveryCommand(
|
public BlockInfoContiguousUnderConstruction[] getLeaseRecoveryCommand(int maxTransfers) {
|
||||||
int maxTransfers) {
|
List<BlockInfoContiguousUnderConstruction> blocks = recoverBlocks.poll(maxTransfers);
|
||||||
List<BlockInfoUnderConstruction> blocks = recoverBlocks.poll(maxTransfers);
|
|
||||||
if(blocks == null)
|
if(blocks == null)
|
||||||
return null;
|
return null;
|
||||||
return blocks.toArray(new BlockInfoUnderConstruction[blocks.size()]);
|
return blocks.toArray(new BlockInfoContiguousUnderConstruction[blocks.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1379,12 +1379,12 @@ public class DatanodeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
//check lease recovery
|
//check lease recovery
|
||||||
BlockInfoUnderConstruction[] blocks = nodeinfo
|
BlockInfoContiguousUnderConstruction[] blocks = nodeinfo
|
||||||
.getLeaseRecoveryCommand(Integer.MAX_VALUE);
|
.getLeaseRecoveryCommand(Integer.MAX_VALUE);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
BlockRecoveryCommand brCommand = new BlockRecoveryCommand(
|
BlockRecoveryCommand brCommand = new BlockRecoveryCommand(
|
||||||
blocks.length);
|
blocks.length);
|
||||||
for (BlockInfoUnderConstruction b : blocks) {
|
for (BlockInfoContiguousUnderConstruction b : blocks) {
|
||||||
final DatanodeStorageInfo[] storages = b.getExpectedStorageLocations();
|
final DatanodeStorageInfo[] storages = b.getExpectedStorageLocations();
|
||||||
// Skip stale nodes during recovery - not heart beated for some time (30s by default).
|
// Skip stale nodes during recovery - not heart beated for some time (30s by default).
|
||||||
final List<DatanodeStorageInfo> recoveryLocations =
|
final List<DatanodeStorageInfo> recoveryLocations =
|
||||||
|
|
|
@ -28,8 +28,7 @@ import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
||||||
import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
||||||
import org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException;
|
import org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstructionContiguous;
|
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem.RecoverLeaseOp;
|
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem.RecoverLeaseOp;
|
||||||
|
@ -96,7 +95,7 @@ final class FSDirTruncateOp {
|
||||||
final BlockInfo last = file.getLastBlock();
|
final BlockInfo last = file.getLastBlock();
|
||||||
if (last != null && last.getBlockUCState()
|
if (last != null && last.getBlockUCState()
|
||||||
== BlockUCState.UNDER_RECOVERY) {
|
== BlockUCState.UNDER_RECOVERY) {
|
||||||
final Block truncatedBlock = ((BlockInfoUnderConstruction) last)
|
final Block truncatedBlock = ((BlockInfoContiguousUnderConstruction) last)
|
||||||
.getTruncateBlock();
|
.getTruncateBlock();
|
||||||
if (truncatedBlock != null) {
|
if (truncatedBlock != null) {
|
||||||
final long truncateLength = file.computeFileSize(false, false)
|
final long truncateLength = file.computeFileSize(false, false)
|
||||||
|
@ -223,12 +222,12 @@ final class FSDirTruncateOp {
|
||||||
oldBlock)));
|
oldBlock)));
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockInfoUnderConstruction truncatedBlockUC;
|
BlockInfoContiguousUnderConstruction truncatedBlockUC;
|
||||||
BlockManager blockManager = fsn.getFSDirectory().getBlockManager();
|
BlockManager blockManager = fsn.getFSDirectory().getBlockManager();
|
||||||
if (shouldCopyOnTruncate) {
|
if (shouldCopyOnTruncate) {
|
||||||
// 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 BlockInfoUnderConstructionContiguous(newBlock,
|
truncatedBlockUC = new BlockInfoContiguousUnderConstruction(newBlock,
|
||||||
file.getPreferredBlockReplication());
|
file.getPreferredBlockReplication());
|
||||||
truncatedBlockUC.setNumBytes(oldBlock.getNumBytes() - lastBlockDelta);
|
truncatedBlockUC.setNumBytes(oldBlock.getNumBytes() - lastBlockDelta);
|
||||||
truncatedBlockUC.setTruncateBlock(oldBlock);
|
truncatedBlockUC.setTruncateBlock(oldBlock);
|
||||||
|
@ -245,7 +244,7 @@ final class FSDirTruncateOp {
|
||||||
blockManager.convertLastBlockToUnderConstruction(file, lastBlockDelta);
|
blockManager.convertLastBlockToUnderConstruction(file, lastBlockDelta);
|
||||||
oldBlock = file.getLastBlock();
|
oldBlock = file.getLastBlock();
|
||||||
assert !oldBlock.isComplete() : "oldBlock should be under construction";
|
assert !oldBlock.isComplete() : "oldBlock should be under construction";
|
||||||
truncatedBlockUC = (BlockInfoUnderConstruction) oldBlock;
|
truncatedBlockUC = (BlockInfoContiguousUnderConstruction) oldBlock;
|
||||||
truncatedBlockUC.setTruncateBlock(new Block(oldBlock));
|
truncatedBlockUC.setTruncateBlock(new Block(oldBlock));
|
||||||
truncatedBlockUC.getTruncateBlock().setNumBytes(
|
truncatedBlockUC.getTruncateBlock().setNumBytes(
|
||||||
oldBlock.getNumBytes() - lastBlockDelta);
|
oldBlock.getNumBytes() - lastBlockDelta);
|
||||||
|
|
|
@ -43,8 +43,7 @@ import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
||||||
import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
||||||
import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
|
import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstructionContiguous;
|
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||||
|
@ -74,7 +73,7 @@ class FSDirWriteFileOp {
|
||||||
Block block) throws IOException {
|
Block block) throws IOException {
|
||||||
// modify file-> block and blocksMap
|
// modify file-> block and blocksMap
|
||||||
// fileNode should be under construction
|
// fileNode should be under construction
|
||||||
BlockInfoUnderConstruction uc = fileNode.removeLastBlock(block);
|
BlockInfoContiguousUnderConstruction uc = fileNode.removeLastBlock(block);
|
||||||
if (uc == null) {
|
if (uc == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +236,7 @@ class FSDirWriteFileOp {
|
||||||
} else {
|
} else {
|
||||||
// add new chosen targets to already allocated block and return
|
// add new chosen targets to already allocated block and return
|
||||||
BlockInfo lastBlockInFile = pendingFile.getLastBlock();
|
BlockInfo lastBlockInFile = pendingFile.getLastBlock();
|
||||||
((BlockInfoUnderConstruction) lastBlockInFile)
|
((BlockInfoContiguousUnderConstruction) lastBlockInFile)
|
||||||
.setExpectedLocations(targets);
|
.setExpectedLocations(targets);
|
||||||
offset = pendingFile.computeFileSize();
|
offset = pendingFile.computeFileSize();
|
||||||
return makeLocatedBlock(fsn, lastBlockInFile, targets, offset);
|
return makeLocatedBlock(fsn, lastBlockInFile, targets, offset);
|
||||||
|
@ -521,8 +520,8 @@ class FSDirWriteFileOp {
|
||||||
fileINode.getPreferredBlockReplication(), true);
|
fileINode.getPreferredBlockReplication(), true);
|
||||||
|
|
||||||
// associate new last block for the file
|
// associate new last block for the file
|
||||||
BlockInfoUnderConstruction blockInfo =
|
BlockInfoContiguousUnderConstruction blockInfo =
|
||||||
new BlockInfoUnderConstructionContiguous(
|
new BlockInfoContiguousUnderConstruction(
|
||||||
block,
|
block,
|
||||||
fileINode.getFileReplication(),
|
fileINode.getFileReplication(),
|
||||||
HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION,
|
HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION,
|
||||||
|
@ -663,8 +662,8 @@ class FSDirWriteFileOp {
|
||||||
"allocation of a new block in " + src + ". Returning previously" +
|
"allocation of a new block in " + src + ". Returning previously" +
|
||||||
" allocated block " + lastBlockInFile);
|
" allocated block " + lastBlockInFile);
|
||||||
long offset = file.computeFileSize();
|
long offset = file.computeFileSize();
|
||||||
BlockInfoUnderConstruction lastBlockUC =
|
BlockInfoContiguousUnderConstruction lastBlockUC =
|
||||||
(BlockInfoUnderConstruction) lastBlockInFile;
|
(BlockInfoContiguousUnderConstruction) lastBlockInFile;
|
||||||
onRetryBlock[0] = makeLocatedBlock(fsn, lastBlockInFile,
|
onRetryBlock[0] = makeLocatedBlock(fsn, lastBlockInFile,
|
||||||
lastBlockUC.getExpectedStorageLocations(), offset);
|
lastBlockUC.getExpectedStorageLocations(), offset);
|
||||||
return new FileState(file, src, iip);
|
return new FileState(file, src, iip);
|
||||||
|
|
|
@ -45,8 +45,7 @@ import org.apache.hadoop.hdfs.protocol.LastBlockWithStatus;
|
||||||
import org.apache.hadoop.hdfs.protocol.LayoutVersion;
|
import org.apache.hadoop.hdfs.protocol.LayoutVersion;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstructionContiguous;
|
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
||||||
|
@ -964,16 +963,16 @@ public class FSEditLogLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
oldLastBlock.setNumBytes(pBlock.getNumBytes());
|
oldLastBlock.setNumBytes(pBlock.getNumBytes());
|
||||||
if (oldLastBlock instanceof BlockInfoUnderConstruction) {
|
if (oldLastBlock instanceof BlockInfoContiguousUnderConstruction) {
|
||||||
fsNamesys.getBlockManager().forceCompleteBlock(file,
|
fsNamesys.getBlockManager().forceCompleteBlock(file,
|
||||||
(BlockInfoUnderConstruction) oldLastBlock);
|
(BlockInfoContiguousUnderConstruction) oldLastBlock);
|
||||||
fsNamesys.getBlockManager().processQueuedMessagesForBlock(pBlock);
|
fsNamesys.getBlockManager().processQueuedMessagesForBlock(pBlock);
|
||||||
}
|
}
|
||||||
} else { // the penultimate block is null
|
} else { // the penultimate block is null
|
||||||
Preconditions.checkState(oldBlocks == null || oldBlocks.length == 0);
|
Preconditions.checkState(oldBlocks == null || oldBlocks.length == 0);
|
||||||
}
|
}
|
||||||
// add the new block
|
// add the new block
|
||||||
BlockInfo newBI = new BlockInfoUnderConstructionContiguous(
|
BlockInfo newBI = new BlockInfoContiguousUnderConstruction(
|
||||||
newBlock, file.getPreferredBlockReplication());
|
newBlock, file.getPreferredBlockReplication());
|
||||||
fsNamesys.getBlockManager().addBlockCollection(newBI, file);
|
fsNamesys.getBlockManager().addBlockCollection(newBI, file);
|
||||||
file.addBlock(newBI);
|
file.addBlock(newBI);
|
||||||
|
@ -1014,11 +1013,11 @@ public class FSEditLogLoader {
|
||||||
oldBlock.getGenerationStamp() != newBlock.getGenerationStamp();
|
oldBlock.getGenerationStamp() != newBlock.getGenerationStamp();
|
||||||
oldBlock.setGenerationStamp(newBlock.getGenerationStamp());
|
oldBlock.setGenerationStamp(newBlock.getGenerationStamp());
|
||||||
|
|
||||||
if (oldBlock instanceof BlockInfoUnderConstruction &&
|
if (oldBlock instanceof BlockInfoContiguousUnderConstruction &&
|
||||||
(!isLastBlock || op.shouldCompleteLastBlock())) {
|
(!isLastBlock || op.shouldCompleteLastBlock())) {
|
||||||
changeMade = true;
|
changeMade = true;
|
||||||
fsNamesys.getBlockManager().forceCompleteBlock(file,
|
fsNamesys.getBlockManager().forceCompleteBlock(file,
|
||||||
(BlockInfoUnderConstruction) oldBlock);
|
(BlockInfoContiguousUnderConstruction) oldBlock);
|
||||||
}
|
}
|
||||||
if (changeMade) {
|
if (changeMade) {
|
||||||
// The state or gen-stamp of the block has changed. So, we may be
|
// The state or gen-stamp of the block has changed. So, we may be
|
||||||
|
@ -1053,7 +1052,7 @@ public class FSEditLogLoader {
|
||||||
// TODO: shouldn't this only be true for the last block?
|
// TODO: shouldn't this only be true for the last block?
|
||||||
// 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 BlockInfoUnderConstructionContiguous(
|
newBI = new BlockInfoContiguousUnderConstruction(
|
||||||
newBlock, file.getPreferredBlockReplication());
|
newBlock, file.getPreferredBlockReplication());
|
||||||
} else {
|
} else {
|
||||||
// OP_CLOSE should add finalized blocks. This code path
|
// OP_CLOSE should add finalized blocks. This code path
|
||||||
|
|
|
@ -54,7 +54,7 @@ import org.apache.hadoop.hdfs.protocol.LayoutVersion;
|
||||||
import org.apache.hadoop.hdfs.protocol.LayoutVersion.Feature;
|
import org.apache.hadoop.hdfs.protocol.LayoutVersion.Feature;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstructionContiguous;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
||||||
|
@ -777,9 +777,8 @@ public class FSImageFormat {
|
||||||
// convert the last block to BlockUC
|
// convert the last block to BlockUC
|
||||||
if (blocks.length > 0) {
|
if (blocks.length > 0) {
|
||||||
BlockInfo lastBlk = blocks[blocks.length - 1];
|
BlockInfo lastBlk = blocks[blocks.length - 1];
|
||||||
blocks[blocks.length - 1] =
|
blocks[blocks.length - 1] = new BlockInfoContiguousUnderConstruction(
|
||||||
new BlockInfoUnderConstructionContiguous(
|
lastBlk, replication);
|
||||||
lastBlk, replication);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockProto;
|
||||||
import org.apache.hadoop.hdfs.protocolPB.PBHelper;
|
import org.apache.hadoop.hdfs.protocolPB.PBHelper;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstructionContiguous;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf.LoaderContext;
|
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf.LoaderContext;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf.SaverContext;
|
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf.SaverContext;
|
||||||
|
@ -363,8 +363,8 @@ public final class FSImageFormatPBINode {
|
||||||
if (blocks.length > 0) {
|
if (blocks.length > 0) {
|
||||||
BlockInfo lastBlk = file.getLastBlock();
|
BlockInfo lastBlk = file.getLastBlock();
|
||||||
// replace the last block of file
|
// replace the last block of file
|
||||||
file.setBlock(file.numBlocks() - 1,
|
file.setBlock(file.numBlocks() - 1, new BlockInfoContiguousUnderConstruction(
|
||||||
new BlockInfoUnderConstructionContiguous(lastBlk, replication));
|
lastBlk, replication));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.hadoop.hdfs.protocol.CachePoolInfo;
|
||||||
import org.apache.hadoop.hdfs.protocol.LayoutVersion;
|
import org.apache.hadoop.hdfs.protocol.LayoutVersion;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstructionContiguous;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotFSImageFormat;
|
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotFSImageFormat;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotFSImageFormat.ReferenceMap;
|
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotFSImageFormat.ReferenceMap;
|
||||||
|
@ -137,7 +137,7 @@ public class FSImageSerialization {
|
||||||
// last block is UNDER_CONSTRUCTION
|
// last block is UNDER_CONSTRUCTION
|
||||||
if(numBlocks > 0) {
|
if(numBlocks > 0) {
|
||||||
blk.readFields(in);
|
blk.readFields(in);
|
||||||
blocks[i] = new BlockInfoUnderConstructionContiguous(
|
blocks[i] = new BlockInfoContiguousUnderConstruction(
|
||||||
blk, blockReplication, BlockUCState.UNDER_CONSTRUCTION, null);
|
blk, blockReplication, BlockUCState.UNDER_CONSTRUCTION, null);
|
||||||
}
|
}
|
||||||
PermissionStatus perm = PermissionStatus.read(in);
|
PermissionStatus perm = PermissionStatus.read(in);
|
||||||
|
|
|
@ -203,7 +203,7 @@ import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretMan
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockCollection;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockCollection;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockIdManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockIdManager;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeManager;
|
||||||
|
@ -3085,8 +3085,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
throw new AlreadyBeingCreatedException(message);
|
throw new AlreadyBeingCreatedException(message);
|
||||||
case UNDER_CONSTRUCTION:
|
case UNDER_CONSTRUCTION:
|
||||||
case UNDER_RECOVERY:
|
case UNDER_RECOVERY:
|
||||||
final BlockInfoUnderConstruction uc =
|
final BlockInfoContiguousUnderConstruction uc = (BlockInfoContiguousUnderConstruction)lastBlock;
|
||||||
(BlockInfoUnderConstruction)lastBlock;
|
|
||||||
// determine if last block was intended to be truncated
|
// determine if last block was intended to be truncated
|
||||||
Block recoveryBlock = uc.getTruncateBlock();
|
Block recoveryBlock = uc.getTruncateBlock();
|
||||||
boolean truncateRecovery = recoveryBlock != null;
|
boolean truncateRecovery = recoveryBlock != null;
|
||||||
|
@ -3202,7 +3201,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInSnapshot(BlockInfoUnderConstruction blockUC) {
|
public boolean isInSnapshot(BlockInfoContiguousUnderConstruction blockUC) {
|
||||||
assert hasReadLock();
|
assert hasReadLock();
|
||||||
final BlockCollection bc = blockUC.getBlockCollection();
|
final BlockCollection bc = blockUC.getBlockCollection();
|
||||||
if (bc == null || !(bc instanceof INodeFile)
|
if (bc == null || !(bc instanceof INodeFile)
|
||||||
|
@ -3249,7 +3248,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
waitForLoadingFSImage();
|
waitForLoadingFSImage();
|
||||||
writeLock();
|
writeLock();
|
||||||
boolean copyTruncate = false;
|
boolean copyTruncate = false;
|
||||||
BlockInfoUnderConstruction truncatedBlock = null;
|
BlockInfoContiguousUnderConstruction truncatedBlock = null;
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
// If a DN tries to commit to the standby, the recovery will
|
// If a DN tries to commit to the standby, the recovery will
|
||||||
|
@ -3306,7 +3305,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
truncatedBlock = (BlockInfoUnderConstruction) iFile
|
truncatedBlock = (BlockInfoContiguousUnderConstruction) iFile
|
||||||
.getLastBlock();
|
.getLastBlock();
|
||||||
long recoveryId = truncatedBlock.getBlockRecoveryId();
|
long recoveryId = truncatedBlock.getBlockRecoveryId();
|
||||||
copyTruncate = truncatedBlock.getBlockId() != storedBlock.getBlockId();
|
copyTruncate = truncatedBlock.getBlockId() != storedBlock.getBlockId();
|
||||||
|
@ -5330,8 +5329,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
assert hasWriteLock();
|
assert hasWriteLock();
|
||||||
// check the vadility of the block and lease holder name
|
// check the vadility of the block and lease holder name
|
||||||
final INodeFile pendingFile = checkUCBlock(oldBlock, clientName);
|
final INodeFile pendingFile = checkUCBlock(oldBlock, clientName);
|
||||||
final BlockInfoUnderConstruction blockinfo
|
final BlockInfoContiguousUnderConstruction blockinfo
|
||||||
= (BlockInfoUnderConstruction)pendingFile.getLastBlock();
|
= (BlockInfoContiguousUnderConstruction)pendingFile.getLastBlock();
|
||||||
|
|
||||||
// check new GS & length: this is not expected
|
// check new GS & length: this is not expected
|
||||||
if (newBlock.getGenerationStamp() <= blockinfo.getGenerationStamp() ||
|
if (newBlock.getGenerationStamp() <= blockinfo.getGenerationStamp() ||
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.INode.BlocksMapUpdateInfo;
|
import org.apache.hadoop.hdfs.server.namenode.INode.BlocksMapUpdateInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +61,7 @@ public class FileUnderConstructionFeature implements INode.Feature {
|
||||||
BlockInfo lastBlock = f.getLastBlock();
|
BlockInfo lastBlock = f.getLastBlock();
|
||||||
assert (lastBlock != null) : "The last block for path "
|
assert (lastBlock != null) : "The last block for path "
|
||||||
+ f.getFullPathName() + " is null when updating its length";
|
+ f.getFullPathName() + " is null when updating its length";
|
||||||
assert (lastBlock instanceof BlockInfoUnderConstruction)
|
assert (lastBlock instanceof BlockInfoContiguousUnderConstruction)
|
||||||
: "The last block for path " + f.getFullPathName()
|
: "The last block for path " + f.getFullPathName()
|
||||||
+ " is not a BlockInfoUnderConstruction when updating its length";
|
+ " is not a BlockInfoUnderConstruction when updating its length";
|
||||||
lastBlock.setNumBytes(lastBlockLength);
|
lastBlock.setNumBytes(lastBlockLength);
|
||||||
|
@ -76,9 +76,9 @@ public class FileUnderConstructionFeature implements INode.Feature {
|
||||||
final BlocksMapUpdateInfo collectedBlocks) {
|
final BlocksMapUpdateInfo collectedBlocks) {
|
||||||
final BlockInfo[] blocks = f.getBlocks();
|
final BlockInfo[] blocks = f.getBlocks();
|
||||||
if (blocks != null && blocks.length > 0
|
if (blocks != null && blocks.length > 0
|
||||||
&& blocks[blocks.length - 1] instanceof BlockInfoUnderConstruction) {
|
&& blocks[blocks.length - 1] instanceof BlockInfoContiguousUnderConstruction) {
|
||||||
BlockInfoUnderConstruction lastUC =
|
BlockInfoContiguousUnderConstruction lastUC =
|
||||||
(BlockInfoUnderConstruction) blocks[blocks.length - 1];
|
(BlockInfoContiguousUnderConstruction) blocks[blocks.length - 1];
|
||||||
if (lastUC.getNumBytes() == 0) {
|
if (lastUC.getNumBytes() == 0) {
|
||||||
// this is a 0-sized block. do not need check its UC state here
|
// this is a 0-sized block. do not need check its UC state here
|
||||||
collectedBlocks.addDeleteBlock(lastUC);
|
collectedBlocks.addDeleteBlock(lastUC);
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy;
|
||||||
import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockCollection;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockCollection;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
||||||
|
@ -231,7 +231,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // BlockCollection, the file should be under construction
|
@Override // BlockCollection, the file should be under construction
|
||||||
public BlockInfoUnderConstruction setLastBlock(
|
public BlockInfoContiguousUnderConstruction setLastBlock(
|
||||||
BlockInfo lastBlock, DatanodeStorageInfo[] locations)
|
BlockInfo lastBlock, DatanodeStorageInfo[] locations)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Preconditions.checkState(isUnderConstruction(),
|
Preconditions.checkState(isUnderConstruction(),
|
||||||
|
@ -240,7 +240,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
if (numBlocks() == 0) {
|
if (numBlocks() == 0) {
|
||||||
throw new IOException("Failed to set last block: File is empty.");
|
throw new IOException("Failed to set last block: File is empty.");
|
||||||
}
|
}
|
||||||
BlockInfoUnderConstruction ucBlock =
|
BlockInfoContiguousUnderConstruction ucBlock =
|
||||||
lastBlock.convertToBlockUnderConstruction(
|
lastBlock.convertToBlockUnderConstruction(
|
||||||
BlockUCState.UNDER_CONSTRUCTION, locations);
|
BlockUCState.UNDER_CONSTRUCTION, locations);
|
||||||
setBlock(numBlocks() - 1, ucBlock);
|
setBlock(numBlocks() - 1, ucBlock);
|
||||||
|
@ -251,7 +251,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
* Remove a block from the block list. This block should be
|
* Remove a block from the block list. This block should be
|
||||||
* the last one on the list.
|
* the last one on the list.
|
||||||
*/
|
*/
|
||||||
BlockInfoUnderConstruction removeLastBlock(Block oldblock) {
|
BlockInfoContiguousUnderConstruction removeLastBlock(Block oldblock) {
|
||||||
Preconditions.checkState(isUnderConstruction(),
|
Preconditions.checkState(isUnderConstruction(),
|
||||||
"file is no longer under construction");
|
"file is no longer under construction");
|
||||||
if (blocks == null || blocks.length == 0) {
|
if (blocks == null || blocks.length == 0) {
|
||||||
|
@ -262,8 +262,8 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockInfoUnderConstruction uc =
|
BlockInfoContiguousUnderConstruction uc =
|
||||||
(BlockInfoUnderConstruction)blocks[size_1];
|
(BlockInfoContiguousUnderConstruction)blocks[size_1];
|
||||||
//copy to a new list
|
//copy to a new list
|
||||||
BlockInfo[] newlist = new BlockInfo[size_1];
|
BlockInfo[] newlist = new BlockInfo[size_1];
|
||||||
System.arraycopy(blocks, 0, newlist, 0, size_1);
|
System.arraycopy(blocks, 0, newlist, 0, size_1);
|
||||||
|
@ -696,7 +696,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
final int last = blocks.length - 1;
|
final int last = blocks.length - 1;
|
||||||
//check if the last block is BlockInfoUnderConstruction
|
//check if the last block is BlockInfoUnderConstruction
|
||||||
long size = blocks[last].getNumBytes();
|
long size = blocks[last].getNumBytes();
|
||||||
if (blocks[last] instanceof BlockInfoUnderConstruction) {
|
if (blocks[last] instanceof BlockInfoContiguousUnderConstruction) {
|
||||||
if (!includesLastUcBlock) {
|
if (!includesLastUcBlock) {
|
||||||
size = 0;
|
size = 0;
|
||||||
} else if (usePreferredBlockSize4LastUcBlock) {
|
} else if (usePreferredBlockSize4LastUcBlock) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.hadoop.hdfs.server.namenode;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.hdfs.protocol.Block;
|
import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
||||||
import org.apache.hadoop.hdfs.util.RwLock;
|
import org.apache.hadoop.hdfs.util.RwLock;
|
||||||
import org.apache.hadoop.ipc.StandbyException;
|
import org.apache.hadoop.ipc.StandbyException;
|
||||||
|
@ -45,7 +45,7 @@ public interface Namesystem extends RwLock, SafeMode {
|
||||||
|
|
||||||
void checkOperation(OperationCategory read) throws StandbyException;
|
void checkOperation(OperationCategory read) throws StandbyException;
|
||||||
|
|
||||||
boolean isInSnapshot(BlockInfoUnderConstruction blockUC);
|
boolean isInSnapshot(BlockInfoContiguousUnderConstruction blockUC);
|
||||||
|
|
||||||
CacheManager getCacheManager();
|
CacheManager getCacheManager();
|
||||||
}
|
}
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.hadoop.hdfs.protocol.Block;
|
import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.INode;
|
import org.apache.hadoop.hdfs.server.namenode.INode;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.INode.BlocksMapUpdateInfo;
|
import org.apache.hadoop.hdfs.server.namenode.INode.BlocksMapUpdateInfo;
|
||||||
|
@ -133,7 +133,7 @@ public class FileDiffList extends
|
||||||
Block dontRemoveBlock = null;
|
Block dontRemoveBlock = null;
|
||||||
if (lastBlock != null && lastBlock.getBlockUCState().equals(
|
if (lastBlock != null && lastBlock.getBlockUCState().equals(
|
||||||
HdfsServerConstants.BlockUCState.UNDER_RECOVERY)) {
|
HdfsServerConstants.BlockUCState.UNDER_RECOVERY)) {
|
||||||
dontRemoveBlock = ((BlockInfoUnderConstruction) lastBlock)
|
dontRemoveBlock = ((BlockInfoContiguousUnderConstruction) lastBlock)
|
||||||
.getTruncateBlock();
|
.getTruncateBlock();
|
||||||
}
|
}
|
||||||
// Collect the remaining blocks of the file, ignoring truncate block
|
// Collect the remaining blocks of the file, ignoring truncate block
|
||||||
|
|
|
@ -110,7 +110,7 @@ import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.BlockOpResponseP
|
||||||
import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
|
import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
|
||||||
import org.apache.hadoop.hdfs.security.token.block.ExportedBlockKeys;
|
import org.apache.hadoop.hdfs.security.token.block.ExportedBlockKeys;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManagerTestUtil;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManagerTestUtil;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
||||||
|
@ -1645,9 +1645,9 @@ public class DFSTestUtil {
|
||||||
BlockInfo storedBlock = bm0.getStoredBlock(blk.getLocalBlock());
|
BlockInfo storedBlock = bm0.getStoredBlock(blk.getLocalBlock());
|
||||||
assertTrue("Block " + blk + " should be under construction, " +
|
assertTrue("Block " + blk + " should be under construction, " +
|
||||||
"got: " + storedBlock,
|
"got: " + storedBlock,
|
||||||
storedBlock instanceof BlockInfoUnderConstruction);
|
storedBlock instanceof BlockInfoContiguousUnderConstruction);
|
||||||
BlockInfoUnderConstruction ucBlock =
|
BlockInfoContiguousUnderConstruction ucBlock =
|
||||||
(BlockInfoUnderConstruction)storedBlock;
|
(BlockInfoContiguousUnderConstruction)storedBlock;
|
||||||
// We expect that the replica with the most recent heart beat will be
|
// We expect that the replica with the most recent heart beat will be
|
||||||
// the one to be in charge of the synchronization / recovery protocol.
|
// the one to be in charge of the synchronization / recovery protocol.
|
||||||
final DatanodeStorageInfo[] storages = ucBlock.getExpectedStorageLocations();
|
final DatanodeStorageInfo[] storages = ucBlock.getExpectedStorageLocations();
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.hadoop.hdfs.DFSTestUtil;
|
||||||
import org.apache.hadoop.hdfs.protocol.Block;
|
import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.server.common.GenerationStamp;
|
import org.apache.hadoop.hdfs.server.common.GenerationStamp;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
||||||
|
import org.apache.hadoop.util.Time;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,8 +40,7 @@ public class TestBlockInfoUnderConstruction {
|
||||||
DatanodeDescriptor dd3 = s3.getDatanodeDescriptor();
|
DatanodeDescriptor dd3 = s3.getDatanodeDescriptor();
|
||||||
|
|
||||||
dd1.isAlive = dd2.isAlive = dd3.isAlive = true;
|
dd1.isAlive = dd2.isAlive = dd3.isAlive = true;
|
||||||
BlockInfoUnderConstruction blockInfo =
|
BlockInfoContiguousUnderConstruction blockInfo = new BlockInfoContiguousUnderConstruction(
|
||||||
new BlockInfoUnderConstructionContiguous(
|
|
||||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP),
|
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP),
|
||||||
(short) 3,
|
(short) 3,
|
||||||
BlockUCState.UNDER_CONSTRUCTION,
|
BlockUCState.UNDER_CONSTRUCTION,
|
||||||
|
@ -51,7 +51,7 @@ public class TestBlockInfoUnderConstruction {
|
||||||
DFSTestUtil.resetLastUpdatesWithOffset(dd2, -1 * 1000);
|
DFSTestUtil.resetLastUpdatesWithOffset(dd2, -1 * 1000);
|
||||||
DFSTestUtil.resetLastUpdatesWithOffset(dd3, -2 * 1000);
|
DFSTestUtil.resetLastUpdatesWithOffset(dd3, -2 * 1000);
|
||||||
blockInfo.initializeBlockRecovery(1);
|
blockInfo.initializeBlockRecovery(1);
|
||||||
BlockInfoUnderConstruction[] blockInfoRecovery = dd2.getLeaseRecoveryCommand(1);
|
BlockInfoContiguousUnderConstruction[] blockInfoRecovery = dd2.getLeaseRecoveryCommand(1);
|
||||||
assertEquals(blockInfoRecovery[0], blockInfo);
|
assertEquals(blockInfoRecovery[0], blockInfo);
|
||||||
|
|
||||||
// Recovery attempt #2.
|
// Recovery attempt #2.
|
||||||
|
|
|
@ -726,7 +726,7 @@ public class TestBlockManager {
|
||||||
// verify the storage info is correct
|
// verify the storage info is correct
|
||||||
assertTrue(bm.getStoredBlock(new Block(receivedBlockId)).findStorageInfo
|
assertTrue(bm.getStoredBlock(new Block(receivedBlockId)).findStorageInfo
|
||||||
(ds) >= 0);
|
(ds) >= 0);
|
||||||
assertTrue(((BlockInfoUnderConstruction) bm.
|
assertTrue(((BlockInfoContiguousUnderConstruction) bm.
|
||||||
getStoredBlock(new Block(receivingBlockId))).getNumExpectedLocations() > 0);
|
getStoredBlock(new Block(receivingBlockId))).getNumExpectedLocations() > 0);
|
||||||
assertTrue(bm.getStoredBlock(new Block(receivingReceivedBlockId))
|
assertTrue(bm.getStoredBlock(new Block(receivingReceivedBlockId))
|
||||||
.findStorageInfo(ds) >= 0);
|
.findStorageInfo(ds) >= 0);
|
||||||
|
@ -747,8 +747,8 @@ public class TestBlockManager {
|
||||||
|
|
||||||
private BlockInfo addUcBlockToBM(long blkId) {
|
private BlockInfo addUcBlockToBM(long blkId) {
|
||||||
Block block = new Block(blkId);
|
Block block = new Block(blkId);
|
||||||
BlockInfoUnderConstruction blockInfo =
|
BlockInfoContiguousUnderConstruction blockInfo =
|
||||||
new BlockInfoUnderConstructionContiguous(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).getPreferredBlockReplication();
|
Mockito.doReturn((short) 3).when(bc).getPreferredBlockReplication();
|
||||||
bm.blocksMap.addBlockCollection(blockInfo, bc);
|
bm.blocksMap.addBlockCollection(blockInfo, bc);
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.hadoop.hdfs.server.protocol.DatanodeCommand;
|
||||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol;
|
import org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol;
|
||||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
||||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage;
|
import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage;
|
||||||
|
import org.apache.hadoop.util.Time;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,8 +173,7 @@ public class TestHeartbeatHandling {
|
||||||
dd1.getStorageInfos()[0],
|
dd1.getStorageInfos()[0],
|
||||||
dd2.getStorageInfos()[0],
|
dd2.getStorageInfos()[0],
|
||||||
dd3.getStorageInfos()[0]};
|
dd3.getStorageInfos()[0]};
|
||||||
BlockInfoUnderConstruction blockInfo =
|
BlockInfoContiguousUnderConstruction blockInfo = new BlockInfoContiguousUnderConstruction(
|
||||||
new BlockInfoUnderConstructionContiguous(
|
|
||||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), (short) 3,
|
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), (short) 3,
|
||||||
BlockUCState.UNDER_RECOVERY, storages);
|
BlockUCState.UNDER_RECOVERY, storages);
|
||||||
dd1.addBlockToBeRecovered(blockInfo);
|
dd1.addBlockToBeRecovered(blockInfo);
|
||||||
|
@ -195,7 +195,7 @@ public class TestHeartbeatHandling {
|
||||||
// More than the default stale interval of 30 seconds.
|
// More than the default stale interval of 30 seconds.
|
||||||
DFSTestUtil.resetLastUpdatesWithOffset(dd2, -40 * 1000);
|
DFSTestUtil.resetLastUpdatesWithOffset(dd2, -40 * 1000);
|
||||||
DFSTestUtil.resetLastUpdatesWithOffset(dd3, 0);
|
DFSTestUtil.resetLastUpdatesWithOffset(dd3, 0);
|
||||||
blockInfo = new BlockInfoUnderConstructionContiguous(
|
blockInfo = new BlockInfoContiguousUnderConstruction(
|
||||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), (short) 3,
|
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), (short) 3,
|
||||||
BlockUCState.UNDER_RECOVERY, storages);
|
BlockUCState.UNDER_RECOVERY, storages);
|
||||||
dd1.addBlockToBeRecovered(blockInfo);
|
dd1.addBlockToBeRecovered(blockInfo);
|
||||||
|
@ -216,7 +216,7 @@ public class TestHeartbeatHandling {
|
||||||
// More than the default stale interval of 30 seconds.
|
// More than the default stale interval of 30 seconds.
|
||||||
DFSTestUtil.resetLastUpdatesWithOffset(dd2, - 40 * 1000);
|
DFSTestUtil.resetLastUpdatesWithOffset(dd2, - 40 * 1000);
|
||||||
DFSTestUtil.resetLastUpdatesWithOffset(dd3, - 80 * 1000);
|
DFSTestUtil.resetLastUpdatesWithOffset(dd3, - 80 * 1000);
|
||||||
blockInfo = new BlockInfoUnderConstructionContiguous(
|
blockInfo = new BlockInfoContiguousUnderConstruction(
|
||||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), (short) 3,
|
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), (short) 3,
|
||||||
BlockUCState.UNDER_RECOVERY, storages);
|
BlockUCState.UNDER_RECOVERY, storages);
|
||||||
dd1.addBlockToBeRecovered(blockInfo);
|
dd1.addBlockToBeRecovered(blockInfo);
|
||||||
|
|
|
@ -1182,8 +1182,7 @@ public class TestReplicationPolicy {
|
||||||
// block under construction, the BlockManager will realize the expected
|
// block under construction, the BlockManager will realize the expected
|
||||||
// replication has been achieved and remove it from the under-replicated
|
// replication has been achieved and remove it from the under-replicated
|
||||||
// queue.
|
// queue.
|
||||||
BlockInfoUnderConstruction info =
|
BlockInfoContiguousUnderConstruction info = new BlockInfoContiguousUnderConstruction(block1, (short) 1);
|
||||||
new BlockInfoUnderConstructionContiguous(block1, (short) 1);
|
|
||||||
BlockCollection bc = mock(BlockCollection.class);
|
BlockCollection bc = mock(BlockCollection.class);
|
||||||
when(bc.getPreferredBlockReplication()).thenReturn((short)1);
|
when(bc.getPreferredBlockReplication()).thenReturn((short)1);
|
||||||
bm.addBlockCollection(info, bc);
|
bm.addBlockCollection(info, bc);
|
||||||
|
@ -1239,7 +1238,7 @@ public class TestReplicationPolicy {
|
||||||
|
|
||||||
DatanodeStorageInfo[] storageAry = {new DatanodeStorageInfo(
|
DatanodeStorageInfo[] storageAry = {new DatanodeStorageInfo(
|
||||||
dataNodes[0], new DatanodeStorage("s1"))};
|
dataNodes[0], new DatanodeStorage("s1"))};
|
||||||
final BlockInfoUnderConstruction ucBlock =
|
final BlockInfoContiguousUnderConstruction ucBlock =
|
||||||
info.convertToBlockUnderConstruction(BlockUCState.UNDER_CONSTRUCTION,
|
info.convertToBlockUnderConstruction(BlockUCState.UNDER_CONSTRUCTION,
|
||||||
storageAry);
|
storageAry);
|
||||||
DatanodeStorageInfo storage = mock(DatanodeStorageInfo.class);
|
DatanodeStorageInfo storage = mock(DatanodeStorageInfo.class);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
||||||
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
||||||
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
|
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -170,7 +170,7 @@ public class TestBlockUnderConstruction {
|
||||||
final List<LocatedBlock> blocks = lb.getLocatedBlocks();
|
final List<LocatedBlock> blocks = lb.getLocatedBlocks();
|
||||||
assertEquals(i, blocks.size());
|
assertEquals(i, blocks.size());
|
||||||
final Block b = blocks.get(blocks.size() - 1).getBlock().getLocalBlock();
|
final Block b = blocks.get(blocks.size() - 1).getBlock().getLocalBlock();
|
||||||
assertTrue(b instanceof BlockInfoUnderConstruction);
|
assertTrue(b instanceof BlockInfoContiguousUnderConstruction);
|
||||||
|
|
||||||
if (++i < NUM_BLOCKS) {
|
if (++i < NUM_BLOCKS) {
|
||||||
// write one more block
|
// write one more block
|
||||||
|
|
|
@ -24,8 +24,7 @@ import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
||||||
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstructionContiguous;
|
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -69,10 +68,8 @@ public class TestCommitBlockSynchronization {
|
||||||
namesystem.dir.getINodeMap().put(file);
|
namesystem.dir.getINodeMap().put(file);
|
||||||
|
|
||||||
FSNamesystem namesystemSpy = spy(namesystem);
|
FSNamesystem namesystemSpy = spy(namesystem);
|
||||||
BlockInfoUnderConstruction blockInfo =
|
BlockInfoContiguousUnderConstruction blockInfo = new BlockInfoContiguousUnderConstruction(
|
||||||
new BlockInfoUnderConstructionContiguous(
|
block, (short) 1, HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION, targets);
|
||||||
block, (short) 1, HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION,
|
|
||||||
targets);
|
|
||||||
blockInfo.setBlockCollection(file);
|
blockInfo.setBlockCollection(file);
|
||||||
blockInfo.setGenerationStamp(genStamp);
|
blockInfo.setGenerationStamp(genStamp);
|
||||||
blockInfo.initializeBlockRecovery(genStamp);
|
blockInfo.initializeBlockRecovery(genStamp);
|
||||||
|
|
|
@ -54,7 +54,7 @@ import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
|
||||||
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
||||||
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
|
@ -1016,7 +1016,7 @@ public class TestFileTruncate {
|
||||||
is(fsn.getBlockIdManager().getGenerationStampV2()));
|
is(fsn.getBlockIdManager().getGenerationStampV2()));
|
||||||
assertThat(file.getLastBlock().getBlockUCState(),
|
assertThat(file.getLastBlock().getBlockUCState(),
|
||||||
is(HdfsServerConstants.BlockUCState.UNDER_RECOVERY));
|
is(HdfsServerConstants.BlockUCState.UNDER_RECOVERY));
|
||||||
long blockRecoveryId = ((BlockInfoUnderConstruction) file.getLastBlock())
|
long blockRecoveryId = ((BlockInfoContiguousUnderConstruction) file.getLastBlock())
|
||||||
.getBlockRecoveryId();
|
.getBlockRecoveryId();
|
||||||
assertThat(blockRecoveryId, is(initialGenStamp + 1));
|
assertThat(blockRecoveryId, is(initialGenStamp + 1));
|
||||||
fsn.getEditLog().logTruncate(
|
fsn.getEditLog().logTruncate(
|
||||||
|
@ -1049,7 +1049,7 @@ public class TestFileTruncate {
|
||||||
is(fsn.getBlockIdManager().getGenerationStampV2()));
|
is(fsn.getBlockIdManager().getGenerationStampV2()));
|
||||||
assertThat(file.getLastBlock().getBlockUCState(),
|
assertThat(file.getLastBlock().getBlockUCState(),
|
||||||
is(HdfsServerConstants.BlockUCState.UNDER_RECOVERY));
|
is(HdfsServerConstants.BlockUCState.UNDER_RECOVERY));
|
||||||
long blockRecoveryId = ((BlockInfoUnderConstruction) file.getLastBlock())
|
long blockRecoveryId = ((BlockInfoContiguousUnderConstruction) file.getLastBlock())
|
||||||
.getBlockRecoveryId();
|
.getBlockRecoveryId();
|
||||||
assertThat(blockRecoveryId, is(initialGenStamp + 1));
|
assertThat(blockRecoveryId, is(initialGenStamp + 1));
|
||||||
fsn.getEditLog().logTruncate(
|
fsn.getEditLog().logTruncate(
|
||||||
|
|
|
@ -72,7 +72,7 @@ import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
||||||
import org.apache.hadoop.hdfs.protocol.LastBlockWithStatus;
|
import org.apache.hadoop.hdfs.protocol.LastBlockWithStatus;
|
||||||
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
||||||
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
|
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.INodeFile;
|
import org.apache.hadoop.hdfs.server.namenode.INodeFile;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper;
|
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper;
|
||||||
|
@ -752,8 +752,8 @@ public class TestRetryCacheWithHA {
|
||||||
boolean checkNamenodeBeforeReturn() throws Exception {
|
boolean checkNamenodeBeforeReturn() throws Exception {
|
||||||
INodeFile fileNode = cluster.getNamesystem(0).getFSDirectory()
|
INodeFile fileNode = cluster.getNamesystem(0).getFSDirectory()
|
||||||
.getINode4Write(file).asFile();
|
.getINode4Write(file).asFile();
|
||||||
BlockInfoUnderConstruction blkUC =
|
BlockInfoContiguousUnderConstruction blkUC =
|
||||||
(BlockInfoUnderConstruction) (fileNode.getBlocks())[1];
|
(BlockInfoContiguousUnderConstruction) (fileNode.getBlocks())[1];
|
||||||
int datanodeNum = blkUC.getExpectedStorageLocations().length;
|
int datanodeNum = blkUC.getExpectedStorageLocations().length;
|
||||||
for (int i = 0; i < CHECKTIMES && datanodeNum != 2; i++) {
|
for (int i = 0; i < CHECKTIMES && datanodeNum != 2; i++) {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.hadoop.hdfs.DistributedFileSystem;
|
||||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||||
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguousUnderConstruction;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
||||||
import org.apache.hadoop.hdfs.server.datanode.BlockPoolSliceStorage;
|
import org.apache.hadoop.hdfs.server.datanode.BlockPoolSliceStorage;
|
||||||
import org.apache.hadoop.hdfs.server.datanode.BlockScanner;
|
import org.apache.hadoop.hdfs.server.datanode.BlockScanner;
|
||||||
|
@ -177,7 +177,7 @@ public class SnapshotTestHelper {
|
||||||
* Specific information for different types of INode:
|
* Specific information for different types of INode:
|
||||||
* {@link INodeDirectory}:childrenSize
|
* {@link INodeDirectory}:childrenSize
|
||||||
* {@link INodeFile}: fileSize, block list. Check {@link BlockInfo#toString()}
|
* {@link INodeFile}: fileSize, block list. Check {@link BlockInfo#toString()}
|
||||||
* and {@link BlockInfoUnderConstruction#toString()} for detailed information.
|
* and {@link BlockInfoContiguousUnderConstruction#toString()} for detailed information.
|
||||||
* {@link FileWithSnapshot}: next link
|
* {@link FileWithSnapshot}: next link
|
||||||
* </pre>
|
* </pre>
|
||||||
* @see INode#dumpTreeRecursively()
|
* @see INode#dumpTreeRecursively()
|
||||||
|
|
Loading…
Reference in New Issue