コード例 #1
0
  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);
    }
  }
コード例 #2
0
ファイル: RetryHandler.java プロジェクト: kidaa/falcon
  @Override
  // SUSPEND CHECKSTYLE CHECK ParameterNumberCheck
  public void handleRerun(
      String clusterName,
      String entityType,
      String entityName,
      String nominalTime,
      String runId,
      String wfId,
      String workflowUser,
      long msgReceivedTime) {
    try {
      Entity entity = EntityUtil.getEntity(entityType, entityName);
      Retry retry = getRetry(entity);

      if (retry == null) {
        LOG.warn(
            "Retry not configured for entity: {} ({}), ignoring failed retried",
            entityType,
            entity.getName());
        return;
      }

      int attempts = retry.getAttempts();
      Frequency delay = retry.getDelay();
      PolicyType policy = retry.getPolicy();
      int intRunId = Integer.parseInt(runId);

      if (attempts > intRunId) {
        AbstractRerunPolicy rerunPolicy = RerunPolicyFactory.getRetryPolicy(policy);
        long delayTime = rerunPolicy.getDelay(delay, Integer.parseInt(runId));
        RetryEvent event =
            new RetryEvent(
                clusterName,
                wfId,
                msgReceivedTime,
                delayTime,
                entityType,
                entityName,
                nominalTime,
                intRunId,
                attempts,
                0,
                workflowUser);
        offerToQueue(event);
      } else {
        LOG.warn(
            "All retry attempt failed out of configured: {} attempt for entity instance: {}:{} "
                + "And WorkflowId: {}",
            attempts,
            entityName,
            nominalTime,
            wfId);

        GenericAlert.alertRetryFailed(
            entityType,
            entityName,
            nominalTime,
            wfId,
            workflowUser,
            runId,
            "All retry attempt failed out of configured: "
                + attempts
                + " attempt for entity instance::");
      }
    } catch (FalconException e) {
      LOG.error("Error during retry of entity instance {}:{}", entityName, nominalTime, e);
      GenericAlert.alertRetryFailed(
          entityType, entityName, nominalTime, wfId, workflowUser, runId, e.getMessage());
    }
  }