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();
}
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());
}
}
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);
}
}
}
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);
}
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);
}
Aggregations