/**
   * 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
 @Override
 protected ModuleRegistrationResource instantiateResource(ArtifactRegistration registration) {
   return new ModuleRegistrationResource(
       registration.getName(),
       registration.getType().name(),
       registration.getCoordinates().toString());
 }
コード例 #3
0
  /**
   * Retrieve detailed information about a particular module.
   *
   * @param type module type
   * @param name module name
   * @return detailed module information
   */
  @RequestMapping(value = "/{type}/{name}", method = RequestMethod.GET)
  @ResponseStatus(HttpStatus.OK)
  public DetailedModuleRegistrationResource info(
      @PathVariable("type") ArtifactType type, @PathVariable("name") String name) {
    Assert.isTrue(type != ArtifactType.library, "Only modules are supported by this endpoint");
    ArtifactRegistration registration = registry.find(name, type);
    if (registration == null) {
      return null;
    }
    DetailedModuleRegistrationResource result =
        new DetailedModuleRegistrationResource(moduleAssembler.toResource(registration));
    Resource resource = moduleResolver.resolve(adapt(registration.getCoordinates()));

    List<ConfigurationMetadataProperty> properties =
        moduleConfigurationMetadataResolver.listProperties(resource);
    for (ConfigurationMetadataProperty property : properties) {
      result.addOption(property);
    }
    return result;
  }
コード例 #4
0
 @Override
 public ModuleRegistrationResource toResource(ArtifactRegistration registration) {
   return createResourceWithId(
       String.format("%s/%s", registration.getType(), registration.getName()), registration);
 }