HDFS-7091. Add forwarding constructor for INodeFile for existing callers. (Arpit Agarwal)

Conflicts:
	hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-6581.txt
	hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java
	hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageSerialization.java
	hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/CreateEditsLog.java
	hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLog.java
	hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSPermissionChecker.java
	hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java
This commit is contained in:
arp 2014-09-18 19:20:25 -07:00 committed by Jitendra Pandey
parent f193d96627
commit a973b2f55e
7 changed files with 17 additions and 10 deletions

View File

@ -789,7 +789,7 @@ INode loadINode(final byte[] localName, boolean isSnapshotINode,
// Images in the old format will not have the lazyPersist flag so it is // Images in the old format will not have the lazyPersist flag so it is
// safe to pass false always. // safe to pass false always.
final INodeFile file = new INodeFile(inodeId, localName, permissions, final INodeFile file = new INodeFile(inodeId, localName, permissions,
modificationTime, atime, blocks, replication, blockSize, (byte)0, false); modificationTime, atime, blocks, replication, blockSize, (byte)0);
if (underConstruction) { if (underConstruction) {
file.toUnderConstruction(clientName, clientMachine); file.toUnderConstruction(clientName, clientMachine);
} }

View File

@ -151,7 +151,7 @@ static INodeFile readINodeUnderConstruction(
// Images in the pre-protobuf format will not have the lazyPersist flag, // Images in the pre-protobuf format will not have the lazyPersist flag,
// so it is safe to pass false always. // so it is safe to pass false always.
INodeFile file = new INodeFile(inodeId, name, perm, modificationTime, INodeFile file = new INodeFile(inodeId, name, perm, modificationTime,
modificationTime, blocks, blockReplication, preferredBlockSize, (byte)0, false); modificationTime, blocks, blockReplication, preferredBlockSize, (byte)0);
file.toUnderConstruction(clientName, clientMachine); file.toUnderConstruction(clientName, clientMachine);
return file; return file;
} }

View File

@ -119,6 +119,13 @@ static boolean getLazyPersistFlag(long header) {
private BlockInfo[] blocks; private BlockInfo[] blocks;
INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime,
long atime, BlockInfo[] blklist, short replication,
long preferredBlockSize) {
this(id, name, permissions, mtime, atime, blklist, replication,
preferredBlockSize, false);
}
INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime, INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime,
long atime, BlockInfo[] blklist, short replication, long atime, BlockInfo[] blklist, short replication,
long preferredBlockSize, byte storagePolicyID, boolean isLazyPersist) { long preferredBlockSize, byte storagePolicyID, boolean isLazyPersist) {

View File

@ -82,7 +82,7 @@ static void addFiles(FSEditLog editLog, int numFiles, short replication,
} }
final INodeFile inode = new INodeFile(inodeId.nextValue(), null, final INodeFile inode = new INodeFile(inodeId.nextValue(), null,
p, 0L, 0L, blocks, replication, blockSize, (byte)0, false); p, 0L, 0L, blocks, replication, blockSize, (byte)0);
inode.toUnderConstruction("", ""); inode.toUnderConstruction("", "");
// Append path to filename with information about blockIDs // Append path to filename with information about blockIDs
@ -97,7 +97,7 @@ static void addFiles(FSEditLog editLog, int numFiles, short replication,
editLog.logMkDir(currentDir, dirInode); editLog.logMkDir(currentDir, dirInode);
} }
INodeFile fileUc = new INodeFile(inodeId.nextValue(), null, INodeFile fileUc = new INodeFile(inodeId.nextValue(), null,
p, 0L, 0L, BlockInfo.EMPTY_ARRAY, replication, blockSize, (byte)0, false); p, 0L, 0L, BlockInfo.EMPTY_ARRAY, replication, blockSize, (byte)0);
fileUc.toUnderConstruction("", ""); fileUc.toUnderConstruction("", "");
editLog.logOpenFile(filePath, fileUc, false, false); editLog.logOpenFile(filePath, fileUc, false, false);
editLog.logCloseFile(filePath, inode); editLog.logCloseFile(filePath, inode);

View File

@ -194,7 +194,7 @@ public void run() {
for (int i = 0; i < numTransactions; i++) { for (int i = 0; i < numTransactions; i++) {
INodeFile inode = new INodeFile(namesystem.allocateNewInodeId(), null, INodeFile inode = new INodeFile(namesystem.allocateNewInodeId(), null,
p, 0L, 0L, BlockInfo.EMPTY_ARRAY, replication, blockSize, (byte)0, false); p, 0L, 0L, BlockInfo.EMPTY_ARRAY, replication, blockSize, (byte)0);
inode.toUnderConstruction("", ""); inode.toUnderConstruction("", "");
editLog.logOpenFile("/filename" + (startIndex + i), inode, false, false); editLog.logOpenFile("/filename" + (startIndex + i), inode, false, false);

View File

@ -432,7 +432,7 @@ private static INodeFile createINodeFile(INodeDirectory parent, String name,
FsPermission.createImmutable(perm)); FsPermission.createImmutable(perm));
INodeFile inodeFile = new INodeFile(INodeId.GRANDFATHER_INODE_ID, INodeFile inodeFile = new INodeFile(INodeId.GRANDFATHER_INODE_ID,
name.getBytes("UTF-8"), permStatus, 0L, 0L, null, REPLICATION, name.getBytes("UTF-8"), permStatus, 0L, 0L, null, REPLICATION,
PREFERRED_BLOCK_SIZE, (byte)0, false); PREFERRED_BLOCK_SIZE, (byte)0);
parent.addChild(inodeFile); parent.addChild(inodeFile);
return inodeFile; return inodeFile;
} }

View File

@ -85,7 +85,7 @@ public class TestINodeFile {
INodeFile createINodeFile(short replication, long preferredBlockSize) { INodeFile createINodeFile(short replication, long preferredBlockSize) {
return new INodeFile(INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, return new INodeFile(INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L,
null, replication, preferredBlockSize, (byte)0, false); null, replication, preferredBlockSize, (byte)0);
} }
private static INodeFile createINodeFile(byte storagePolicyID) { private static INodeFile createINodeFile(byte storagePolicyID) {
@ -286,7 +286,7 @@ private INodeFile[] createINodeFiles(int nCount, String fileNamePrefix) {
INodeFile[] iNodes = new INodeFile[nCount]; INodeFile[] iNodes = new INodeFile[nCount];
for (int i = 0; i < nCount; i++) { for (int i = 0; i < nCount; i++) {
iNodes[i] = new INodeFile(i, null, perm, 0L, 0L, null, replication, iNodes[i] = new INodeFile(i, null, perm, 0L, 0L, null, replication,
preferredBlockSize, (byte)0, false); preferredBlockSize, (byte)0);
iNodes[i].setLocalName(DFSUtil.string2Bytes(fileNamePrefix + i)); iNodes[i].setLocalName(DFSUtil.string2Bytes(fileNamePrefix + i));
BlockInfo newblock = new BlockInfo(replication); BlockInfo newblock = new BlockInfo(replication);
iNodes[i].addBlock(newblock); iNodes[i].addBlock(newblock);
@ -344,7 +344,7 @@ public void testValueOf () throws IOException {
{//cast from INodeFileUnderConstruction {//cast from INodeFileUnderConstruction
final INode from = new INodeFile( final INode from = new INodeFile(
INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, null, replication, INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, null, replication,
1024L, (byte)0, false); 1024L, (byte)0);
from.asFile().toUnderConstruction("client", "machine"); from.asFile().toUnderConstruction("client", "machine");
//cast to INodeFile, should success //cast to INodeFile, should success
@ -1068,7 +1068,7 @@ public void testFilesInGetListingOps() throws Exception {
public void testFileUnderConstruction() { public void testFileUnderConstruction() {
replication = 3; replication = 3;
final INodeFile file = new INodeFile(INodeId.GRANDFATHER_INODE_ID, null, final INodeFile file = new INodeFile(INodeId.GRANDFATHER_INODE_ID, null,
perm, 0L, 0L, null, replication, 1024L, (byte)0, false); perm, 0L, 0L, null, replication, 1024L, (byte)0);
assertFalse(file.isUnderConstruction()); assertFalse(file.isUnderConstruction());
final String clientName = "client"; final String clientName = "client";