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

项目: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    文件:CommandWithDestination.java   
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
  // if more than one arg, the destination must be a directory
  // if one arg, the dst must not exist or must be a directory
  if (args.size() > 1) {
    if (!dst.exists) {
      throw new PathNotFoundException(dst.toString());
    }
    if (!dst.stat.isDirectory()) {
      throw new PathIsNotDirectoryException(dst.toString());
    }
  } else if (dst.exists) {
    if (!dst.stat.isDirectory() && !overwrite) {
      throw new PathExistsException(dst.toString());
    }
  } else if (!dst.parentExists()) {
    throw new PathNotFoundException(dst.toString());
  }
  super.processArguments(args);
}
项目:Hydrograph    文件:LingualSchemaCreatorTest.java   
@AfterClass
public static void cleanUp() {
    System.gc();
    Configuration configuration = new Configuration();
    FileSystem fileSystem = null;

    try {
        fileSystem = FileSystem.get(configuration);
        Path deletingFilePath = new Path("testData/MetaData/");
        if (!fileSystem.exists(deletingFilePath)) {
            throw new PathNotFoundException(deletingFilePath.toString());
        } else {

            boolean isDeleted = fileSystem.delete(deletingFilePath, true);
            if (isDeleted) {
                fileSystem.deleteOnExit(deletingFilePath);
            }
        }
        fileSystem.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:hadoop    文件:RegistryPathUtils.java   
/**
 * Get the parent of a path
 * @param path path to look at
 * @return the parent path
 * @throws PathNotFoundException if the path was at root.
 */
public static String parentOf(String path) throws PathNotFoundException {
  List<String> elements = split(path);

  int size = elements.size();
  if (size == 0) {
    throw new PathNotFoundException("No parent of " + path);
  }
  if (size == 1) {
    return "/";
  }
  elements.remove(size - 1);
  StringBuilder parent = new StringBuilder(path.length());
  for (String element : elements) {
    parent.append("/");
    parent.append(element);
  }
  return parent.toString();
}
项目:hadoop    文件:RegistryUtils.java   
/**
 * List children of a directory and retrieve their
 * {@link RegistryPathStatus} values.
 * <p>
 * This is not an atomic operation; A child may be deleted
 * during the iteration through the child entries. If this happens,
 * the <code>PathNotFoundException</code> is caught and that child
 * entry ommitted.
 *
 * @param path path
 * @return a possibly empty map of child entries listed by
 * their short name.
 * @throws PathNotFoundException path is not in the registry.
 * @throws InvalidPathnameException the path is invalid.
 * @throws IOException Any other IO Exception
 */
public static Map<String, RegistryPathStatus> statChildren(
    RegistryOperations registryOperations,
    String path)
    throws PathNotFoundException,
    InvalidPathnameException,
    IOException {
  List<String> childNames = registryOperations.list(path);
  Map<String, RegistryPathStatus> results =
      new HashMap<String, RegistryPathStatus>();
  for (String childName : childNames) {
    String child = join(path, childName);
    try {
      RegistryPathStatus stat = registryOperations.stat(child);
      results.put(childName, stat);
    } catch (PathNotFoundException pnfe) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("stat failed on {}: moved? {}", child, pnfe, pnfe);
      }
      // and continue
    }
  }
  return results;
}
项目:hadoop    文件:CuratorService.java   
/**
 * Stat the file
 * @param path path of operation
 * @return a curator stat entry
 * @throws IOException on a failure
 * @throws PathNotFoundException if the path was not found
 */
public Stat zkStat(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  Stat stat;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Stat {}", fullpath);
    }
    stat = curator.checkExists().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (stat == null) {
    throw new PathNotFoundException(path);
  }
  return stat;
}
项目:hadoop    文件:CuratorService.java   
/**
 * Get the ACLs of a path
 * @param path path of operation
 * @return a possibly empty list of ACLs
 * @throws IOException
 */
public List<ACL> zkGetACLS(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  List<ACL> acls;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("GetACLS {}", fullpath);
    }
    acls = curator.getACL().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (acls == null) {
    throw new PathNotFoundException(path);
  }
  return acls;
}
项目:hadoop    文件:CommandWithDestination.java   
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
  // if more than one arg, the destination must be a directory
  // if one arg, the dst must not exist or must be a directory
  if (args.size() > 1) {
    if (!dst.exists) {
      throw new PathNotFoundException(dst.toString());
    }
    if (!dst.stat.isDirectory()) {
      throw new PathIsNotDirectoryException(dst.toString());
    }
  } else if (dst.exists) {
    if (!dst.stat.isDirectory() && !overwrite) {
      throw new PathExistsException(dst.toString());
    }
  } else if (!dst.parentExists()) {
    throw new PathNotFoundException(dst.toString());
  }
  super.processArguments(args);
}
项目:aliyun-oss-hadoop-fs    文件:RegistryPathUtils.java   
/**
 * Get the parent of a path
 * @param path path to look at
 * @return the parent path
 * @throws PathNotFoundException if the path was at root.
 */
public static String parentOf(String path) throws PathNotFoundException {
  List<String> elements = split(path);

  int size = elements.size();
  if (size == 0) {
    throw new PathNotFoundException("No parent of " + path);
  }
  if (size == 1) {
    return "/";
  }
  elements.remove(size - 1);
  StringBuilder parent = new StringBuilder(path.length());
  for (String element : elements) {
    parent.append("/");
    parent.append(element);
  }
  return parent.toString();
}
项目:aliyun-oss-hadoop-fs    文件:RegistryUtils.java   
/**
 * List children of a directory and retrieve their
 * {@link RegistryPathStatus} values.
 * <p>
 * This is not an atomic operation; A child may be deleted
 * during the iteration through the child entries. If this happens,
 * the <code>PathNotFoundException</code> is caught and that child
 * entry ommitted.
 *
 * @param path path
 * @return a possibly empty map of child entries listed by
 * their short name.
 * @throws PathNotFoundException path is not in the registry.
 * @throws InvalidPathnameException the path is invalid.
 * @throws IOException Any other IO Exception
 */
public static Map<String, RegistryPathStatus> statChildren(
    RegistryOperations registryOperations,
    String path)
    throws PathNotFoundException,
    InvalidPathnameException,
    IOException {
  List<String> childNames = registryOperations.list(path);
  Map<String, RegistryPathStatus> results =
      new HashMap<String, RegistryPathStatus>();
  for (String childName : childNames) {
    String child = join(path, childName);
    try {
      RegistryPathStatus stat = registryOperations.stat(child);
      results.put(childName, stat);
    } catch (PathNotFoundException pnfe) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("stat failed on {}: moved? {}", child, pnfe, pnfe);
      }
      // and continue
    }
  }
  return results;
}
项目:aliyun-oss-hadoop-fs    文件:CuratorService.java   
/**
 * Stat the file
 * @param path path of operation
 * @return a curator stat entry
 * @throws IOException on a failure
 * @throws PathNotFoundException if the path was not found
 */
public Stat zkStat(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  Stat stat;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Stat {}", fullpath);
    }
    stat = curator.checkExists().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (stat == null) {
    throw new PathNotFoundException(path);
  }
  return stat;
}
项目:aliyun-oss-hadoop-fs    文件:CuratorService.java   
/**
 * Get the ACLs of a path
 * @param path path of operation
 * @return a possibly empty list of ACLs
 * @throws IOException
 */
public List<ACL> zkGetACLS(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  List<ACL> acls;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("GetACLS {}", fullpath);
    }
    acls = curator.getACL().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (acls == null) {
    throw new PathNotFoundException(path);
  }
  return acls;
}
项目: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");
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:CommandWithDestination.java   
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
  // if more than one arg, the destination must be a directory
  // if one arg, the dst must not exist or must be a directory
  if (args.size() > 1) {
    if (!dst.exists) {
      throw new PathNotFoundException(dst.toString());
    }
    if (!dst.stat.isDirectory()) {
      throw new PathIsNotDirectoryException(dst.toString());
    }
  } else if (dst.exists) {
    if (!dst.stat.isDirectory() && !overwrite) {
      throw new PathExistsException(dst.toString());
    }
  } else if (!dst.parentExists()) {
    throw new PathNotFoundException(dst.toString());
  }
  super.processArguments(args);
}
项目:big-c    文件:RegistryPathUtils.java   
/**
 * Get the parent of a path
 * @param path path to look at
 * @return the parent path
 * @throws PathNotFoundException if the path was at root.
 */
public static String parentOf(String path) throws PathNotFoundException {
  List<String> elements = split(path);

  int size = elements.size();
  if (size == 0) {
    throw new PathNotFoundException("No parent of " + path);
  }
  if (size == 1) {
    return "/";
  }
  elements.remove(size - 1);
  StringBuilder parent = new StringBuilder(path.length());
  for (String element : elements) {
    parent.append("/");
    parent.append(element);
  }
  return parent.toString();
}
项目:big-c    文件:RegistryUtils.java   
/**
 * List children of a directory and retrieve their
 * {@link RegistryPathStatus} values.
 * <p>
 * This is not an atomic operation; A child may be deleted
 * during the iteration through the child entries. If this happens,
 * the <code>PathNotFoundException</code> is caught and that child
 * entry ommitted.
 *
 * @param path path
 * @return a possibly empty map of child entries listed by
 * their short name.
 * @throws PathNotFoundException path is not in the registry.
 * @throws InvalidPathnameException the path is invalid.
 * @throws IOException Any other IO Exception
 */
public static Map<String, RegistryPathStatus> statChildren(
    RegistryOperations registryOperations,
    String path)
    throws PathNotFoundException,
    InvalidPathnameException,
    IOException {
  List<String> childNames = registryOperations.list(path);
  Map<String, RegistryPathStatus> results =
      new HashMap<String, RegistryPathStatus>();
  for (String childName : childNames) {
    String child = join(path, childName);
    try {
      RegistryPathStatus stat = registryOperations.stat(child);
      results.put(childName, stat);
    } catch (PathNotFoundException pnfe) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("stat failed on {}: moved? {}", child, pnfe, pnfe);
      }
      // and continue
    }
  }
  return results;
}
项目:big-c    文件:CuratorService.java   
/**
 * Stat the file
 * @param path path of operation
 * @return a curator stat entry
 * @throws IOException on a failure
 * @throws PathNotFoundException if the path was not found
 */
public Stat zkStat(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  Stat stat;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Stat {}", fullpath);
    }
    stat = curator.checkExists().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (stat == null) {
    throw new PathNotFoundException(path);
  }
  return stat;
}
项目:big-c    文件:CuratorService.java   
/**
 * Get the ACLs of a path
 * @param path path of operation
 * @return a possibly empty list of ACLs
 * @throws IOException
 */
public List<ACL> zkGetACLS(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  List<ACL> acls;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("GetACLS {}", fullpath);
    }
    acls = curator.getACL().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (acls == null) {
    throw new PathNotFoundException(path);
  }
  return acls;
}
项目: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");
    }
  }
}
项目:big-c    文件:CommandWithDestination.java   
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
  // if more than one arg, the destination must be a directory
  // if one arg, the dst must not exist or must be a directory
  if (args.size() > 1) {
    if (!dst.exists) {
      throw new PathNotFoundException(dst.toString());
    }
    if (!dst.stat.isDirectory()) {
      throw new PathIsNotDirectoryException(dst.toString());
    }
  } else if (dst.exists) {
    if (!dst.stat.isDirectory() && !overwrite) {
      throw new PathExistsException(dst.toString());
    }
  } else if (!dst.parentExists()) {
    throw new PathNotFoundException(dst.toString());
  }
  super.processArguments(args);
}
项目:pravega    文件:HDFSExceptionHelpers.java   
/**
 * Translates HDFS specific Exceptions to Pravega-equivalent Exceptions and re-throws them as such.
 *
 * @param segmentName Name of the stream segment on which the exception occurs.
 * @param e           The exception to be translated.
 * @return Nothing. This method always throws.
 */
static <T> T throwException(String segmentName, Throwable e) throws StreamSegmentException {
    if (e instanceof RemoteException) {
        e = ((RemoteException) e).unwrapRemoteException();
    }

    if (e instanceof PathNotFoundException || e instanceof FileNotFoundException) {
        throw new StreamSegmentNotExistsException(segmentName, e);
    }

    if (e instanceof FileAlreadyExistsException) {
        throw new StreamSegmentExistsException(segmentName, e);
    }

    if (e instanceof AclException) {
        throw new StreamSegmentSealedException(segmentName, e);
    }

    throw Lombok.sneakyThrow(e);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:RegistryPathUtils.java   
/**
 * Get the parent of a path
 * @param path path to look at
 * @return the parent path
 * @throws PathNotFoundException if the path was at root.
 */
public static String parentOf(String path) throws PathNotFoundException {
  List<String> elements = split(path);

  int size = elements.size();
  if (size == 0) {
    throw new PathNotFoundException("No parent of " + path);
  }
  if (size == 1) {
    return "/";
  }
  elements.remove(size - 1);
  StringBuilder parent = new StringBuilder(path.length());
  for (String element : elements) {
    parent.append("/");
    parent.append(element);
  }
  return parent.toString();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:RegistryUtils.java   
/**
 * List children of a directory and retrieve their
 * {@link RegistryPathStatus} values.
 * <p>
 * This is not an atomic operation; A child may be deleted
 * during the iteration through the child entries. If this happens,
 * the <code>PathNotFoundException</code> is caught and that child
 * entry ommitted.
 *
 * @param path path
 * @return a possibly empty map of child entries listed by
 * their short name.
 * @throws PathNotFoundException path is not in the registry.
 * @throws InvalidPathnameException the path is invalid.
 * @throws IOException Any other IO Exception
 */
public static Map<String, RegistryPathStatus> statChildren(
    RegistryOperations registryOperations,
    String path)
    throws PathNotFoundException,
    InvalidPathnameException,
    IOException {
  List<String> childNames = registryOperations.list(path);
  Map<String, RegistryPathStatus> results =
      new HashMap<String, RegistryPathStatus>();
  for (String childName : childNames) {
    String child = join(path, childName);
    try {
      RegistryPathStatus stat = registryOperations.stat(child);
      results.put(childName, stat);
    } catch (PathNotFoundException pnfe) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("stat failed on {}: moved? {}", child, pnfe, pnfe);
      }
      // and continue
    }
  }
  return results;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:CuratorService.java   
/**
 * Stat the file
 * @param path path of operation
 * @return a curator stat entry
 * @throws IOException on a failure
 * @throws PathNotFoundException if the path was not found
 */
public Stat zkStat(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  Stat stat;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Stat {}", fullpath);
    }
    stat = curator.checkExists().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (stat == null) {
    throw new PathNotFoundException(path);
  }
  return stat;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:CuratorService.java   
/**
 * Get the ACLs of a path
 * @param path path of operation
 * @return a possibly empty list of ACLs
 * @throws IOException
 */
public List<ACL> zkGetACLS(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  List<ACL> acls;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("GetACLS {}", fullpath);
    }
    acls = curator.getACL().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (acls == null) {
    throw new PathNotFoundException(path);
  }
  return acls;
}
项目: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-2.6.0-cdh5.4.3    文件:CommandWithDestination.java   
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
  // if more than one arg, the destination must be a directory
  // if one arg, the dst must not exist or must be a directory
  if (args.size() > 1) {
    if (!dst.exists) {
      throw new PathNotFoundException(dst.toString());
    }
    if (!dst.stat.isDirectory()) {
      throw new PathIsNotDirectoryException(dst.toString());
    }
  } else if (dst.exists) {
    if (!dst.stat.isDirectory() && !overwrite) {
      throw new PathExistsException(dst.toString());
    }
  } else if (!dst.parentExists()) {
    throw new PathNotFoundException(dst.toString());
  }
  super.processArguments(args);
}
项目: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 processArguments(LinkedList<PathData> args)
throws IOException {
  // if more than one arg, the destination must be a directory
  // if one arg, the dst must not exist or must be a directory
  if (args.size() > 1) {
    if (!dst.exists) {
      throw new PathNotFoundException(dst.toString());
    }
    if (!dst.stat.isDirectory()) {
      throw new PathIsNotDirectoryException(dst.toString());
    }
  } else if (dst.exists) {
    if (!dst.stat.isDirectory() && !overwrite) {
      throw new PathExistsException(dst.toString());
    }
  } else if (!dst.parentExists()) {
    throw new PathNotFoundException(dst.toString());
  }
  super.processArguments(args);
}
项目:hops    文件:RegistryPathUtils.java   
/**
 * Get the parent of a path
 * @param path path to look at
 * @return the parent path
 * @throws PathNotFoundException if the path was at root.
 */
public static String parentOf(String path) throws PathNotFoundException {
  List<String> elements = split(path);

  int size = elements.size();
  if (size == 0) {
    throw new PathNotFoundException("No parent of " + path);
  }
  if (size == 1) {
    return "/";
  }
  elements.remove(size - 1);
  StringBuilder parent = new StringBuilder(path.length());
  for (String element : elements) {
    parent.append("/");
    parent.append(element);
  }
  return parent.toString();
}
项目:hops    文件:RegistryUtils.java   
/**
 * List children of a directory and retrieve their
 * {@link RegistryPathStatus} values.
 * <p>
 * This is not an atomic operation; A child may be deleted
 * during the iteration through the child entries. If this happens,
 * the <code>PathNotFoundException</code> is caught and that child
 * entry ommitted.
 *
 * @param path path
 * @return a possibly empty map of child entries listed by
 * their short name.
 * @throws PathNotFoundException path is not in the registry.
 * @throws InvalidPathnameException the path is invalid.
 * @throws IOException Any other IO Exception
 */
public static Map<String, RegistryPathStatus> statChildren(
    RegistryOperations registryOperations,
    String path)
    throws PathNotFoundException,
    InvalidPathnameException,
    IOException {
  List<String> childNames = registryOperations.list(path);
  Map<String, RegistryPathStatus> results =
      new HashMap<String, RegistryPathStatus>();
  for (String childName : childNames) {
    String child = join(path, childName);
    try {
      RegistryPathStatus stat = registryOperations.stat(child);
      results.put(childName, stat);
    } catch (PathNotFoundException pnfe) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("stat failed on {}: moved? {}", child, pnfe, pnfe);
      }
      // and continue
    }
  }
  return results;
}
项目:hops    文件:CuratorService.java   
/**
 * Stat the file
 * @param path path of operation
 * @return a curator stat entry
 * @throws IOException on a failure
 * @throws PathNotFoundException if the path was not found
 */
public Stat zkStat(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  Stat stat;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Stat {}", fullpath);
    }
    stat = curator.checkExists().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (stat == null) {
    throw new PathNotFoundException(path);
  }
  return stat;
}
项目:hops    文件:CuratorService.java   
/**
 * Get the ACLs of a path
 * @param path path of operation
 * @return a possibly empty list of ACLs
 * @throws IOException
 */
public List<ACL> zkGetACLS(String path) throws IOException {
  checkServiceLive();
  String fullpath = createFullPath(path);
  List<ACL> acls;
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("GetACLS {}", fullpath);
    }
    acls = curator.getACL().forPath(fullpath);
  } catch (Exception e) {
    throw operationFailure(fullpath, "read()", e);
  }
  if (acls == null) {
    throw new PathNotFoundException(path);
  }
  return acls;
}
项目: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    文件:CommandWithDestination.java   
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
  // if more than one arg, the destination must be a directory
  // if one arg, the dst must not exist or must be a directory
  if (args.size() > 1) {
    if (!dst.exists) {
      throw new PathNotFoundException(dst.toString());
    }
    if (!dst.stat.isDirectory()) {
      throw new PathIsNotDirectoryException(dst.toString());
    }
  } else if (dst.exists) {
    if (!dst.stat.isDirectory() && !overwrite) {
      throw new PathExistsException(dst.toString());
    }
  } else if (!dst.parentExists()) {
    throw new PathNotFoundException(dst.toString())
        .withFullyQualifiedPath(dst.path.toUri().toString());
  }
  super.processArguments(args);
}
项目: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 processArguments(LinkedList<PathData> args)
throws IOException {
  // if more than one arg, the destination must be a directory
  // if one arg, the dst must not exist or must be a directory
  if (args.size() > 1) {
    if (!dst.exists) {
      throw new PathNotFoundException(dst.toString());
    }
    if (!dst.stat.isDirectory()) {
      throw new PathIsNotDirectoryException(dst.toString());
    }
  } else if (dst.exists) {
    if (!dst.stat.isDirectory() && !overwrite) {
      throw new PathExistsException(dst.toString());
    }
  } else if (!dst.parentExists()) {
    throw new PathNotFoundException(dst.toString());
  }
  super.processArguments(args);
}
项目: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 processArguments(LinkedList<PathData> args)
throws IOException {
  // if more than one arg, the destination must be a directory
  // if one arg, the dst must not exist or must be a directory
  if (args.size() > 1) {
    if (!dst.exists) {
      throw new PathNotFoundException(dst.toString());
    }
    if (!dst.stat.isDirectory()) {
      throw new PathIsNotDirectoryException(dst.toString());
    }
  } else if (dst.exists) {
    if (!dst.stat.isDirectory() && !overwrite) {
      throw new PathExistsException(dst.toString());
    }
  } else if (!dst.parentExists()) {
    throw new PathNotFoundException(dst.toString());
  }
  super.processArguments(args);
}