Java 类org.apache.hadoop.fs.PathIOException 实例源码

项目:hadoop-oss    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:hadoop    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:hadoop-oss    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item) || !canBeSafelyDeleted(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:hadoop    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:aliyun-oss-hadoop-fs    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item) || !canBeSafelyDeleted(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:aliyun-oss-hadoop-fs    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:big-c    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:big-c    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:hadoop-plus    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:hadoop-plus    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:hadoop-plus    文件:CommandWithDestination.java   
@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);
    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;
      }    
      dst.refreshStatus(); // need to update stat to know it exists now
    }      
    super.recursePath(src);
  } finally {
    dst = savedDst;
  }
}
项目:PDHC    文件:TrueDelete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:hops    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item) || !canBeSafelyDeleted(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:hops    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:hops    文件:MoveCommands.java   
@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());
  }
}
项目:hadoop-TCP    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:hadoop-TCP    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:hadoop-TCP    文件:CommandWithDestination.java   
@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);
    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;
      }    
      dst.refreshStatus(); // need to update stat to know it exists now
    }      
    super.recursePath(src);
  } finally {
    dst = savedDst;
  }
}
项目:hardfs    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:hardfs    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:hardfs    文件:CommandWithDestination.java   
@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);
    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;
      }    
      dst.refreshStatus(); // need to update stat to know it exists now
    }      
    super.recursePath(src);
  } finally {
    dst = savedDst;
  }
}
项目:hadoop-on-lustre2    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isDirectory() && !deleteDirs) {
    throw new PathIsDirectoryException(item.toString());
  }

  // TODO: if the user wants the trash to be used but there is any
  // problem (ie. creating the trash dir, moving the item to be deleted,
  // etc), then the path will just be deleted because moveToTrash returns
  // false and it falls thru to fs.delete.  this doesn't seem right
  if (moveToTrash(item)) {
    return;
  }
  if (!item.fs.delete(item.path, deleteDirs)) {
    throw new PathIOException(item.toString());
  }
  out.println("Deleted " + item);
}
项目:hadoop-on-lustre2    文件:CommandWithDestination.java   
/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
项目:hadoop-on-lustre2    文件:CommandWithDestination.java   
@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);
    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;
      }    
      dst.refreshStatus(); // need to update stat to know it exists now
    }      
    super.recursePath(src);
  } finally {
    dst = savedDst;
  }
}
项目:hadoop-oss    文件:SetReplication.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isSymlink()) {
    throw new PathIOException(item.toString(), "Symlinks unsupported");
  }

  if (item.stat.isFile()) {
    if (!item.fs.setReplication(item.path, newRep)) {
      throw new IOException("Could not set replication for: " + item);
    }
    out.println("Replication " + newRep + " set: " + item);
    if (waitOpt) waitList.add(item);
  } 
}
项目:hadoop-oss    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (!item.stat.isDirectory()) {
    throw new PathIsNotDirectoryException(item.toString());
  }      
  if (item.fs.listStatus(item.path).length == 0) {
    if (!item.fs.delete(item.path, false)) {
      throw new PathIOException(item.toString());
    }
  } else if (!ignoreNonEmpty) {
    throw new PathIsNotEmptyDirectoryException(item.toString());
  }
}
项目:hadoop-oss    文件:CommandWithDestination.java   
@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;
      }    
      dst.refreshStatus(); // need to update stat to know it exists now
    }      
    super.recursePath(src);
    if (dst.stat.isDirectory()) {
      preserveAttributes(src, dst, preserveRawXattrs);
    }
  } finally {
    dst = savedDst;
  }
}
项目:hadoop-oss    文件:Touch.java   
@Override
protected void processPath(PathData item) throws IOException {
  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);
}
项目:hadoop-oss    文件:MoveCommands.java   
@Override
protected void postProcessPath(PathData src) throws IOException {
  if (!src.fs.delete(src.path, false)) {
    // we have no way to know the actual error...
    PathIOException e = new PathIOException(src.toString());
    e.setOperation("remove");
    throw e;
  }
}
项目:hadoop-oss    文件:MoveCommands.java   
@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.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());
  }
}
项目:hadoop-oss    文件:PathData.java   
/**
 * Ensure that the file exists and if it is or is not a directory
 * @param typeRequirement Set it to the desired requirement.
 * @throws PathIOException if file doesn't exist or the type does not match
 * what was specified in typeRequirement.
 */
private void checkIfExists(FileTypeRequirement typeRequirement) 
throws PathIOException {
  if (!exists) {
    throw new PathNotFoundException(toString());      
  }

  if ((typeRequirement == FileTypeRequirement.SHOULD_BE_DIRECTORY)
     && !stat.isDirectory()) {
    throw new PathIsNotDirectoryException(toString());
  } else if ((typeRequirement == FileTypeRequirement.SHOULD_NOT_BE_DIRECTORY)
            && stat.isDirectory()) {
    throw new PathIsDirectoryException(toString());
  }
}
项目:hadoop-oss    文件:Mkdir.java   
@Override
protected void processNonexistentPath(PathData item) throws IOException {
  // check if parent exists. this is complicated because getParent(a/b/c/) returns a/b/c, but
  // we want a/b
  if (!createParents &&
      !item.fs.exists(new Path(item.path.toString()).getParent())) {
    throw new PathNotFoundException(item.toString());
  }
  if (!item.fs.mkdirs(item.path)) {
    throw new PathIOException(item.toString());
  }
}
项目:hadoop-oss    文件:TestPathExceptions.java   
@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());
}
项目:hadoop    文件:SetReplication.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (item.stat.isSymlink()) {
    throw new PathIOException(item.toString(), "Symlinks unsupported");
  }

  if (item.stat.isFile()) {
    if (!item.fs.setReplication(item.path, newRep)) {
      throw new IOException("Could not set replication for: " + item);
    }
    out.println("Replication " + newRep + " set: " + item);
    if (waitOpt) waitList.add(item);
  } 
}
项目:hadoop    文件:Delete.java   
@Override
protected void processPath(PathData item) throws IOException {
  if (!item.stat.isDirectory()) {
    throw new PathIsNotDirectoryException(item.toString());
  }      
  if (item.fs.listStatus(item.path).length == 0) {
    if (!item.fs.delete(item.path, false)) {
      throw new PathIOException(item.toString());
    }
  } else if (!ignoreNonEmpty) {
    throw new PathIsNotEmptyDirectoryException(item.toString());
  }
}
项目:hadoop    文件:CommandWithDestination.java   
@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;
      }    
      dst.refreshStatus(); // need to update stat to know it exists now
    }      
    super.recursePath(src);
    if (dst.stat.isDirectory()) {
      preserveAttributes(src, dst, preserveRawXattrs);
    }
  } finally {
    dst = savedDst;
  }
}
项目:hadoop    文件:Touchz.java   
@Override
protected void processPath(PathData item) throws IOException {
  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);
}
项目:hadoop    文件:MoveCommands.java   
@Override
protected void postProcessPath(PathData src) throws IOException {
  if (!src.fs.delete(src.path, false)) {
    // we have no way to know the actual error...
    PathIOException e = new PathIOException(src.toString());
    e.setOperation("remove");
    throw e;
  }
}