private long launchTask(LaunchRequest request) { log.info(String.format("Launching Task %s", request.getTaskName())); return taskOperations.launch(request.getTaskName(), request.getDeploymentProperties(), request.getCommandlineArguments()); }
@CliCommand(value = LAUNCH, help = "Launch a previously created task") public String launch( @CliOption(key = { "", "name" }, help = "the name of the task to launch", mandatory = true, optionContext = "existing-task disable-string-converter") String name, @CliOption(key = { PROPERTIES_OPTION }, help = "the properties for this launch") String properties, @CliOption(key = { PROPERTIES_FILE_OPTION }, help = "the properties for this launch (as a File)") File propertiesFile, @CliOption(key = { ARGUMENTS_OPTION }, help = "the commandline arguments for this launch") String arguments, @CliOption(key = { PLATFORM_NAME}, help = "the platform name to use for this launch", unspecifiedDefaultValue = "default") String platformName) throws IOException { int which = Assertions.atMostOneOf(PROPERTIES_OPTION, properties, PROPERTIES_FILE_OPTION, propertiesFile); Map<String, String> propertiesToUse = DeploymentPropertiesUtils.parseDeploymentProperties(properties, propertiesFile, which); List<String> argumentsToUse = new ArrayList<String>(); if (StringUtils.hasText(arguments)) { argumentsToUse.add(arguments); } DeploymentPropertiesUtils.validateDeploymentProperties(propertiesToUse); if (StringUtils.hasText(platformName)) { propertiesToUse.put("spring.cloud.dataflow.task.platformName", platformName); } taskOperations().launch(name, propertiesToUse, argumentsToUse); return String.format("Launched task '%s'", name); }
@CliCommand(value = LAUNCH, help = "Launch a previously created task") public String launch( @CliOption(key = { "", "name" }, help = "the name of the task to launch", mandatory = true, optionContext = "existing-task disable-string-converter") String name, @CliOption(key = { PROPERTIES_OPTION }, help = "the properties for this launch", mandatory = false) String properties, @CliOption(key = { PROPERTIES_FILE_OPTION }, help = "the properties for this launch (as a File)", mandatory = false) File propertiesFile, @CliOption(key = { ARGUMENTS_OPTION }, help = "the commandline arguments for this launch", mandatory = false) String arguments) throws IOException { int which = Assertions.atMostOneOf(PROPERTIES_OPTION, properties, PROPERTIES_FILE_OPTION, propertiesFile); Map<String, String> propertiesToUse = DeploymentPropertiesUtils.parseDeploymentProperties(properties, propertiesFile, which); List<String> argumentsToUse = new ArrayList<String>(); if (StringUtils.hasText(arguments)) { argumentsToUse.add(arguments); } DeploymentPropertiesUtils.validateDeploymentProperties(propertiesToUse); taskOperations().launch(name, propertiesToUse, argumentsToUse); return String.format("Launched task '%s'", name); }
/** * Executes the task as specified by the taskName with the associated * properties and arguments. * @param contribution mutable state to be passed back to update the current step execution * @param chunkContext contains the task-execution-id used by the listener. * @return Repeat status of FINISHED. */ @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { String tmpTaskName = this.taskName.substring(0, this.taskName.lastIndexOf('_')); List<String> args = this.arguments; ExecutionContext stepExecutionContext = chunkContext.getStepContext().getStepExecution(). getExecutionContext(); if(stepExecutionContext.containsKey("task-arguments")) { args = (List<String>) stepExecutionContext.get("task-arguments"); } long executionId = this.taskOperations.launch(tmpTaskName, this.properties, args); stepExecutionContext.put("task-execution-id", executionId); stepExecutionContext.put("task-arguments", args); waitForTaskToComplete(executionId); return RepeatStatus.FINISHED; }