コード例 #1
0
    @Override
    public void run() {

      String sourceUrl = "NOT YET DEFINED";
      String destUrl = "NOT YET DEFINED";
      try {
        sourceUrl = source.getURL().toString();
        destUrl = dest.getURL().toString();

        logger.debug("Copying files from " + source + " to " + dest);
        dest.copyFrom(source, fileSelector);
        logger.debug("Finished copying files from " + source + " to " + dest);

      } catch (FileSystemException e) {
        logger.error("An error occured while copying files from " + source + " to " + dest, e);
        if (jobId != null) {
          logger.info(
              "Job  "
                  + jobId
                  + " will be removed from the known job list. The system will not attempt again to retrieve data for this job. You could try to manually copy the data from the location  "
                  + sourceUrl);

          for (ISchedulerEventListenerExtended l : eventListeners) {
            l.pullDataFailed(jobId, sourceUrl, e);
          }
          removeAwaitedJob(jobId);
          return;
        }
      } // catch

      removeAwaitedJob(jobId);
      // delete source data
      String url = "NOT YET DEFINED";
      for (FileObject fo : foldersToDelete) {
        try {
          url = fo.getURL().toString();
          fo.delete(Selectors.SELECT_ALL);
          fo.delete();
        } catch (FileSystemException e) {
          logger.warn(
              "Could not delete temporary fioles at location "
                  + url
                  + " . although the copy of these files to "
                  + destUrl
                  + " has been successffully performed.");
        }
      }

      for (ISchedulerEventListenerExtended l : eventListeners) {
        l.pullDataFinished(jobId, destUrl);
      }
    }
コード例 #2
0
ファイル: Shell.java プロジェクト: penSecIT/commons-vfs
  /** Does a 'cp' command. */
  private void cp(final String[] cmd) throws Exception {
    if (cmd.length < 3) {
      throw new Exception("USAGE: cp <src> <dest>");
    }

    final FileObject src = mgr.resolveFile(cwd, cmd[1]);
    FileObject dest = mgr.resolveFile(cwd, cmd[2]);
    if (dest.exists() && dest.getType() == FileType.FOLDER) {
      dest = dest.resolveFile(src.getName().getBaseName());
    }

    dest.copyFrom(src, Selectors.SELECT_ALL);
  }
コード例 #3
0
  /**
   * @param job
   * @param inputFolder
   * @return
   * @throws FileSystemException
   */
  protected boolean pushData(Job job, String localInputFolderPath) throws FileSystemException {

    String push_URL = job.getGenericInformations().get(GENERIC_INFO_PUSH_URL_PROPERTY_NAME);

    if ((push_URL == null) || (push_URL.trim().equals(""))) {
      return false;
    } // push inputData

    // TODO - if the copy fails, try to remove the files from the remote
    // folder before throwing an exception
    FileObject remoteFolder = fsManager.resolveFile(push_URL);
    FileObject localfolder = fsManager.resolveFile(localInputFolderPath);
    logger.debug("Pushing files from " + localfolder + " to " + remoteFolder);

    // create the selector
    DSFileSelector fileSelector = new DSFileSelector();

    TaskFlowJob tfj = (TaskFlowJob) job;
    for (Task t : tfj.getTasks()) {
      List<InputSelector> inputFileSelectors = t.getInputFilesList();
      for (InputSelector is : inputFileSelectors) {
        org.ow2.proactive.scheduler.common.task.dataspaces.FileSelector fs = is.getInputFiles();
        if (fs.getIncludes() != null) fileSelector.addIncludes(Arrays.asList(fs.getIncludes()));

        if (fs.getExcludes() != null) fileSelector.addExcludes(Arrays.asList(fs.getExcludes()));
      }
    }

    // We need to check if a pattern exist in both includes and excludes.
    // This may happen if a task one defines, for instance "*.txt" as includes
    // and a task two defines "*.txt" as excludes. In this case we should remove it from the
    // fileSelector's excludes.

    Set<String> includes = fileSelector.getIncludes();
    Set<String> excludes = fileSelector.getExcludes();

    Set<String> intersection = new HashSet<String>(includes);
    intersection.retainAll(excludes);
    excludes.removeAll(intersection);
    fileSelector.setExcludes(excludes);

    remoteFolder.copyFrom(localfolder, fileSelector);

    logger.debug("Finished push operation from " + localfolder + " to " + remoteFolder);
    return true;
  }
コード例 #4
0
ファイル: CopyHandler.java プロジェクト: stain/moxo
 protected void copyOrMove(FileObject object, FileObject target, int depth)
     throws FileSystemException {
   target.copyFrom(object, new DepthFileSelector(depth));
 }