INodeFile extends INodeWithAdditionalFields implements INodeFileAttributes, BlockCollection { public static INodeFile valueOf(INode inode, String path ) throws FileNotFoundException { return valueOf(inode, path, false); } INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime,
            long atime, BlockInfo[] blklist, short replication,
            long preferredBlockSize);   INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime,
      long atime, BlockInfo[] blklist, short replication,
      long preferredBlockSize, byte storagePolicyID);  INodeFile(INodeFile that);  INodeFile(INodeFile that, FileDiffList diffs); static INodeFile valueOf(INode inode, String path
      ); static INodeFile valueOf(INode inode, String path, boolean acceptNull); @Override final boolean isFile(); @Override final INodeFile asFile(); @Override boolean metadataEquals(INodeFileAttributes other); final FileUnderConstructionFeature getFileUnderConstructionFeature(); @Override // BlockCollection boolean isUnderConstruction(); INodeFile toCompleteFile(long mtime); @Override // BlockCollection void setBlock(int index, BlockInfo blk); @Override // BlockCollection, the file should be under construction BlockInfoUnderConstruction setLastBlock(BlockInfo lastBlock,
      DatanodeStorageInfo[] locations); FileWithSnapshotFeature addSnapshotFeature(FileDiffList diffs); final FileWithSnapshotFeature getFileWithSnapshotFeature(); final boolean isWithSnapshot(); @Override String toDetailString(); @Override INodeFileAttributes getSnapshotINode(final int snapshotId); @Override void recordModification(final int latestSnapshotId); FileDiffList getDiffs(); final short getFileReplication(int snapshot); @Override // INodeFileAttributes final short getFileReplication(); @Override // BlockCollection short getBlockReplication(); final void setFileReplication(short replication); final INodeFile setFileReplication(short replication,
      int latestSnapshotId); @Override long getPreferredBlockSize(); @Override byte getLocalStoragePolicyID(); @Override byte getStoragePolicyID(); final void setStoragePolicyID(byte storagePolicyId,
      int latestSnapshotId); @Override long getHeaderLong(); @Override BlockInfo[] getBlocks(); void setBlocks(BlockInfo[] blocks); @Override Quota.Counts cleanSubtree(final int snapshot, int priorSnapshotId,
      final BlocksMapUpdateInfo collectedBlocks,
      final List<INode> removedINodes, final boolean countDiffChange); @Override void destroyAndCollectBlocks(BlocksMapUpdateInfo collectedBlocks,
      final List<INode> removedINodes); @Override String getName(); @Override final Quota.Counts computeQuotaUsage(Quota.Counts counts,
      boolean useCache, int lastSnapshotId); @Override final ContentSummaryComputationContext computeContentSummary(
      final ContentSummaryComputationContext summary); final long computeFileSize(); final long computeFileSize(int snapshotId); final long computeFileSizeNotIncludingLastUcBlock(); final long computeFileSize(boolean includesLastUcBlock,
      boolean usePreferredBlockSize4LastUcBlock); final long diskspaceConsumed(); final long diskspaceConsumed(int lastSnapshotId); @Override BlockInfo getLastBlock(); @Override int numBlocks(); @VisibleForTesting @Override void dumpTreeRecursively(PrintWriter out, StringBuilder prefix,
      final int snapshotId);  }
@Test public void testValueOf () throws IOException { final String path = "/testValueOf"; final short replication = 3; { final INode from = null; try { INodeFile.valueOf(from, path); fail(); } catch(FileNotFoundException fnfe) { assertTrue(fnfe.getMessage().contains("File does not exist")); } try { INodeDirectory.valueOf(from, path); fail(); } catch(FileNotFoundException e) { assertTrue(e.getMessage().contains("Directory does not exist")); } } { final INode from = createINodeFile(replication, preferredBlockSize); final INodeFile f = INodeFile.valueOf(from, path); assertTrue(f == from); try { INodeDirectory.valueOf(from, path); fail(); } catch(PathIsNotDirectoryException e) { } } { final INode from = new INodeFile( INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, null, replication, 1024L, (byte)0); from.asFile().toUnderConstruction("client", "machine"); final INodeFile f = INodeFile.valueOf(from, path); assertTrue(f == from); try { INodeDirectory.valueOf(from, path); fail(); } catch(PathIsNotDirectoryException expected) { } } { final INode from = new INodeDirectory(INodeId.GRANDFATHER_INODE_ID, null, perm, 0L); try { INodeFile.valueOf(from, path); fail(); } catch(FileNotFoundException fnfe) { assertTrue(fnfe.getMessage().contains("Path is not a file")); } final INodeDirectory d = INodeDirectory.valueOf(from, path); assertTrue(d == from); } }