Example usage for org.apache.hadoop.hdfs DFSUtil isValidName

List of usage examples for org.apache.hadoop.hdfs DFSUtil isValidName

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DFSUtil isValidName.

Prototype

public static boolean isValidName(String src) 

Source Link

Document

Whether the pathname is valid.

Usage

From source file:com.bigstep.datalake.DLFileSystem.java

License:Apache License

@Override
public synchronized void setWorkingDirectory(final Path dir) {
    String result = makeAbsolute(dir).toUri().getPath();
    if (!DFSUtil.isValidName(result)) {
        throw new IllegalArgumentException("Invalid DFS directory name " + result);
    }// www . j  a  v  a 2 s .  com
    workingDir = makeAbsolute(dir);
}

From source file:com.mellanox.r4h.DistributedFileSystem.java

License:Apache License

@Override
public void setWorkingDirectory(Path dir) {
    String result = fixRelativePart(dir).toUri().getPath();
    if (!DFSUtil.isValidName(result)) {
        throw new IllegalArgumentException("Invalid DFS directory name " + result);
    }/*from www.  j  a  v a  2  s .  c  o  m*/
    workingDir = fixRelativePart(dir);
}

From source file:com.mellanox.r4h.DistributedFileSystem.java

License:Apache License

/**
 * Checks that the passed URI belongs to this filesystem and returns
 * just the path component. Expects a URI with an absolute path.
 * //from w w  w  .  j  a va 2  s .  c o  m
 * @param file
 *            URI with absolute path
 * @return path component of {file}
 * @throws IllegalArgumentException
 *             if URI does not belong to this DFS
 */
private String getPathName(Path file) {
    checkPath(file);
    String result = file.toUri().getPath();
    if (!DFSUtil.isValidName(result)) {
        throw new IllegalArgumentException(
                "Pathname " + result + " from " + file + " is not a valid DFS filename.");
    }
    return result;
}

From source file:org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem.java

License:Apache License

/** {@inheritDoc} */
@Override/*from   ww  w . ja  v a 2s  .  co  m*/
public void setWorkingDirectory(Path newPath) {
    if (newPath == null) {
        Path homeDir = getHomeDirectory();

        if (secondaryFs != null)
            secondaryFs.setWorkingDirectory(toSecondary(homeDir));

        workingDir.set(homeDir);
    } else {
        Path fixedNewPath = fixRelativePart(newPath);

        String res = fixedNewPath.toUri().getPath();

        if (!DFSUtil.isValidName(res))
            throw new IllegalArgumentException("Invalid DFS directory name " + res);

        if (secondaryFs != null)
            secondaryFs.setWorkingDirectory(toSecondary(fixedNewPath));

        workingDir.set(fixedNewPath);
    }
}

From source file:org.apache.ignite.internal.processors.hadoop.fs.GridHadoopDistributedFileSystem.java

License:Apache License

/** {@inheritDoc} */
@Override//  w  w w  .j av a  2  s . c o m
public void setWorkingDirectory(Path dir) {
    Path fixedDir = fixRelativePart(dir);

    String res = fixedDir.toUri().getPath();

    if (!DFSUtil.isValidName(res))
        throw new IllegalArgumentException("Invalid DFS directory name " + res);

    workingDir.set(fixedDir);
}