hdfs 路径不支持‘:’

本文详细解析了HDFS路径的命名规则,指出HDFS不支持相对路径、路径中包含':'和'//'的情况,并介绍了DFSUtilClient类中isValidName方法的具体实现,以及DistributedFileSystem如何通过Path API放宽路径格式限制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

hdfs 路径不支持‘:’,但Linux支持。

-put: Pathname /public/platform/control_center/file_center/weiflow/core-user-core-submit-core-dispatch-train_988-1527240620176599/:q from /public/platform/control_center/file_center/weiflow/core-user-core-submit-core-dispatch-train_988-1527240620176599/:q is not a valid DFS filename.

 

可以查看此文件:

/Users/suanec/ksp/yarn/hadoop-2.7.3-src/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSUtilClient.java

org.apache.hadoop.hdfs.DFSUtilClient

 

  /**
   * Whether the pathname is valid.  Currently prohibits relative paths,
   * names which contain a ":" or "//", or other non-canonical paths.
   */
  public static boolean isValidName(String src) {
    // Path must be absolute.
    if (!src.startsWith(Path.SEPARATOR)) {
      return false;
    }

    // Check for ".." "." ":" "/"
    String[] components = StringUtils.split(src, '/');
    for (int i = 0; i < components.length; i++) {
      String element = components[i];
      if (element.equals(".")  ||
          (element.contains(":"))  ||
          (element.contains("/"))) {
        return false;
      }
      // ".." is allowed in path starting with /.reserved/.inodes
      if (element.equals("..")) {
        if (components.length > 4
            && components[1].equals(".reserved")
            && components[2].equals(".inodes")) {
          continue;
        }
        return false;
      }
      // The string may start or end with a /, but not have
      // "//" in the middle.
      if (element.isEmpty() && i != components.length - 1 &&
          i != 0) {
        return false;
      }
    }
    return true;
  }

 

hdfs当前方法不支持相对路径,不支持路径中有":"、"/",不支持其他非标准路径格式。

hdfs的DistributedFileSystem,利用Path的api做了相对路径的转换和解析。一定程度上放宽了路径格式的限制。

转载于:https://www.cnblogs.com/suanec/p/9878439.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值