/** * Request the launching of an existing task definition. The name must be included in * the path. * * @param taskName the name of the existing task to be executed (required) * @param properties the runtime properties for the task, as a comma-delimited list of * key=value pairs * @param arguments the runtime commandline arguments * @return the taskExecutionId for the executed task */ @RequestMapping(value = "", method = RequestMethod.POST, params = "name") @ResponseStatus(HttpStatus.CREATED) public long launch(@RequestParam("name") String taskName, @RequestParam(required = false) String properties, @RequestParam(required = false) String arguments) { Map<String, String> propertiesToUse = DeploymentPropertiesUtils.parse(properties); DeploymentPropertiesUtils.validateDeploymentProperties(propertiesToUse); List<String> argumentsToUse = DeploymentPropertiesUtils.parseParamList(arguments, " "); return this.taskService.executeTask(taskName, propertiesToUse, argumentsToUse); }
/** * Parses a String comprised of 0 or more comma-delimited key=value pairs where each key * has the format: {@code app.[appname].[key]} or {@code deployer.[appname].[key]}. Values * may themselves contain commas, since the split points will be based upon the key * pattern. * <p> * Logic of parsing key/value pairs from a string is based on few rules and assumptions 1. * keys will not have commas or equals. 2. First raw split is done by commas which will * need to be fixed later if value is a comma-delimited list. * * @param s the string to parse * @return the Map of parsed key value pairs */ public static Map<String, String> parse(String s) { Map<String, String> deploymentProperties = new LinkedHashMap<>(); List<String> pairs = parseParamList(s, ","); // add what we got, addKeyValuePairAsProperty // handles rest as trimming, etc for (String pair : pairs) { addKeyValuePairAsProperty(pair, deploymentProperties); } return deploymentProperties; }
@Override public void schedule(String scheduleName, String taskDefinitionName, Map<String, String> taskProperties, List<String> commandLineArgs) { MultiValueMap<String, Object> values = new LinkedMultiValueMap<>(); values.add("scheduleName", scheduleName); values.add("properties", DeploymentPropertiesUtils.format(taskProperties)); values.add("taskDefinitionName", taskDefinitionName); values.add("arguments", commandLineArgs); restTemplate.postForObject(schedulesLink.getHref(), values, Long.class); }
/** * Request the launching of an existing task definition. The name must be included in the * path. * * @param taskName the name of the existing task to be executed (required) * @param properties the runtime properties for the task, as a comma-delimited list of * key=value pairs * @param arguments the runtime commandline arguments * @return the taskExecutionId for the executed task */ @RequestMapping(value = "", method = RequestMethod.POST, params = "name") @ResponseStatus(HttpStatus.CREATED) public long launch(@RequestParam("name") String taskName, @RequestParam(required = false) String properties, @RequestParam(required = false) String arguments) { Map<String, String> propertiesToUse = DeploymentPropertiesUtils.parse(properties); List<String> argumentsToUse = DeploymentPropertiesUtils.parseParamList(arguments, " "); return this.taskExecutionService.executeTask(taskName, propertiesToUse, argumentsToUse); }
/** * Create a schedule for an existing * {@link org.springframework.cloud.dataflow.core.TaskDefinition} name. * * @param scheduleName the name of the schedule being created. * @param taskDefinitionName the name of the existing task to be executed (required) * @param properties the runtime properties for the task, as a comma-delimited list of * key=value pairs * @param arguments the runtime commandline arguments */ @RequestMapping(value = "", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void save(@RequestParam("scheduleName") String scheduleName, @RequestParam("taskDefinitionName") String taskDefinitionName, @RequestParam String properties, @RequestParam(required = false) List<String> arguments) { Map<String, String> propertiesToUse = DeploymentPropertiesUtils.parse(properties); schedulerService.schedule(scheduleName, taskDefinitionName, propertiesToUse, arguments); }
DeploymentPropertiesUtils.validateDeploymentProperties(taskDeploymentProperties); .extractAndQualifyDeployerProperties(taskExecutionInformation.getTaskDeploymentProperties(), registeredAppName); if (StringUtils.hasText(this.dataflowServerUri) && taskExecutionInformation.isComposed()) {
@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); }
@Override public void doDeployStream(StreamDefinition streamDefinition, Map<String, String> deploymentProperties) { Map<String, String> deploymentPropertiesToUse = deploymentProperties.entrySet().stream() .filter(mapEntry -> !mapEntry.getKey().startsWith(SkipperStream.SKIPPER_KEY_PREFIX)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); List<AppDeploymentRequest> appDeploymentRequests = this.appDeploymentRequestCreator .createRequests(streamDefinition, deploymentPropertiesToUse); DeploymentPropertiesUtils.validateDeploymentProperties(deploymentPropertiesToUse); this.appDeployerStreamDeployer.deployStream(new StreamDeploymentRequest(streamDefinition.getName(), streamDefinition.getDslText(), appDeploymentRequests, new HashMap<>())); }
.extractAndQualifyDeployerProperties(updateProperties, currentApp.getName());
/** * Request deployment of an existing stream definition. * * @param name the name of an existing stream definition (required) * @param properties the deployment properties for the stream as a comma-delimited list of key=value pairs */ @RequestMapping(value = "/{name}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void deploy(@PathVariable("name") String name, @RequestParam(required = false) String properties) { StreamDefinition stream = this.repository.findOne(name); Assert.notNull(stream, String.format("no stream defined: %s", name)); deployStream(stream, DeploymentPropertiesUtils.parse(properties)); }
.extractAndQualifyDeployerProperties(taskDeploymentProperties, taskDefinition.getRegisteredAppName()); if (StringUtils.hasText(this.dataflowServerUri) && taskNode.isComposed()) { TaskServiceUtils.updateDataFlowUriIfNeeded(this.dataflowServerUri, appDeploymentProperties, commandLineArgs); DeploymentPropertiesUtils.validateDeploymentProperties(taskDeploymentProperties); taskDeploymentProperties = extractAndQualifySchedulerProperties(taskDeploymentProperties); ScheduleRequest scheduleRequest = new ScheduleRequest(revisedDefinition, taskDeploymentProperties,
@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); }
.extractAndQualifyDeployerProperties(updateProperties, currentApp.getName());
/** * Create a schedule for an existing * {@link org.springframework.cloud.dataflow.core.TaskDefinition} name. * * @param scheduleName the name of the schedule being created. * @param taskDefinitionName the name of the existing task to be executed (required) * @param properties the runtime properties for the task, as a comma-delimited list of * key=value pairs * @param arguments the runtime commandline arguments */ @RequestMapping(value = "", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void save(@RequestParam("scheduleName") String scheduleName, @RequestParam("taskDefinitionName") String taskDefinitionName, @RequestParam String properties, @RequestParam(required = false) List<String> arguments) { Map<String, String> propertiesToUse = DeploymentPropertiesUtils.parse(properties); schedulerService.schedule(scheduleName, taskDefinitionName, propertiesToUse, arguments); }
.extractAndQualifyDeployerProperties(taskDeploymentProperties, taskDefinition.getRegisteredAppName()); if (StringUtils.hasText(this.dataflowServerUri) && taskNode.isComposed()) { TaskServiceUtils.updateDataFlowUriIfNeeded(this.dataflowServerUri, appDeploymentProperties, commandLineArgs); DeploymentPropertiesUtils.validateDeploymentProperties(taskDeploymentProperties); taskDeploymentProperties = extractAndQualifySchedulerProperties(taskDeploymentProperties); ScheduleRequest scheduleRequest = new ScheduleRequest(revisedDefinition, taskDeploymentProperties,
/** * Parses a String comprised of 0 or more comma-delimited key=value pairs where each key * has the format: {@code app.[appname].[key]} or {@code deployer.[appname].[key]}. Values * may themselves contain commas, since the split points will be based upon the key * pattern. * <p> * Logic of parsing key/value pairs from a string is based on few rules and assumptions 1. * keys will not have commas or equals. 2. First raw split is done by commas which will * need to be fixed later if value is a comma-delimited list. * * @param s the string to parse * @return the Map of parsed key value pairs */ public static Map<String, String> parse(String s) { Map<String, String> deploymentProperties = new LinkedHashMap<>(); List<String> pairs = parseParamList(s, ","); // add what we got, addKeyValuePairAsProperty // handles rest as trimming, etc for (String pair : pairs) { addKeyValuePairAsProperty(pair, deploymentProperties); } return deploymentProperties; }
.extractAndQualifyDeployerProperties(streamDeploymentProperties, currentApp.getName()); deployerDeploymentProperties.put(AppDeployer.GROUP_PROPERTY_KEY, currentApp.getStreamName());
@Override public void schedule(String scheduleName, String taskDefinitionName, Map<String, String> taskProperties, List<String> commandLineArgs) { MultiValueMap<String, Object> values = new LinkedMultiValueMap<>(); values.add("scheduleName", scheduleName); values.add("properties", DeploymentPropertiesUtils.format(taskProperties)); values.add("taskDefinitionName", taskDefinitionName); values.add("arguments", commandLineArgs); restTemplate.postForObject(schedulesLink.getHref(), values, Long.class); }