You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by is...@apache.org on 2023/01/24 12:41:31 UTC

[ignite-3] branch ignite-18583 updated (f901e1b754 -> 0b0264d873)

This is an automated email from the ASF dual-hosted git repository.

isapego pushed a change to branch ignite-18583
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


    from f901e1b754 IGNITE-18583 Fix warning
     new 3deeec5ff6 IGNITE-18583 Improve logging performance
     new 0b0264d873 IGNITE-18583 Implement node startup waiting

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../cpp/ignite/client/detail/cluster_connection.cpp          |  6 ++++--
 modules/platforms/cpp/ignite/client/detail/node_connection.h |  6 +++++-
 modules/platforms/cpp/ignite/client/ignite_logger.h          |  6 ++++++
 modules/platforms/cpp/tests/client-test/gtest_logger.h       |  4 ++++
 .../platforms/cpp/tests/client-test/ignite_runner_suite.h    |  2 +-
 modules/platforms/cpp/tests/client-test/main.cpp             | 12 ++++++++++--
 6 files changed, 30 insertions(+), 6 deletions(-)


[ignite-3] 01/02: IGNITE-18583 Improve logging performance

Posted by is...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

isapego pushed a commit to branch ignite-18583
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit 3deeec5ff6951c989c2d07a53ddffc359c9d8015
Author: Igor Sapego <is...@apache.org>
AuthorDate: Tue Jan 24 16:29:35 2023 +0400

    IGNITE-18583 Improve logging performance
---
 modules/platforms/cpp/ignite/client/detail/cluster_connection.cpp | 6 ++++--
 modules/platforms/cpp/ignite/client/detail/node_connection.h      | 6 +++++-
 modules/platforms/cpp/ignite/client/ignite_logger.h               | 6 ++++++
 modules/platforms/cpp/tests/client-test/gtest_logger.h            | 4 ++++
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/modules/platforms/cpp/ignite/client/detail/cluster_connection.cpp b/modules/platforms/cpp/ignite/client/detail/cluster_connection.cpp
index a26a03dcf4..283d5bad23 100644
--- a/modules/platforms/cpp/ignite/client/detail/cluster_connection.cpp
+++ b/modules/platforms/cpp/ignite/client/detail/cluster_connection.cpp
@@ -113,7 +113,8 @@ void cluster_connection::on_connection_closed(uint64_t id, std::optional<ignite_
 }
 
 void cluster_connection::on_message_received(uint64_t id, bytes_view msg) {
-    m_logger->log_debug("Message on Connection ID " + std::to_string(id) + ", size: " + std::to_string(msg.size()));
+    if (m_logger->is_debug_enabled())
+        m_logger->log_debug("Message on Connection ID " + std::to_string(id) + ", size: " + std::to_string(msg.size()));
 
     std::shared_ptr<node_connection> connection = find_client(id);
     if (!connection)
@@ -155,7 +156,8 @@ std::shared_ptr<node_connection> cluster_connection::find_client(uint64_t id) {
 }
 
 void cluster_connection::on_message_sent(uint64_t id) {
-    m_logger->log_debug("Message sent successfully on Connection ID " + std::to_string(id));
+    if (m_logger->is_debug_enabled())
+        m_logger->log_debug("Message sent successfully on Connection ID " + std::to_string(id));
 }
 
 void cluster_connection::remove_client(uint64_t id) {
diff --git a/modules/platforms/cpp/ignite/client/detail/node_connection.h b/modules/platforms/cpp/ignite/client/detail/node_connection.h
index 1a9ace1df9..a2dcc2544e 100644
--- a/modules/platforms/cpp/ignite/client/detail/node_connection.h
+++ b/modules/platforms/cpp/ignite/client/detail/node_connection.h
@@ -115,7 +115,11 @@ public:
             }
         }
 
-        m_logger->log_debug("Performing request: op=" + std::to_string(int(op)) + ", req_id=" + std::to_string(reqId));
+        if (m_logger->is_debug_enabled()) {
+            m_logger->log_debug(
+                "Performing request: op=" + std::to_string(int(op)) + ", req_id=" + std::to_string(reqId));
+        }
+
         bool sent = m_pool->send(m_id, std::move(message));
         if (!sent) {
             get_and_remove_handler(reqId);
diff --git a/modules/platforms/cpp/ignite/client/ignite_logger.h b/modules/platforms/cpp/ignite/client/ignite_logger.h
index 40d61cacb3..3e86556ac8 100644
--- a/modules/platforms/cpp/ignite/client/ignite_logger.h
+++ b/modules/platforms/cpp/ignite/client/ignite_logger.h
@@ -67,6 +67,12 @@ public:
      * @param message Debug message.
      */
     virtual void log_debug(std::string_view message) = 0;
+
+    /**
+     * Check whether debug is enabled.
+     * @return
+     */
+    [[nodiscard]] virtual bool is_debug_enabled() const = 0;
 };
 
 } // namespace ignite
diff --git a/modules/platforms/cpp/tests/client-test/gtest_logger.h b/modules/platforms/cpp/tests/client-test/gtest_logger.h
index ef0d6a9eed..8dafe45153 100644
--- a/modules/platforms/cpp/tests/client-test/gtest_logger.h
+++ b/modules/platforms/cpp/tests/client-test/gtest_logger.h
@@ -60,6 +60,10 @@ public:
             std::cout << "[          ] [ DEBUG ]   " + get_timestamp() + std::string(message) + '\n' << std::flush;
     }
 
+    [[nodiscard]] bool is_debug_enabled() const override {
+        return true;
+    }
+
 private:
     /**
      * Get timestamp in string format.


[ignite-3] 02/02: IGNITE-18583 Implement node startup waiting

Posted by is...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

isapego pushed a commit to branch ignite-18583
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit 0b0264d873bdf6e857b9ae239a1cbf2b1bec21e8
Author: Igor Sapego <is...@apache.org>
AuthorDate: Tue Jan 24 16:37:00 2023 +0400

    IGNITE-18583 Implement node startup waiting
---
 .../platforms/cpp/tests/client-test/ignite_runner_suite.h    |  2 +-
 modules/platforms/cpp/tests/client-test/main.cpp             | 12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h b/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h
index 20e152e735..3ffc59d38d 100644
--- a/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h
+++ b/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h
@@ -36,7 +36,7 @@ using namespace std::string_view_literals;
  * Test suite.
  */
 class ignite_runner_suite : public ::testing::Test {
-protected:
+public:
     static constexpr std::initializer_list<std::string_view> SINGLE_NODE_ADDR = {"127.0.0.1:10942"sv};
     static constexpr std::initializer_list<std::string_view> NODE_ADDRS = {"127.0.0.1:10942"sv, "127.0.0.1:10943"sv};
     static constexpr std::string_view TABLE_1 = "tbl1"sv;
diff --git a/modules/platforms/cpp/tests/client-test/main.cpp b/modules/platforms/cpp/tests/client-test/main.cpp
index 00a871e5d6..b3538207f9 100644
--- a/modules/platforms/cpp/tests/client-test/main.cpp
+++ b/modules/platforms/cpp/tests/client-test/main.cpp
@@ -16,6 +16,7 @@
  */
 
 #include "ignite_runner.h"
+#include "ignite_runner_suite.h"
 #include "test_utils.h"
 
 #include <ignite/common/ignite_error.h>
@@ -58,6 +59,14 @@ void set_process_abort_handler(std::function<void(int)> handler) {
     signal(SIGSEGV, signal_handler);
 }
 
+void wait_node_startup(std::chrono::seconds timeout) {
+    using namespace ignite;
+    for (auto addr : ignite_runner_suite::NODE_ADDRS) {
+        ignite_client_configuration cfg{addr};
+        auto client = ignite_client::start(cfg, timeout);
+    }
+}
+
 int main(int argc, char **argv) {
     if (ignite::single_node_mode())
         std::cout << "Tests run in a single-node mode." << std::endl;
@@ -75,8 +84,7 @@ int main(int argc, char **argv) {
     try {
         runner.start();
 
-        // TODO: Implement node startup await
-        std::this_thread::sleep_for(std::chrono::seconds(60));
+        wait_node_startup(std::chrono::seconds(60));
 
         ::testing::InitGoogleTest(&argc, argv);
         [[maybe_unused]] int run_res = RUN_ALL_TESTS();