本文整理匯總了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);
}
}