|
@@ -44,10 +44,10 @@ import org.apache.hadoop.hdfs.DistributedFileSystem;
|
|
|
import org.apache.hadoop.hdfs.protocol.Block;
|
|
|
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
|
|
|
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
|
|
-import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
|
import org.apache.hadoop.hdfs.protocol.FSLimitException;
|
|
|
import org.apache.hadoop.hdfs.protocol.FSLimitException.MaxDirectoryItemsExceededException;
|
|
|
import org.apache.hadoop.hdfs.protocol.FSLimitException.PathComponentTooLongException;
|
|
|
+import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsLocatedFileStatus;
|
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
@@ -57,6 +57,7 @@ import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
|
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
|
|
+import org.apache.hadoop.hdfs.server.namenode.INodeDirectory.INodesInPath;
|
|
|
import org.apache.hadoop.hdfs.util.ByteArray;
|
|
|
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
@@ -551,8 +552,9 @@ public class FSDirectory implements Closeable {
|
|
|
}
|
|
|
|
|
|
byte[][] dstComponents = INode.getPathComponents(dst);
|
|
|
- INode[] dstInodes = new INode[dstComponents.length];
|
|
|
- rootDir.getExistingPathINodes(dstComponents, dstInodes, false);
|
|
|
+ INodesInPath dstInodesInPath = rootDir.getExistingPathINodes(dstComponents,
|
|
|
+ dstComponents.length, false);
|
|
|
+ INode[] dstInodes = dstInodesInPath.getINodes();
|
|
|
if (dstInodes[dstInodes.length-1] != null) {
|
|
|
NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: "
|
|
|
+"failed to rename "+src+" to "+dst+
|
|
@@ -567,7 +569,7 @@ public class FSDirectory implements Closeable {
|
|
|
}
|
|
|
|
|
|
// Ensure dst has quota to accommodate rename
|
|
|
- verifyQuotaForRename(srcInodes,dstInodes);
|
|
|
+ verifyQuotaForRename(srcInodes, dstInodes);
|
|
|
|
|
|
INode dstChild = null;
|
|
|
INode srcChild = null;
|
|
@@ -673,8 +675,9 @@ public class FSDirectory implements Closeable {
|
|
|
throw new IOException(error);
|
|
|
}
|
|
|
final byte[][] dstComponents = INode.getPathComponents(dst);
|
|
|
- final INode[] dstInodes = new INode[dstComponents.length];
|
|
|
- rootDir.getExistingPathINodes(dstComponents, dstInodes, false);
|
|
|
+ INodesInPath dstInodesInPath = rootDir.getExistingPathINodes(dstComponents,
|
|
|
+ dstComponents.length, false);
|
|
|
+ final INode[] dstInodes = dstInodesInPath.getINodes();
|
|
|
INode dstInode = dstInodes[dstInodes.length - 1];
|
|
|
if (dstInodes.length == 1) {
|
|
|
error = "rename destination cannot be the root";
|
|
@@ -1455,12 +1458,13 @@ public class FSDirectory implements Closeable {
|
|
|
src = normalizePath(src);
|
|
|
String[] names = INode.getPathNames(src);
|
|
|
byte[][] components = INode.getPathComponents(names);
|
|
|
- INode[] inodes = new INode[components.length];
|
|
|
- final int lastInodeIndex = inodes.length - 1;
|
|
|
+ final int lastInodeIndex = components.length - 1;
|
|
|
|
|
|
writeLock();
|
|
|
try {
|
|
|
- rootDir.getExistingPathINodes(components, inodes, false);
|
|
|
+ INodesInPath inodesInPath = rootDir.getExistingPathINodes(components,
|
|
|
+ components.length, false);
|
|
|
+ INode[] inodes = inodesInPath.getINodes();
|
|
|
|
|
|
// find the index of the first null in inodes[]
|
|
|
StringBuilder pathbuilder = new StringBuilder();
|
|
@@ -1530,16 +1534,14 @@ public class FSDirectory implements Closeable {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- */
|
|
|
INode unprotectedMkdir(String src, PermissionStatus permissions,
|
|
|
long timestamp) throws QuotaExceededException,
|
|
|
UnresolvedLinkException {
|
|
|
assert hasWriteLock();
|
|
|
byte[][] components = INode.getPathComponents(src);
|
|
|
- INode[] inodes = new INode[components.length];
|
|
|
-
|
|
|
- rootDir.getExistingPathINodes(components, inodes, false);
|
|
|
+ INodesInPath inodesInPath = rootDir.getExistingPathINodes(components,
|
|
|
+ components.length, false);
|
|
|
+ INode[] inodes = inodesInPath.getINodes();
|
|
|
unprotectedMkdir(inodes, inodes.length-1, components[inodes.length-1],
|
|
|
permissions, timestamp);
|
|
|
return inodes[inodes.length-1];
|
|
@@ -1568,10 +1570,11 @@ public class FSDirectory implements Closeable {
|
|
|
byte[] path = components[components.length-1];
|
|
|
child.setLocalName(path);
|
|
|
cacheName(child);
|
|
|
- INode[] inodes = new INode[components.length];
|
|
|
writeLock();
|
|
|
try {
|
|
|
- rootDir.getExistingPathINodes(components, inodes, false);
|
|
|
+ INodesInPath inodesInPath = rootDir.getExistingPathINodes(components,
|
|
|
+ components.length, false);
|
|
|
+ INode[] inodes = inodesInPath.getINodes();
|
|
|
return addChild(inodes, inodes.length-1, child, childDiskspace);
|
|
|
} finally {
|
|
|
writeUnlock();
|