Java Code Examples for org.apache.hadoop.hdfs.server.common.Util#fileAsURI()

The following examples show how to use org.apache.hadoop.hdfs.server.common.Util#fileAsURI() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NNStorage.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Return the storage directory corresponding to the passed URI
 * @param uri URI of a storage directory
 * @return The matching storage directory or null if none found
 */
StorageDirectory getStorageDirectory(URI uri) {
  try {
    uri = Util.fileAsURI(new File(uri));
    Iterator<StorageDirectory> it = dirIterator();
    for (; it.hasNext(); ) {
      StorageDirectory sd = it.next();
      if (Util.fileAsURI(sd.getRoot()).equals(uri)) {
        return sd;
      }
    }
  } catch (IOException ioe) {
    LOG.warn("Error converting file to URI", ioe);
  }
  return null;
}
 
Example 2
Source File: NNStorage.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Return the storage directory corresponding to the passed URI
 * @param uri URI of a storage directory
 * @return The matching storage directory or null if none found
 */
StorageDirectory getStorageDirectory(URI uri) {
  try {
    uri = Util.fileAsURI(new File(uri));
    Iterator<StorageDirectory> it = dirIterator();
    for (; it.hasNext(); ) {
      StorageDirectory sd = it.next();
      if (Util.fileAsURI(sd.getRoot()).equals(uri)) {
        return sd;
      }
    }
  } catch (IOException ioe) {
    LOG.warn("Error converting file to URI", ioe);
  }
  return null;
}