org.apache.hadoop.fs.Path#isAbsolute ( )源码实例Demo

下面列出了org.apache.hadoop.fs.Path#isAbsolute ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ignite   文件: IgniteHadoopFileSystem.java
/**
 * Convert Hadoop path into IGFS path.
 *
 * @param path Hadoop path.
 * @return IGFS path.
 */
@Nullable private IgfsPath convert(Path path) {
    if (path == null)
        return null;

    return path.isAbsolute() ? new IgfsPath(path.toUri().getPath()) :
        new IgfsPath(workingDir, path.toUri().getPath());
}
 
源代码2 项目: RDFS   文件: RaidNode.java
/**
 * Make an absolute path relative by stripping the leading /
 */
static Path makeRelative(Path path) {
	if (!path.isAbsolute()) {
		return path;
	}
	String p = path.toUri().getPath();
	String relative = p.substring(1, p.length());
	return new Path(relative);
}
 
源代码3 项目: hadoop   文件: ChRootedFileSystem.java
/**
 * @param path
 * @return  full path including the chroot 
 */
protected Path fullPath(final Path path) {
  super.checkPath(path);
  return path.isAbsolute() ? 
      new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString)
          + path.toUri().getPath()) :
      new Path(chRootPathPartString + workingDir.toUri().getPath(), path);
}
 
源代码4 项目: hadoop   文件: ContainerLaunch.java
public final void symlink(Path src, Path dst) throws IOException {
  if (!src.isAbsolute()) {
    throw new IOException("Source must be absolute");
  }
  if (dst.isAbsolute()) {
    throw new IOException("Destination must be relative");
  }
  if (dst.toUri().getPath().indexOf('/') != -1) {
    mkdir(dst.getParent());
  }
  link(src, dst);
}
 
源代码5 项目: ignite   文件: HadoopRawLocalFileSystem.java
/**
 * Converts Hadoop path to local path.
 *
 * @param path Hadoop path.
 * @return Local path.
 */
File convert(Path path) {
    checkPath(path);

    if (path.isAbsolute())
        return new File(path.toUri().getPath());

    return new File(getWorkingDirectory().toUri().getPath(), path.toUri().getPath());
}
 
源代码6 项目: big-c   文件: NativeAzureFileSystem.java
/**
 * Get the absolute version of the path (fully qualified).
 * This is public for testing purposes.
 *
 * @param path
 * @return fully qualified path
 */
@VisibleForTesting
public Path makeAbsolute(Path path) {
  if (path.isAbsolute()) {
    return path;
  }
  return new Path(workingDir, path);
}
 
源代码7 项目: sahara-extra   文件: SwiftNativeFileSystem.java
/**
 * Makes path absolute
 *
 * @param path path to file
 * @return absolute path
 */
protected Path makeAbsolute(Path path) {
  if (path.isAbsolute()) {
    return path;
  }
  return new Path(workingDir, path);
}
 
源代码8 项目: hadoop   文件: NativeAzureFileSystem.java
/**
 * Get the absolute version of the path (fully qualified).
 * This is public for testing purposes.
 *
 * @param path
 * @return fully qualified path
 */
@VisibleForTesting
public Path makeAbsolute(Path path) {
  if (path.isAbsolute()) {
    return path;
  }
  return new Path(workingDir, path);
}
 
@Override
public Path getAbsoluteTestRootPath(FileSystem fSys) {
  Path testRootPath = new Path(TEST_ROOT_DIR);
  if (testRootPath.isAbsolute()) {
    return testRootPath;
  } else {
    return new Path(fSys.getWorkingDirectory(), TEST_ROOT_DIR);
  }
}
 
源代码10 项目: big-c   文件: NativeS3FileSystem.java
private static String pathToKey(Path path) {
  if (path.toUri().getScheme() != null && path.toUri().getPath().isEmpty()) {
    // allow uris without trailing slash after bucket to refer to root,
    // like s3n://mybucket
    return "";
  }
  if (!path.isAbsolute()) {
    throw new IllegalArgumentException("Path must be absolute: " + path);
  }
  String ret = path.toUri().getPath().substring(1); // remove initial slash
  if (ret.endsWith("/") && (ret.indexOf("/") != ret.length() - 1)) {
    ret = ret.substring(0, ret.length() -1);
}
  return ret;
}
 
源代码11 项目: kylin   文件: KylinConfigBase.java
public String getMetastoreBigCellHdfsDirectory() {

        if (cachedBigCellDirectory != null)
            return cachedBigCellDirectory;

        String root = getOptional("kylin.env.hdfs-metastore-bigcell-dir");

        if (root == null) {
            return getJdbcHdfsWorkingDirectory();
        }

        Path path = new Path(root);
        if (!path.isAbsolute())
            throw new IllegalArgumentException(
                    "kylin.env.hdfs-metastore-bigcell-dir must be absolute, but got " + root);

        // make sure path is qualified
        try {
            FileSystem fs = HadoopUtil.getReadFileSystem();
            path = fs.makeQualified(path);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        root = new Path(path, StringUtils.replaceChars(getMetadataUrlPrefix(), ':', '-')).toString();

        if (!root.endsWith("/"))
            root += "/";

        cachedBigCellDirectory = root;
        if (cachedBigCellDirectory.startsWith(FILE_SCHEME)) {
            cachedBigCellDirectory = cachedBigCellDirectory.replace(FILE_SCHEME, "file://");
        } else if (cachedBigCellDirectory.startsWith(MAPRFS_SCHEME)) {
            cachedBigCellDirectory = cachedBigCellDirectory.replace(MAPRFS_SCHEME, "maprfs://");
        }

        return cachedBigCellDirectory;
    }
 
源代码12 项目: big-c   文件: ChRootedFileSystem.java
/**
 * @param path
 * @return  full path including the chroot 
 */
protected Path fullPath(final Path path) {
  super.checkPath(path);
  return path.isAbsolute() ? 
      new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString)
          + path.toUri().getPath()) :
      new Path(chRootPathPartString + workingDir.toUri().getPath(), path);
}
 
源代码13 项目: spork   文件: LoadFunc.java
/**
 * Construct the absolute path from the file location and the current
 * directory. The current directory is either of the form 
 * {code}hdfs://<nodename>:<nodeport>/<directory>{code} in Hadoop 
 * MapReduce mode, or of the form 
 * {code}file:///<directory>{code} in Hadoop local mode.
 * 
 * @param location the location string specified in the load statement
 * @param curDir the current file system directory
 * @return the absolute path of file in the file system
 * @throws FrontendException if the scheme of the location is incompatible
 *         with the scheme of the file system
 */
public static String getAbsolutePath(String location, Path curDir) 
        throws FrontendException {
    
    if (location == null || curDir == null) {
        throw new FrontendException(
                "location: " + location + " curDir: " + curDir);
    }

    URI fsUri = curDir.toUri();
    String fsScheme = fsUri.getScheme();
    if (fsScheme == null) {
        throw new FrontendException("curDir: " + curDir);           
    }
    
    fsScheme = fsScheme.toLowerCase();
    String authority = fsUri.getAuthority();
    if(authority == null) {
        authority = "";
    }
    Path rootDir = new Path(fsScheme, authority, "/");
    
    ArrayList<String> pathStrings = new ArrayList<String>();
    
    String[] fnames = getPathStrings(location);
    for (String fname: fnames) {
        // remove leading/trailing whitespace(s)
        fname = fname.trim();
        Path p = new Path(fname);
        URI uri = p.toUri();
        // if the supplied location has a scheme (i.e. uri is absolute) or 
        // an absolute path, just use it.
        if(! (uri.isAbsolute() || p.isAbsolute())) {
            String scheme = uri.getScheme();
            if (scheme != null) {
                scheme = scheme.toLowerCase();
            }
            
            if (scheme != null && !scheme.equals(fsScheme)) {
                throw new FrontendException("Incompatible file URI scheme: "
                        + scheme + " : " + fsScheme);               
            }            
            String path = uri.getPath();
        
            fname = (p.isAbsolute()) ? 
                        new Path(rootDir, path).toString() : 
                            new Path(curDir, path).toString();
        }
        fname = fname.replaceFirst("^file:/([^/])", "file:///$1");
        // remove the trailing /
        fname = fname.replaceFirst("/$", "");
        pathStrings.add(fname);
    }

    return join(pathStrings, ",");
}
 
源代码14 项目: hadoop-gpu   文件: NativeS3FileSystem.java
private static String pathToKey(Path path) {
  if (!path.isAbsolute()) {
    throw new IllegalArgumentException("Path must be absolute: " + path);
  }
  return path.toUri().getPath().substring(1); // remove initial slash
}
 
源代码15 项目: RDFS   文件: NativeS3FileSystem.java
private static String pathToKey(Path path) {
  if (!path.isAbsolute()) {
    throw new IllegalArgumentException("Path must be absolute: " + path);
  }
  return path.toUri().getPath().substring(1); // remove initial slash
}
 
源代码16 项目: big-c   文件: Jets3tFileSystemStore.java
private String pathToKey(Path path) {
  if (!path.isAbsolute()) {
    throw new IllegalArgumentException("Path must be absolute: " + path);
  }
  return path.toUri().getPath();
}
 
源代码17 项目: hadoop-gpu   文件: KosmosFileSystem.java
private Path makeAbsolute(Path path) {
if (path.isAbsolute()) {
    return path;
}
return new Path(workingDir, path);
   }
 
源代码18 项目: hadoop-gpu   文件: S3FileSystem.java
private Path makeAbsolute(Path path) {
  if (path.isAbsolute()) {
    return path;
  }
  return new Path(workingDir, path);
}
 
源代码19 项目: big-c   文件: S3FileSystem.java
private Path makeAbsolute(Path path) {
  if (path.isAbsolute()) {
    return path;
  }
  return new Path(workingDir, path);
}
 
源代码20 项目: RDFS   文件: MigrationTool.java
private String pathToKey(Path path) {
  if (!path.isAbsolute()) {
    throw new IllegalArgumentException("Path must be absolute: " + path);
  }
  return urlEncode(path.toUri().getPath());
}