private static INodeFile newINodeFile( long id, PermissionStatus permissions, long mtime, long atime, Short replication, Byte ecPolicyID, long preferredBlockSize, byte storagePolicyId, BlockType blockType) { return new INodeFile(id, null, permissions, mtime, atime, BlockInfo.EMPTY_ARRAY, replication, ecPolicyID, preferredBlockSize, storagePolicyId, blockType); }
INodeFile file = new INodeFile(inodeId, name, perm, modificationTime, modificationTime, blocksContiguous, blockReplication, preferredBlockSize); file.toUnderConstruction(clientName, clientMachine);
private static INodeFile newINodeFile(long id, PermissionStatus permissions, long mtime, long atime, short replication, long preferredBlockSize, byte storagePolicyId) { return new INodeFile(id, null, permissions, mtime, atime, BlockInfoContiguous.EMPTY_ARRAY, replication, preferredBlockSize, storagePolicyId); }
private static INodeFile newINodeFile(long id, PermissionStatus permissions, long mtime, long atime, short replication, long preferredBlockSize, byte storagePolicyId) { return new INodeFile(id, null, permissions, mtime, atime, BlockInfoContiguous.EMPTY_ARRAY, replication, preferredBlockSize, storagePolicyId); }
private static INodeFile createINodeFile(byte storagePolicyID) { return new INodeFile(INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, null, (short)3, 1024L, storagePolicyID); }
INodeFile createINodeFile(short replication, long preferredBlockSize) { return new INodeFile(INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, null, replication, preferredBlockSize, (byte)0); }
parent.getLoaderContext().getStringTable()); final INodeFile file = new INodeFile(n.getId(), n.getName().toByteArray(), permissions, f.getModificationTime(), f.getAccessTime(), blocks, replication, ecPolicyID,
/** * IllegalArgumentException is expected for setting below lower bound * for PreferredBlockSize. * @throws IllegalArgumentException as the result */ @Test(expected=IllegalArgumentException.class) public void testPreferredBlockSizeBelowLowerBound () throws IllegalArgumentException { replication = 3; preferredBlockSize = -1; INodeFile inf = new INodeFile(new PermissionStatus(userName, null, FsPermission.getDefault()), null, replication, 0L, 0L, preferredBlockSize); }
/** * IllegalArgumentException is expected for setting below lower bound * for Replication. * @throws IllegalArgumentException as the result */ @Test(expected=IllegalArgumentException.class) public void testReplicationBelowLowerBound () throws IllegalArgumentException { replication = -1; preferredBlockSize = 128*1024*1024; INodeFile inf = new INodeFile(new PermissionStatus(userName, null, FsPermission.getDefault()), null, replication, 0L, 0L, preferredBlockSize); }
/** * IllegalArgumentException is expected for setting above upper bound * for PreferredBlockSize. * @throws IllegalArgumentException as the result */ @Test(expected=IllegalArgumentException.class) public void testPreferredBlockSizeAboveUpperBound () throws IllegalArgumentException { replication = 3; preferredBlockSize = BLKSIZE_MAXVALUE+1; INodeFile inf = new INodeFile(new PermissionStatus(userName, null, FsPermission.getDefault()), null, replication, 0L, 0L, preferredBlockSize); }
INodeFile convertToInodeFile() { INodeFile obj = new INodeFile(getPermissionStatus(), getBlocks(), getReplication(), getModificationTime(), getModificationTime(), getPreferredBlockSize()); return obj; }
private static INodeFile createINodeFile(INodeDirectory parent, String name, String owner, String group, short perm) throws IOException { PermissionStatus permStatus = PermissionStatus.createImmutable(owner, group, FsPermission.createImmutable(perm)); INodeFile inodeFile = new INodeFile(INodeId.GRANDFATHER_INODE_ID, name.getBytes("UTF-8"), permStatus, 0L, 0L, null, REPLICATION, PREFERRED_BLOCK_SIZE, (byte)0); parent.addChild(inodeFile); return inodeFile; } }
@Test public void testPreferredBlockSizeUpperBound () { replication = 3; preferredBlockSize = BLKSIZE_MAXVALUE; INodeFile inf = new INodeFile(new PermissionStatus(userName, null, FsPermission.getDefault()), null, replication, 0L, 0L, preferredBlockSize); assertEquals("True has to be returned in this case", BLKSIZE_MAXVALUE, inf.getPreferredBlockSize()); }
INodeFile convertToInodeFile() { INodeFile obj = new INodeFile(getPermissionStatus(), getBlocks(), getReplication(), getModificationTime(), getModificationTime(), getPreferredBlockSize()); return obj; }
/** * Test for the PreferredBlockSize value. Sets a value and checks if it was * set correct. */ @Test public void testPreferredBlockSize () { replication = 3; preferredBlockSize = 128*1024*1024; INodeFile inf = new INodeFile(new PermissionStatus(userName, null, FsPermission.getDefault()), null, replication, 0L, 0L, preferredBlockSize); assertEquals("True has to be returned in this case", preferredBlockSize, inf.getPreferredBlockSize()); }
/** * Test for the Replication value. Sets a value and checks if it was set * correct. */ @Test public void testReplication () { replication = 3; preferredBlockSize = 128*1024*1024; INodeFile inf = new INodeFile(new PermissionStatus(userName, null, FsPermission.getDefault()), null, replication, 0L, 0L, preferredBlockSize); assertEquals("True has to be returned in this case", replication, inf.getReplication()); }
private static FSNamesystem setupFileSystem() throws IOException { Configuration conf = new Configuration(); conf.setLong(DFS_NAMENODE_ACCESSTIME_PRECISION_KEY, 1L); FSEditLog editlog = mock(FSEditLog.class); FSImage image = mock(FSImage.class); when(image.getEditLog()).thenReturn(editlog); final FSNamesystem fsn = new FSNamesystem(conf, image, true); final FSDirectory fsd = fsn.getFSDirectory(); INodesInPath iip = fsd.getINodesInPath("/", true); PermissionStatus perm = new PermissionStatus( "hdfs", "supergroup", FsPermission.createImmutable((short) 0x1ff)); final INodeFile file = new INodeFile( MOCK_INODE_ID, FILE_NAME.getBytes(Charsets.UTF_8), perm, 1, 1, new BlockInfoContiguous[] {}, (short) 1, DFS_BLOCK_SIZE_DEFAULT); fsn.getFSDirectory().addINode(iip, file); return fsn; }
@Override public void run() { PermissionStatus p = namesystem.createFsOwnerPermissions( new FsPermission((short)0777)); FSEditLog editLog = namesystem.getEditLog(); for (int i = 0; i < numTransactions; i++) { INodeFile inode = new INodeFile(namesystem.dir.allocateNewInodeId(), null, p, 0L, 0L, BlockInfoContiguous.EMPTY_ARRAY, replication, blockSize); inode.toUnderConstruction("", ""); editLog.logOpenFile("/filename" + (startIndex + i), inode, false, false); editLog.logCloseFile("/filename" + (startIndex + i), inode); editLog.logSync(); } } }
@Test public void testFileUnderConstruction() { replication = 3; final INodeFile file = new INodeFile(INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, null, replication, 1024L, (byte)0); assertFalse(file.isUnderConstruction()); final String clientName = "client"; final String clientMachine = "machine"; file.toUnderConstruction(clientName, clientMachine); assertTrue(file.isUnderConstruction()); FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature(); assertEquals(clientName, uc.getClientName()); assertEquals(clientMachine, uc.getClientMachine()); file.toCompleteFile(Time.now()); assertFalse(file.isUnderConstruction()); }