org.apache.hadoop.fs.Path.toUri() - java examples

Here are the examples of the java api org.apache.hadoop.fs.Path.toUri() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : ExpandedPolicy.java
Copyright Apache License 2.0
Author : facebookarchive
private static String normalizePath(Path p) {
    String result = p.toUri().getPath();
    if (!result.endsWith(Path.SEPARATOR)) {
        result += Path.SEPARATOR;
    }
    return result;
}

19 View Complete Implementation : PseudoLocalFs.java
Copyright Apache License 2.0
Author : aliyun-beta
/**
 * Validate if the path provided is of expected format of Pseudo Local File
 * System based files.
 * @param path file path
 * @return the file size
 * @throws FileNotFoundException
 */
long validateFileNameFormat(Path path) throws FileNotFoundException {
    path = path.makeQualified(this);
    boolean valid = true;
    long fileSize = 0;
    if (!path.toUri().getScheme().equals(getUri().getScheme())) {
        valid = false;
    } else {
        String[] parts = path.toUri().getPath().split("\\.");
        try {
            fileSize = Long.parseLong(parts[parts.length - 1]);
            valid = (fileSize >= 0);
        } catch (NumberFormatException e) {
            valid = false;
        }
    }
    if (!valid) {
        throw new FileNotFoundException("File " + path + " does not exist in pseudo local file system");
    }
    return fileSize;
}

19 View Complete Implementation : CorruptFileBlockIterator.java
Copyright Apache License 2.0
Author : facebookarchive
private String path2String(Path path) {
    return path.toUri().getPath();
}

19 View Complete Implementation : KosmosFileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
public FSDataInputStream open(Path path, int bufferSize) throws IOException {
    if (!exists(path))
        throw new IOException("File does not exist: " + path);
    Path absolute = makeAbsolute(path);
    String srep = absolute.toUri().getPath();
    return kfsImpl.open(srep, bufferSize);
}

19 View Complete Implementation : RoleModel.java
Copyright Apache License 2.0
Author : apache
/**
 * Given a path, return the S3 resource to it.
 * If {@code isDirectory} is true, a "/" is added to the path.
 * This is critical when adding wildcard permissions under
 * a directory, and also needed when locking down dir-as-file
 * and dir-as-directory-marker access.
 * @param path a path
 * @param isDirectory is this a directory?
 * @param addWildcard add a * to the tail of the key?
 * @return a resource for a statement.
 */
public static String resource(Path path, final boolean isDirectory, boolean addWildcard) {
    String key = pathToKey(path);
    if (isDirectory && !key.isEmpty()) {
        key = key + "/";
    }
    return resource(path.toUri().getHost(), key, addWildcard);
}

19 View Complete Implementation : AbstractITestS3AMetadataStoreScale.java
Copyright Apache License 2.0
Author : apache
protected Path movePath(Path p, Path src, Path dest) {
    String srcStr = src.toUri().getPath();
    String pathStr = p.toUri().getPath();
    // Strip off src dir
    pathStr = pathStr.substring(srcStr.length());
    // Prepend new dest
    return new Path(dest, pathStr);
}

19 View Complete Implementation : RoleModel.java
Copyright Apache License 2.0
Author : apache
/**
 * Variant of {@link S3AFileSystem#pathToKey(Path)} which doesn't care
 * about working directories, so can be static and stateless.
 * @param path path to map
 * @return key or ""
 */
public static String pathToKey(Path path) {
    if (path.toUri().getScheme() != null && path.toUri().getPath().isEmpty()) {
        return "";
    }
    return path.toUri().getPath().substring(1);
}

19 View Complete Implementation : KosmosFileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
public FileStatus getFileStatus(Path path) throws IOException {
    Path absolute = makeAbsolute(path);
    String srep = absolute.toUri().getPath();
    if (!kfsImpl.exists(srep)) {
        throw new FileNotFoundException("File " + path + " does not exist.");
    }
    if (kfsImpl.isDirectory(srep)) {
        // System.out.println("Status of path: " + path + " is dir");
        return new FileStatus(0, true, 1, 0, kfsImpl.getModificationTime(srep), path.makeQualified(this));
    } else {
        // System.out.println("Status of path: " + path + " is file");
        return new FileStatus(kfsImpl.filesize(srep), false, kfsImpl.getReplication(srep), getDefaultBlockSize(), kfsImpl.getModificationTime(srep), path.makeQualified(this));
    }
}

19 View Complete Implementation : CorruptFileBlockIterator.java
Copyright Apache License 2.0
Author : aliyun-beta
private String path2String(Path path) {
    return path.toUri().getPath();
}

19 View Complete Implementation : KosmosFileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
public boolean rename(Path src, Path dst) throws IOException {
    Path absoluteS = makeAbsolute(src);
    String srepS = absoluteS.toUri().getPath();
    Path absoluteD = makeAbsolute(dst);
    String srepD = absoluteD.toUri().getPath();
    // System.out.println("Calling rename on: " + srepS + " -> " + srepD);
    return kfsImpl.rename(srepS, srepD) == 0;
}

19 View Complete Implementation : FileOutputCommitter.java
Copyright Apache License 2.0
Author : facebookarchive
private Path getFinalPath(Path jobOutputDir, Path taskOutput, Path taskOutputPath) throws IOException {
    URI taskOutputUri = taskOutput.toUri();
    URI relativePath = taskOutputPath.toUri().relativize(taskOutputUri);
    if (taskOutputUri == relativePath) {
        // taskOutputPath is not a parent of taskOutput
        throw new IOException("Can not get the relative path: base = " + taskOutputPath + " child = " + taskOutput);
    }
    if (relativePath.getPath().length() > 0) {
        return new Path(jobOutputDir, relativePath.getPath());
    } else {
        return jobOutputDir;
    }
}

19 View Complete Implementation : PseudoLocalFs.java
Copyright Apache License 2.0
Author : apache
/**
 * Validate if the path provided is of expected format of Pseudo Local File
 * System based files.
 * @param path file path
 * @return the file size
 * @throws FileNotFoundException
 */
long validateFileNameFormat(Path path) throws FileNotFoundException {
    path = this.makeQualified(path);
    boolean valid = true;
    long fileSize = 0;
    if (!path.toUri().getScheme().equals(getUri().getScheme())) {
        valid = false;
    } else {
        String[] parts = path.toUri().getPath().split("\\.");
        try {
            fileSize = Long.parseLong(parts[parts.length - 1]);
            valid = (fileSize >= 0);
        } catch (NumberFormatException e) {
            valid = false;
        }
    }
    if (!valid) {
        throw new FileNotFoundException("File " + path + " does not exist in pseudo local file system");
    }
    return fileSize;
}

19 View Complete Implementation : ChRootedFileSystem.java
Copyright Apache License 2.0
Author : aliyun-beta
/**
 * Strip out the root from the path.
 * @param p - fully qualified path p
 * @return -  the remaining path  without the begining /
 * @throws IOException if the p is not prefixed with root
 */
String stripOutRoot(final Path p) throws IOException {
    try {
        checkPath(p);
    } catch (IllegalArgumentException e) {
        throw new IOException("Internal Error - path " + p + " should have been with URI: " + myUri);
    }
    String pathPart = p.toUri().getPath();
    return (pathPart.length() == chRootPathPartString.length()) ? "" : pathPart.substring(chRootPathPartString.length() + (chRootPathPart.isRoot() ? 0 : 1));
}

19 View Complete Implementation : RoleModel.java
Copyright Apache License 2.0
Author : apache
/**
 * Given a directory path, return the S3 resource to it.
 * @param path a path
 * @return a resource for a statement.
 */
public static String[] directory(Path path) {
    String host = path.toUri().getHost();
    String key = pathToKey(path);
    if (!key.isEmpty()) {
        return new String[] { resource(host, key + "/", true), resource(host, key, false), resource(host, key + "/", false) };
    } else {
        return new String[] { resource(host, key, true) };
    }
}

19 View Complete Implementation : URL.java
Copyright Apache License 2.0
Author : apache
@Public
@Stable
public static URL fromPath(Path path) {
    return fromURI(path.toUri());
}

19 View Complete Implementation : ChRootedFileSystem.java
Copyright Apache License 2.0
Author : apache
/**
 * Strip out the root from the path.
 * @param p - fully qualified path p
 * @return -  the remaining path  without the beginning /
 * @throws IOException if the p is not prefixed with root
 */
String stripOutRoot(final Path p) throws IOException {
    try {
        checkPath(p);
    } catch (IllegalArgumentException e) {
        throw new IOException("Internal Error - path " + p + " should have been with URI: " + myUri);
    }
    String pathPart = p.toUri().getPath();
    return (pathPart.length() == chRootPathPartString.length()) ? "" : pathPart.substring(chRootPathPartString.length() + (chRootPathPart.isRoot() ? 0 : 1));
}

19 View Complete Implementation : FileSystemRMStateStore.java
Copyright Apache License 2.0
Author : apache
@Override
protected synchronized void startInternal() throws Exception {
    // create filesystem only now, as part of service-start. By this time, RM is
    // authenticated with kerberos so we are good to create a file-system
    // handle.
    fsConf = new Configuration(getConfig());
    String scheme = fsWorkingPath.toUri().getScheme();
    if (scheme == null) {
        scheme = FileSystem.getDefaultUri(fsConf).getScheme();
    }
    if (scheme != null) {
        String disableCacheName = String.format("fs.%s.impl.disable.cache", scheme);
        fsConf.setBoolean(disableCacheName, true);
    }
    fs = fsWorkingPath.getFileSystem(fsConf);
    mkdirsWithRetries(rmDTSecretManagerRoot);
    mkdirsWithRetries(rmAppRoot);
    mkdirsWithRetries(amrmTokenSecretManagerRoot);
    mkdirsWithRetries(reservationRoot);
    mkdirsWithRetries(proxyCARoot);
}

19 View Complete Implementation : KosmosFileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
public boolean setReplication(Path path, short replication) throws IOException {
    Path absolute = makeAbsolute(path);
    String srep = absolute.toUri().getPath();
    int res = kfsImpl.setReplication(srep, replication);
    return res >= 0;
}

19 View Complete Implementation : CorruptFileBlockIterator.java
Copyright Apache License 2.0
Author : apache
private String path2String(Path path) {
    return path.toUri().getPath();
}

19 View Complete Implementation : WasbFsck.java
Copyright Apache License 2.0
Author : aliyun-beta
private boolean containsColon(Path p) {
    return p.toUri().getPath().toString().contains(":");
}

19 View Complete Implementation : KosmosFileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
public FileStatus[] listStatus(Path path) throws IOException {
    Path absolute = makeAbsolute(path);
    String srep = absolute.toUri().getPath();
    if (kfsImpl.isFile(srep))
        return new FileStatus[] { getFileStatus(path) };
    return kfsImpl.readdirplus(absolute);
}

19 View Complete Implementation : WasbFsck.java
Copyright Apache License 2.0
Author : apache
private boolean containsColon(Path p) {
    return p.toUri().getPath().toString().contains(":");
}

19 View Complete Implementation : FileDeletionMatcher.java
Copyright Apache License 2.0
Author : apache
public boolean comparePaths(Path p1, String p2) {
    if (p1 == null && p2 != null) {
        return false;
    } else if (p1 != null && p2 == null) {
        return false;
    } else if (p1 != null && p2 != null) {
        return p1.toUri().getPath().contains(p2.toString());
    }
    return true;
}

18 View Complete Implementation : S3AFileSystem.java
Copyright Apache License 2.0
Author : aliyun-beta
/* Turns a path (relative or otherwise) into an S3 key
   */
private String pathToKey(Path path) {
    if (!path.isAbsolute()) {
        path = new Path(workingDir, path);
    }
    if (path.toUri().getScheme() != null && path.toUri().getPath().isEmpty()) {
        return "";
    }
    return path.toUri().getPath().substring(1);
}

18 View Complete Implementation : SwiftNativeFileSystemStore.java
Copyright Apache License 2.0
Author : aliyun-beta
/**
 * Upload part of a larger file.
 *
 * @param path        destination path
 * @param partNumber  item number in the path
 * @param inputStream input data
 * @param length      length of the data
 * @throws IOException on a problem
 */
public void uploadFilePart(Path path, int partNumber, InputStream inputStream, long length) throws IOException {
    String stringPath = path.toUri().toString();
    String parreplacedionFilename = SwiftUtils.parreplacedionFilenameFromNumber(partNumber);
    if (stringPath.endsWith("/")) {
        stringPath = stringPath.concat(parreplacedionFilename);
    } else {
        stringPath = stringPath.concat("/").concat(parreplacedionFilename);
    }
    swiftRestClient.upload(new SwiftObjectPath(toDirPath(path).getContainer(), stringPath), inputStream, length);
}

18 View Complete Implementation : BlockReconstructor.java
Copyright Apache License 2.0
Author : facebookarchive
/**
 * Is the path a parity file of a given Codec?
 */
boolean isParityFile(Path p, Codec c) {
    return isParityFile(p.toUri().getPath(), c);
}

18 View Complete Implementation : SwiftObjectPath.java
Copyright Apache License 2.0
Author : apache
/**
 * Create a path tuple of (container, path), where the container is
 * chosen from the host of the URI.
 * A trailing slash can be added to the path. This is the point where
 * these /-es need to be appended, because when you construct a {@link Path}
 * instance, {@link Path#normalizePath(String, String)} is called
 * -which strips off any trailing slash.
 *
 * @param uri              uri to start from
 * @param path             path underneath
 * @param addTrailingSlash should a trailing slash be added if there isn't one.
 * @return a new instance.
 * @throws SwiftConfigurationException if the URI host doesn't parse into
 *                                     container.service
 */
public static SwiftObjectPath fromPath(URI uri, Path path, boolean addTrailingSlash) throws SwiftConfigurationException {
    String url = path.toUri().getPath().replaceAll(PATH_PART_PATTERN.pattern(), "");
    // add a trailing slash if needed
    if (addTrailingSlash && !url.endsWith("/")) {
        url += "/";
    }
    String container = uri.getHost();
    if (container == null) {
        // no container, not good: replace with ""
        container = "";
    } else if (container.contains(".")) {
        // its a container.service URI. Strip the container
        container = RestClientBindings.extractContainerName(container);
    }
    return new SwiftObjectPath(container, url);
}

18 View Complete Implementation : AzureBlobStorageTestAccount.java
Copyright Apache License 2.0
Author : apache
public static String toMockUri(Path path) {
    // Remove the first SEPARATOR
    return toMockUri(path.toUri().getRawPath().substring(1));
}

18 View Complete Implementation : S3FileSystem.java
Copyright Apache License 2.0
Author : aliyun-beta
private boolean renameRecursive(Path src, Path dst) throws IOException {
    INode srcINode = store.retrieveINode(src);
    store.storeINode(dst, srcINode);
    store.deleteINode(src);
    if (srcINode.isDirectory()) {
        for (Path oldSrc : store.listDeepSubPaths(src)) {
            INode inode = store.retrieveINode(oldSrc);
            if (inode == null) {
                return false;
            }
            String oldSrcPath = oldSrc.toUri().getPath();
            String srcPath = src.toUri().getPath();
            String dstPath = dst.toUri().getPath();
            Path newDst = new Path(oldSrcPath.replaceFirst(srcPath, dstPath));
            store.storeINode(newDst, inode);
            store.deleteINode(oldSrc);
        }
    }
    return true;
}

18 View Complete Implementation : TestMRAsyncDiskService.java
Copyright Apache License 2.0
Author : apache
@Test
public /**
 * Test that the relativeToWorking() method above does what we expect.
 */
void testRelativeToWorking() {
    replacedertEquals(".", relativeToWorking(System.getProperty("user.dir", ".")));
    String cwd = System.getProperty("user.dir", ".");
    Path cwdPath = new Path(cwd);
    Path subdir = new Path(cwdPath, "foo");
    replacedertEquals("foo", relativeToWorking(subdir.toUri().getPath()));
    Path subsubdir = new Path(subdir, "bar");
    replacedertEquals("foo/bar", relativeToWorking(subsubdir.toUri().getPath()));
    Path parent = new Path(cwdPath, "..");
    replacedertEquals("..", relativeToWorking(parent.toUri().getPath()));
    Path sideways = new Path(parent, "baz");
    replacedertEquals("../baz", relativeToWorking(sideways.toUri().getPath()));
}

18 View Complete Implementation : FileSystemRMStateStore.java
Copyright Apache License 2.0
Author : aliyun-beta
@Override
protected synchronized void startInternal() throws Exception {
    // create filesystem only now, as part of service-start. By this time, RM is
    // authenticated with kerberos so we are good to create a file-system
    // handle.
    fsConf = new Configuration(getConfig());
    fsConf.setBoolean("dfs.client.retry.policy.enabled", true);
    String retryPolicy = fsConf.get(YarnConfiguration.FS_RM_STATE_STORE_RETRY_POLICY_SPEC, YarnConfiguration.DEFAULT_FS_RM_STATE_STORE_RETRY_POLICY_SPEC);
    fsConf.set("dfs.client.retry.policy.spec", retryPolicy);
    String scheme = fsWorkingPath.toUri().getScheme();
    if (scheme == null) {
        scheme = FileSystem.getDefaultUri(fsConf).getScheme();
    }
    if (scheme != null) {
        String disableCacheName = String.format("fs.%s.impl.disable.cache", scheme);
        fsConf.setBoolean(disableCacheName, true);
    }
    fs = fsWorkingPath.getFileSystem(fsConf);
    mkdirsWithRetries(rmDTSecretManagerRoot);
    mkdirsWithRetries(rmAppRoot);
    mkdirsWithRetries(amrmTokenSecretManagerRoot);
    mkdirsWithRetries(reservationRoot);
}

18 View Complete Implementation : NativeS3FileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
private static String pathToKey(Path path) {
    if (!path.isAbsolute()) {
        throw new IllegalArgumentException("Path must be absolute: " + path);
    }
    // remove initial slash
    return path.toUri().getPath().substring(1);
}

18 View Complete Implementation : KosmosFileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
@Deprecated
public long getLength(Path path) throws IOException {
    Path absolute = makeAbsolute(path);
    String srep = absolute.toUri().getPath();
    return kfsImpl.filesize(srep);
}

18 View Complete Implementation : ChRootedFs.java
Copyright Apache License 2.0
Author : apache
/**
 * Strip out the root from the path.
 *
 * @param p - fully qualified path p
 * @return -  the remaining path  without the beginning /
 */
public String stripOutRoot(final Path p) {
    try {
        checkPath(p);
    } catch (IllegalArgumentException e) {
        throw new RuntimeException("Internal Error - path " + p + " should have been with URI" + myUri);
    }
    String pathPart = p.toUri().getPath();
    return (pathPart.length() == chRootPathPartString.length()) ? "" : pathPart.substring(chRootPathPartString.length() + (chRootPathPart.isRoot() ? 0 : 1));
}

18 View Complete Implementation : TestViewFileSystemDelegation.java
Copyright Apache License 2.0
Author : apache
static void setupFileSystem(URI uri, Clreplaced clazz) throws Exception {
    String scheme = uri.getScheme();
    conf.set("fs." + scheme + ".impl", clazz.getName());
    FakeFileSystem fs = (FakeFileSystem) FileSystem.get(uri, conf);
    replacedertEquals(uri, fs.getUri());
    Path targetPath = new FileSystemTestHelper().getAbsoluteTestRootPath(fs);
    ConfigUtil.addLink(conf, "/mounts/" + scheme, targetPath.toUri());
}

18 View Complete Implementation : Paths.java
Copyright Apache License 2.0
Author : apache
/**
 * Using {@code URI#relativize()}, build the relative path from the
 * base path to the full path.
 * If {@code childPath} is not a child of {@code basePath} the outcome
 * os undefined.
 * @param basePath base path
 * @param fullPath full path under the base path.
 * @return the relative path
 */
public static String getRelativePath(Path basePath, Path fullPath) {
    return basePath.toUri().relativize(fullPath.toUri()).getPath();
}

18 View Complete Implementation : TestStagingCommitter.java
Copyright Apache License 2.0
Author : apache
@Test
public void testCommitPathConstruction() throws Exception {
    Path committedTaskPath = committer.getCommittedTaskPath(tac);
    replacedertEquals("Path should be in HDFS: " + committedTaskPath, "hdfs", committedTaskPath.toUri().getScheme());
    String ending = STAGING_UPLOADS + "/_temporary/0/task_job_0001_r_000002";
    replacedertTrue("Did not end with \"" + ending + "\" :" + committedTaskPath, committedTaskPath.toString().endsWith(ending));
}

18 View Complete Implementation : TestReadStripedFileWithMissingBlocks.java
Copyright Apache License 2.0
Author : apache
@Test
public void testReadFileWithMissingBlocks() throws Exception {
    try {
        setup();
        Path srcPath = new Path("/foo");
        final byte[] expected = StripedFileTestUtil.generateBytes(fileLength);
        DFSTestUtil.writeFile(fs, srcPath, new String(expected));
        StripedFileTestUtil.waitBlockGroupsReported(fs, srcPath.toUri().getPath());
        StripedFileTestUtil.verifyLength(fs, srcPath, fileLength);
        for (int missingData = 1; missingData <= dataBlocks; missingData++) {
            for (int missingParity = 0; missingParity <= parityBlocks - missingData; missingParity++) {
                readFileWithMissingBlocks(srcPath, fileLength, missingData, missingParity, expected);
            }
        }
    } finally {
        tearDown();
    }
}

18 View Complete Implementation : CosNFileSystem.java
Copyright Apache License 2.0
Author : apache
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 cosn://mybucket
        return "";
    }
    if (!path.isAbsolute()) {
        throw new IllegalArgumentException("Path must be absolute: " + path);
    }
    String ret = path.toUri().getPath();
    if (ret.endsWith("/") && (ret.indexOf("/") != ret.length() - 1)) {
        ret = ret.substring(0, ret.length() - 1);
    }
    return ret;
}

18 View Complete Implementation : SwiftNativeFileSystemStore.java
Copyright Apache License 2.0
Author : apache
/**
 * Upload part of a larger file.
 *
 * @param path        destination path
 * @param partNumber  item number in the path
 * @param inputStream input data
 * @param length      length of the data
 * @throws IOException on a problem
 */
public void uploadFilePart(Path path, int partNumber, InputStream inputStream, long length) throws IOException {
    String stringPath = path.toUri().toString();
    String parreplacedionFilename = SwiftUtils.parreplacedionFilenameFromNumber(partNumber);
    if (stringPath.endsWith("/")) {
        stringPath = stringPath.concat(parreplacedionFilename);
    } else {
        stringPath = stringPath.concat("/").concat(parreplacedionFilename);
    }
    swiftRestClient.upload(new SwiftObjectPath(toDirPath(path).getContainer(), stringPath), inputStream, length);
}

18 View Complete Implementation : AliyunOSSFileSystem.java
Copyright Apache License 2.0
Author : apache
/**
 * Turn a path (relative or otherwise) into an OSS key.
 *
 * @param path the path of the file.
 * @return the key of the object that represents the file.
 */
private String pathToKey(Path path) {
    if (!path.isAbsolute()) {
        path = new Path(workingDir, path);
    }
    return path.toUri().getPath().substring(1);
}

18 View Complete Implementation : DistributedRaidFileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
/**
 * 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);
}

18 View Complete Implementation : S3FileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
private boolean renameRecursive(Path src, Path dst) throws IOException {
    INode srcINode = store.retrieveINode(src);
    store.storeINode(dst, srcINode);
    store.deleteINode(src);
    if (srcINode.isDirectory()) {
        for (Path oldSrc : store.listDeepSubPaths(src)) {
            INode inode = store.retrieveINode(oldSrc);
            if (inode == null) {
                return false;
            }
            String oldSrcPath = oldSrc.toUri().getPath();
            String srcPath = src.toUri().getPath();
            String dstPath = dst.toUri().getPath();
            Path newDst = new Path(oldSrcPath.replaceFirst(srcPath, dstPath));
            store.storeINode(newDst, inode);
            store.deleteINode(oldSrc);
        }
    }
    return true;
}

18 View Complete Implementation : StatisticsCollector.java
Copyright Apache License 2.0
Author : facebookarchive
private boolean underPolicy(Path filePath, List<Path> roots) throws IOException {
    String rawPath = filePath.toUri().getPath();
    for (Path root : roots) {
        String rawRoot = root.toUri().getPath();
        if (isAncestorPath(rawRoot, rawPath)) {
            return true;
        }
    }
    return false;
}

18 View Complete Implementation : TestDistributedCache.java
Copyright Apache License 2.0
Author : facebookarchive
/**
 * test delete cache
 */
public void testDeleteCache() throws Exception {
    // We first test the size of files exceeds the limit
    long now = System.currentTimeMillis();
    Path firstLocalCache = DistributedCache.getLocalCache(firstCacheFile.toUri(), conf, new Path(TEST_CACHE_BASE_DIR), localfs.getFileStatus(firstCacheFile), false, now, new Path(TEST_ROOT_DIR), null);
    // Release the first cache so that it can be deleted when sweeping
    DistributedCache.releaseCache(firstCacheFile.toUri(), conf, now);
    DistributedCache.getLocalCache(secondCacheFile.toUri(), conf, new Path(TEST_CACHE_BASE_DIR), localfs.getFileStatus(firstCacheFile), false, now, new Path(TEST_ROOT_DIR), null);
    // The total size is about 6 * 1024 which is greater than 5 * 1024.
    // So released cache should be deleted.
    checkCacheDeletion(localfs, firstLocalCache);
    // Now we test the number of files limit
    Path thirdLocalCache = DistributedCache.getLocalCache(thirdCacheFile.toUri(), conf, new Path(TEST_CACHE_BASE_DIR), localfs.getFileStatus(firstCacheFile), false, now, new Path(TEST_ROOT_DIR), null);
    // Release the third cache so that it can be deleted when sweeping
    DistributedCache.releaseCache(thirdCacheFile.toUri(), conf, now);
    DistributedCache.getLocalCache(fourthCacheFile.toUri(), conf, new Path(TEST_CACHE_BASE_DIR), localfs.getFileStatus(firstCacheFile), false, now, new Path(TEST_ROOT_DIR), null);
    // The total number of caches is now 3 which is greater than 2.
    // So released cache should be deleted.
    checkCacheDeletion(localfs, thirdLocalCache);
}

18 View Complete Implementation : ITestReadAndSeekPageBlobAfterWrite.java
Copyright Apache License 2.0
Author : apache
/**
 * Make sure the file name (key) is a page blob file name. If anybody changes that,
 * we need to come back and update this test clreplaced.
 */
@Test
public void testIsPageBlobFileName() {
    AzureNativeFileSystemStore store = ((NativeAzureFileSystem) fs).getStore();
    String[] a = blobPath.toUri().getPath().split("/");
    String key2 = a[1] + "/";
    replacedertTrue("Not a page blob: " + blobPath, store.isPageBlobKey(key2));
}

18 View Complete Implementation : AzureBlobFileSystem.java
Copyright Apache License 2.0
Author : apache
/**
 * Qualify a path to one which uses this FileSystem and, if relative,
 * made absolute.
 * @param path to qualify.
 * @return this path if it contains a scheme and authority and is absolute, or
 * a new path that includes a path and authority and is fully qualified
 * @see Path#makeQualified(URI, Path)
 * @throws IllegalArgumentException if the path has a schema/URI different
 * from this FileSystem.
 */
@Override
public Path makeQualified(Path path) {
    // To support format: abfs://{dfs.nameservices}/file/path,
    // path need to be first converted to URI, then get the raw path string,
    // during which {dfs.nameservices} will be omitted.
    if (path != null) {
        String uriPath = path.toUri().getPath();
        path = uriPath.isEmpty() ? path : new Path(uriPath);
    }
    return super.makeQualified(path);
}

18 View Complete Implementation : DistCpUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Gets relative path of child path with respect to a root path
 * For ex. If childPath = /tmp/abc/xyz/file and
 *            sourceRootPath = /tmp/abc
 * Relative path would be /xyz/file
 *         If childPath = /file and
 *            sourceRootPath = /
 * Relative path would be /file
 * @param sourceRootPath - Source root path
 * @param childPath - Path for which relative path is required
 * @return - Relative portion of the child path (always prefixed with /
 *           unless it is empty
 */
public static String getRelativePath(Path sourceRootPath, Path childPath) {
    String childPathString = childPath.toUri().getPath();
    String sourceRootPathString = sourceRootPath.toUri().getPath();
    return sourceRootPathString.equals("/") ? childPathString : childPathString.substring(sourceRootPathString.length());
}

18 View Complete Implementation : KosmosFileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
// recursively delete the directory and its contents
public boolean delete(Path path, boolean recursive) throws IOException {
    Path absolute = makeAbsolute(path);
    String srep = absolute.toUri().getPath();
    if (kfsImpl.isFile(srep))
        return kfsImpl.remove(srep) == 0;
    FileStatus[] dirEntries = listStatus(absolute);
    if ((!recursive) && (dirEntries != null) && (dirEntries.length != 0)) {
        throw new IOException("Directory " + path.toString() + " is not empty.");
    }
    if (dirEntries != null) {
        for (int i = 0; i < dirEntries.length; i++) {
            delete(new Path(absolute, dirEntries[i].getPath()), recursive);
        }
    }
    return kfsImpl.rmdir(srep) == 0;
}

18 View Complete Implementation : TestFTPFileSystem.java
Copyright Apache License 2.0
Author : facebookarchive
/**
 * Tests FTPFileSystem, create(), open(), delete(), mkdirs(), rename(),
 * listStatus(), getStatus() APIs. *
 *
 * @throws Exception
 */
public void testReadWrite() throws Exception {
    DFSTestUtil util = new DFSTestUtil("TestFTPFileSystem", 20, 3, 1024 * 1024);
    localFs.setWorkingDirectory(workDir);
    Path localData = new Path(workDir, "srcData");
    Path remoteData = new Path("srcData");
    util.createFiles(localFs, localData.toUri().getPath());
    boolean dataConsistency = util.checkFiles(localFs, localData.getName());
    replacedertTrue("Test data corrupted", dataConsistency);
    // Copy files and directories recursively to FTP file system.
    boolean filesCopied = FileUtil.copy(localFs, localData, ftpFs, remoteData, false, defaultConf);
    replacedertTrue("Copying to FTPFileSystem failed", filesCopied);
    // Rename the remote copy
    Path renamedData = new Path("Renamed");
    boolean renamed = ftpFs.rename(remoteData, renamedData);
    replacedertTrue("Rename failed", renamed);
    // Copy files and directories from FTP file system and delete remote copy.
    filesCopied = FileUtil.copy(ftpFs, renamedData, localFs, workDir, true, defaultConf);
    replacedertTrue("Copying from FTPFileSystem fails", filesCopied);
    // Check if the data was received completely without any corruption.
    dataConsistency = util.checkFiles(localFs, renamedData.getName());
    replacedertTrue("Invalid or corrupted data recieved from FTP Server!", dataConsistency);
    // Delete local copies
    boolean deleteSuccess = localFs.delete(renamedData, true) & localFs.delete(localData, true);
    replacedertTrue("Local test data deletion failed", deleteSuccess);
}