當前位置: 首頁>>代碼示例>>Java>>正文


Java Path.SEPARATOR_CHAR屬性代碼示例

本文整理匯總了Java中org.apache.hadoop.fs.Path.SEPARATOR_CHAR屬性的典型用法代碼示例。如果您正苦於以下問題:Java Path.SEPARATOR_CHAR屬性的具體用法?Java Path.SEPARATOR_CHAR怎麽用?Java Path.SEPARATOR_CHAR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.hadoop.fs.Path的用法示例。


在下文中一共展示了Path.SEPARATOR_CHAR屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findLongestDirPrefix

private static int findLongestDirPrefix(String cwd, String path, boolean isDir) {
  // add the path separator to dirs to simplify finding the longest match
  if (!cwd.endsWith(Path.SEPARATOR)) {
    cwd += Path.SEPARATOR;
  }
  if (isDir && !path.endsWith(Path.SEPARATOR)) {
    path += Path.SEPARATOR;
  }

  // find longest directory prefix 
  int len = Math.min(cwd.length(), path.length());
  int lastSep = -1;
  for (int i=0; i < len; i++) {
    if (cwd.charAt(i) != path.charAt(i)) break;
    if (cwd.charAt(i) == Path.SEPARATOR_CHAR) lastSep = i;
  }
  return lastSep;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:18,代碼來源:PathData.java

示例2: getRelativePathName

/**
 * Get the relative path name with respect to the root of the volume.
 * @param absolutePathName The absolute path name
 * @param volume Root of the volume.
 * @return null if the absolute path name is outside of the volume.
 */
private String getRelativePathName(String absolutePathName,
    String volume) {
  
  absolutePathName = normalizePath(absolutePathName);
  // Get the file names
  if (!absolutePathName.startsWith(volume)) {
    return null;
  }
  // Get rid of the volume prefix
  String fileName = absolutePathName.substring(volume.length());
  if (fileName.charAt(0) == Path.SEPARATOR_CHAR) {
    fileName = fileName.substring(1);
  }
  return fileName;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:MRAsyncDiskService.java

示例3: findLeaseWithPrefixPath

static private Map<String, Lease> findLeaseWithPrefixPath(
    String prefix, SortedMap<String, Lease> path2lease) {
  if (LOG.isDebugEnabled()) {
    LOG.debug(LeaseManager.class.getSimpleName() + ".findLease: prefix=" + prefix);
  }

  final Map<String, Lease> entries = new HashMap<String, Lease>();
  int srclen = prefix.length();
  
  // prefix may ended with '/'
  if (prefix.charAt(srclen - 1) == Path.SEPARATOR_CHAR) {
    srclen -= 1;
  }

  for(Map.Entry<String, Lease> entry : path2lease.tailMap(prefix).entrySet()) {
    final String p = entry.getKey();
    if (!p.startsWith(prefix)) {
      return entries;
    }
    if (p.length() == srclen || p.charAt(srclen) == Path.SEPARATOR_CHAR) {
      entries.put(entry.getKey(), entry.getValue());
    }
  }
  return entries;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:LeaseManager.java

示例4: validateDestination

private static void validateDestination(
    String src, String dst, INode srcInode)
    throws IOException {
  String error;
  if (srcInode.isSymlink() &&
      dst.equals(srcInode.asSymlink().getSymlinkString())) {
    throw new FileAlreadyExistsException("Cannot rename symlink " + src
        + " to its target " + dst);
  }
  // dst cannot be a directory or a file under src
  if (dst.startsWith(src)
      && dst.charAt(src.length()) == Path.SEPARATOR_CHAR) {
    error = "Rename destination " + dst
        + " is a directory or file under source " + src;
    NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: "
        + error);
    throw new IOException(error);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:FSDirRenameOp.java

示例5: testMRAsyncDiskServiceStartupCleaning

/**
 * This test creates some directories inside the toBeDeleted directory and
 * then start the asyncDiskService.
 * AsyncDiskService will create tasks to delete the content inside the
 * toBeDeleted directories.
 */
@Test
public void testMRAsyncDiskServiceStartupCleaning() throws Throwable {
  FileSystem localFileSystem = FileSystem.getLocal(new Configuration());
  String[] vols = new String[]{TEST_ROOT_DIR + "/0",
      TEST_ROOT_DIR + "/1"};

  String a = "a";
  String b = "b";
  String c = "b/c";
  String d = "d";
  
  // Create directories inside SUBDIR
  String suffix = Path.SEPARATOR_CHAR + MRAsyncDiskService.TOBEDELETED;
  File fa = new File(vols[0] + suffix, a);
  File fb = new File(vols[1] + suffix, b);
  File fc = new File(vols[1] + suffix, c);
  File fd = new File(vols[1] + suffix, d);
  
  // Create the directories
  fa.mkdirs();
  fb.mkdirs();
  fc.mkdirs();
  fd.mkdirs();

  assertTrue(fa.exists());
  assertTrue(fb.exists());
  assertTrue(fc.exists());
  assertTrue(fd.exists());
  
  // Create the asyncDiskService which will delete all contents inside SUBDIR
  MRAsyncDiskService service = new MRAsyncDiskService(
      localFileSystem, vols);
  
  // Make sure everything is cleaned up
  makeSureCleanedUp(vols, service);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:42,代碼來源:TestMRAsyncDiskService.java

示例6: getSnapshotPath

public static String getSnapshotPath(String snapshottableDir,
    String snapshotRelativePath) {
  final StringBuilder b = new StringBuilder(snapshottableDir);
  if (b.charAt(b.length() - 1) != Path.SEPARATOR_CHAR) {
    b.append(Path.SEPARATOR);
  }
  return b.append(HdfsConstants.DOT_SNAPSHOT_DIR)
      .append(Path.SEPARATOR)
      .append(snapshotRelativePath)
      .toString();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:11,代碼來源:Snapshot.java

示例7: getPathElements

@VisibleForTesting
String[] getPathElements(String path) {
  path = path.trim();
  if (path.charAt(0) != Path.SEPARATOR_CHAR) {
    throw new IllegalArgumentException("It must be an absolute path: " +
        path);
  }
  int numOfElements = StringUtils.countMatches(path, Path.SEPARATOR);
  if (path.length() > 1 && path.endsWith(Path.SEPARATOR)) {
    numOfElements--;
  }
  String[] pathElements = new String[numOfElements];
  int elementIdx = 0;
  int idx = 0;
  int found = path.indexOf(Path.SEPARATOR_CHAR, idx);
  while (found > -1) {
    if (found > idx) {
      pathElements[elementIdx++] = path.substring(idx, found);
    }
    idx = found + 1;
    found = path.indexOf(Path.SEPARATOR_CHAR, idx);
  }
  if (idx < path.length()) {
    pathElements[elementIdx] = path.substring(idx);
  }
  return pathElements;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:27,代碼來源:INodeAttributeProvider.java

示例8: isAncestorPath

static private boolean isAncestorPath(Path xp, Path yp) {
  final String x = xp.toString();
  final String y = yp.toString();
  if (!y.startsWith(x)) {
    return false;
  }
  final int len = x.length();
  return y.length() == len || y.charAt(len) == Path.SEPARATOR_CHAR;  
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:9,代碼來源:DistCpV1.java

示例9: getCacheEntryFilePath

private String getCacheEntryFilePath(String checksum, String filename) {
  return SharedCacheUtil.getCacheEntryPath(this.cacheDepth,
      this.cacheRoot, checksum) + Path.SEPARATOR_CHAR + filename;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:4,代碼來源:ClientProtocolService.java

示例10: moveAndDeleteRelativePath

/**
 * Move the path name on one volume to a temporary location and then 
 * delete them.
 * 
 * This functions returns when the moves are done, but not necessarily all
 * deletions are done. This is usually good enough because applications 
 * won't see the path name under the old name anyway after the move. 
 * 
 * @param volume       The disk volume
 * @param pathName     The path name relative to volume root.
 * @throws IOException If the move failed 
 * @return   false     if the file is not found
 */
public boolean moveAndDeleteRelativePath(String volume, String pathName)
    throws IOException {
  
  volume = normalizePath(volume);
  
  // Move the file right now, so that it can be deleted later
  String newPathName = 
      format.format(new Date()) + "_" + uniqueId.getAndIncrement();
  newPathName = TOBEDELETED + Path.SEPARATOR_CHAR + newPathName;
  
  Path source = new Path(volume, pathName);
  Path target = new Path(volume, newPathName);
  try {
    if (!localFileSystem.rename(source, target)) {
      // If the source does not exists, return false.
      // This is necessary because rename can return false if the source  
      // does not exists.
      if (!localFileSystem.exists(source)) {
        return false;
      }
      // Try to recreate the parent directory just in case it gets deleted.
      if (!localFileSystem.mkdirs(new Path(volume, TOBEDELETED))) {
        throw new IOException("Cannot create " + TOBEDELETED + " under "
            + volume);
      }
      // Try rename again. If it fails, return false.
      if (!localFileSystem.rename(source, target)) {
        throw new IOException("Cannot rename " + source + " to "
            + target);
      }
    }
  } catch (FileNotFoundException e) {
    // Return false in case that the file is not found.  
    return false;
  }

  DeleteTask task = new DeleteTask(volume, pathName, newPathName);
  execute(volume, task);
  return true;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:53,代碼來源:MRAsyncDiskService.java


注:本文中的org.apache.hadoop.fs.Path.SEPARATOR_CHAR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。