[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_r454393012 ## File path: libminifi/include/core/PropertyValidation.h ## @@ -259,6 +259,22 @@ class UnsignedLongValidator : public PropertyValidator { } }; +class NonBlankValidator : public PropertyValidator { + public: + explicit NonBlankValidator(const std::string& name) + : PropertyValidator(name) { + } + ~NonBlankValidator() override = default; + + ValidationResult validate(const std::string& subject, const std::shared_ptr& input) const final { +return validate(subject, input->getStringValue()); Review comment: How would it validate not being blank? I think we should trim both left and right and check if the result is empty. 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: us...@infra.apache.org
[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_r453631636 ## File path: extensions/standard-processors/processors/RetryFlowFile.cpp ## @@ -0,0 +1,183 @@ +/** + * + * 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") Review comment: Looking at NiFi code is always a good source of hints and what we see there worth consideration, but it's not an unerring guidance or revelation. In case we think that our implementation definitely requires a valid value for the given property to work, I think we should make it required. In case of properties that define attribute names I would also consider something like this: https://www.javadoc.io/doc/org.apache.nifi/nifi-processor-utils/0.7.0/org/apache/nifi/processor/util/StandardValidators.html#NON_BLANK_VALIDATOR As we request a valid string here that can name an attribute. 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: us...@infra.apache.org
[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_r450889316 ## File path: extensions/standard-processors/processors/RetryFlowFile.cpp ## @@ -0,0 +1,183 @@ +/** + * + * 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(3) Review comment: This as well ## File path: extensions/standard-processors/processors/RetryFlowFile.cpp ## @@ -0,0 +1,183 @@ +/** + * + * 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") Review comment: Shouldn't this be required? ## File path: extensions/standard-processors/processors/RetryFlowFile.cpp ## @@ -0,0 +1,183 @@ +/** + * + * 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( +
[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_r445507956 ## 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(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(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(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({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(),
[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_r445507956 ## 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(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(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(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({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(),
[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_r445442179 ## 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(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(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(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({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(),
[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_r445441788 ## 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(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(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(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({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(),
[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_r445441133 ## 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(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(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(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({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(),
[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(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(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(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({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(),