org.apache.hadoop.fs.Path.makeQualified()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(282)

本文整理了Java中org.apache.hadoop.fs.Path.makeQualified()方法的一些代码示例,展示了Path.makeQualified()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.makeQualified()方法的具体详情如下:
包路径:org.apache.hadoop.fs.Path
类名称:Path
方法名:makeQualified

Path.makeQualified介绍

[英]Returns a qualified path object.
[中]返回一个限定路径对象。

代码示例

代码示例来源:origin: apache/hbase

/**
 * Gets the qualified root dir of the mob files.
 * @param conf The current configuration.
 * @return The qualified root dir.
 * @throws IOException
 */
public static Path getQualifiedMobRootDir(Configuration conf) throws IOException {
 Path hbaseDir = new Path(conf.get(HConstants.HBASE_DIR));
 Path mobRootDir = new Path(hbaseDir, MobConstants.MOB_DIR_NAME);
 FileSystem fs = mobRootDir.getFileSystem(conf);
 return mobRootDir.makeQualified(fs.getUri(), fs.getWorkingDirectory());
}

代码示例来源:origin: apache/hbase

/**
 * @param c configuration
 * @return {@link Path} to hbase root directory from
 *     configuration as a qualified Path.
 * @throws IOException e
 */
public static Path getRootDir(final Configuration c) throws IOException {
 Path p = new Path(c.get(HConstants.HBASE_DIR));
 FileSystem fs = p.getFileSystem(c);
 return p.makeQualified(fs.getUri(), fs.getWorkingDirectory());
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public Path getHomeDirectory() {
  Path path = new Path("/user/" + user);
  return path.makeQualified(getUri(), null);
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public Path getInitialWorkingDirectory() {
  File f = new File(System.getProperty("user.dir"));
  return new Path(f.getAbsoluteFile().toURI()).makeQualified(getUri(), null);
}

代码示例来源:origin: apache/hive

/**
 * Shamelessly cloned from GenericOptionsParser.
 */
public static String realFile(String newFile, Configuration conf) throws IOException {
 Path path = new Path(newFile);
 URI pathURI = path.toUri();
 FileSystem fs;
 if (pathURI.getScheme() == null) {
  fs = FileSystem.getLocal(conf);
 } else {
  fs = path.getFileSystem(conf);
 }
 if (!fs.exists(path)) {
  return null;
 }
 String file = path.makeQualified(fs).toString();
 return file;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/** 
 * Return the current user's home directory in this file system.
 * The default implementation returns "/user/$USER/".
 * 
 * @return current user's home directory.
 */
public Path getHomeDirectory() {
 return new Path("/user/"+System.getProperty("user.name")).makeQualified(
                               getUri(), null);
}

代码示例来源:origin: apache/drill

/**
 * Shamelessly cloned from GenericOptionsParser.
 */
public static String realFile(String newFile, Configuration conf) throws IOException {
 Path path = new Path(newFile);
 URI pathURI = path.toUri();
 FileSystem fs;
 if (pathURI.getScheme() == null) {
  fs = FileSystem.getLocal(conf);
 } else {
  fs = path.getFileSystem(conf);
 }
 if (!fs.exists(path)) {
  return null;
 }
 String file = path.makeQualified(fs).toString();
 return file;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

DeprecatedRawLocalFileStatus(File f, long defaultBlockSize, FileSystem fs)
 throws IOException {
 super(f.length(), f.isDirectory(), 1, defaultBlockSize,
   f.lastModified(), getLastAccessTime(f),
   null, null, null,
   new Path(f.getPath()).makeQualified(fs.getUri(),
    fs.getWorkingDirectory()));
}

代码示例来源:origin: apache/hbase

/**
 * Return Qualified Path of the specified family/file
 *
 * @param familyName Column Family Name
 * @param fileName File Name
 * @return The qualified Path for the specified family/file
 */
Path getStoreFilePath(final String familyName, final String fileName) {
 Path familyDir = getStoreDir(familyName);
 return new Path(familyDir, fileName).makeQualified(fs.getUri(), fs.getWorkingDirectory());
}

代码示例来源:origin: apache/hbase

/**
 * @param c configuration
 * @return {@link Path} to hbase log root directory: e.g. {@value HBASE_WAL_DIR} from
 *     configuration as a qualified Path. Defaults to HBase root dir.
 * @throws IOException e
 */
public static Path getWALRootDir(final Configuration c) throws IOException {
 Path p = new Path(c.get(HBASE_WAL_DIR, c.get(HConstants.HBASE_DIR)));
 if (!isValidWALRootDir(p, c)) {
  return getRootDir(c);
 }
 FileSystem fs = p.getFileSystem(c);
 return p.makeQualified(fs.getUri(), fs.getWorkingDirectory());
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

public Stat(Path path, long blockSize, boolean deref, FileSystem fs)
  throws IOException {
 super(0L, true);
 // Original path
 this.original = path;
 // Qualify the original and strip out URI fragment via toUri().getPath()
 Path stripped = new Path(
   original.makeQualified(fs.getUri(), fs.getWorkingDirectory())
   .toUri().getPath());
 // Re-qualify the bare stripped path and store it
 this.qualified = 
   stripped.makeQualified(fs.getUri(), fs.getWorkingDirectory());
 // Strip back down to a plain path
 this.path = new Path(qualified.toUri().getPath());
 this.blockSize = blockSize;
 this.dereference = deref;
 // LANG = C setting
 Map<String, String> env = new HashMap<String, String>();
 env.put("LANG", "C");
 setEnvironment(env);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public FileStatus getFileStatus(final Path f) throws IOException {
 checkPathIsSlash(f);
 return new FileStatus(0, true, 0, 0, creationTime, creationTime,
   PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
   new Path(theInternalDir.fullPath).makeQualified(
     myUri, null));
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public FileStatus getFileStatus(Path f) throws IOException {
 checkPathIsSlash(f);
 return new FileStatus(0, true, 0, 0, creationTime, creationTime,
   PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
   new Path(theInternalDir.fullPath).makeQualified(
     myUri, ROOT_PATH));
}

代码示例来源:origin: apache/hive

return path.makeQualified(FileSystem.get(conf));
return new Path(scheme, authority, pathUri.getPath());

代码示例来源:origin: apache/hbase

/**
 * Finds the Jar for a class or creates it if it doesn't exist. If the class is in
 * a directory in the classpath, it creates a Jar on the fly with the
 * contents of the directory and returns the path to that Jar. If a Jar is
 * created, it is created in the system temporary directory. Otherwise,
 * returns an existing jar that contains a class of the same name. Maintains
 * a mapping from jar contents to the tmp jar created.
 * @param my_class the class to find.
 * @param fs the FileSystem with which to qualify the returned path.
 * @param packagedClasses a map of class name to path.
 * @return a jar file that contains the class.
 * @throws IOException
 */
private static Path findOrCreateJar(Class<?> my_class, FileSystem fs,
  Map<String, String> packagedClasses)
throws IOException {
 // attempt to locate an existing jar for the class.
 String jar = findContainingJar(my_class, packagedClasses);
 if (null == jar || jar.isEmpty()) {
  jar = getJar(my_class);
  updateMap(jar, packagedClasses);
 }
 if (null == jar || jar.isEmpty()) {
  return null;
 }
 LOG.debug(String.format("For class %s, using jar %s", my_class.getName(), jar));
 return new Path(jar).makeQualified(fs.getUri(), fs.getWorkingDirectory());
}

代码示例来源:origin: apache/hive

return new Path(jar).makeQualified(fs);

代码示例来源:origin: apache/hive

return path.makeQualified(fs.getUri(), fs.getWorkingDirectory());
return new Path(scheme, authority, pathUri.getPath());

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public FileStatus getFileLinkStatus(final Path f)
  throws IOException {
 // look up i internalDirs children - ignore first Slash
 INode<AbstractFileSystem> inode =
   theInternalDir.getChildren().get(f.toUri().toString().substring(1));
 if (inode == null) {
  throw new FileNotFoundException(
    "viewFs internal mount table - missing entry:" + f);
 }
 FileStatus result;
 if (inode.isLink()) {
  INodeLink<AbstractFileSystem> inodelink = 
   (INodeLink<AbstractFileSystem>) inode;
  result = new FileStatus(0, false, 0, 0, creationTime, creationTime,
    PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
    inodelink.getTargetLink(),
    new Path(inode.fullPath).makeQualified(
      myUri, null));
 } else {
  result = new FileStatus(0, true, 0, 0, creationTime, creationTime,
   PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
   new Path(inode.fullPath).makeQualified(
     myUri, null));
 }
 return result;
}

代码示例来源:origin: apache/hive

public static Path hadoopFsPath(String fname, final Configuration conf, String user)
 throws URISyntaxException, IOException, InterruptedException {
 if (fname == null || conf == null) {
  return null;
 }
 UserGroupInformation ugi;
 if (user!=null) {
  ugi = UgiFactory.getUgi(user);
 } else {
  ugi = UserGroupInformation.getLoginUser();
 }
 final String finalFName = new String(fname);
 final FileSystem defaultFs =
   ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
    @Override
    public FileSystem run()
     throws URISyntaxException, IOException, InterruptedException {
     return FileSystem.get(new URI(finalFName), conf);
    }
   });
 fname = addUserHomeDirectoryIfApplicable(fname, user);
 URI u = new URI(fname);
 Path p = new Path(u).makeQualified(defaultFs);
 if (hadoopFsIsMissing(defaultFs, p))
  throw new FileNotFoundException("File " + fname + " does not exist.");
 FileSystem.closeAllForUGI(ugi);
 return p;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public FileStatus[] listStatus(Path f) throws AccessControlException,
  FileNotFoundException, IOException {
 checkPathIsSlash(f);
 FileStatus[] result = new FileStatus[theInternalDir.getChildren().size()];
 int i = 0;
 for (Entry<String, INode<FileSystem>> iEntry :
   theInternalDir.getChildren().entrySet()) {
  INode<FileSystem> inode = iEntry.getValue();
  if (inode.isLink()) {
   INodeLink<FileSystem> link = (INodeLink<FileSystem>) inode;
   result[i++] = new FileStatus(0, false, 0, 0,
    creationTime, creationTime, PERMISSION_555,
    ugi.getShortUserName(), ugi.getPrimaryGroupName(),
    link.getTargetLink(),
    new Path(inode.fullPath).makeQualified(
      myUri, null));
  } else {
   result[i++] = new FileStatus(0, true, 0, 0,
    creationTime, creationTime, PERMISSION_555,
    ugi.getShortUserName(), ugi.getGroupNames()[0],
    new Path(inode.fullPath).makeQualified(
      myUri, null));
  }
 }
 return result;
}

相关文章