当前位置: 首页>>代码示例>>Java>>正文


Java PathIOException类代码示例

本文整理汇总了Java中org.apache.hadoop.fs.PathIOException的典型用法代码示例。如果您正苦于以下问题:Java PathIOException类的具体用法?Java PathIOException怎么用?Java PathIOException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PathIOException类属于org.apache.hadoop.fs包,在下文中一共展示了PathIOException类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRemoteDestination

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
/**
 *  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");
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:26,代码来源:CommandWithDestination.java

示例2: processPath

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:Delete.java

示例3: processPath

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:Delete.java

示例4: recursePath

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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;
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:26,代码来源:CommandWithDestination.java

示例5: processPath

import org.apache.hadoop.fs.PathIOException; //导入依赖的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());
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:19,代码来源:MoveCommands.java

示例6: processPath

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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);
  } 
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:SetReplication.java

示例7: recursePath

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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;
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:31,代码来源:CommandWithDestination.java

示例8: processPath

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:12,代码来源:Touch.java

示例9: postProcessPath

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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;
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:MoveCommands.java

示例10: processPath

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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());
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:MoveCommands.java

示例11: checkIfExists

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
/**
 * 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());
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:PathData.java

示例12: processNonexistentPath

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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());
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:13,代码来源:Mkdir.java

示例13: testWithThrowable

import org.apache.hadoop.fs.PathIOException; //导入依赖的package包/类
@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());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:8,代码来源:TestPathExceptions.java


注:本文中的org.apache.hadoop.fs.PathIOException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。