|
@@ -2764,9 +2764,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
LocatedBlock[] onRetryBlock = new LocatedBlock[1];
|
|
LocatedBlock[] onRetryBlock = new LocatedBlock[1];
|
|
- final INodeFile pendingFile = analyzeFileState(
|
|
|
|
|
|
+ FileState fileState = analyzeFileState(
|
|
src, fileId, clientName, previous, onRetryBlock);
|
|
src, fileId, clientName, previous, onRetryBlock);
|
|
- src = pendingFile.getFullPathName();
|
|
|
|
|
|
+ final INodeFile pendingFile = fileState.inode;
|
|
|
|
+ src = fileState.path;
|
|
|
|
|
|
if (onRetryBlock[0] != null && onRetryBlock[0].getLocations().length > 0) {
|
|
if (onRetryBlock[0] != null && onRetryBlock[0].getLocations().length > 0) {
|
|
// This is a retry. Just return the last block if having locations.
|
|
// This is a retry. Just return the last block if having locations.
|
|
@@ -2802,8 +2803,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
// Run the full analysis again, since things could have changed
|
|
// Run the full analysis again, since things could have changed
|
|
// while chooseTarget() was executing.
|
|
// while chooseTarget() was executing.
|
|
LocatedBlock[] onRetryBlock = new LocatedBlock[1];
|
|
LocatedBlock[] onRetryBlock = new LocatedBlock[1];
|
|
- final INodeFile pendingFile =
|
|
|
|
|
|
+ FileState fileState =
|
|
analyzeFileState(src, fileId, clientName, previous, onRetryBlock);
|
|
analyzeFileState(src, fileId, clientName, previous, onRetryBlock);
|
|
|
|
+ final INodeFile pendingFile = fileState.inode;
|
|
|
|
+ src = fileState.path;
|
|
|
|
|
|
if (onRetryBlock[0] != null) {
|
|
if (onRetryBlock[0] != null) {
|
|
if (onRetryBlock[0].getLocations().length > 0) {
|
|
if (onRetryBlock[0].getLocations().length > 0) {
|
|
@@ -2839,7 +2842,17 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
return makeLocatedBlock(newBlock, targets, offset);
|
|
return makeLocatedBlock(newBlock, targets, offset);
|
|
}
|
|
}
|
|
|
|
|
|
- INodeFile analyzeFileState(String src,
|
|
|
|
|
|
+ static class FileState {
|
|
|
|
+ public final INodeFile inode;
|
|
|
|
+ public final String path;
|
|
|
|
+
|
|
|
|
+ public FileState(INodeFile inode, String fullPath) {
|
|
|
|
+ this.inode = inode;
|
|
|
|
+ this.path = fullPath;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FileState analyzeFileState(String src,
|
|
long fileId,
|
|
long fileId,
|
|
String clientName,
|
|
String clientName,
|
|
ExtendedBlock previous,
|
|
ExtendedBlock previous,
|
|
@@ -2927,7 +2940,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
onRetryBlock[0] = makeLocatedBlock(lastBlockInFile,
|
|
onRetryBlock[0] = makeLocatedBlock(lastBlockInFile,
|
|
((BlockInfoUnderConstruction)lastBlockInFile).getExpectedStorageLocations(),
|
|
((BlockInfoUnderConstruction)lastBlockInFile).getExpectedStorageLocations(),
|
|
offset);
|
|
offset);
|
|
- return pendingFile;
|
|
|
|
|
|
+ return new FileState(pendingFile, src);
|
|
} else {
|
|
} else {
|
|
// Case 3
|
|
// Case 3
|
|
throw new IOException("Cannot allocate block in " + src + ": " +
|
|
throw new IOException("Cannot allocate block in " + src + ": " +
|
|
@@ -2940,7 +2953,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
if (!checkFileProgress(pendingFile, false)) {
|
|
if (!checkFileProgress(pendingFile, false)) {
|
|
throw new NotReplicatedYetException("Not replicated yet: " + src);
|
|
throw new NotReplicatedYetException("Not replicated yet: " + src);
|
|
}
|
|
}
|
|
- return pendingFile;
|
|
|
|
|
|
+ return new FileState(pendingFile, src);
|
|
}
|
|
}
|
|
|
|
|
|
LocatedBlock makeLocatedBlock(Block blk, DatanodeStorageInfo[] locs,
|
|
LocatedBlock makeLocatedBlock(Block blk, DatanodeStorageInfo[] locs,
|