當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。