private static void bindRetryProperties(
      final Retry processRetry, final Properties extensionProperties) {
    final PolicyType defaultRetryPolicy = PolicyType.PERIODIC;
    final int defaultRetryAttempts = 3;
    final Frequency defaultRetryDelay = new Frequency("minutes(30)");

    String retryPolicy =
        extensionProperties.getProperty(ExtensionProperties.RETRY_POLICY.getName());
    if (StringUtils.isNotBlank(retryPolicy)) {
      processRetry.setPolicy(PolicyType.fromValue(retryPolicy));
    } else {
      processRetry.setPolicy(defaultRetryPolicy);
    }

    String retryAttempts =
        extensionProperties.getProperty(ExtensionProperties.RETRY_ATTEMPTS.getName());
    if (StringUtils.isNotBlank(retryAttempts)) {
      processRetry.setAttempts(Integer.parseInt(retryAttempts));
    } else {
      processRetry.setAttempts(defaultRetryAttempts);
    }

    String retryDelay = extensionProperties.getProperty(ExtensionProperties.RETRY_DELAY.getName());
    if (StringUtils.isNotBlank(retryDelay)) {
      processRetry.setDelay(Frequency.fromString(retryDelay));
    } else {
      processRetry.setDelay(defaultRetryDelay);
    }

    String retryOnTimeout =
        extensionProperties.getProperty(ExtensionProperties.RETRY_ON_TIMEOUT.getName());
    if (StringUtils.isNotBlank(retryOnTimeout)) {
      processRetry.setOnTimeout(Boolean.valueOf(retryOnTimeout));
    } else {
      processRetry.setOnTimeout(false);
    }
  }
Esempio n. 2
0
 public String marshal(Frequency value) {
   return (org.apache.falcon.entity.v0.Frequency.toString(value));
 }
Esempio n. 3
0
 public Frequency unmarshal(String value) {
   return (org.apache.falcon.entity.v0.Frequency.fromString(value));
 }
  private static org.apache.falcon.entity.v0.process.Process bindAttributesInTemplate(
      final String processTemplate,
      final Properties extensionProperties,
      final String extensionName,
      final String wfPath,
      final String wfLibPath)
      throws FalconException {
    if (StringUtils.isBlank(processTemplate) || extensionProperties == null) {
      throw new FalconException("Process template or properties cannot be null");
    }

    org.apache.falcon.entity.v0.process.Process process;
    try {
      Unmarshaller unmarshaller = EntityType.PROCESS.getUnmarshaller();
      // Validation can be skipped for unmarshalling as we want to bind template with the
      // properties.
      // Vaildation is handled as part of marshalling
      unmarshaller.setSchema(null);
      unmarshaller.setEventHandler(
          new ValidationEventHandler() {
            public boolean handleEvent(ValidationEvent validationEvent) {
              return true;
            }
          });
      process =
          (org.apache.falcon.entity.v0.process.Process)
              unmarshaller.unmarshal(new StringReader(processTemplate));
    } catch (Exception e) {
      throw new FalconException(e);
    }

    /* For optional properties user might directly set them in the process xml and might not set it in properties
       file. Before doing the submission validation is done to confirm process xml doesn't have
       EXTENSION_VAR_PATTERN
    */

    String processName = extensionProperties.getProperty(ExtensionProperties.JOB_NAME.getName());
    if (StringUtils.isNotEmpty(processName)) {
      process.setName(processName);
    }

    // DR process template has only one cluster
    bindClusterProperties(process.getClusters().getClusters().get(0), extensionProperties);

    // bind scheduling properties
    String processFrequency =
        extensionProperties.getProperty(ExtensionProperties.FREQUENCY.getName());
    if (StringUtils.isNotEmpty(processFrequency)) {
      process.setFrequency(Frequency.fromString(processFrequency));
    }

    String zone = extensionProperties.getProperty(ExtensionProperties.TIMEZONE.getName());
    if (StringUtils.isNotBlank(zone)) {
      process.setTimezone(TimeZone.getTimeZone(zone));
    } else {
      process.setTimezone(TimeZone.getTimeZone("UTC"));
    }

    bindWorkflowProperties(process.getWorkflow(), extensionName, wfPath, wfLibPath);
    bindRetryProperties(process.getRetry(), extensionProperties);
    bindNotificationProperties(process.getNotification(), extensionProperties);
    bindACLProperties(process.getACL(), extensionProperties);
    bindTagsProperties(process, extensionProperties);
    bindCustomProperties(process.getProperties(), extensionProperties);

    return process;
  }