Package org.apache.hadoop.fs.shell.PathExceptions

Examples of org.apache.hadoop.fs.shell.PathExceptions.PathIOException


  protected String path = "some/file";
  protected String error = "KABOOM";

  @Test
  public void testWithDefaultString() throws Exception {
    PathIOException pe = new PathIOException(path);
    assertEquals(new Path(path), pe.getPath());
    assertEquals("`" + path + "': Input/output error", pe.getMessage());
  }
View Full Code Here


  }

  @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());
  }
View Full Code Here

    assertEquals("`" + path + "': Input/output error: " + error, pe.getMessage());
  }

  @Test
  public void testWithCustomString() throws Exception {
    PathIOException pe = new PathIOException(path, error);
    assertEquals(new Path(path), pe.getPath());
    assertEquals("`" + path + "': " + error, pe.getMessage());
  }
View Full Code Here

  }

  @Override
  protected void processNonexistentPath(PathData item) throws IOException {
    if (!item.fs.mkdirs(item.path)) {
      throw new PathIOException(item.toString());
    }
  }
View Full Code Here

          throw new PathNotFoundException(pathString);
        case 1:
          dst = items[0];
          break;
        default:
          throw new PathIOException(pathString, "Too many matches");
      }
    }
  }
View Full Code Here

    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;
      }
      if (dstPath.startsWith(srcPath+Path.SEPARATOR)) {
        PathIOException e = new PathIOException(src.toString(),
            "is a subdirectory of itself");
        e.setTargetPath(target.toString());
        throw e;
      }
    }
    super.processPathArgument(src);
  }
View Full Code Here

          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;
        }   
        dst.refreshStatus(); // need to update stat to know it exists now
      }     
      super.recursePath(src);
View Full Code Here

      FSDataOutputStream out = target.fs.create(tempFile.path, true);
      IOUtils.copyBytes(in, out, getConf(), true);
      // the rename method with an option to delete the target is deprecated
      if (target.exists && !target.fs.delete(target.path, false)) {
        // too bad we don't know why it failed
        PathIOException e = new PathIOException(target.toString());
        e.setOperation("delete");
        throw e;
      }
      if (!tempFile.fs.rename(tempFile.path, target.path)) {
        // too bad we don't know why it failed
        PathIOException e = new PathIOException(tempFile.toString());
        e.setOperation("rename");
        e.setTargetPath(target.toString());
        throw e;
      }
      tempFile = null;
    } finally {
      if (tempFile != null) {
View Full Code Here

      if (item.stat.isDirectory()) {
        // TODO: handle this
        throw new PathIsDirectoryException(item.toString());
      }
      if (item.stat.getLen() != 0) {
        throw new PathIOException(item.toString(), "Not a zero-length file");
      }
      touchz(item);
    }
View Full Code Here

    }

    @Override
    protected void processPath(PathData src, PathData target) throws IOException {
      if (!src.fs.getUri().equals(target.fs.getUri())) {
        throw new PathIOException(src.toString(),
            "Does not match target filesystem");
      }
      if (!target.fs.rename(src.path, target.path)) {
        // we have no way to know the actual error...
        throw new PathIOException(src.toString());
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.fs.shell.PathExceptions.PathIOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.