lordgamez commented on code in PR #1568:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1568#discussion_r1200792149


##########
libminifi/include/c2/ControllerSocketProtocol.h:
##########
@@ -61,6 +66,46 @@ class ControllerSocketProtocol {
   std::weak_ptr<ControllerSocketReporter> controller_socket_reporter_;
   std::shared_ptr<Configure> configuration_;
   std::shared_ptr<core::logging::Logger> logger_ = 
core::logging::LoggerFactory<ControllerSocketProtocol>::getLogger();
+  std::mutex initialization_mutex_;
+
+  // Some commands need to restart the controller socket to reinitialize the 
socket with new data for example new SSL data in case of a flow update
+  // These commands are handled on a separate thread, and while these commands 
are handled other incoming commands are dropped
+  class SocketRestartCommandProcessor {
+   public:
+    explicit SocketRestartCommandProcessor(state::StateMonitor& update_sink_);
+    ~SocketRestartCommandProcessor();
+
+    enum class Command {
+      FLOW_UPDATE,
+      START
+    };
+
+    struct CommandData {
+      Command command;
+      std::string data;
+    };
+
+    void enqueue(const CommandData& command_data) {
+      is_socket_restarting_ = true;
+      command_queue_.enqueue(command_data);
+      command_queue_condition_variable_.notify_all();
+    }
+
+    bool isSocketRestarting() const {
+      return is_socket_restarting_;
+    }
+
+   private:
+    mutable std::atomic_bool is_socket_restarting_ = false;
+    state::StateMonitor& update_sink_;
+    std::thread command_processor_thread_;
+    std::mutex cv_mutex_;
+    std::condition_variable command_queue_condition_variable_;
+    std::atomic_bool running_ = true;
+    moodycamel::ConcurrentQueue<CommandData> command_queue_;

Review Comment:
   Thanks for the detailed description, good to know these differences. I 
replaced the in `moodycamel::ConcurrentQueue` with the 
`utils::ConditionConcurrentQueue` in 87bce05ddabb9a2ee89ecac9681c123c0adbb17a



##########
cmake/MiNiFiOptions.cmake:
##########
@@ -120,6 +120,8 @@ add_minifi_option(ENABLE_KUBERNETES "Enables the Kubernetes 
extensions." ON)
 add_minifi_option(ENABLE_TEST_PROCESSORS "Enables test processors" OFF)
 add_minifi_option(ENABLE_PROMETHEUS "Enables Prometheus support." ON)
 add_minifi_option(DISABLE_JEMALLOC "Disables jemalloc." OFF)
+add_minifi_option(DISABLE_CURL "Disables curl." OFF)
+add_minifi_option(DISABLE_CONTROLLER "Disables build of MiNiFi controller 
binary." OFF)

Review Comment:
   These options were present already so I didn't want to change them as they 
may break our builds. The options are only added here to be available for the 
docker builds as well.



##########
docker/test/integration/features/minifi_controller.feature:
##########
@@ -0,0 +1,76 @@
+# 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.
+
+Feature: MiNiFi Controller functionalities
+  Test MiNiFi Controller functionalities
+
+  Background:
+    Given the content of "/tmp/output" is monitored
+
+  Scenario: Flow config can be updated through MiNiFi controller
+    Given a GenerateFlowFile processor
+    And a file with the content "test" is present in "/tmp/input"
+    And controller socket properties are set up
+    When all instances start up
+    And MiNiFi config is updated through MiNiFi controller
+    Then a flowfile with the content "test" is placed in the monitored 
directory in less than 60 seconds
+    And the updated config is persisted
+
+  Scenario: A component can be stopped
+    Given a GenerateFlowFile processor
+    And a file with the content "test" is present in "/tmp/input"
+    And controller socket properties are set up
+    When all instances start up
+    And the GenerateFlowFile component is stopped through MiNiFi controller
+    Then the GenerateFlowFile component is not running
+    And the FlowController component is running
+
+  Scenario: If FlowController is stopped all other components are stopped
+    Given a GenerateFlowFile processor
+    And a file with the content "test" is present in "/tmp/input"
+    And controller socket properties are set up
+    When all instances start up
+    And the FlowController component is stopped through MiNiFi controller
+    And the FlowController component is started through MiNiFi controller
+    Then the GenerateFlowFile component is not running
+    And the FlowController component is not running
+
+  Scenario: FlowController can be stopped and restarted
+    Given a GenerateFlowFile processor
+    And a file with the content "test" is present in "/tmp/input"
+    And controller socket properties are set up
+    When all instances start up
+    And the FlowController component is stopped through MiNiFi controller
+    And the FlowController component is started through MiNiFi controller
+    Then the GenerateFlowFile component is running
+    And the FlowController component is running

Review Comment:
   Good catch! As the start operation is not immediate the previous test could 
still pass with the negative checks before the start operation was finished. I 
fixed the test in 87bce05ddabb9a2ee89ecac9681c123c0adbb17a



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

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

Reply via email to