Search in sources :

Example 11 with UnresolvedLinkException

use of org.apache.hadoop.fs.UnresolvedLinkException in project hadoop by apache.

the class NameNodeRpcServer method getLinkTarget.

// ClientProtocol
@Override
public String getLinkTarget(String path) throws IOException {
    checkNNStartup();
    metrics.incrGetLinkTargetOps();
    HdfsFileStatus stat = null;
    try {
        stat = namesystem.getFileInfo(path, false);
    } catch (UnresolvedPathException e) {
        return e.getResolvedPath().toString();
    } catch (UnresolvedLinkException e) {
        // The NameNode should only throw an UnresolvedPathException
        throw new AssertionError("UnresolvedLinkException thrown");
    }
    if (stat == null) {
        throw new FileNotFoundException("File does not exist: " + path);
    } else if (!stat.isSymlink()) {
        throw new IOException("Path " + path + " is not a symbolic link");
    }
    return stat.getSymlink();
}
Also used : UnresolvedLinkException(org.apache.hadoop.fs.UnresolvedLinkException) HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) UnresolvedPathException(org.apache.hadoop.hdfs.protocol.UnresolvedPathException)

Example 12 with UnresolvedLinkException

use of org.apache.hadoop.fs.UnresolvedLinkException in project incubator-crail by apache.

the class CrailHDFS method createInternal.

@Override
public FSDataOutputStream createInternal(Path path, EnumSet<CreateFlag> flag, FsPermission absolutePermission, int bufferSize, short replication, long blockSize, Progressable progress, ChecksumOpt checksumOpt, boolean createParent) throws AccessControlException, FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, UnresolvedLinkException, IOException {
    CrailFile fileInfo = null;
    try {
        fileInfo = dfs.create(path.toUri().getRawPath(), CrailNodeType.DATAFILE, CrailStorageClass.PARENT, CrailLocationClass.PARENT, true).get().asFile();
    } catch (Exception e) {
        if (e.getMessage().contains(RpcErrors.messages[RpcErrors.ERR_PARENT_MISSING])) {
            fileInfo = null;
        } else {
            throw new IOException(e);
        }
    }
    if (fileInfo == null) {
        Path parent = path.getParent();
        this.mkdir(parent, FsPermission.getDirDefault(), true);
        try {
            fileInfo = dfs.create(path.toUri().getRawPath(), CrailNodeType.DATAFILE, CrailStorageClass.PARENT, CrailLocationClass.PARENT, true).get().asFile();
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
    CrailBufferedOutputStream outputStream = null;
    if (fileInfo != null) {
        try {
            fileInfo.syncDir();
            outputStream = fileInfo.getBufferedOutputStream(Integer.MAX_VALUE);
        } catch (Exception e) {
            throw new IOException(e);
        }
    } else {
        throw new IOException("Failed to create file, path " + path.toString());
    }
    if (outputStream != null) {
        return new CrailHDFSOutputStream(outputStream, statistics);
    } else {
        throw new IOException("Failed to create file, path " + path.toString());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) CrailFile(org.apache.crail.CrailFile) CrailBufferedOutputStream(org.apache.crail.CrailBufferedOutputStream) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) UnresolvedLinkException(org.apache.hadoop.fs.UnresolvedLinkException) ParentNotDirectoryException(org.apache.hadoop.fs.ParentNotDirectoryException) FileAlreadyExistsException(org.apache.hadoop.fs.FileAlreadyExistsException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(org.apache.hadoop.security.AccessControlException) UnsupportedFileSystemException(org.apache.hadoop.fs.UnsupportedFileSystemException)

Example 13 with UnresolvedLinkException

use of org.apache.hadoop.fs.UnresolvedLinkException in project incubator-crail by apache.

the class CrailHDFS method mkdir.

@Override
public void mkdir(Path path, FsPermission permission, boolean createParent) throws AccessControlException, FileAlreadyExistsException, FileNotFoundException, UnresolvedLinkException, IOException {
    try {
        CrailDirectory file = dfs.create(path.toUri().getRawPath(), CrailNodeType.DIRECTORY, CrailStorageClass.PARENT, CrailLocationClass.DEFAULT, true).get().asDirectory();
        file.syncDir();
    } catch (Exception e) {
        if (e.getMessage().contains(RpcErrors.messages[RpcErrors.ERR_PARENT_MISSING])) {
            Path parent = path.getParent();
            mkdir(parent, permission, createParent);
            mkdir(path, permission, createParent);
        } else if (e.getMessage().contains(RpcErrors.messages[RpcErrors.ERR_FILE_EXISTS])) {
        } else {
            throw new IOException(e);
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) CrailDirectory(org.apache.crail.CrailDirectory) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) UnresolvedLinkException(org.apache.hadoop.fs.UnresolvedLinkException) ParentNotDirectoryException(org.apache.hadoop.fs.ParentNotDirectoryException) FileAlreadyExistsException(org.apache.hadoop.fs.FileAlreadyExistsException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(org.apache.hadoop.security.AccessControlException) UnsupportedFileSystemException(org.apache.hadoop.fs.UnsupportedFileSystemException)

Example 14 with UnresolvedLinkException

use of org.apache.hadoop.fs.UnresolvedLinkException in project SSM by Intel-bigdata.

the class SmartFileSystem method setPermission.

@Override
public void setPermission(Path p, final FsPermission permission) throws IOException {
    statistics.incrementWriteOps(1);
    Path absF = fixRelativePart(p);
    new FileSystemLinkResolver<Void>() {

        @Override
        public Void doCall(final Path p) throws IOException, UnresolvedLinkException {
            smartDFSClient.setPermission(getPathName(p), permission);
            return null;
        }

        @Override
        public Void next(final FileSystem fs, final Path p) throws IOException {
            fs.setPermission(p, permission);
            return null;
        }
    }.resolve(this, absF);
}
Also used : Path(org.apache.hadoop.fs.Path) UnresolvedLinkException(org.apache.hadoop.fs.UnresolvedLinkException) FileSystem(org.apache.hadoop.fs.FileSystem) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) IOException(java.io.IOException)

Example 15 with UnresolvedLinkException

use of org.apache.hadoop.fs.UnresolvedLinkException in project SSM by Intel-bigdata.

the class SmartFileSystem method removeAcl.

@Override
public void removeAcl(Path path) throws IOException {
    final Path absF = fixRelativePart(path);
    new FileSystemLinkResolver<Void>() {

        @Override
        public Void doCall(final Path p) throws IOException {
            smartDFSClient.removeAcl(getPathName(p));
            return null;
        }

        @Override
        public Void next(final FileSystem fs, final Path p) throws IOException, UnresolvedLinkException {
            fs.removeAcl(p);
            return null;
        }
    }.resolve(this, absF);
}
Also used : Path(org.apache.hadoop.fs.Path) UnresolvedLinkException(org.apache.hadoop.fs.UnresolvedLinkException) FileSystem(org.apache.hadoop.fs.FileSystem) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) IOException(java.io.IOException)

Aggregations

UnresolvedLinkException (org.apache.hadoop.fs.UnresolvedLinkException)15 IOException (java.io.IOException)13 Path (org.apache.hadoop.fs.Path)11 FileNotFoundException (java.io.FileNotFoundException)7 FileSystem (org.apache.hadoop.fs.FileSystem)7 URISyntaxException (java.net.URISyntaxException)6 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)6 ParentNotDirectoryException (org.apache.hadoop.fs.ParentNotDirectoryException)6 UnsupportedFileSystemException (org.apache.hadoop.fs.UnsupportedFileSystemException)6 AccessControlException (org.apache.hadoop.security.AccessControlException)6 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)4 FileStatus (org.apache.hadoop.fs.FileStatus)3 CrailFile (org.apache.crail.CrailFile)2 CrailNode (org.apache.crail.CrailNode)2 FileSystemLinkResolver (org.apache.hadoop.fs.FileSystemLinkResolver)2 FsPermission (org.apache.hadoop.fs.permission.FsPermission)2 HdfsFileStatus (org.apache.hadoop.hdfs.protocol.HdfsFileStatus)2 ArrayList (java.util.ArrayList)1 CrailBlockLocation (org.apache.crail.CrailBlockLocation)1 CrailBufferedInputStream (org.apache.crail.CrailBufferedInputStream)1