From faa56b82ee45065ed28c4e6903a742b126c0cbb2 Mon Sep 17 00:00:00 2001 From: Ferenc Gerlits Date: Thu, 16 Jan 2025 09:59:27 +0100 Subject: [PATCH] MINIFICPP-2498 Funnels should be usable as terminators The output relationship of a funnel is now auto-terminated by default. You can connect it to a processor's input, but you don't have to. --- .../features/core_functionality.feature | 8 ++++++ libminifi/include/Funnel.h | 2 ++ libminifi/src/Funnel.cpp | 26 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 libminifi/src/Funnel.cpp diff --git a/docker/test/integration/features/core_functionality.feature b/docker/test/integration/features/core_functionality.feature index ef4bc5df21..21b071f64d 100644 --- a/docker/test/integration/features/core_functionality.feature +++ b/docker/test/integration/features/core_functionality.feature @@ -39,6 +39,14 @@ Feature: Core flow functionalities Then at least one flowfile with the content "first_custom_text" is placed in the monitored directory in less than 20 seconds And at least one flowfile with the content "second_custom_text" is placed in the monitored directory in less than 20 seconds + @CORE + Scenario: A funnel can be used as a terminator + Given a GenerateFlowFile processor with the "Data Format" property set to "Text" + And a Funnel with the name "TerminalFunnel" is set up + And the "success" relationship of the GenerateFlowFile processor is connected to the TerminalFunnel + When the MiNiFi instance starts up + Then the Minifi logs do not contain the following message: "Connect empty for non auto terminated relationship" after 5 seconds + @CORE Scenario: The default configuration uses RocksDB for both the flow file and content repositories Given a GenerateFlowFile processor with the "Data Format" property set to "Text" diff --git a/libminifi/include/Funnel.h b/libminifi/include/Funnel.h index dfdcca7dfe..b6b3a73633 100644 --- a/libminifi/include/Funnel.h +++ b/libminifi/include/Funnel.h @@ -31,6 +31,8 @@ class Funnel final : public ForwardingNode { MINIFIAPI static constexpr core::annotation::Input InputRequirement = core::annotation::Input::INPUT_REQUIRED; ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS + + void onSchedule(core::ProcessContext&, core::ProcessSessionFactory&) override; }; } // namespace org::apache::nifi::minifi diff --git a/libminifi/src/Funnel.cpp b/libminifi/src/Funnel.cpp new file mode 100644 index 0000000000..fee7ccf78f --- /dev/null +++ b/libminifi/src/Funnel.cpp @@ -0,0 +1,26 @@ +/** + * 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 "Funnel.h" + +namespace org::apache::nifi::minifi { + +void Funnel::onSchedule(core::ProcessContext&, core::ProcessSessionFactory&) { + addAutoTerminatedRelationship(Success); +} + +} // namespace org::apache::nifi::minifi