/**
   * Request the launching of an existing task definition. The name must be included in the path.
   *
   * @param name 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
   */
  @RequestMapping(value = "/{name}", method = RequestMethod.POST)
  @ResponseStatus(HttpStatus.CREATED)
  public void deploy(
      @PathVariable("name") String name, @RequestParam(required = false) String properties) {
    TaskDefinition taskDefinition = this.repository.findOne(name);
    if (taskDefinition == null) {
      throw new NoSuchTaskDefinitionException(name);
    }

    ModuleDefinition module = taskDefinition.getModuleDefinition();
    ArtifactRegistration registration = this.registry.find(module.getName(), ArtifactType.task);
    if (registration == null) {
      throw new IllegalArgumentException(
          String.format(
              "Module %s of type %s not found in registry", module.getName(), ArtifactType.task));
    }
    ArtifactCoordinates coordinates = registration.getCoordinates();

    Map<String, String> deploymentProperties = new HashMap<>();
    module = updateTaskProperties(module, module.getName());
    deploymentProperties.putAll(DeploymentPropertiesUtils.parse(properties));
    deploymentProperties.put(
        ModuleDeployer.GROUP_DEPLOYMENT_ID,
        taskDefinition.getName() + "-" + System.currentTimeMillis());

    this.moduleDeployer.deploy(
        new ModuleDeploymentRequest(module, coordinates, deploymentProperties));
  }
コード例 #2
0
 /**
  * Create a new builder that is initialized with properties of the given definition. Useful for
  * "mutating" a definition by building a slightly different copy.
  */
 public static Builder from(ModuleDefinition definition) {
   Builder builder = new Builder();
   builder
       .setGroup(definition.getGroup())
       .setLabel(definition.getLabel())
       .setName(definition.getName())
       .addParameters(definition.getParameters());
   return builder;
 }