Пример #1
0
 //
 // If the destination is a subdirectory of the source, then
 // generate exception
 //
 private static void checkDependencies(FileSystem srcFS, Path src, FileSystem dstFS, Path dst)
     throws IOException {
   if (srcFS == dstFS) {
     String srcq = src.makeQualified(srcFS).toString() + Path.SEPARATOR;
     String dstq = dst.makeQualified(dstFS).toString() + Path.SEPARATOR;
     if (dstq.startsWith(srcq)) {
       if (srcq.length() == dstq.length()) {
         throw new IOException("Cannot copy " + src + " to itself.");
       } else {
         throw new IOException("Cannot copy " + src + " to its subdirectory " + dst);
       }
     }
   }
 }
Пример #2
0
  /**
   * Add an file path to the current set of classpath entries It adds the file to cache as well.
   *
   * @param file Path of the file to be added
   * @param conf Configuration that contains the classpath setting
   */
  public static void addFileToClassPath(Path file, Configuration conf) throws IOException {
    String classpath = conf.get("mapred.job.classpath.files");
    conf.set(
        "mapred.job.classpath.files",
        classpath == null
            ? file.toString()
            : classpath + System.getProperty("path.separator") + file.toString());
    URI uri = file.makeQualified(file.getFileSystem(conf)).toUri();

    addCacheFile(uri, conf);
  }
Пример #3
0
  private static URI addArchiveToClassPathHelper(Path archive, Configuration conf)
      throws IOException {

    String classpath = conf.get("mapred.job.classpath.archives");

    // the scheme/authority use ':' as separator. put the unqualified path in classpath
    String archivePath = archive.toUri().getPath();

    conf.set(
        "mapred.job.classpath.archives",
        classpath == null
            ? archivePath
            : classpath + System.getProperty("path.separator") + archivePath);
    return archive.makeQualified(archive.getFileSystem(conf)).toUri();
  }