You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/06/25 09:17:31 UTC

[GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request #821: MINIFICPP-1251 - Implement and test RetryFlowFile processor

arpadboda commented on a change in pull request #821:
URL: https://github.com/apache/nifi-minifi-cpp/pull/821#discussion_r445409666



##########
File path: extensions/standard-processors/processors/RetryFlowFile.cpp
##########
@@ -0,0 +1,212 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RetryFlowFile.h"
+
+#include "core/PropertyValidation.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+core::Property RetryFlowFile::RetryAttribute(core::PropertyBuilder::createProperty("Retry Attribute")
+    ->withDescription(
+        "The name of the attribute that contains the current retry count for the FlowFile."
+        "WARNING: If the name matches an attribute already on the FlowFile that does not contain a numerical value, "
+        "the processor will either overwrite that attribute with '1' or fail based on configuration.")
+    ->withDefaultValue("flowfile.retries")
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::MaximumRetries(core::PropertyBuilder::createProperty("Maximum Retries")
+    ->withDescription("The maximum number of times a FlowFile can be retried before being passed to the 'retries_exceeded' relationship.")
+    ->withDefaultValue<uint64_t>(3)
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::PenalizeRetries(core::PropertyBuilder::createProperty("Penalize Retries")
+  ->withDescription("If set to 'true', this Processor will penalize input FlowFiles before passing them to the 'retry' relationship. This does not apply to the 'retries_exceeded' relationship.")
+  ->withDefaultValue<bool>(true)
+  ->build());
+
+core::Property RetryFlowFile::FailOnNonNumericalOverwrite(core::PropertyBuilder::createProperty("Fail on Non-numerical Overwrite")
+    ->withDescription("If the FlowFile already has the attribute defined in 'Retry Attribute' that is *not* a number, fail the FlowFile instead of resetting that value to '1'")
+    ->withDefaultValue<bool>(false)
+    ->build());
+
+core::Property RetryFlowFile::ReuseMode(core::PropertyBuilder::createProperty("Reuse Mode")
+    ->withDescription(
+        "Defines how the Processor behaves if the retry FlowFile has a different retry UUID than "
+        "the instance that received the FlowFile. This generally means that the attribute was "
+        "not reset after being successfully retried by a previous instance of this processor.")
+    ->withAllowableValues<std::string>({FAIL_ON_REUSE, WARN_ON_REUSE, RESET_REUSE})
+    ->withDefaultValue(FAIL_ON_REUSE)
+    ->build());
+
+core::Relationship RetryFlowFile::Retry("retry",
+  "Input FlowFile has not exceeded the configured maximum retry count, pass this relationship back to the input Processor to create a limited feedback loop.");
+core::Relationship RetryFlowFile::RetriesExceeded("retries_exceeded",
+  "Input FlowFile has exceeded the configured maximum retry count, do not pass this relationship back to the input Processor to terminate the limited feedback loop.");
+core::Relationship RetryFlowFile::Failure("failure",
+    "The processor is configured such that a non-numerical value on 'Retry Attribute' results in a failure instead of resetting "
+    "that value to '1'. This will immediately terminate the limited feedback loop. Might also include when 'Maximum Retries' contains "
+    " attribute expression language that does not resolve to an Integer.");
+
+void RetryFlowFile::initialize() {
+  setSupportedProperties({
+    RetryAttribute,
+    MaximumRetries,
+    PenalizeRetries,
+    FailOnNonNumericalOverwrite,
+    ReuseMode,
+  });
+  setSupportedRelationships({
+    Retry,
+    RetriesExceeded,
+    Failure,
+  });
+}
+
+void RetryFlowFile::onSchedule(core::ProcessContext* context, core::ProcessSessionFactory* /* sessionFactory */) {
+  context->getProperty(RetryAttribute.getName(), retry_attribute_);
+  context->getProperty(MaximumRetries.getName(), maximum_retries_);
+  context->getProperty(PenalizeRetries.getName(), penalize_retries_);
+  context->getProperty(FailOnNonNumericalOverwrite.getName(), fail_on_non_numerical_overwrite_);
+  context->getProperty(ReuseMode.getName(), reuse_mode_);
+  readDynamicPropertyKeys(context);
+}
+
+void RetryFlowFile::onTrigger(core::ProcessContext* context, core::ProcessSession* session) {
+  std::shared_ptr<FlowFileRecord> flow_file = std::static_pointer_cast<FlowFileRecord> (session->get());
+  if (!flow_file) {
+    return;
+  }
+
+  bool failure_due_to_non_numerical_retry;
+  uint64_t retry_property_value;
+  std::tie(retry_property_value, failure_due_to_non_numerical_retry) = getRetryPropertyValue(flow_file);
+  if (failure_due_to_non_numerical_retry) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+  if (updateUUIDMarkerAndCheckFailOnReuse(flow_file)) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+
+  if (retry_property_value < maximum_retries_) {
+    try {
+      flow_file->setAttribute(retry_attribute_, std::to_string(gsl::narrow_cast<uint64_t>(retry_property_value + 1)));
+    }
+    catch(const gsl::narrowing_error& e) {
+      logger_->log_error("Narrowing Exception: %s", e.what());
+      session->transfer(flow_file, Failure);
+      return;
+    }
+    if (penalize_retries_) {
+      session->penalize(flow_file);
+    }
+    session->transfer(flow_file, Retry);
+    return;
+  }
+  if (!setRetriesExceededAttributesOnFlowFile(context, flow_file)) {
+    session->transfer(flow_file, Failure);
+    yield();
+    return;
+  }
+  session->transfer(flow_file, RetriesExceeded);
+}
+
+void RetryFlowFile::readDynamicPropertyKeys(core::ProcessContext* context) {
+  exceeded_flowfile_attribute_keys.clear();
+  const std::vector<std::string> dynamic_prop_keys = context->getDynamicPropertyKeys();
+  logger_->log_info("RetryFlowFile registering %d keys", dynamic_prop_keys.size());
+  for (const auto& key : dynamic_prop_keys) {
+    exceeded_flowfile_attribute_keys.emplace_back(core::PropertyBuilder::createProperty(key)->withDescription("auto generated")->supportsExpressionLanguage(true)->build());
+    logger_->log_info("RetryFlowFile registered attribute '%s'", key);
+  }
+}
+
+// Returns (1, true) on non-numerical or out-of-bounds retry value
+std::pair<uint64_t, bool> RetryFlowFile::getRetryPropertyValue(const std::shared_ptr<FlowFileRecord>& flow_file) {
+  std::string value_as_string;
+  try {
+    if (flow_file->getAttribute(retry_attribute_, value_as_string)) {
+      return std::make_pair(std::stoul(value_as_string), false);

Review comment:
       stoul**l**
   
   stoul returns unsigned long, which is 32 bits on Win.

##########
File path: extensions/standard-processors/processors/RetryFlowFile.cpp
##########
@@ -0,0 +1,212 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RetryFlowFile.h"
+
+#include "core/PropertyValidation.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+core::Property RetryFlowFile::RetryAttribute(core::PropertyBuilder::createProperty("Retry Attribute")
+    ->withDescription(
+        "The name of the attribute that contains the current retry count for the FlowFile."
+        "WARNING: If the name matches an attribute already on the FlowFile that does not contain a numerical value, "
+        "the processor will either overwrite that attribute with '1' or fail based on configuration.")
+    ->withDefaultValue("flowfile.retries")
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::MaximumRetries(core::PropertyBuilder::createProperty("Maximum Retries")
+    ->withDescription("The maximum number of times a FlowFile can be retried before being passed to the 'retries_exceeded' relationship.")
+    ->withDefaultValue<uint64_t>(3)
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::PenalizeRetries(core::PropertyBuilder::createProperty("Penalize Retries")
+  ->withDescription("If set to 'true', this Processor will penalize input FlowFiles before passing them to the 'retry' relationship. This does not apply to the 'retries_exceeded' relationship.")
+  ->withDefaultValue<bool>(true)
+  ->build());
+
+core::Property RetryFlowFile::FailOnNonNumericalOverwrite(core::PropertyBuilder::createProperty("Fail on Non-numerical Overwrite")
+    ->withDescription("If the FlowFile already has the attribute defined in 'Retry Attribute' that is *not* a number, fail the FlowFile instead of resetting that value to '1'")
+    ->withDefaultValue<bool>(false)
+    ->build());
+
+core::Property RetryFlowFile::ReuseMode(core::PropertyBuilder::createProperty("Reuse Mode")
+    ->withDescription(
+        "Defines how the Processor behaves if the retry FlowFile has a different retry UUID than "
+        "the instance that received the FlowFile. This generally means that the attribute was "
+        "not reset after being successfully retried by a previous instance of this processor.")
+    ->withAllowableValues<std::string>({FAIL_ON_REUSE, WARN_ON_REUSE, RESET_REUSE})
+    ->withDefaultValue(FAIL_ON_REUSE)
+    ->build());
+
+core::Relationship RetryFlowFile::Retry("retry",
+  "Input FlowFile has not exceeded the configured maximum retry count, pass this relationship back to the input Processor to create a limited feedback loop.");
+core::Relationship RetryFlowFile::RetriesExceeded("retries_exceeded",
+  "Input FlowFile has exceeded the configured maximum retry count, do not pass this relationship back to the input Processor to terminate the limited feedback loop.");
+core::Relationship RetryFlowFile::Failure("failure",
+    "The processor is configured such that a non-numerical value on 'Retry Attribute' results in a failure instead of resetting "
+    "that value to '1'. This will immediately terminate the limited feedback loop. Might also include when 'Maximum Retries' contains "
+    " attribute expression language that does not resolve to an Integer.");
+
+void RetryFlowFile::initialize() {
+  setSupportedProperties({
+    RetryAttribute,
+    MaximumRetries,
+    PenalizeRetries,
+    FailOnNonNumericalOverwrite,
+    ReuseMode,
+  });
+  setSupportedRelationships({
+    Retry,
+    RetriesExceeded,
+    Failure,
+  });
+}
+
+void RetryFlowFile::onSchedule(core::ProcessContext* context, core::ProcessSessionFactory* /* sessionFactory */) {
+  context->getProperty(RetryAttribute.getName(), retry_attribute_);
+  context->getProperty(MaximumRetries.getName(), maximum_retries_);
+  context->getProperty(PenalizeRetries.getName(), penalize_retries_);
+  context->getProperty(FailOnNonNumericalOverwrite.getName(), fail_on_non_numerical_overwrite_);
+  context->getProperty(ReuseMode.getName(), reuse_mode_);
+  readDynamicPropertyKeys(context);
+}
+
+void RetryFlowFile::onTrigger(core::ProcessContext* context, core::ProcessSession* session) {
+  std::shared_ptr<FlowFileRecord> flow_file = std::static_pointer_cast<FlowFileRecord> (session->get());
+  if (!flow_file) {
+    return;
+  }
+
+  bool failure_due_to_non_numerical_retry;
+  uint64_t retry_property_value;
+  std::tie(retry_property_value, failure_due_to_non_numerical_retry) = getRetryPropertyValue(flow_file);
+  if (failure_due_to_non_numerical_retry) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+  if (updateUUIDMarkerAndCheckFailOnReuse(flow_file)) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+
+  if (retry_property_value < maximum_retries_) {
+    try {
+      flow_file->setAttribute(retry_attribute_, std::to_string(gsl::narrow_cast<uint64_t>(retry_property_value + 1)));
+    }
+    catch(const gsl::narrowing_error& e) {
+      logger_->log_error("Narrowing Exception: %s", e.what());
+      session->transfer(flow_file, Failure);
+      return;
+    }
+    if (penalize_retries_) {
+      session->penalize(flow_file);
+    }
+    session->transfer(flow_file, Retry);
+    return;
+  }
+  if (!setRetriesExceededAttributesOnFlowFile(context, flow_file)) {
+    session->transfer(flow_file, Failure);
+    yield();
+    return;
+  }
+  session->transfer(flow_file, RetriesExceeded);
+}
+
+void RetryFlowFile::readDynamicPropertyKeys(core::ProcessContext* context) {
+  exceeded_flowfile_attribute_keys.clear();
+  const std::vector<std::string> dynamic_prop_keys = context->getDynamicPropertyKeys();
+  logger_->log_info("RetryFlowFile registering %d keys", dynamic_prop_keys.size());
+  for (const auto& key : dynamic_prop_keys) {
+    exceeded_flowfile_attribute_keys.emplace_back(core::PropertyBuilder::createProperty(key)->withDescription("auto generated")->supportsExpressionLanguage(true)->build());
+    logger_->log_info("RetryFlowFile registered attribute '%s'", key);
+  }
+}
+
+// Returns (1, true) on non-numerical or out-of-bounds retry value
+std::pair<uint64_t, bool> RetryFlowFile::getRetryPropertyValue(const std::shared_ptr<FlowFileRecord>& flow_file) {
+  std::string value_as_string;
+  try {
+    if (flow_file->getAttribute(retry_attribute_, value_as_string)) {
+      return std::make_pair(std::stoul(value_as_string), false);
+    }
+  }
+  catch(const std::invalid_argument&) {
+    if (fail_on_non_numerical_overwrite_) {
+      logger_->log_info("Non-numerical retry property in RetryFlowFile. Sending flowfile to failure...", value_as_string);
+      return std::make_pair(1, true);
+    }
+    logger_->log_info("Non-numerical retry property in RetryFlowFile: overwriting %s with 1.", value_as_string);
+  }
+  catch(const std::out_of_range&) {
+    logger_->log_error("Narrowing Exception for %s, treating it as non-numerical value", value_as_string);
+  }
+  return std::make_pair(1, false);
+}
+
+// Returns true on fail on reuse scenario
+bool RetryFlowFile::updateUUIDMarkerAndCheckFailOnReuse(const std::shared_ptr<FlowFileRecord>& flow_file) {
+  const std::string last_retried_by_property_name = retry_attribute_ + ".uuid";
+  const std::string current_processor_uuid = getUUIDStr();
+  std::string last_retried_by_uuid;
+  if (flow_file->getAttribute(last_retried_by_property_name, last_retried_by_uuid)) {
+    if (last_retried_by_uuid != current_processor_uuid) {
+      if (reuse_mode_ == FAIL_ON_REUSE) {
+        logger_->log_error("FlowFile %s was previously retried with the same attribute by a different "
+            "processor (uuid: %s, current uuid: %s). Transfering flowfile to 'failure'...",
+            flow_file->getUUIDStr(), last_retried_by_uuid, current_processor_uuid);
+        return true;
+      }
+      if (reuse_mode_ == WARN_ON_REUSE) {
+        logger_->log_warn("Reusing retry attribute that belongs to different processor. Resetting value to 1.");
+      } else {  // Assuming reuse_mode_ == RESET_REUSE
+        logger_->log_debug("Reusing retry attribute that belongs to different processor. Resetting value to 1.");
+      }
+    }
+  }
+  flow_file->setAttribute(last_retried_by_property_name, getUUIDStr());
+  return false;
+}
+
+bool RetryFlowFile::setRetriesExceededAttributesOnFlowFile(core::ProcessContext* context, const std::shared_ptr<FlowFileRecord>& flow_file) {

Review comment:
       Const!
   
   I don't think this function should return true or false. 
   
   This should be void. In case something throws when trying to set attributes (shouldn't), just let the exception fly and that results in a rollback. 

##########
File path: extensions/standard-processors/processors/RetryFlowFile.cpp
##########
@@ -0,0 +1,212 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RetryFlowFile.h"
+
+#include "core/PropertyValidation.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+core::Property RetryFlowFile::RetryAttribute(core::PropertyBuilder::createProperty("Retry Attribute")
+    ->withDescription(
+        "The name of the attribute that contains the current retry count for the FlowFile."
+        "WARNING: If the name matches an attribute already on the FlowFile that does not contain a numerical value, "
+        "the processor will either overwrite that attribute with '1' or fail based on configuration.")
+    ->withDefaultValue("flowfile.retries")
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::MaximumRetries(core::PropertyBuilder::createProperty("Maximum Retries")
+    ->withDescription("The maximum number of times a FlowFile can be retried before being passed to the 'retries_exceeded' relationship.")
+    ->withDefaultValue<uint64_t>(3)
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::PenalizeRetries(core::PropertyBuilder::createProperty("Penalize Retries")
+  ->withDescription("If set to 'true', this Processor will penalize input FlowFiles before passing them to the 'retry' relationship. This does not apply to the 'retries_exceeded' relationship.")
+  ->withDefaultValue<bool>(true)
+  ->build());
+
+core::Property RetryFlowFile::FailOnNonNumericalOverwrite(core::PropertyBuilder::createProperty("Fail on Non-numerical Overwrite")
+    ->withDescription("If the FlowFile already has the attribute defined in 'Retry Attribute' that is *not* a number, fail the FlowFile instead of resetting that value to '1'")
+    ->withDefaultValue<bool>(false)
+    ->build());
+
+core::Property RetryFlowFile::ReuseMode(core::PropertyBuilder::createProperty("Reuse Mode")
+    ->withDescription(
+        "Defines how the Processor behaves if the retry FlowFile has a different retry UUID than "
+        "the instance that received the FlowFile. This generally means that the attribute was "
+        "not reset after being successfully retried by a previous instance of this processor.")
+    ->withAllowableValues<std::string>({FAIL_ON_REUSE, WARN_ON_REUSE, RESET_REUSE})
+    ->withDefaultValue(FAIL_ON_REUSE)
+    ->build());
+
+core::Relationship RetryFlowFile::Retry("retry",
+  "Input FlowFile has not exceeded the configured maximum retry count, pass this relationship back to the input Processor to create a limited feedback loop.");
+core::Relationship RetryFlowFile::RetriesExceeded("retries_exceeded",
+  "Input FlowFile has exceeded the configured maximum retry count, do not pass this relationship back to the input Processor to terminate the limited feedback loop.");
+core::Relationship RetryFlowFile::Failure("failure",
+    "The processor is configured such that a non-numerical value on 'Retry Attribute' results in a failure instead of resetting "
+    "that value to '1'. This will immediately terminate the limited feedback loop. Might also include when 'Maximum Retries' contains "
+    " attribute expression language that does not resolve to an Integer.");
+
+void RetryFlowFile::initialize() {
+  setSupportedProperties({
+    RetryAttribute,
+    MaximumRetries,
+    PenalizeRetries,
+    FailOnNonNumericalOverwrite,
+    ReuseMode,
+  });
+  setSupportedRelationships({
+    Retry,
+    RetriesExceeded,
+    Failure,
+  });
+}
+
+void RetryFlowFile::onSchedule(core::ProcessContext* context, core::ProcessSessionFactory* /* sessionFactory */) {
+  context->getProperty(RetryAttribute.getName(), retry_attribute_);
+  context->getProperty(MaximumRetries.getName(), maximum_retries_);
+  context->getProperty(PenalizeRetries.getName(), penalize_retries_);
+  context->getProperty(FailOnNonNumericalOverwrite.getName(), fail_on_non_numerical_overwrite_);
+  context->getProperty(ReuseMode.getName(), reuse_mode_);
+  readDynamicPropertyKeys(context);
+}
+
+void RetryFlowFile::onTrigger(core::ProcessContext* context, core::ProcessSession* session) {
+  std::shared_ptr<FlowFileRecord> flow_file = std::static_pointer_cast<FlowFileRecord> (session->get());
+  if (!flow_file) {
+    return;
+  }
+
+  bool failure_due_to_non_numerical_retry;
+  uint64_t retry_property_value;
+  std::tie(retry_property_value, failure_due_to_non_numerical_retry) = getRetryPropertyValue(flow_file);
+  if (failure_due_to_non_numerical_retry) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+  if (updateUUIDMarkerAndCheckFailOnReuse(flow_file)) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+
+  if (retry_property_value < maximum_retries_) {
+    try {
+      flow_file->setAttribute(retry_attribute_, std::to_string(gsl::narrow_cast<uint64_t>(retry_property_value + 1)));
+    }
+    catch(const gsl::narrowing_error& e) {
+      logger_->log_error("Narrowing Exception: %s", e.what());
+      session->transfer(flow_file, Failure);
+      return;
+    }
+    if (penalize_retries_) {
+      session->penalize(flow_file);
+    }
+    session->transfer(flow_file, Retry);
+    return;
+  }
+  if (!setRetriesExceededAttributesOnFlowFile(context, flow_file)) {
+    session->transfer(flow_file, Failure);
+    yield();
+    return;
+  }
+  session->transfer(flow_file, RetriesExceeded);
+}
+
+void RetryFlowFile::readDynamicPropertyKeys(core::ProcessContext* context) {
+  exceeded_flowfile_attribute_keys.clear();
+  const std::vector<std::string> dynamic_prop_keys = context->getDynamicPropertyKeys();
+  logger_->log_info("RetryFlowFile registering %d keys", dynamic_prop_keys.size());
+  for (const auto& key : dynamic_prop_keys) {
+    exceeded_flowfile_attribute_keys.emplace_back(core::PropertyBuilder::createProperty(key)->withDescription("auto generated")->supportsExpressionLanguage(true)->build());
+    logger_->log_info("RetryFlowFile registered attribute '%s'", key);
+  }
+}
+
+// Returns (1, true) on non-numerical or out-of-bounds retry value
+std::pair<uint64_t, bool> RetryFlowFile::getRetryPropertyValue(const std::shared_ptr<FlowFileRecord>& flow_file) {
+  std::string value_as_string;
+  try {
+    if (flow_file->getAttribute(retry_attribute_, value_as_string)) {
+      return std::make_pair(std::stoul(value_as_string), false);
+    }
+  }
+  catch(const std::invalid_argument&) {
+    if (fail_on_non_numerical_overwrite_) {
+      logger_->log_info("Non-numerical retry property in RetryFlowFile. Sending flowfile to failure...", value_as_string);
+      return std::make_pair(1, true);
+    }
+    logger_->log_info("Non-numerical retry property in RetryFlowFile: overwriting %s with 1.", value_as_string);
+  }
+  catch(const std::out_of_range&) {
+    logger_->log_error("Narrowing Exception for %s, treating it as non-numerical value", value_as_string);
+  }
+  return std::make_pair(1, false);
+}
+
+// Returns true on fail on reuse scenario
+bool RetryFlowFile::updateUUIDMarkerAndCheckFailOnReuse(const std::shared_ptr<FlowFileRecord>& flow_file) {

Review comment:
       This looks const as well, doesn't seem to change anything in the processor.
   
   I would prefer to have this separated into two functions: one to check reuse, the other to update.

##########
File path: extensions/standard-processors/processors/RetryFlowFile.cpp
##########
@@ -0,0 +1,212 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RetryFlowFile.h"
+
+#include "core/PropertyValidation.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+core::Property RetryFlowFile::RetryAttribute(core::PropertyBuilder::createProperty("Retry Attribute")
+    ->withDescription(
+        "The name of the attribute that contains the current retry count for the FlowFile."
+        "WARNING: If the name matches an attribute already on the FlowFile that does not contain a numerical value, "
+        "the processor will either overwrite that attribute with '1' or fail based on configuration.")
+    ->withDefaultValue("flowfile.retries")
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::MaximumRetries(core::PropertyBuilder::createProperty("Maximum Retries")
+    ->withDescription("The maximum number of times a FlowFile can be retried before being passed to the 'retries_exceeded' relationship.")
+    ->withDefaultValue<uint64_t>(3)
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::PenalizeRetries(core::PropertyBuilder::createProperty("Penalize Retries")
+  ->withDescription("If set to 'true', this Processor will penalize input FlowFiles before passing them to the 'retry' relationship. This does not apply to the 'retries_exceeded' relationship.")
+  ->withDefaultValue<bool>(true)
+  ->build());
+
+core::Property RetryFlowFile::FailOnNonNumericalOverwrite(core::PropertyBuilder::createProperty("Fail on Non-numerical Overwrite")
+    ->withDescription("If the FlowFile already has the attribute defined in 'Retry Attribute' that is *not* a number, fail the FlowFile instead of resetting that value to '1'")
+    ->withDefaultValue<bool>(false)
+    ->build());
+
+core::Property RetryFlowFile::ReuseMode(core::PropertyBuilder::createProperty("Reuse Mode")
+    ->withDescription(
+        "Defines how the Processor behaves if the retry FlowFile has a different retry UUID than "
+        "the instance that received the FlowFile. This generally means that the attribute was "
+        "not reset after being successfully retried by a previous instance of this processor.")
+    ->withAllowableValues<std::string>({FAIL_ON_REUSE, WARN_ON_REUSE, RESET_REUSE})
+    ->withDefaultValue(FAIL_ON_REUSE)
+    ->build());
+
+core::Relationship RetryFlowFile::Retry("retry",
+  "Input FlowFile has not exceeded the configured maximum retry count, pass this relationship back to the input Processor to create a limited feedback loop.");
+core::Relationship RetryFlowFile::RetriesExceeded("retries_exceeded",
+  "Input FlowFile has exceeded the configured maximum retry count, do not pass this relationship back to the input Processor to terminate the limited feedback loop.");
+core::Relationship RetryFlowFile::Failure("failure",
+    "The processor is configured such that a non-numerical value on 'Retry Attribute' results in a failure instead of resetting "
+    "that value to '1'. This will immediately terminate the limited feedback loop. Might also include when 'Maximum Retries' contains "
+    " attribute expression language that does not resolve to an Integer.");
+
+void RetryFlowFile::initialize() {
+  setSupportedProperties({
+    RetryAttribute,
+    MaximumRetries,
+    PenalizeRetries,
+    FailOnNonNumericalOverwrite,
+    ReuseMode,
+  });
+  setSupportedRelationships({
+    Retry,
+    RetriesExceeded,
+    Failure,
+  });
+}
+
+void RetryFlowFile::onSchedule(core::ProcessContext* context, core::ProcessSessionFactory* /* sessionFactory */) {
+  context->getProperty(RetryAttribute.getName(), retry_attribute_);
+  context->getProperty(MaximumRetries.getName(), maximum_retries_);
+  context->getProperty(PenalizeRetries.getName(), penalize_retries_);
+  context->getProperty(FailOnNonNumericalOverwrite.getName(), fail_on_non_numerical_overwrite_);
+  context->getProperty(ReuseMode.getName(), reuse_mode_);
+  readDynamicPropertyKeys(context);
+}
+
+void RetryFlowFile::onTrigger(core::ProcessContext* context, core::ProcessSession* session) {
+  std::shared_ptr<FlowFileRecord> flow_file = std::static_pointer_cast<FlowFileRecord> (session->get());
+  if (!flow_file) {
+    return;
+  }
+
+  bool failure_due_to_non_numerical_retry;
+  uint64_t retry_property_value;
+  std::tie(retry_property_value, failure_due_to_non_numerical_retry) = getRetryPropertyValue(flow_file);
+  if (failure_due_to_non_numerical_retry) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+  if (updateUUIDMarkerAndCheckFailOnReuse(flow_file)) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+
+  if (retry_property_value < maximum_retries_) {
+    try {
+      flow_file->setAttribute(retry_attribute_, std::to_string(gsl::narrow_cast<uint64_t>(retry_property_value + 1)));
+    }
+    catch(const gsl::narrowing_error& e) {
+      logger_->log_error("Narrowing Exception: %s", e.what());
+      session->transfer(flow_file, Failure);
+      return;
+    }
+    if (penalize_retries_) {
+      session->penalize(flow_file);
+    }
+    session->transfer(flow_file, Retry);
+    return;
+  }
+  if (!setRetriesExceededAttributesOnFlowFile(context, flow_file)) {
+    session->transfer(flow_file, Failure);
+    yield();
+    return;
+  }
+  session->transfer(flow_file, RetriesExceeded);
+}
+
+void RetryFlowFile::readDynamicPropertyKeys(core::ProcessContext* context) {
+  exceeded_flowfile_attribute_keys.clear();
+  const std::vector<std::string> dynamic_prop_keys = context->getDynamicPropertyKeys();
+  logger_->log_info("RetryFlowFile registering %d keys", dynamic_prop_keys.size());
+  for (const auto& key : dynamic_prop_keys) {
+    exceeded_flowfile_attribute_keys.emplace_back(core::PropertyBuilder::createProperty(key)->withDescription("auto generated")->supportsExpressionLanguage(true)->build());
+    logger_->log_info("RetryFlowFile registered attribute '%s'", key);
+  }
+}
+
+// Returns (1, true) on non-numerical or out-of-bounds retry value
+std::pair<uint64_t, bool> RetryFlowFile::getRetryPropertyValue(const std::shared_ptr<FlowFileRecord>& flow_file) {
+  std::string value_as_string;
+  try {
+    if (flow_file->getAttribute(retry_attribute_, value_as_string)) {
+      return std::make_pair(std::stoul(value_as_string), false);
+    }
+  }
+  catch(const std::invalid_argument&) {
+    if (fail_on_non_numerical_overwrite_) {
+      logger_->log_info("Non-numerical retry property in RetryFlowFile. Sending flowfile to failure...", value_as_string);
+      return std::make_pair(1, true);
+    }
+    logger_->log_info("Non-numerical retry property in RetryFlowFile: overwriting %s with 1.", value_as_string);
+  }
+  catch(const std::out_of_range&) {
+    logger_->log_error("Narrowing Exception for %s, treating it as non-numerical value", value_as_string);
+  }
+  return std::make_pair(1, false);
+}
+
+// Returns true on fail on reuse scenario
+bool RetryFlowFile::updateUUIDMarkerAndCheckFailOnReuse(const std::shared_ptr<FlowFileRecord>& flow_file) {
+  const std::string last_retried_by_property_name = retry_attribute_ + ".uuid";
+  const std::string current_processor_uuid = getUUIDStr();
+  std::string last_retried_by_uuid;
+  if (flow_file->getAttribute(last_retried_by_property_name, last_retried_by_uuid)) {
+    if (last_retried_by_uuid != current_processor_uuid) {
+      if (reuse_mode_ == FAIL_ON_REUSE) {
+        logger_->log_error("FlowFile %s was previously retried with the same attribute by a different "
+            "processor (uuid: %s, current uuid: %s). Transfering flowfile to 'failure'...",
+            flow_file->getUUIDStr(), last_retried_by_uuid, current_processor_uuid);
+        return true;
+      }
+      if (reuse_mode_ == WARN_ON_REUSE) {
+        logger_->log_warn("Reusing retry attribute that belongs to different processor. Resetting value to 1.");
+      } else {  // Assuming reuse_mode_ == RESET_REUSE
+        logger_->log_debug("Reusing retry attribute that belongs to different processor. Resetting value to 1.");
+      }
+    }
+  }
+  flow_file->setAttribute(last_retried_by_property_name, getUUIDStr());
+  return false;
+}
+
+bool RetryFlowFile::setRetriesExceededAttributesOnFlowFile(core::ProcessContext* context, const std::shared_ptr<FlowFileRecord>& flow_file) {
+  try {
+    for (const auto& attribute : exceeded_flowfile_attribute_keys) {
+      std::string value;
+      context->getDynamicProperty(attribute, value, flow_file);
+      flow_file->setAttribute(attribute.getName(), value);
+      logger_->log_info("Set attribute '%s' of flow file '%s' with value '%s'", attribute.getName(), flow_file->getUUIDStr(), value);
+    }
+    return true;
+  }
+  catch (const std::exception& e) {

Review comment:
       What do we expect to throw here?

##########
File path: extensions/standard-processors/processors/RetryFlowFile.cpp
##########
@@ -0,0 +1,212 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RetryFlowFile.h"
+
+#include "core/PropertyValidation.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+core::Property RetryFlowFile::RetryAttribute(core::PropertyBuilder::createProperty("Retry Attribute")
+    ->withDescription(
+        "The name of the attribute that contains the current retry count for the FlowFile."
+        "WARNING: If the name matches an attribute already on the FlowFile that does not contain a numerical value, "
+        "the processor will either overwrite that attribute with '1' or fail based on configuration.")
+    ->withDefaultValue("flowfile.retries")
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::MaximumRetries(core::PropertyBuilder::createProperty("Maximum Retries")
+    ->withDescription("The maximum number of times a FlowFile can be retried before being passed to the 'retries_exceeded' relationship.")
+    ->withDefaultValue<uint64_t>(3)
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::PenalizeRetries(core::PropertyBuilder::createProperty("Penalize Retries")
+  ->withDescription("If set to 'true', this Processor will penalize input FlowFiles before passing them to the 'retry' relationship. This does not apply to the 'retries_exceeded' relationship.")
+  ->withDefaultValue<bool>(true)
+  ->build());
+
+core::Property RetryFlowFile::FailOnNonNumericalOverwrite(core::PropertyBuilder::createProperty("Fail on Non-numerical Overwrite")
+    ->withDescription("If the FlowFile already has the attribute defined in 'Retry Attribute' that is *not* a number, fail the FlowFile instead of resetting that value to '1'")
+    ->withDefaultValue<bool>(false)
+    ->build());
+
+core::Property RetryFlowFile::ReuseMode(core::PropertyBuilder::createProperty("Reuse Mode")
+    ->withDescription(
+        "Defines how the Processor behaves if the retry FlowFile has a different retry UUID than "
+        "the instance that received the FlowFile. This generally means that the attribute was "
+        "not reset after being successfully retried by a previous instance of this processor.")
+    ->withAllowableValues<std::string>({FAIL_ON_REUSE, WARN_ON_REUSE, RESET_REUSE})
+    ->withDefaultValue(FAIL_ON_REUSE)
+    ->build());
+
+core::Relationship RetryFlowFile::Retry("retry",
+  "Input FlowFile has not exceeded the configured maximum retry count, pass this relationship back to the input Processor to create a limited feedback loop.");
+core::Relationship RetryFlowFile::RetriesExceeded("retries_exceeded",
+  "Input FlowFile has exceeded the configured maximum retry count, do not pass this relationship back to the input Processor to terminate the limited feedback loop.");
+core::Relationship RetryFlowFile::Failure("failure",
+    "The processor is configured such that a non-numerical value on 'Retry Attribute' results in a failure instead of resetting "
+    "that value to '1'. This will immediately terminate the limited feedback loop. Might also include when 'Maximum Retries' contains "
+    " attribute expression language that does not resolve to an Integer.");
+
+void RetryFlowFile::initialize() {
+  setSupportedProperties({
+    RetryAttribute,
+    MaximumRetries,
+    PenalizeRetries,
+    FailOnNonNumericalOverwrite,
+    ReuseMode,
+  });
+  setSupportedRelationships({
+    Retry,
+    RetriesExceeded,
+    Failure,
+  });
+}
+
+void RetryFlowFile::onSchedule(core::ProcessContext* context, core::ProcessSessionFactory* /* sessionFactory */) {
+  context->getProperty(RetryAttribute.getName(), retry_attribute_);
+  context->getProperty(MaximumRetries.getName(), maximum_retries_);
+  context->getProperty(PenalizeRetries.getName(), penalize_retries_);
+  context->getProperty(FailOnNonNumericalOverwrite.getName(), fail_on_non_numerical_overwrite_);
+  context->getProperty(ReuseMode.getName(), reuse_mode_);
+  readDynamicPropertyKeys(context);
+}
+
+void RetryFlowFile::onTrigger(core::ProcessContext* context, core::ProcessSession* session) {
+  std::shared_ptr<FlowFileRecord> flow_file = std::static_pointer_cast<FlowFileRecord> (session->get());
+  if (!flow_file) {
+    return;
+  }
+
+  bool failure_due_to_non_numerical_retry;
+  uint64_t retry_property_value;
+  std::tie(retry_property_value, failure_due_to_non_numerical_retry) = getRetryPropertyValue(flow_file);
+  if (failure_due_to_non_numerical_retry) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+  if (updateUUIDMarkerAndCheckFailOnReuse(flow_file)) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+
+  if (retry_property_value < maximum_retries_) {
+    try {
+      flow_file->setAttribute(retry_attribute_, std::to_string(gsl::narrow_cast<uint64_t>(retry_property_value + 1)));
+    }
+    catch(const gsl::narrowing_error& e) {
+      logger_->log_error("Narrowing Exception: %s", e.what());
+      session->transfer(flow_file, Failure);
+      return;
+    }
+    if (penalize_retries_) {
+      session->penalize(flow_file);
+    }
+    session->transfer(flow_file, Retry);
+    return;
+  }
+  if (!setRetriesExceededAttributesOnFlowFile(context, flow_file)) {
+    session->transfer(flow_file, Failure);
+    yield();
+    return;
+  }
+  session->transfer(flow_file, RetriesExceeded);
+}
+
+void RetryFlowFile::readDynamicPropertyKeys(core::ProcessContext* context) {
+  exceeded_flowfile_attribute_keys.clear();
+  const std::vector<std::string> dynamic_prop_keys = context->getDynamicPropertyKeys();
+  logger_->log_info("RetryFlowFile registering %d keys", dynamic_prop_keys.size());
+  for (const auto& key : dynamic_prop_keys) {
+    exceeded_flowfile_attribute_keys.emplace_back(core::PropertyBuilder::createProperty(key)->withDescription("auto generated")->supportsExpressionLanguage(true)->build());
+    logger_->log_info("RetryFlowFile registered attribute '%s'", key);
+  }
+}
+
+// Returns (1, true) on non-numerical or out-of-bounds retry value
+std::pair<uint64_t, bool> RetryFlowFile::getRetryPropertyValue(const std::shared_ptr<FlowFileRecord>& flow_file) {

Review comment:
       Why doesn't this return an optional?
   In case the optional has no value, this couldn't get the attribute. 
   The function itself could be const. 

##########
File path: extensions/standard-processors/processors/RetryFlowFile.cpp
##########
@@ -0,0 +1,212 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RetryFlowFile.h"
+
+#include "core/PropertyValidation.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+core::Property RetryFlowFile::RetryAttribute(core::PropertyBuilder::createProperty("Retry Attribute")
+    ->withDescription(
+        "The name of the attribute that contains the current retry count for the FlowFile."
+        "WARNING: If the name matches an attribute already on the FlowFile that does not contain a numerical value, "
+        "the processor will either overwrite that attribute with '1' or fail based on configuration.")
+    ->withDefaultValue("flowfile.retries")
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::MaximumRetries(core::PropertyBuilder::createProperty("Maximum Retries")
+    ->withDescription("The maximum number of times a FlowFile can be retried before being passed to the 'retries_exceeded' relationship.")
+    ->withDefaultValue<uint64_t>(3)
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::PenalizeRetries(core::PropertyBuilder::createProperty("Penalize Retries")
+  ->withDescription("If set to 'true', this Processor will penalize input FlowFiles before passing them to the 'retry' relationship. This does not apply to the 'retries_exceeded' relationship.")
+  ->withDefaultValue<bool>(true)
+  ->build());
+
+core::Property RetryFlowFile::FailOnNonNumericalOverwrite(core::PropertyBuilder::createProperty("Fail on Non-numerical Overwrite")
+    ->withDescription("If the FlowFile already has the attribute defined in 'Retry Attribute' that is *not* a number, fail the FlowFile instead of resetting that value to '1'")
+    ->withDefaultValue<bool>(false)
+    ->build());
+
+core::Property RetryFlowFile::ReuseMode(core::PropertyBuilder::createProperty("Reuse Mode")
+    ->withDescription(
+        "Defines how the Processor behaves if the retry FlowFile has a different retry UUID than "
+        "the instance that received the FlowFile. This generally means that the attribute was "
+        "not reset after being successfully retried by a previous instance of this processor.")
+    ->withAllowableValues<std::string>({FAIL_ON_REUSE, WARN_ON_REUSE, RESET_REUSE})
+    ->withDefaultValue(FAIL_ON_REUSE)
+    ->build());
+
+core::Relationship RetryFlowFile::Retry("retry",
+  "Input FlowFile has not exceeded the configured maximum retry count, pass this relationship back to the input Processor to create a limited feedback loop.");
+core::Relationship RetryFlowFile::RetriesExceeded("retries_exceeded",
+  "Input FlowFile has exceeded the configured maximum retry count, do not pass this relationship back to the input Processor to terminate the limited feedback loop.");
+core::Relationship RetryFlowFile::Failure("failure",
+    "The processor is configured such that a non-numerical value on 'Retry Attribute' results in a failure instead of resetting "
+    "that value to '1'. This will immediately terminate the limited feedback loop. Might also include when 'Maximum Retries' contains "
+    " attribute expression language that does not resolve to an Integer.");
+
+void RetryFlowFile::initialize() {
+  setSupportedProperties({
+    RetryAttribute,
+    MaximumRetries,
+    PenalizeRetries,
+    FailOnNonNumericalOverwrite,
+    ReuseMode,
+  });
+  setSupportedRelationships({
+    Retry,
+    RetriesExceeded,
+    Failure,
+  });
+}
+
+void RetryFlowFile::onSchedule(core::ProcessContext* context, core::ProcessSessionFactory* /* sessionFactory */) {
+  context->getProperty(RetryAttribute.getName(), retry_attribute_);
+  context->getProperty(MaximumRetries.getName(), maximum_retries_);
+  context->getProperty(PenalizeRetries.getName(), penalize_retries_);
+  context->getProperty(FailOnNonNumericalOverwrite.getName(), fail_on_non_numerical_overwrite_);
+  context->getProperty(ReuseMode.getName(), reuse_mode_);
+  readDynamicPropertyKeys(context);
+}
+
+void RetryFlowFile::onTrigger(core::ProcessContext* context, core::ProcessSession* session) {
+  std::shared_ptr<FlowFileRecord> flow_file = std::static_pointer_cast<FlowFileRecord> (session->get());
+  if (!flow_file) {
+    return;
+  }
+
+  bool failure_due_to_non_numerical_retry;
+  uint64_t retry_property_value;
+  std::tie(retry_property_value, failure_due_to_non_numerical_retry) = getRetryPropertyValue(flow_file);
+  if (failure_due_to_non_numerical_retry) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+  if (updateUUIDMarkerAndCheckFailOnReuse(flow_file)) {
+    session->transfer(flow_file, Failure);
+    return;
+  }
+
+  if (retry_property_value < maximum_retries_) {
+    try {
+      flow_file->setAttribute(retry_attribute_, std::to_string(gsl::narrow_cast<uint64_t>(retry_property_value + 1)));
+    }
+    catch(const gsl::narrowing_error& e) {

Review comment:
       How could it occur?
   
   If maximum_retries_ is a valid uint64 and retry_property_value is less, I don't think incrementing it by one can cause any issues anyhow. 

##########
File path: libminifi/test/TestBase.h
##########
@@ -251,6 +251,8 @@ class TestPlan {
   std::shared_ptr<core::Processor> addProcessor(const std::string &processor_name, utils::Identifier& uuid, const std::string &name, const std::initializer_list<core::Relationship>& relationships,
                                                 bool linkToPrevious = false);
 
+  std::shared_ptr<minifi::Connection> addConnection(const std::shared_ptr<core::Processor> source_proc, const core::Relationship& source_relationship, const std::shared_ptr<core::Processor>& destination_proc);

Review comment:
       I don't think the relationship being in the middle is the best signature, but this is only my personal opinion, I can live with this in case the majority prefers this. 

##########
File path: extensions/standard-processors/tests/unit/RetryFlowFileTests.cpp
##########
@@ -0,0 +1,226 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define CATCH_CONFIG_MAIN
+
+#include <memory>
+#include <string>
+#include <set>
+
+#include "TestBase.h"
+
+#include "processors/GenerateFlowFile.h"
+#include "processors/UpdateAttribute.h"
+#include "processors/RetryFlowFile.h"
+#include "processors/PutFile.h"
+#include "processors/LogAttribute.h"
+#include "utils/file/FileUtils.h"
+#include "utils/OptionalUtils.h"
+#include "utils/RegexUtils.h"
+#include "utils/TestUtils.h"
+
+namespace {
+using org::apache::nifi::minifi::utils::createTempDir;
+using org::apache::nifi::minifi::utils::optional;
+
+std::vector<std::pair<std::string, std::string>> list_dir_all(const std::string& dir, const std::shared_ptr<logging::Logger>& logger, bool recursive = true) {
+  return org::apache::nifi::minifi::utils::file::FileUtils::list_dir_all(dir, logger, recursive);

Review comment:
       Why? Using would do the job. 

##########
File path: extensions/standard-processors/processors/RetryFlowFile.cpp
##########
@@ -0,0 +1,212 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RetryFlowFile.h"
+
+#include "core/PropertyValidation.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+core::Property RetryFlowFile::RetryAttribute(core::PropertyBuilder::createProperty("Retry Attribute")
+    ->withDescription(
+        "The name of the attribute that contains the current retry count for the FlowFile."
+        "WARNING: If the name matches an attribute already on the FlowFile that does not contain a numerical value, "
+        "the processor will either overwrite that attribute with '1' or fail based on configuration.")
+    ->withDefaultValue("flowfile.retries")
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::MaximumRetries(core::PropertyBuilder::createProperty("Maximum Retries")
+    ->withDescription("The maximum number of times a FlowFile can be retried before being passed to the 'retries_exceeded' relationship.")
+    ->withDefaultValue<uint64_t>(3)
+    ->supportsExpressionLanguage(true)
+    ->build());
+
+core::Property RetryFlowFile::PenalizeRetries(core::PropertyBuilder::createProperty("Penalize Retries")
+  ->withDescription("If set to 'true', this Processor will penalize input FlowFiles before passing them to the 'retry' relationship. This does not apply to the 'retries_exceeded' relationship.")
+  ->withDefaultValue<bool>(true)
+  ->build());
+
+core::Property RetryFlowFile::FailOnNonNumericalOverwrite(core::PropertyBuilder::createProperty("Fail on Non-numerical Overwrite")
+    ->withDescription("If the FlowFile already has the attribute defined in 'Retry Attribute' that is *not* a number, fail the FlowFile instead of resetting that value to '1'")
+    ->withDefaultValue<bool>(false)
+    ->build());
+
+core::Property RetryFlowFile::ReuseMode(core::PropertyBuilder::createProperty("Reuse Mode")
+    ->withDescription(
+        "Defines how the Processor behaves if the retry FlowFile has a different retry UUID than "
+        "the instance that received the FlowFile. This generally means that the attribute was "
+        "not reset after being successfully retried by a previous instance of this processor.")
+    ->withAllowableValues<std::string>({FAIL_ON_REUSE, WARN_ON_REUSE, RESET_REUSE})
+    ->withDefaultValue(FAIL_ON_REUSE)
+    ->build());
+
+core::Relationship RetryFlowFile::Retry("retry",
+  "Input FlowFile has not exceeded the configured maximum retry count, pass this relationship back to the input Processor to create a limited feedback loop.");
+core::Relationship RetryFlowFile::RetriesExceeded("retries_exceeded",
+  "Input FlowFile has exceeded the configured maximum retry count, do not pass this relationship back to the input Processor to terminate the limited feedback loop.");
+core::Relationship RetryFlowFile::Failure("failure",
+    "The processor is configured such that a non-numerical value on 'Retry Attribute' results in a failure instead of resetting "
+    "that value to '1'. This will immediately terminate the limited feedback loop. Might also include when 'Maximum Retries' contains "
+    " attribute expression language that does not resolve to an Integer.");
+
+void RetryFlowFile::initialize() {
+  setSupportedProperties({
+    RetryAttribute,
+    MaximumRetries,
+    PenalizeRetries,
+    FailOnNonNumericalOverwrite,
+    ReuseMode,
+  });
+  setSupportedRelationships({
+    Retry,
+    RetriesExceeded,
+    Failure,
+  });
+}
+
+void RetryFlowFile::onSchedule(core::ProcessContext* context, core::ProcessSessionFactory* /* sessionFactory */) {
+  context->getProperty(RetryAttribute.getName(), retry_attribute_);
+  context->getProperty(MaximumRetries.getName(), maximum_retries_);
+  context->getProperty(PenalizeRetries.getName(), penalize_retries_);
+  context->getProperty(FailOnNonNumericalOverwrite.getName(), fail_on_non_numerical_overwrite_);
+  context->getProperty(ReuseMode.getName(), reuse_mode_);
+  readDynamicPropertyKeys(context);
+}
+
+void RetryFlowFile::onTrigger(core::ProcessContext* context, core::ProcessSession* session) {
+  std::shared_ptr<FlowFileRecord> flow_file = std::static_pointer_cast<FlowFileRecord> (session->get());
+  if (!flow_file) {
+    return;

Review comment:
       yield




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org