Search in sources :

Example 1 with PathIOException

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);
}
Also used : PathIOException(org.apache.hadoop.fs.PathIOException)

Example 2 with PathIOException

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;
    }
}
Also used : PathIOException(org.apache.hadoop.fs.PathIOException) PathIsNotDirectoryException(org.apache.hadoop.fs.PathIsNotDirectoryException)

Example 3 with PathIOException

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);
}
Also used : PathIOException(org.apache.hadoop.fs.PathIOException) IOException(java.io.IOException) PathIOException(org.apache.hadoop.fs.PathIOException) RemoteException(org.apache.hadoop.ipc.RemoteException) Test(org.junit.Test)

Example 4 with 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());
}
Also used : Path(org.apache.hadoop.fs.Path) PathIOException(org.apache.hadoop.fs.PathIOException) IOException(java.io.IOException) PathIOException(org.apache.hadoop.fs.PathIOException) Test(org.junit.Test)

Example 5 with PathIOException

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());
}
Also used : Path(org.apache.hadoop.fs.Path) PathIOException(org.apache.hadoop.fs.PathIOException) Test(org.junit.Test)

Aggregations

PathIOException (org.apache.hadoop.fs.PathIOException)6 Test (org.junit.Test)4 Path (org.apache.hadoop.fs.Path)3 IOException (java.io.IOException)2 PathIsNotDirectoryException (org.apache.hadoop.fs.PathIsNotDirectoryException)1 RemoteException (org.apache.hadoop.ipc.RemoteException)1