<commit_before>package com.twitter.heron.scheduler.util;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import com.twitter.heron.scheduler.api.Constants;
import com.twitter.heron.scheduler.api.IUploader;
import com.twitter.heron.scheduler.api.context.LaunchContext;

/**
 * A source-file parameterized shell copy utility.
 * 
 * For example:
 *   --config-property heron.uploader.copy.command="cp %s /devops/jobs/"
 * OR
 *   --config-property heron.uploader.copy.command="aws s3 cp %s s3://twitter.com/devops/jobs/"
 * OR
 *   --config-property ="curl -0 -v -X PUT --data-binary @%s https://artifactory.twitter.biz/libs-releases-local/com/twitter/devops/jobs/"
 */
public class CopyCommandUploader implements IUploader {
  private volatile LaunchContext context;

  @Override
  public void initialize(LaunchContext context) {
    this.context = context;
  }

  private String getUploaderCommand() {
    return context.getPropertyWithException(Constants.HERON_UPLOADER_COPY_COMMAND);
  }

  @Override
  public boolean uploadPackage(String topologyPackage) {
    String fileName = Paths.get(topologyPackage).getFileName().toString();
    String copyCommand = String.format(getUploaderCommand(), topologyPackage);
    return 0 == ShellUtility.runProcess(context.isVerbose(), copyCommand, null, null);
  }

  @Override
  public void undo() {
    // do nothing
  }
}<commit_msg>added comment<commit_after>package com.twitter.heron.scheduler.util;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import com.twitter.heron.scheduler.api.Constants;
import com.twitter.heron.scheduler.api.IUploader;
import com.twitter.heron.scheduler.api.context.LaunchContext;

/**
 * A source-file parameterized topology copy utility in use with heron-cli2.
 * 
 * For example:
 * 1. Copy the generated topology.tar.gz to path /devops/jobs/
 *
 *   --config-property heron.uploader.copy.command='\"cp %s /devops/jobs/\"''
 *
 * 2. Copy the generated topology.tar.gz to AWS S3 s3://twitter.com/devops/jobs/
 *
 *   --config-property heron.uploader.copy.command='\"aws s3 cp %s s3://twitter.com/devops/jobs/\"'
 *
 * 3. Use curl to upload the generated topology.tar.gz to twitter artifactory
 *
 *   --config-property heron.uploader.copy.command='\"curl -0 -v -X PUT --data-binary @%s https://artifactory.twitter.biz/libs-releases-local/com/twitter/devops/jobs/\"'
 */
public class CopyCommandUploader implements IUploader {
  private volatile LaunchContext context;

  @Override
  public void initialize(LaunchContext context) {
    this.context = context;
  }

  private String getUploaderCommand() {
    return context.getPropertyWithException(Constants.HERON_UPLOADER_COPY_COMMAND);
  }

  @Override
  public boolean uploadPackage(String topologyPackage) {
    String fileName = Paths.get(topologyPackage).getFileName().toString();
    String copyCommand = String.format(getUploaderCommand(), topologyPackage);
    return 0 == ShellUtility.runProcess(context.isVerbose(), copyCommand, null, null);
  }

  @Override
  public void undo() {
    // do nothing
  }
}
{'fraction_non_alphanumeric': 0.12584704743465633, 'fraction_numerical': 0.00451758631816715, 'mean_word_length': 4.115511551155116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6349653', 'n_tokens_mistral': 1001, 'n_tokens_neox': 961, 'n_words': 207}