设为首页 收藏本站
查看: 467|回复: 0

[经验分享] java hadoop file system API

[复制链接]

尚未签到

发表于 2015-7-13 10:29:08 | 显示全部楼层 |阅读模式
org.apache.hadoop.fs
Class FileSystem




  • java.lang.Object
  • org.apache.hadoop.fs.FileSystem




  • All Implemented Interfaces:Closeable, AutoCloseable, ConfigurableDirect Known Subclasses:FilterFileSystem, FTPFileSystem, KosmosFileSystem, NativeS3FileSystem, RawLocalFileSystem, S3FileSystem, ViewFileSystem
    @InterfaceAudience.Public
    @InterfaceStability.Stable
    public abstract class FileSystem
    extends Configured
    implements Closeable

    An abstract base class for a fairly generic filesystem. It may be implemented as a distributed filesystem, or as a "local" one that reflects the locally-connected disk. The local version exists for small Hadoop instances and for testing.  All user code that may potentially use the Hadoop Distributed File System should be written to use a FileSystem object. The Hadoop DFS is a multi-machine system that appears as a single disk. It's useful because of its fault tolerance and potentially very large capacity.
      The local implementation is LocalFileSystem and distributed implementation is DistributedFileSystem.








    • Field Summary

      Fields

      Modifier and TypeField and Description

      static String
      DEFAULT_FS


      static String
      FS_DEFAULT_NAME_KEY


      static org.apache.commons.logging.Log
      LOG


      static int
      SHUTDOWN_HOOK_PRIORITY

      Priority of the FileSystem shutdown hook.



      protected org.apache.hadoop.fs.FileSystem.Statistics
      statistics

      The statistics for this file system.





    • Constructor Summary

      Constructors

      ModifierConstructor and Description

      protected
      FileSystem()




    • Method Summary

      [table]Methods

      [tr]Modifier and TypeMethod and Description[/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]append(Path f)

      Append to an existing file (optional operation).
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]append(Path f, int bufferSize)

      Append to an existing file (optional operation).
      [/td]
      [/tr]
      [tr]
      [td]abstract FSDataOutputStream[/td]
      [td]append(Path f, int bufferSize, Progressable progress)

      Append to an existing file (optional operation).
      [/td]
      [/tr]
      [tr]
      [td]boolean[/td]
      [td]cancelDeleteOnExit(Path f)

      Cancel the deletion of the path when the FileSystem is closed
      [/td]
      [/tr]
      [tr]
      [td]protected void[/td]
      [td]checkPath(Path path)

      Check that a Path belongs to this FileSystem.
      [/td]
      [/tr]
      [tr]
      [td]static void[/td]
      [td]clearStatistics()

      Reset all statistics for all file systems
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]close()

      No more filesystem operations are needed.
      [/td]
      [/tr]
      [tr]
      [td]static void[/td]
      [td]closeAll()

      Close all cached filesystems.
      [/td]
      [/tr]
      [tr]
      [td]static void[/td]
      [td]closeAllForUGI(org.apache.hadoop.security.UserGroupInformation ugi)

      Close all cached filesystems for a given UGI.
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]completeLocalOutput(Path fsOutputFile, Path tmpLocalFile)

      Called when we're all done writing to the target.
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]concat(Path trg, Path[] psrcs)

      Concat existing files together.
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]copyFromLocalFile(boolean delSrc, boolean overwrite, Path[] srcs, Path dst)

      The src files are on the local disk.
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]copyFromLocalFile(boolean delSrc, boolean overwrite, Path src, Path dst)

      The src file is on the local disk.
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]copyFromLocalFile(boolean delSrc, Path src, Path dst)

      The src file is on the local disk.
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]copyFromLocalFile(Path src, Path dst)

      The src file is on the local disk.
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]copyToLocalFile(boolean delSrc, Path src, Path dst)

      The src file is under FS, and the dst is on the local disk.
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]copyToLocalFile(boolean delSrc, Path src, Path dst, boolean useRawLocalFileSystem)

      The src file is under FS, and the dst is on the local disk.
      [/td]
      [/tr]
      [tr]
      [td]void[/td]
      [td]copyToLocalFile(Path src, Path dst)

      The src file is under FS, and the dst is on the local disk.
      [/td]
      [/tr]
      [tr]
      [td]static FSDataOutputStream[/td]
      [td]create(FileSystem fs, Path file, FsPermission permission)

      create a file with the provided permission The permission of the file is set to be the provided permission as in setPermission, not permission&~umask It is implemented using two RPCs.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f)

      Create an FSDataOutputStream at the indicated Path.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, boolean overwrite)

      Create an FSDataOutputStream at the indicated Path.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, boolean overwrite, int bufferSize)

      Create an FSDataOutputStream at the indicated Path.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, boolean overwrite, int bufferSize, Progressable progress)

      Create an FSDataOutputStream at the indicated Path with write-progress reporting.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize)

      Create an FSDataOutputStream at the indicated Path.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)

      Create an FSDataOutputStream at the indicated Path with write-progress reporting.
      [/td]
      [/tr]
      [tr]
      [td]abstract FSDataOutputStream[/td]
      [td]create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)

      Create an FSDataOutputStream at the indicated Path with write-progress reporting.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, FsPermission permission, EnumSet flags, int bufferSize, short replication, long blockSize, Progressable progress)

      Create an FSDataOutputStream at the indicated Path with write-progress reporting.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, FsPermission permission, EnumSet flags, int bufferSize, short replication, long blockSize, Progressable progress, org.apache.hadoop.fs.Options.ChecksumOpt checksumOpt)

      Create an FSDataOutputStream at the indicated Path with a custom checksum option
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, Progressable progress)

      Create an FSDataOutputStream at the indicated Path with write-progress reporting.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, short replication)

      Create an FSDataOutputStream at the indicated Path.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]create(Path f, short replication, Progressable progress)

      Create an FSDataOutputStream at the indicated Path with write-progress reporting.
      [/td]
      [/tr]
      [tr]
      [td]boolean[/td]
      [td]createNewFile(Path f)

      Creates the given Path as a brand-new zero-length file.
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]createNonRecursive(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)

      Deprecated.

      API only for 0.20-append
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]createNonRecursive(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)

      Deprecated.

      API only for 0.20-append
      [/td]
      [/tr]
      [tr]
      [td]FSDataOutputStream[/td]
      [td]createNonRecursive(Path f, FsPermission permission, EnumSet flags, int bufferSize, short replication, long blockSize,Progressable progress)

      Deprecated.

      API only for 0.20-append
      [/td]
      [/tr]
      [tr]
      [td]boolean[/td]
      [td]delete(Path f)

      Deprecated.

      Use delete(Path, boolean) instead.
      [/td]
      [/tr]
      [tr]
      [td]abstract boolean[/td]
      [td]delete(Path f, boolean recursive)

      Delete a file.
      [/td]
      [/tr]
      [tr]
      [td]boolean[/td]
      [td]deleteOnExit(Path f)

      Mark a path to be deleted when FileSystem is closed.
      [/td]
      [/tr]
      [tr]
      [td]boolean[/td]
      [td]exists(Path f)

      Check if exists.
      [/td]
      [/tr]
      [tr]
      [td]static FileSystem[/td]
      [td]get(Configuration conf)

      Returns the configured filesystem implementation.
      [/td]
      [/tr]
      [tr]
      [td]static FileSystem[/td]
      [td]get(URI uri, Configuration conf)

      Returns the FileSystem for this URI's scheme and authority.
      [/td]
      [/tr]
      [tr]
      [td]static FileSystem[/td]
      [td]get(URI uri, Configuration conf, String user)

      Get a filesystem instance based on the uri, the passed configuration and the user
      [/td]
      [/tr]
      [tr]
      [td]static List[/td]
      [td]getAllStatistics()

      Return the FileSystem classes that have Statistics
      [/td]
      [/tr]
      [tr]
      [td]long[/td]
      [td]getBlockSize(Path f)

      Deprecated.

      Use getFileStatus() instead
      [/td]
      [/tr]
      [tr]
      [td]protected URI[/td]
      [td]getCanonicalUri()

      Resolve the uri's hostname and add the default port if not in the uri
      [/td]
      [/tr]
      [tr]
      [td]ContentSummary[/td]
      [td]getContentSummary(Path f)

      Return the ContentSummary of a given Path.
      [/td]
      [/tr]
      [tr]
      [td]long[/td]
      [td]getDefaultBlockSize()

      Deprecated.

      use getDefaultBlockSize(Path) instead
      [/td]
      [/tr]
      [tr]
      [td]long[/td]
      [td]getDefaultBlockSize(Path f)

      Return the number of bytes that large input files should be optimally be split into to minimize i/o time.
      [/td]
      [/tr]
      [tr]
      [td]protected int[/td]
      [td]getDefaultPort()

      Get the default port for this file system.
      [/td]
      [/tr]
      [tr]
      [td]short[/td]
      [td]getDefaultReplication()

      Deprecated.

      use getDefaultReplication(Path) instead
      [/td]
      [/tr]
      [tr]
      [td]short[/td]
      [td]getDefaultReplication(Path path)

      Get the default replication for a path.
      [/td]
      [/tr]
      [tr]
      [td]static URI[/td]
      [td]getDefaultUri(Configuration conf)

      Get the default filesystem URI from a configuration.
      [/td]
      [/tr]
      [tr]
      [td]BlockLocation[][/td]
      [td]getFileBlockLocations(FileStatus file, long start, long len)

      Return an array containing hostnames, offset and size of portions of the given file.
      [/td]
      [/tr]
      [tr]
      [td]BlockLocation[][/td]
      [td]getFileBlockLocations(Path p, long start, long len)

      Return an array containing hostnames, offset and size of portions of the given file.
      [/td]
      [/tr]
      [tr]
      [td]FileChecksum[/td]
      [td]getFileChecksum(Path f)

      Get the checksum of a file.
      [/td]
      [/tr]
      [tr]
      [td]abstract FileStatus[/td]
      [td]getFileStatus(Path f)

      Return a file status object that represents the path.
      [/td]
      [/tr]
      [tr]
      [td]static Class

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-86211-1-1.html 上篇帖子: Hadoop HA 学习 下篇帖子: 安装Hadoop 1.1.2 (三 安装配置Hadoop)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表