本文整理汇总了Java中org.apache.hadoop.fs.PathExistsException类的典型用法代码示例。如果您正苦于以下问题:Java PathExistsException类的具体用法?Java PathExistsException怎么用?Java PathExistsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PathExistsException类属于org.apache.hadoop.fs包,在下文中一共展示了PathExistsException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processArguments
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
// if more than one arg, the destination must be a directory
// if one arg, the dst must not exist or must be a directory
if (args.size() > 1) {
if (!dst.exists) {
throw new PathNotFoundException(dst.toString());
}
if (!dst.stat.isDirectory()) {
throw new PathIsNotDirectoryException(dst.toString());
}
} else if (dst.exists) {
if (!dst.stat.isDirectory() && !overwrite) {
throw new PathExistsException(dst.toString());
}
} else if (!dst.parentExists()) {
throw new PathNotFoundException(dst.toString());
}
super.processArguments(args);
}
示例2: copyStreamToTarget
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
/**
* If direct write is disabled ,copies the stream contents to a temporary
* file "<target>._COPYING_". If the copy is
* successful, the temporary file will be renamed to the real path,
* else the temporary file will be deleted.
* if direct write is enabled , then creation temporary file is skipped.
* @param in the input stream for the copy
* @param target where to store the contents of the stream
* @throws IOException if copy fails
*/
protected void copyStreamToTarget(InputStream in, PathData target)
throws IOException {
if (target.exists && (target.stat.isDirectory() || !overwrite)) {
throw new PathExistsException(target.toString());
}
TargetFileSystem targetFs = new TargetFileSystem(target.fs);
try {
PathData tempTarget = direct ? target : target.suffix("._COPYING_");
targetFs.setWriteChecksum(writeChecksum);
targetFs.writeStreamToFile(in, tempTarget, lazyPersist, direct);
if (!direct) {
targetFs.rename(tempTarget, target);
}
} finally {
targetFs.close(); // last ditch effort to ensure temp file is removed
}
}
示例3: copyStreamToTarget
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
/**
* Copies the stream contents to a temporary file. If the copy is
* successful, the temporary file will be renamed to the real path,
* else the temporary file will be deleted.
* @param in the input stream for the copy
* @param target where to store the contents of the stream
* @throws IOException if copy fails
*/
protected void copyStreamToTarget(InputStream in, PathData target)
throws IOException {
if (target.exists && (target.stat.isDirectory() || !overwrite)) {
throw new PathExistsException(target.toString());
}
TargetFileSystem targetFs = new TargetFileSystem(target.fs);
try {
PathData tempTarget = target.suffix("._COPYING_");
targetFs.setWriteChecksum(writeChecksum);
targetFs.writeStreamToFile(in, tempTarget, lazyPersist);
targetFs.rename(tempTarget, target);
} finally {
targetFs.close(); // last ditch effort to ensure temp file is removed
}
}
示例4: copyStreamToTarget
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
/**
* Copies the stream contents to a temporary file. If the copy is
* successful, the temporary file will be renamed to the real path,
* else the temporary file will be deleted.
* @param in the input stream for the copy
* @param target where to store the contents of the stream
* @throws IOException if copy fails
*/
protected void copyStreamToTarget(InputStream in, PathData target)
throws IOException {
if (target.exists && (target.stat.isDirectory() || !overwrite)) {
throw new PathExistsException(target.toString());
}
TargetFileSystem targetFs = new TargetFileSystem(target.fs);
try {
PathData tempTarget = target.suffix("._COPYING_");
targetFs.setWriteChecksum(writeChecksum);
targetFs.writeStreamToFile(in, tempTarget);
targetFs.rename(tempTarget, target);
} finally {
targetFs.close(); // last ditch effort to ensure temp file is removed
}
}
示例5: processArguments
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
// if more than one arg, the destination must be a directory
// if one arg, the dst must not exist or must be a directory
if (args.size() > 1) {
if (!dst.exists) {
throw new PathNotFoundException(dst.toString());
}
if (!dst.stat.isDirectory()) {
throw new PathIsNotDirectoryException(dst.toString());
}
} else if (dst.exists) {
if (!dst.stat.isDirectory() && !overwrite) {
throw new PathExistsException(dst.toString());
}
} else if (!dst.parentExists()) {
throw new PathNotFoundException(dst.toString())
.withFullyQualifiedPath(dst.path.toUri().toString());
}
super.processArguments(args);
}
示例6: processPath
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
@Override
protected void processPath(PathData src, PathData target) throws IOException {
String srcUri = src.fs.getUri().getScheme() + "://" +
src.fs.getUri().getHost();
String dstUri = target.fs.getUri().getScheme() + "://" +
target.fs.getUri().getHost();
if (!srcUri.equals(dstUri)) {
throw new PathIOException(src.toString(),
"Does not match target filesystem");
}
if (target.exists) {
throw new PathExistsException(target.toString());
}
if (!target.fs.rename(src.path, target.path)) {
// we have no way to know the actual error...
throw new PathIOException(src.toString());
}
}
示例7: processPath
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
@Override
protected void processPath(PathData src, PathData target) throws IOException {
// unlike copy, don't merge existing dirs during move
if (target.exists && target.stat.isDirectory()) {
throw new PathExistsException(target.toString());
}
super.processPath(src, target);
}
示例8: processPath
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
@Override
protected void processPath(PathData item) throws IOException {
if (item.stat.isDirectory()) {
if (!createParents) {
throw new PathExistsException(item.toString());
}
} else {
throw new PathIsNotDirectoryException(item.toString());
}
}
示例9: cast
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
/**
* Cast IO exception to IGFS exception.
*
* @param msg Error message.
* @param e IO exception.
* @return IGFS exception.
*/
public static IgfsException cast(String msg, IOException e) {
if (e instanceof FileNotFoundException)
return new IgfsPathNotFoundException(e);
else if (e instanceof ParentNotDirectoryException)
return new IgfsParentNotDirectoryException(msg, e);
else if (e instanceof PathIsNotEmptyDirectoryException)
return new IgfsDirectoryNotEmptyException(e);
else if (e instanceof PathExistsException)
return new IgfsPathAlreadyExistsException(msg, e);
else
return new IgfsException(msg, e);
}
示例10: testCreateCheckOverwrite
import org.apache.hadoop.fs.PathExistsException; //导入依赖的package包/类
/** @throws Exception If failed. */
public void testCreateCheckOverwrite() throws Exception {
Path fsHome = new Path(primaryFsUri);
Path dir = new Path(fsHome, "/someDir1/someDir2/someDir3");
final Path file = new Path(dir, "someFile");
FSDataOutputStream out = fs.create(file, EnumSet.noneOf(CreateFlag.class),
Options.CreateOpts.perms(FsPermission.getDefault()));
out.close();
// Check intermediate directory permissions.
assertEquals(FsPermission.getDefault(), fs.getFileStatus(dir).getPermission());
assertEquals(FsPermission.getDefault(), fs.getFileStatus(dir.getParent()).getPermission());
assertEquals(FsPermission.getDefault(), fs.getFileStatus(dir.getParent().getParent()).getPermission());
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
return fs.create(file, EnumSet.noneOf(CreateFlag.class),
Options.CreateOpts.perms(FsPermission.getDefault()));
}
}, PathExistsException.class, null);
// Overwrite should be successful.
FSDataOutputStream out1 = fs.create(file, EnumSet.of(CreateFlag.OVERWRITE),
Options.CreateOpts.perms(FsPermission.getDefault()));
out1.close();
}