Example #1
0
 @Override
 public void undeployAll() {
   // TODO: we should revisit here to check on instance repository
   for (JobDefinition definition : getDefinitionRepository().findAll()) {
     undeploy(definition.getName());
   }
 }
Example #2
0
  public void deploy(
      String name,
      String jobParameters,
      String dateFormat,
      String numberFormat,
      Boolean makeUnique) {
    Assert.hasText(name, "name cannot be blank or null");
    JobDefinition definition = getDefinitionRepository().findOne(name);
    if (definition == null) {
      throwNoSuchDefinitionException(name);
    }
    List<ModuleDeploymentRequest> requests = parse(name, definition.getDefinition());
    // If the job definition has trigger then, check if the trigger exists
    // TODO: should we do this at the parser?
    // but currently the parser has reference to StreamDefinitionRepository only.
    if (requests != null
        && requests.get(0).getParameters().containsKey(ModuleType.TRIGGER.getTypeName())) {
      String triggerName = requests.get(0).getParameters().get(ModuleType.TRIGGER.getTypeName());
      if (triggerDefinitionRepository.findOne(triggerName) == null) {
        throwNoSuchDefinitionException(triggerName, ModuleType.TRIGGER.getTypeName());
      }
    }

    for (ModuleDeploymentRequest request : requests) {
      if ("job".equals(request.getType())) {
        if (jobParameters != null) {
          request.setParameter("jobParameters", jobParameters);
        }
        if (dateFormat != null) {
          request.setParameter("dateFormat", dateFormat);
        }
        if (numberFormat != null) {
          request.setParameter("numberFormat", numberFormat);
        }
        if (makeUnique != null) {
          request.setParameter("makeUnique", String.valueOf(makeUnique));
        }
      }
    }

    try {
      sendDeploymentRequests(name, requests);
    } catch (MessageHandlingException mhe) {
      Throwable cause = mhe.getCause();
      if (cause == null) {
        throw mhe;
      }
      String exceptionClassName = cause.getClass().getName();
      if (exceptionClassName.equals(BEAN_CREATION_EXCEPTION)
          || exceptionClassName.equals(BEAN_DEFINITION_EXEPTION)) {
        throw new MissingRequiredDefinitionException(definition.getName(), cause.getMessage());
      } else {
        throw mhe;
      }
    }
  }
Example #3
0
 @Override
 public void undeploy(String name) {
   JobDefinition job = getDefinitionRepository().findOne(name);
   if (job == null) {
     throwNoSuchDefinitionException(name);
   }
   List<ModuleDeploymentRequest> requests = parse(name, job.getDefinition());
   for (ModuleDeploymentRequest request : requests) {
     request.setRemove(true);
   }
   try {
     sendDeploymentRequests(name, requests);
   } catch (MessageHandlingException ex) {
     // Job is not deployed.
   }
 }