本文整理汇总了Java中org.apache.hadoop.fs.Path.isRoot方法的典型用法代码示例。如果您正苦于以下问题:Java Path.isRoot方法的具体用法?Java Path.isRoot怎么用?Java Path.isRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.fs.Path
的用法示例。
在下文中一共展示了Path.isRoot方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteUnnecessaryFakeDirectories
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private void deleteUnnecessaryFakeDirectories(Path f) throws IOException {
while (true) {
try {
String key = pathToKey(f);
if (key.isEmpty()) {
break;
}
S3AFileStatus status = getFileStatus(f);
if (status.isDirectory() && status.isEmptyDirectory()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Deleting fake directory " + key + "/");
}
s3.deleteObject(bucket, key + "/");
statistics.incrementWriteOps(1);
}
} catch (FileNotFoundException | AmazonServiceException e) {
}
if (f.isRoot()) {
break;
}
f = f.getParent();
}
}
示例2: open
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
@Override
public FSDataInputStream open(Path f, int bufferSize) throws IOException {
Path absolutePath = toAbsolutePath(f);
checkPath(absolutePath);
// Handle root
if (absolutePath.isRoot()) {
throw new AccessControlException("Cannot open " + f);
}
try {
RemotePath remotePath = getRemotePath(absolutePath);
FileSystem delegate = getDelegateFileSystem(remotePath.address);
return delegate.open(remotePath.path, bufferSize);
} catch (IllegalArgumentException e) {
throw (FileNotFoundException) (new FileNotFoundException("No file " + absolutePath).initCause(e));
}
}
示例3: delete
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
@Override
public boolean delete(Path f, boolean recursive) throws IOException {
Path absolutePath = toAbsolutePath(f);
checkPath(absolutePath);
// Handle root
if (absolutePath.isRoot()) {
throw new AccessControlException("Cannot delete " + f);
}
if (!isRemoteFile(f)) {
// In our remote view, there might be a directory, so delete task should handle this case
return new DeleteTask(absolutePath, recursive).get();
}
try {
RemotePath remotePath = getRemotePath(absolutePath);
FileSystem delegate = getDelegateFileSystem(remotePath.address);
return delegate.delete(remotePath.path, recursive);
} catch (IllegalArgumentException e) {
throw (FileNotFoundException) (new FileNotFoundException("No file " + absolutePath).initCause(e));
}
}
示例4: mkdirs
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
@Override
public boolean mkdirs(Path f, FsPermission permission) throws IOException {
Path absolutePath = toAbsolutePath(f);
checkPath(absolutePath);
// Handle root
if (absolutePath.isRoot()) {
// Path always exists
return true;
}
if (isRemoteFile(absolutePath)) {
// Attemping to create a subdirectory for a file
throw new IOException("Cannot create a directory under file " + f);
}
return new MkdirsTask(absolutePath, permission).get();
}
示例5: createOutputPath
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
* Create the output folder and optionally set ownership.
*/
private void createOutputPath(final Path path) throws IOException {
if (filesUser == null && filesGroup == null) {
outputFs.mkdirs(path);
} else {
Path parent = path.getParent();
if (!outputFs.exists(parent) && !parent.isRoot()) {
createOutputPath(parent);
}
outputFs.mkdirs(path);
if (filesUser != null || filesGroup != null) {
// override the owner when non-null user/group is specified
outputFs.setOwner(path, filesUser, filesGroup);
}
if (filesMode > 0) {
outputFs.setPermission(path, new FsPermission(filesMode));
}
}
}
示例6: rejectRootOperation
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
* Block any operation on the root path. This is a safety check
* @param path path in the filesystem
* @param allowRootOperation can the root directory be manipulated?
* @throws IOException if the operation was rejected
*/
public static void rejectRootOperation(Path path,
boolean allowRootOperation) throws IOException {
if (path.isRoot() && !allowRootOperation) {
throw new IOException("Root directory operation rejected: " + path);
}
}
示例7: getFileStatus
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
@Override
public FileStatus getFileStatus(Path f) throws IOException {
if (f.isRoot()) {
return new FileStatus(0, true, 0, 0, 0, f);
}
return null;
}
示例8: create
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
* Create a new file. Three possibilities:
* - This is a data node and you're trying to create a unqualified file => write locally.
* - This is a client node and you're trying to create unqualified file => pick a random data node and write there.
* - The path you provide is qualified => write to that node.
*/
@Override
public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize,
short replication, long blockSize, Progressable progress) throws IOException {
final Path absolutePath = toAbsolutePath(f);
checkPath(absolutePath);
// Handle root
if (absolutePath.isRoot()) {
throw new AccessControlException("Cannot create " + f);
}
if(!isRemoteFile(f)){
if (isDirectory(absolutePath)) {
throw new FileAlreadyExistsException("Directory already exists: " + f);
}
// Only canonicalized path/remote files are allowed
throw new IOException("Cannot create non-canonical path " + f);
}
try {
RemotePath remotePath = getRemotePath(absolutePath);
return getDelegateFileSystem(remotePath.address).create(remotePath.path, permission, overwrite, bufferSize, replication, blockSize, progress);
} catch (IllegalArgumentException e) {
throw (IOException) (new IOException("Cannot create file " + absolutePath).initCause(e));
}
}
示例9: append
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
* Create a new file. Three possibilities:
* - This is a data node and you're trying to append a unqualified file => write locally.
* - The path you provide is qualified => write to that node.
*
* If this is a client node and you try to write to a unqualified file, we'll throw
*/
@Override
public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException {
Path absolutePath = toAbsolutePath(f);
checkPath(absolutePath);
// Handle root
if (absolutePath.isRoot()) {
throw new AccessControlException("Cannot open " + f);
}
if(!isRemoteFile(f)){
if (isDirectory(absolutePath)) {
throw new FileAlreadyExistsException("Directory already exists: " + f);
}
// Only fully canonicalized/remote files are allowed
throw new IOException("Cannot create non-canonical path " + f);
}
try {
RemotePath remotePath = getRemotePath(absolutePath);
FileSystem delegate = getDelegateFileSystem(remotePath.address);
return delegate.append(remotePath.path, bufferSize, progress);
} catch (IllegalArgumentException e) {
throw (FileNotFoundException) (new FileNotFoundException("No file " + absolutePath).initCause(e));
}
}
示例10: addParentDirectoriesRecursively
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private void addParentDirectoriesRecursively(Path path) throws IOException {
if (!path.isRoot()) {
Path parent = path.getParent();
IndexDirectory newEntry = new IndexDirectory(fs.getFileStatus(parent));
newEntry.addChild(path.getName());
index.addEntry(newEntry);
addParentDirectoriesRecursively(parent);
}
}