Package eu.stratosphere.core.fs

Examples of eu.stratosphere.core.fs.Path


    if (exists(f) && !overwrite) {
      throw new IOException("File already exists:" + f);
    }

    final Path parent = f.getParent();
    if (parent != null && !mkdirs(parent)) {
      throw new IOException("Mkdirs failed to create " + parent.toString());
    }

    final File file = pathToFile(f);
    return new LocalDataOutputStream(file);
  }
View Full Code Here


  public void setCopyTasks(Map<String, FutureTask<Path>> cpTasks) {
      this.cacheCopyTasks = cpTasks;
  }

  public File getFile(String name) {
    Path tmp = null;
    //The FutureTask.get() method will block until the file is ready.
    try {
      tmp = cacheCopyTasks.get(name).get();
    } catch (Exception  e) {
      throw new RuntimeException("Error while getting file from distributed cache", e);
    }
    return new File(tmp.toString());
  }
View Full Code Here

  private JobGraph getJobGraph(OptimizedPlan optPlan, List<File> jarFiles) {
    NepheleJobGraphGenerator gen = new NepheleJobGraphGenerator();
    JobGraph job = gen.compileJobGraph(optPlan);
   
    for (File jar : jarFiles) {
      job.addJar(new Path(jar.getAbsolutePath()));
    }
   
    return job;
  }
View Full Code Here

   
    DataOutputStream dos = new DataOutputStream(new FileOutputStream(tempFile));
    dos.writeBytes(content);
    dos.close();
     
    return new FileInputSplit(0, new Path(this.tempFile.toURI().toString()), 0, this.tempFile.length(), new String[] {"localhost"});
  }
View Full Code Here

   
    // TODO The job-submission web interface passes empty args (and thus empty
    // paths) to compute the preview graph. The following is a workaround for
    // this situation and we should fix this.
    if (filePath.isEmpty()) {
      setFilePath(new Path());
      return;
    }
   
    setFilePath(new Path(filePath));
  }
View Full Code Here

  public void configure(Configuration parameters) {
    // get the file path
    String filePath = parameters.getString(FILE_PARAMETER_KEY, null);
    if (filePath != null) {
      try {
        this.filePath = new Path(filePath);
      }
      catch (RuntimeException rex) {
        throw new RuntimeException("Could not create a valid URI from the given file path name: " + rex.getMessage());
      }
    }
View Full Code Here

   
    final FileBaseStatistics cachedFileStats = (cachedStats != null && cachedStats instanceof FileBaseStatistics) ?
      (FileBaseStatistics) cachedStats : null;
       
    try {
      final Path path = this.filePath;
      final FileSystem fs = FileSystem.get(path.toUri());
     
      return getFileStats(cachedFileStats, path, fs, new ArrayList<FileStatus>(1));
    } catch (IOException ioex) {
      if (LOG.isWarnEnabled()) {
        LOG.warn("Could not determine statistics for file '" + this.filePath + "' due to an io error: "
View Full Code Here

    }
   
    // take the desired number of splits into account
    minNumSplits = Math.max(minNumSplits, this.numSplits);
   
    final Path path = this.filePath;
    final List<FileInputSplit> inputSplits = new ArrayList<FileInputSplit>(minNumSplits);

    // get all the files that are involved in the splits
    List<FileStatus> files = new ArrayList<FileStatus>();
    long totalLength = 0;

    final FileSystem fs = path.getFileSystem();
    final FileStatus pathFile = fs.getFileStatus(path);

    if(!acceptFile(pathFile)) {
      throw new IOException("The given file does not pass the file-filter");
    }
View Full Code Here

        throw new IllegalArgumentException("The output path has been specified neither via constructor/setters" +
            ", nor via the Configuration.");
      }
     
      try {
        this.outputFilePath = new Path(filePath);
      }
      catch (RuntimeException rex) {
        throw new RuntimeException("Could not create a valid URI from the given file path name: " + rex.getMessage());
      }
    }
View Full Code Here

    @Override
    public void run() {

      try {
        Path p = this.path;
        final FileSystem fs = p.getFileSystem();

        // initialize output path.
        if(this.numTasks == 1 && outDirMode == OutputDirectoryMode.PARONLY) {
          // output is not written in parallel and should go to a single file
         
          if(!fs.isDistributedFS()) {
            // prepare local output path
            // checks for write mode and removes existing files in case of OVERWRITE mode
            if(!fs.initOutPathLocalFS(p, writeMode, false)) {
              // output preparation failed! Cancel task.
              throw new IOException("Output path could not be initialized. Canceling task.");
            }
          }
         
        } else if(this.numTasks > 1 || outDirMode == OutputDirectoryMode.ALWAYS) {
          // output is written in parallel into a directory or should always be written to a directory
         
          if(!fs.isDistributedFS()) {
            // File system is not distributed.
            // We need to prepare the output path on each executing node.
            if(!fs.initOutPathLocalFS(p, writeMode, true)) {
              // output preparation failed! Cancel task.
              throw new IOException("Output directory could not be created. Canceling task.");
            }
          }
         
          // Suffix the path with the parallel instance index
          p = p.suffix("/" + this.taskIndex);
         
        } else {
          // invalid number of subtasks (<= 0)
          throw new IllegalArgumentException("Invalid number of subtasks. Canceling task.");
        }
View Full Code Here

TOP

Related Classes of eu.stratosphere.core.fs.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.