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



##########
File path: extensions/standard-processors/processors/RetryFlowFile.h
##########
@@ -0,0 +1,121 @@
+/**
+ *
+ * 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.
+ */
+#ifndef EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_RETRYFLOWFILE_H_
+#define EXTENSIONS_STANDARD_PROCESSORS_PROCESSORS_RETRYFLOWFILE_H_
+
+#include <atomic>
+#include <memory>
+#include <queue>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "core/state/nodes/MetricsBase.h"
+#include "FlowFileRecord.h"
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/Core.h"
+#include "core/Resource.h"
+#include "core/logging/LoggerConfiguration.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+class RetryFlowFile : public core::Processor {
+ public:
+  explicit RetryFlowFile(std::string name, utils::Identifier uuid = 
utils::Identifier())
+      : Processor(name, uuid),
+        logger_(logging::LoggerFactory<RetryFlowFile>::getLogger()) {}
+  // Destructor
+  virtual ~RetryFlowFile() = default;
+  // Processor Name
+  static constexpr char const* ProcessorName = "RetryFlowFile";
+  // Supported Properties
+  static core::Property RetryAttribute;
+  static core::Property MaximumRetries;
+  static core::Property PenalizeRetries;
+  static core::Property FailOnNonNumericalOverwrite;
+  static core::Property ReuseMode;
+  // Supported Relationships
+  static core::Relationship Retry;
+  static core::Relationship RetriesExceeded;
+  static core::Relationship Failure;
+  // ReuseMode allowable values
+  static constexpr char const* FAIL_ON_REUSE = "Fail on Reuse";
+  static constexpr char const* WARN_ON_REUSE = "Warn on Reuse";
+  static constexpr char const*   RESET_REUSE = "Reset Reuse";
+
+ public:
+  bool supportsDynamicProperties() override {
+    return true;
+  }
+  /**
+   * Function that's executed when the processor is scheduled.
+   * @param context process context.
+   * @param sessionFactory process session factory that is used when creating
+   * ProcessSession objects.
+   */
+  void onSchedule(core::ProcessContext* context, core::ProcessSessionFactory* 
/* sessionFactory */) override;
+  /**
+   * Execution trigger for the RetryFlowFile Processor
+   * @param context processor context
+   * @param session processor session reference.
+   */
+  void onTrigger(core::ProcessContext* context, core::ProcessSession* session) 
override;
+
+  // Initialize, overwrite by NiFi RetryFlowFile
+  void initialize() override;
+
+
+ private:
+  void readDynamicPropertyKeys(core::ProcessContext* context);
+  // Returns (1, true) on non-numerical or out-of-bounds retry value
+  std::pair<uint64_t, bool> getRetryPropertyValue(const 
std::shared_ptr<FlowFileRecord>& flow_file);
+  // Returns true on fail on reuse scenario
+  bool updateUUIDMarkerAndCheckFailOnReuse(const 
std::shared_ptr<FlowFileRecord>& flow_file);
+  bool setRetriesExceededAttributesOnFlowFile(core::ProcessContext* context, 
const std::shared_ptr<FlowFileRecord>& flow_file);
+
+  std::string retry_attribute_;
+  uint64_t maximum_retries_ = 3;  // The real default value is set by the 
default on the MaximumRetries property
+  bool penalize_retries_ =  true;  // The real default value is set by the 
default on the PenalizeRetries property
+  bool fail_on_non_numerical_overwrite_ = false;  // The real default value is 
set by the default on the FailOnNonNumericalOverwrite property
+  std::string reuse_mode_;

Review comment:
       This is definitely not worth the trouble. There is already a list of 
strings of allowable values, adding an enum and keeping the two sync is just an 
extra layer of complexity.




----------------------------------------------------------------
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:
[email protected]


Reply via email to