public static LocalResource createLocalResourceOfFile ( YarnConfiguration yarnConf , String resource ) throws IOException { LocalResource localResource = Records . newRecord ( LocalResource . class ) ; Path resourcePath = new Path ( resource ) ; FileStatus jarStat = FileSystem . get ( resourcePath . toUri ( ) , yarnConf ) . getFileStatus ( resourcePath ) ; localResource . setResource ( ConverterUtils . getYarnUrlFromPath ( resourcePath ) ) ; localResource . setSize ( jarStat . getLen ( ) ) ; localResource . setTimestamp ( jarStat . getModificationTime ( ) ) ; localResource . setType ( LocalResourceType . FILE ) ; localResource . setVisibility ( LocalResourceVisibility . PUBLIC ) ; return localResource ; }
Creates a local resource for a file on HDFS .