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


Java Path.isAbsolute方法代码示例

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


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

示例1: makeRelative

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
 * Make a path relative with respect to a root path.
 * absPath is always assumed to descend from root.
 * Otherwise returned path is null.
 */
static String makeRelative(Path root, Path absPath) {
  if (!absPath.isAbsolute()) {
    throw new IllegalArgumentException("!absPath.isAbsolute(), absPath="
        + absPath);
  }
  String p = absPath.toUri().getPath();

  StringTokenizer pathTokens = new StringTokenizer(p, "/");
  for(StringTokenizer rootTokens = new StringTokenizer(
      root.toUri().getPath(), "/"); rootTokens.hasMoreTokens(); ) {
    if (!rootTokens.nextToken().equals(pathTokens.nextToken())) {
      return null;
    }
  }
  StringBuilder sb = new StringBuilder();
  for(; pathTokens.hasMoreTokens(); ) {
    sb.append(pathTokens.nextToken());
    if (pathTokens.hasMoreTokens()) { sb.append(Path.SEPARATOR); }
  }
  return sb.length() == 0? ".": sb.toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:DistCpV1.java

示例2: parse

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
 * The parse method parses the command-line options and creates a corresponding Options object.
 *
 * @param args Command-line arguments
 * @return The Options object, corresponding to the specified command-line.
 * @throws IllegalArgumentException Thrown if the parse fails.
 */
public S3MapReduceCpOptions parse(String... args) throws IllegalArgumentException {
  try {
    jCommander.parse(args);
  } catch (Exception e) {
    throw new IllegalArgumentException("Unable to parse arguments: " + Arrays.toString(args), e);
  }

  if (options.isHelp()) {
    return options;
  }

  for (Path source : options.getSources()) {
    if (!source.isAbsolute()) {
      throw new IllegalArgumentException("Source paths must be absolute: " + Arrays.toString(args));
    }
  }

  if (!options.getTarget().isAbsolute()) {
    throw new IllegalArgumentException("Destination URI must be absolute: " + Arrays.toString(args));
  }

  if (options.getCredentialsProvider() != null && !options.getCredentialsProvider().isAbsolute()) {
    throw new IllegalArgumentException("Credentials provider URI must be absolute: " + Arrays.toString(args));
  }

  if (options.getMaxMaps() <= 0) {
    options.setMaxMaps(1);
  }

  if (options.getLogPath() != null && !options.getLogPath().isAbsolute()) {
    throw new IllegalArgumentException("Log path must be absolute: " + Arrays.toString(args));
  }

  return options;
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:43,代码来源:OptionsParser.java

示例3: symlink

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
public final void symlink(Path src, Path dst) throws IOException {
  if (!src.isAbsolute()) {
    throw new IOException("Source must be absolute");
  }
  if (dst.isAbsolute()) {
    throw new IOException("Destination must be relative");
  }
  if (dst.toUri().getPath().indexOf('/') != -1) {
    mkdir(dst.getParent());
  }
  link(src, dst);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:ContainerLaunch.java

示例4: makeAbsolute

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
 * Get the absolute version of the path (fully qualified).
 * This is public for testing purposes.
 *
 * @param path
 * @return fully qualified path
 */
@VisibleForTesting
public Path makeAbsolute(Path path) {
  if (path.isAbsolute()) {
    return path;
  }
  return new Path(workingDir, path);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:NativeAzureFileSystem.java

示例5: toAbsolutePath

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path toAbsolutePath(Path p) {
  if (p.isAbsolute()) {
    return p;
  }

  return new Path(workingDirectory, p);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:8,代码来源:PseudoDistributedFileSystem.java

示例6: makeAbsolute

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
 * Makes path absolute
 *
 * @param path path to file
 * @return absolute path
 */
protected Path makeAbsolute(Path path) {
  if (path.isAbsolute()) {
    return path;
  }
  return new Path(workingDir, path);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:SwiftNativeFileSystem.java

示例7: pathToKey

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private static String pathToKey(Path path) {
  if (path.toUri().getScheme() != null && path.toUri().getPath().isEmpty()) {
    // allow uris without trailing slash after bucket to refer to root,
    // like s3n://mybucket
    return "";
  }
  if (!path.isAbsolute()) {
    throw new IllegalArgumentException("Path must be absolute: " + path);
  }
  String ret = path.toUri().getPath().substring(1); // remove initial slash
  if (ret.endsWith("/") && (ret.indexOf("/") != ret.length() - 1)) {
    ret = ret.substring(0, ret.length() -1);
}
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:NativeS3FileSystem.java

示例8: normalize

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path normalize(Path path) {
  if (!path.isAbsolute()) {
    throw new IllegalArgumentException("Path must be absolute: " + path);
  }
  return new Path(path.toUri().getPath());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:InMemoryFileSystemStore.java

示例9: setWorkingDirectory

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
@Override
public void setWorkingDirectory(final Path new_dir) {
  workingDir = new_dir.isAbsolute() ? new_dir : new Path(workingDir, new_dir);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:ChRootedFileSystem.java

示例10: confChanged

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/** This method gets called everytime before any read/write to make sure
 * that any change to localDirs is reflected immediately.
 */
private synchronized void confChanged(Configuration conf) 
    throws IOException {
  String newLocalDirs = conf.get(contextCfgItemName);
  if (!newLocalDirs.equals(savedLocalDirs)) {
    localDirs = StringUtils.getTrimmedStrings(newLocalDirs);
    localFS = FileSystem.getLocal(conf);
    int numDirs = localDirs.length;
    ArrayList<String> dirs = new ArrayList<String>(numDirs);
    ArrayList<DF> dfList = new ArrayList<DF>(numDirs);
    for (int i = 0; i < numDirs; i++) {
      try {
        // filter problematic directories
        Path tmpDir = new Path(localDirs[i]);
        if(localFS.mkdirs(tmpDir)|| localFS.exists(tmpDir)) {
          try {

            File tmpFile = tmpDir.isAbsolute()
              ? new File(localFS.makeQualified(tmpDir).toUri())
              : new File(localDirs[i]);

            DiskChecker.checkDir(tmpFile);
            dirs.add(tmpFile.getPath());
            dfList.add(new DF(tmpFile, 30000));

          } catch (DiskErrorException de) {
            LOG.warn( localDirs[i] + " is not writable\n", de);
          }
        } else {
          LOG.warn( "Failed to create " + localDirs[i]);
        }
      } catch (IOException ie) { 
        LOG.warn( "Failed to create " + localDirs[i] + ": " +
            ie.getMessage() + "\n", ie);
      } //ignore
    }
    localDirs = dirs.toArray(new String[dirs.size()]);
    dirDF = dfList.toArray(new DF[dirs.size()]);
    savedLocalDirs = newLocalDirs;
    
    // randomize the first disk picked in the round-robin selection 
    dirNumLastAccessed = dirIndexRandomizer.nextInt(dirs.size());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:47,代码来源:LocalDirAllocator.java

示例11: makeAbsolute

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path makeAbsolute(final Path f) {
  return f.isAbsolute() ? f : new Path(workingDir, f);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:4,代码来源:ViewFileSystem.java

示例12: makeAbsolute

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path makeAbsolute(Path f) {
  return f.isAbsolute()? f: new Path(workingDir, f);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:4,代码来源:WebHdfsFileSystem.java

示例13: makeAbsolute

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path makeAbsolute(Path path) {
  if (path.isAbsolute()) {
    return path;
  }
  return new Path(workingDir, path);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:NativeS3FileSystem.java

示例14: pathToKey

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private String pathToKey(Path path) {
  if (!path.isAbsolute()) {
    throw new IllegalArgumentException("Path must be absolute: " + path);
  }
  return path.toUri().getPath();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:Jets3tFileSystemStore.java

示例15: pathToKey

import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private String pathToKey(Path path) {
  if (!path.isAbsolute()) {
    throw new IllegalArgumentException("Path must be absolute: " + path);
  }
  return urlEncode(path.toUri().getPath());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:MigrationTool.java


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