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 2022/03/09 11:42:13 UTC

[GitHub] [nifi-minifi-cpp] lordgamez opened a new pull request #1280: MINIFICPP-1770 Add C2 NO_OPERATION response if property update is NoOp

lordgamez opened a new pull request #1280:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1280


   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1280: MINIFICPP-1770 Add C2 NO_OPERATION response if property update is NoOp

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1280:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1280#discussion_r831104636



##########
File path: libminifi/src/Configure.cpp
##########
@@ -30,6 +30,14 @@ namespace nifi {
 namespace minifi {
 
 bool Configure::get(const std::string& key, std::string& value) const {
+  const std::string_view log_prefix = "nifi.log.";

Review comment:
       Good idea, updated in 50839c9804f63ec6a588c765821dce6b170b3af0




-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1280: MINIFICPP-1770 Add C2 NO_OPERATION response if property update is NoOp

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1280:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1280#discussion_r831057966



##########
File path: libminifi/include/c2/C2Agent.h
##########
@@ -150,10 +150,16 @@ class C2Agent : public state::UpdateController {
    */
   void handle_describe(const C2ContentResponse &resp);
 
+
+  enum class UpdateResult {
+    NO_UPDATE,
+    UPDATE_SUCCESFUL,

Review comment:
       typo
   ```suggestion
       UPDATE_SUCCESSFUL,
   ```

##########
File path: libminifi/src/Configure.cpp
##########
@@ -30,6 +30,14 @@ namespace nifi {
 namespace minifi {
 
 bool Configure::get(const std::string& key, std::string& value) const {
+  const std::string_view log_prefix = "nifi.log.";

Review comment:
       Could you make this delegate to the `std::optional`-returning overload, to reduce code duplication? And the prefix could be `static constexpr` to force the construction to compile-time.
   ```suggestion
     static constexpr std::string_view log_prefix = "nifi.log.";
   ```




-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1280: MINIFICPP-1770 Add C2 NO_OPERATION response if property update is NoOp

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1280:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1280#discussion_r831206143



##########
File path: extensions/http-curl/tests/HTTPHandlers.h
##########
@@ -792,20 +792,40 @@ class C2AcknowledgeHandler : public ServerAwareHandler {
     rapidjson::Document root;
     root.Parse(req.data(), req.size());
     if (root.IsObject() && root.HasMember("operationId")) {
-      std::lock_guard<std::mutex> guard(mtx_);
+      std::lock_guard<std::mutex> guard(ack_operations_mtx_);

Review comment:
       `ack_operations_mtx_` is released before locking `apply_count_mtx_`, so they are never locked at the same time. Since only one is held at a time, it's not possible that this function and another thread are waiting for each other.




-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] adamdebreceni closed pull request #1280: MINIFICPP-1770 Add C2 NO_OPERATION response if property update is NoOp

Posted by GitBox <gi...@apache.org>.
adamdebreceni closed pull request #1280:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1280


   


-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1280: MINIFICPP-1770 Add C2 NO_OPERATION response if property update is NoOp

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1280:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1280#discussion_r831104449



##########
File path: libminifi/include/c2/C2Agent.h
##########
@@ -150,10 +150,16 @@ class C2Agent : public state::UpdateController {
    */
   void handle_describe(const C2ContentResponse &resp);
 
+
+  enum class UpdateResult {
+    NO_UPDATE,
+    UPDATE_SUCCESFUL,

Review comment:
       Good catch, fixed in 50839c9804f63ec6a588c765821dce6b170b3af0




-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1280: MINIFICPP-1770 Add C2 NO_OPERATION response if property update is NoOp

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1280:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1280#discussion_r832084357



##########
File path: extensions/http-curl/tests/HTTPHandlers.h
##########
@@ -792,20 +792,40 @@ class C2AcknowledgeHandler : public ServerAwareHandler {
     rapidjson::Document root;
     root.Parse(req.data(), req.size());
     if (root.IsObject() && root.HasMember("operationId")) {
-      std::lock_guard<std::mutex> guard(mtx_);
+      std::lock_guard<std::mutex> guard(ack_operations_mtx_);
       acknowledged_operations_.insert(root["operationId"].GetString());
     }
+
+    if (root.IsObject() && root.HasMember("operationState")) {
+      if (root["operationState"].IsObject() && root["operationState"].HasMember("state")) {
+        std::lock_guard<std::mutex> guard(apply_count_mtx_);
+        auto result_state = root["operationState"]["state"].GetString();
+        if (apply_count_.find(result_state) != apply_count_.end()) {

Review comment:
       Good call! Updated in 4198ad6599cd8ae739342b5376347c60329d53b6




-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] adam-markovics commented on a change in pull request #1280: MINIFICPP-1770 Add C2 NO_OPERATION response if property update is NoOp

Posted by GitBox <gi...@apache.org>.
adam-markovics commented on a change in pull request #1280:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1280#discussion_r831157243



##########
File path: extensions/http-curl/tests/HTTPHandlers.h
##########
@@ -792,20 +792,40 @@ class C2AcknowledgeHandler : public ServerAwareHandler {
     rapidjson::Document root;
     root.Parse(req.data(), req.size());
     if (root.IsObject() && root.HasMember("operationId")) {
-      std::lock_guard<std::mutex> guard(mtx_);
+      std::lock_guard<std::mutex> guard(ack_operations_mtx_);

Review comment:
       With locking two mutexes, you always have to be careful. Is it possible to have another thread locking them in the reverse order than here? So, first `apply_count_mtx_` and then `ack_operations_mtx_`? That could result in a deadlock. It's possible by calling `isAcknowledged` first and `getApplyCount` second, for example.




-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1280: MINIFICPP-1770 Add C2 NO_OPERATION response if property update is NoOp

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1280:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1280#discussion_r832004923



##########
File path: extensions/http-curl/tests/HTTPHandlers.h
##########
@@ -792,20 +792,40 @@ class C2AcknowledgeHandler : public ServerAwareHandler {
     rapidjson::Document root;
     root.Parse(req.data(), req.size());
     if (root.IsObject() && root.HasMember("operationId")) {
-      std::lock_guard<std::mutex> guard(mtx_);
+      std::lock_guard<std::mutex> guard(ack_operations_mtx_);
       acknowledged_operations_.insert(root["operationId"].GetString());
     }
+
+    if (root.IsObject() && root.HasMember("operationState")) {
+      if (root["operationState"].IsObject() && root["operationState"].HasMember("state")) {
+        std::lock_guard<std::mutex> guard(apply_count_mtx_);
+        auto result_state = root["operationState"]["state"].GetString();
+        if (apply_count_.find(result_state) != apply_count_.end()) {

Review comment:
       note: `++apply_count[result_state]` would achieve the same result




-- 
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-unsubscribe@nifi.apache.org

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