|
@@ -3151,7 +3151,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
String clientMachine = null;
|
|
String clientMachine = null;
|
|
|
|
|
|
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
|
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
|
- NameNode.stateChangeLog.debug("BLOCK* NameSystem.getAdditionalBlock: "
|
|
|
|
|
|
+ NameNode.stateChangeLog.debug("BLOCK* getAdditionalBlock: "
|
|
+ src + " inodeId " + fileId + " for " + clientName);
|
|
+ src + " inodeId " + fileId + " for " + clientName);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3374,7 +3374,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
}
|
|
}
|
|
|
|
|
|
// Check if the penultimate block is minimally replicated
|
|
// Check if the penultimate block is minimally replicated
|
|
- if (!checkFileProgress(pendingFile, false)) {
|
|
|
|
|
|
+ if (!checkFileProgress(src, pendingFile, false)) {
|
|
throw new NotReplicatedYetException("Not replicated yet: " + src);
|
|
throw new NotReplicatedYetException("Not replicated yet: " + src);
|
|
}
|
|
}
|
|
return new FileState(pendingFile, src);
|
|
return new FileState(pendingFile, src);
|
|
@@ -3622,14 +3622,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
}
|
|
}
|
|
// Check the state of the penultimate block. It should be completed
|
|
// Check the state of the penultimate block. It should be completed
|
|
// before attempting to complete the last one.
|
|
// before attempting to complete the last one.
|
|
- if (!checkFileProgress(pendingFile, false)) {
|
|
|
|
|
|
+ if (!checkFileProgress(src, pendingFile, false)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
// commit the last block and complete it if it has minimum replicas
|
|
// commit the last block and complete it if it has minimum replicas
|
|
commitOrCompleteLastBlock(pendingFile, last);
|
|
commitOrCompleteLastBlock(pendingFile, last);
|
|
|
|
|
|
- if (!checkFileProgress(pendingFile, true)) {
|
|
|
|
|
|
+ if (!checkFileProgress(src, pendingFile, true)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3653,8 +3653,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
throws IOException {
|
|
throws IOException {
|
|
assert hasWriteLock();
|
|
assert hasWriteLock();
|
|
BlockInfo b = dir.addBlock(src, inodesInPath, newBlock, targets);
|
|
BlockInfo b = dir.addBlock(src, inodesInPath, newBlock, targets);
|
|
- NameNode.stateChangeLog.info("BLOCK* allocateBlock: " + src + ". "
|
|
|
|
- + getBlockPoolId() + " " + b);
|
|
|
|
|
|
+ NameNode.stateChangeLog.info("BLOCK* allocate " + b + " for " + src);
|
|
DatanodeStorageInfo.incrementBlocksScheduled(targets);
|
|
DatanodeStorageInfo.incrementBlocksScheduled(targets);
|
|
return b;
|
|
return b;
|
|
}
|
|
}
|
|
@@ -3675,30 +3674,21 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
* replicated. If not, return false. If checkall is true, then check
|
|
* replicated. If not, return false. If checkall is true, then check
|
|
* all blocks, otherwise check only penultimate block.
|
|
* all blocks, otherwise check only penultimate block.
|
|
*/
|
|
*/
|
|
- boolean checkFileProgress(INodeFile v, boolean checkall) {
|
|
|
|
|
|
+ private boolean checkFileProgress(String src, INodeFile v, boolean checkall) {
|
|
readLock();
|
|
readLock();
|
|
try {
|
|
try {
|
|
if (checkall) {
|
|
if (checkall) {
|
|
- //
|
|
|
|
// check all blocks of the file.
|
|
// check all blocks of the file.
|
|
- //
|
|
|
|
for (BlockInfo block: v.getBlocks()) {
|
|
for (BlockInfo block: v.getBlocks()) {
|
|
- if (!block.isComplete()) {
|
|
|
|
- LOG.info("BLOCK* checkFileProgress: " + block
|
|
|
|
- + " has not reached minimal replication "
|
|
|
|
- + blockManager.minReplication);
|
|
|
|
|
|
+ if (!isCompleteBlock(src, block, blockManager.minReplication)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- //
|
|
|
|
// check the penultimate block of this file
|
|
// check the penultimate block of this file
|
|
- //
|
|
|
|
BlockInfo b = v.getPenultimateBlock();
|
|
BlockInfo b = v.getPenultimateBlock();
|
|
- if (b != null && !b.isComplete()) {
|
|
|
|
- LOG.warn("BLOCK* checkFileProgress: " + b
|
|
|
|
- + " has not reached minimal replication "
|
|
|
|
- + blockManager.minReplication);
|
|
|
|
|
|
+ if (b != null
|
|
|
|
+ && !isCompleteBlock(src, b, blockManager.minReplication)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3708,6 +3698,19 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static boolean isCompleteBlock(String src, BlockInfo b, int minRepl) {
|
|
|
|
+ if (!b.isComplete()) {
|
|
|
|
+ final BlockInfoUnderConstruction uc = (BlockInfoUnderConstruction)b;
|
|
|
|
+ final int numNodes = b.numNodes();
|
|
|
|
+ LOG.info("BLOCK* " + b + " is not COMPLETE (ucState = "
|
|
|
|
+ + uc.getBlockUCState() + ", replication# = " + numNodes
|
|
|
|
+ + (numNodes < minRepl? " < ": " >= ")
|
|
|
|
+ + " minimum = " + minRepl + ") in file " + src);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////
|
|
// Here's how to handle block-copy failure during client write:
|
|
// Here's how to handle block-copy failure during client write:
|
|
// -- As usual, the client's write should result in a streaming
|
|
// -- As usual, the client's write should result in a streaming
|
|
@@ -5152,9 +5155,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
if(!nameNodeHasResourcesAvailable()) {
|
|
if(!nameNodeHasResourcesAvailable()) {
|
|
String lowResourcesMsg = "NameNode low on available disk space. ";
|
|
String lowResourcesMsg = "NameNode low on available disk space. ";
|
|
if (!isInSafeMode()) {
|
|
if (!isInSafeMode()) {
|
|
- FSNamesystem.LOG.warn(lowResourcesMsg + "Entering safe mode.");
|
|
|
|
|
|
+ LOG.warn(lowResourcesMsg + "Entering safe mode.");
|
|
} else {
|
|
} else {
|
|
- FSNamesystem.LOG.warn(lowResourcesMsg + "Already in safe mode.");
|
|
|
|
|
|
+ LOG.warn(lowResourcesMsg + "Already in safe mode.");
|
|
}
|
|
}
|
|
enterSafeMode(true);
|
|
enterSafeMode(true);
|
|
}
|
|
}
|
|
@@ -7014,11 +7017,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
if (cacheEntry != null && cacheEntry.isSuccess()) {
|
|
if (cacheEntry != null && cacheEntry.isSuccess()) {
|
|
return; // Return previous response
|
|
return; // Return previous response
|
|
}
|
|
}
|
|
- LOG.info("updatePipeline(block=" + oldBlock
|
|
|
|
- + ", newGenerationStamp=" + newBlock.getGenerationStamp()
|
|
|
|
|
|
+ LOG.info("updatePipeline(" + oldBlock.getLocalBlock()
|
|
|
|
+ + ", newGS=" + newBlock.getGenerationStamp()
|
|
+ ", newLength=" + newBlock.getNumBytes()
|
|
+ ", newLength=" + newBlock.getNumBytes()
|
|
+ ", newNodes=" + Arrays.asList(newNodes)
|
|
+ ", newNodes=" + Arrays.asList(newNodes)
|
|
- + ", clientName=" + clientName
|
|
|
|
|
|
+ + ", client=" + clientName
|
|
+ ")");
|
|
+ ")");
|
|
waitForLoadingFSImage();
|
|
waitForLoadingFSImage();
|
|
writeLock();
|
|
writeLock();
|
|
@@ -7036,7 +7039,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
RetryCache.setState(cacheEntry, success);
|
|
RetryCache.setState(cacheEntry, success);
|
|
}
|
|
}
|
|
getEditLog().logSync();
|
|
getEditLog().logSync();
|
|
- LOG.info("updatePipeline(" + oldBlock + ") successfully to " + newBlock);
|
|
|
|
|
|
+ LOG.info("updatePipeline(" + oldBlock.getLocalBlock() + " => "
|
|
|
|
+ + newBlock.getLocalBlock() + ") success");
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|