예제 #1
0
  protected void addWriterOutputToExistingDir(
      Path writerOutputDir,
      Path publisherOutputDir,
      WorkUnitState workUnitState,
      int branchId,
      ParallelRunner parallelRunner)
      throws IOException {
    boolean preserveFileName =
        workUnitState.getPropAsBoolean(
            ForkOperatorUtils.getPropertyNameForBranch(
                ConfigurationKeys.SOURCE_FILEBASED_PRESERVE_FILE_NAME, this.numBranches, branchId),
            false);

    // Go through each file in writerOutputDir and move it into publisherOutputDir
    for (FileStatus status : this.fileSystemByBranches.get(branchId).listStatus(writerOutputDir)) {

      // Preserve the file name if configured, use specified name otherwise
      Path finalOutputPath =
          preserveFileName
              ? new Path(
                  publisherOutputDir,
                  workUnitState.getProp(
                      ForkOperatorUtils.getPropertyNameForBranch(
                          ConfigurationKeys.DATA_PUBLISHER_FINAL_NAME, this.numBranches, branchId)))
              : new Path(publisherOutputDir, status.getPath().getName());

      LOG.info(String.format("Moving %s to %s", status.getPath(), finalOutputPath));
      parallelRunner.renamePath(status.getPath(), finalOutputPath, Optional.<String>absent());
    }
  }