Skip to content

Commit

Permalink
Revert "HDFS-8652. Track BlockInfo instead of Block in CorruptReplica…
Browse files Browse the repository at this point in the history
…sMap. Contributed by Jing Zhao."

This reverts commit d62b63d.
  • Loading branch information
Jing9 committed Jul 7, 2015
1 parent 559425d commit bc99aaf
Show file tree
Hide file tree
Showing 17 changed files with 168 additions and 169 deletions.
2 changes: 0 additions & 2 deletions hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
Expand Up @@ -701,8 +701,6 @@ Release 2.8.0 - UNRELEASED


HDFS-8709. Clarify automatic sync in FSEditLog#logEdit. (wang) HDFS-8709. Clarify automatic sync in FSEditLog#logEdit. (wang)


HDFS-8652. Track BlockInfo instead of Block in CorruptReplicasMap. (jing9)

OPTIMIZATIONS OPTIMIZATIONS


HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
Expand Down
Expand Up @@ -179,7 +179,7 @@ public int getCapacity() {
* information indicating the index of the block in the * information indicating the index of the block in the
* corresponding block group. * corresponding block group.
*/ */
abstract void addStorage(DatanodeStorageInfo storage, Block reportedBlock); abstract boolean addStorage(DatanodeStorageInfo storage, Block reportedBlock);


/** /**
* Remove {@link DatanodeStorageInfo} location for a block * Remove {@link DatanodeStorageInfo} location for a block
Expand All @@ -192,11 +192,6 @@ public int getCapacity() {
*/ */
abstract void replaceBlock(BlockInfo newBlock); abstract void replaceBlock(BlockInfo newBlock);


/**
* @return true if there is no storage storing the block
*/
abstract boolean hasEmptyStorage();

/** /**
* Find specified DatanodeStorageInfo. * Find specified DatanodeStorageInfo.
* @return DatanodeStorageInfo or null if not found. * @return DatanodeStorageInfo or null if not found.
Expand Down
Expand Up @@ -45,8 +45,8 @@ protected BlockInfoContiguous(BlockInfo from) {
} }


@Override @Override
void addStorage(DatanodeStorageInfo storage, Block reportedBlock) { boolean addStorage(DatanodeStorageInfo storage, Block reportedBlock) {
ContiguousBlockStorageOp.addStorage(this, storage); return ContiguousBlockStorageOp.addStorage(this, storage);
} }


@Override @Override
Expand All @@ -73,9 +73,4 @@ BlockInfoUnderConstruction convertCompleteBlockToUC(
ucBlock.setBlockCollection(getBlockCollection()); ucBlock.setBlockCollection(getBlockCollection());
return ucBlock; return ucBlock;
} }

@Override
boolean hasEmptyStorage() {
return ContiguousBlockStorageOp.hasEmptyStorage(this);
}
} }
Expand Up @@ -18,6 +18,7 @@
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;


Expand Down Expand Up @@ -273,17 +274,18 @@ public void initializeBlockRecovery(long recoveryId) {
"No blocks found, lease removed."); "No blocks found, lease removed.");
} }
boolean allLiveReplicasTriedAsPrimary = true; boolean allLiveReplicasTriedAsPrimary = true;
for (ReplicaUnderConstruction replica : replicas) { 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 (replica.isAlive()) { if (replicas.get(i).isAlive()) {
allLiveReplicasTriedAsPrimary = allLiveReplicasTriedAsPrimary allLiveReplicasTriedAsPrimary =
&& replica.getChosenAsPrimary(); (allLiveReplicasTriedAsPrimary &&
replicas.get(i).getChosenAsPrimary());
} }
} }
if (allLiveReplicasTriedAsPrimary) { if (allLiveReplicasTriedAsPrimary) {
// Just set all the replicas to be chosen whether they are alive or not. // Just set all the replicas to be chosen whether they are alive or not.
for (ReplicaUnderConstruction replica : replicas) { for (int i = 0; i < replicas.size(); i++) {
replica.setChosenAsPrimary(false); replicas.get(i).setChosenAsPrimary(false);
} }
} }
long mostRecentLastUpdate = 0; long mostRecentLastUpdate = 0;
Expand Down Expand Up @@ -343,6 +345,10 @@ void addReplicaIfNotPresent(DatanodeStorageInfo storage,
* Convert an under construction block to a complete block. * Convert an under construction block to a complete block.
* *
* @return 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(); public abstract BlockInfo convertToCompleteBlock();


Expand Down Expand Up @@ -380,8 +386,8 @@ public void appendStringTo(StringBuilder sb) {
} }


private void appendUCParts(StringBuilder sb) { private void appendUCParts(StringBuilder sb) {
sb.append("{UCState=").append(blockUCState).append(", truncateBlock=") sb.append("{UCState=").append(blockUCState)
.append(truncateBlock) .append(", truncateBlock=" + truncateBlock)
.append(", primaryNodeIndex=").append(primaryNodeIndex) .append(", primaryNodeIndex=").append(primaryNodeIndex)
.append(", replicas=["); .append(", replicas=[");
if (replicas != null) { if (replicas != null) {
Expand Down
Expand Up @@ -55,6 +55,10 @@ public BlockInfoUnderConstructionContiguous(Block blk, short replication,
* Convert an under construction block to a complete block. * Convert an under construction block to a complete block.
* *
* @return BlockInfo - 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 @Override
public BlockInfoContiguous convertToCompleteBlock() { public BlockInfoContiguous convertToCompleteBlock() {
Expand All @@ -65,8 +69,8 @@ public BlockInfoContiguous convertToCompleteBlock() {
} }


@Override @Override
void addStorage(DatanodeStorageInfo storage, Block reportedBlock) { boolean addStorage(DatanodeStorageInfo storage, Block reportedBlock) {
ContiguousBlockStorageOp.addStorage(this, storage); return ContiguousBlockStorageOp.addStorage(this, storage);
} }


@Override @Override
Expand All @@ -84,11 +88,6 @@ void replaceBlock(BlockInfo newBlock) {
ContiguousBlockStorageOp.replaceBlock(this, newBlock); ContiguousBlockStorageOp.replaceBlock(this, newBlock);
} }


@Override
boolean hasEmptyStorage() {
return ContiguousBlockStorageOp.hasEmptyStorage(this);
}

@Override @Override
public void setExpectedLocations(DatanodeStorageInfo[] targets) { public void setExpectedLocations(DatanodeStorageInfo[] targets) {
int numLocations = targets == null ? 0 : targets.length; int numLocations = targets == null ? 0 : targets.length;
Expand Down

0 comments on commit bc99aaf

Please sign in to comment.