use of org.apache.hadoop.fs.PathIOException in project hadoop by apache.
the class CommandWithDestination method processPathArgument.
@Override
protected void processPathArgument(PathData src) throws IOException {
if (src.stat.isDirectory() && src.fs.equals(dst.fs)) {
PathData target = getTargetPath(src);
String srcPath = src.fs.makeQualified(src.path).toString();
String dstPath = dst.fs.makeQualified(target.path).toString();
if (dstPath.equals(srcPath)) {
PathIOException e = new PathIOException(src.toString(), "are identical");
e.setTargetPath(dstPath.toString());
throw e;
}
// except for the root
if (!srcPath.endsWith(Path.SEPARATOR)) {
srcPath += Path.SEPARATOR;
}
if (dstPath.startsWith(srcPath)) {
PathIOException e = new PathIOException(src.toString(), "is a subdirectory of itself");
e.setTargetPath(target.toString());
throw e;
}
}
super.processPathArgument(src);
}
use of org.apache.hadoop.fs.PathIOException in project hadoop by apache.
the class CommandWithDestination method recursePath.
@Override
protected void recursePath(PathData src) throws IOException {
PathData savedDst = dst;
try {
// modify dst as we descend to append the basename of the
// current directory being processed
dst = getTargetPath(src);
final boolean preserveRawXattrs = checkPathsForReservedRaw(src.path, dst.path);
if (dst.exists) {
if (!dst.stat.isDirectory()) {
throw new PathIsNotDirectoryException(dst.toString());
}
} else {
if (!dst.fs.mkdirs(dst.path)) {
// too bad we have no clue what failed
PathIOException e = new PathIOException(dst.toString());
e.setOperation("mkdir");
throw e;
}
// need to update stat to know it exists now
dst.refreshStatus();
}
super.recursePath(src);
if (dst.stat.isDirectory()) {
preserveAttributes(src, dst, preserveRawXattrs);
}
} finally {
dst = savedDst;
}
}
use of org.apache.hadoop.fs.PathIOException in project hadoop by apache.
the class TestPathExceptions method testRemoteExceptionUnwrap.
@Test
public void testRemoteExceptionUnwrap() throws Exception {
PathIOException pe;
RemoteException re;
IOException ie;
pe = new PathIOException(path);
re = new RemoteException(PathIOException.class.getName(), "test constructor1");
ie = re.unwrapRemoteException();
assertTrue(ie instanceof PathIOException);
ie = re.unwrapRemoteException(PathIOException.class);
assertTrue(ie instanceof PathIOException);
pe = new PathIOException(path, "constructor2");
re = new RemoteException(PathIOException.class.getName(), "test constructor2");
ie = re.unwrapRemoteException();
assertTrue(ie instanceof PathIOException);
ie = re.unwrapRemoteException(PathIOException.class);
assertTrue(ie instanceof PathIOException);
}
use of org.apache.hadoop.fs.PathIOException in project hadoop by apache.
the class TestPathExceptions method testWithThrowable.
@Test
public void testWithThrowable() throws Exception {
IOException ioe = new IOException("KABOOM");
PathIOException pe = new PathIOException(path, ioe);
assertEquals(new Path(path), pe.getPath());
assertEquals("`" + path + "': Input/output error: " + error, pe.getMessage());
}
use of org.apache.hadoop.fs.PathIOException in project hadoop by apache.
the class TestPathExceptions method testWithDefaultString.
@Test
public void testWithDefaultString() throws Exception {
PathIOException pe = new PathIOException(path);
assertEquals(new Path(path), pe.getPath());
assertEquals("`" + path + "': Input/output error", pe.getMessage());
}
Aggregations