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

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


The following commit(s) were added to refs/heads/main by this push:
     new 2efe7840f4 IGNITE-22526 Rename job_state to job_status and vice versa 
(#4002)
2efe7840f4 is described below

commit 2efe7840f4c7334d5dd0e223c8ec9c1c0928fa41
Author: Igor Sapego <[email protected]>
AuthorDate: Thu Jun 27 21:59:12 2024 +0400

    IGNITE-22526 Rename job_state to job_status and vice versa (#4002)
---
 .../cpp/ignite/client/compute/job_execution.cpp    |  4 +--
 .../cpp/ignite/client/compute/job_execution.h      | 20 ++++++-------
 .../cpp/ignite/client/compute/job_state.h          | 31 +++++++++++---------
 .../cpp/ignite/client/compute/job_status.h         | 33 ++++++++++------------
 .../ignite/client/detail/compute/compute_impl.cpp  | 32 ++++++++++-----------
 .../ignite/client/detail/compute/compute_impl.h    |  8 +++---
 .../client/detail/compute/job_execution_impl.cpp   | 16 +++++------
 .../client/detail/compute/job_execution_impl.h     | 20 ++++++-------
 .../cpp/tests/client-test/compute_test.cpp         | 24 ++++++++--------
 9 files changed, 94 insertions(+), 94 deletions(-)

diff --git a/modules/platforms/cpp/ignite/client/compute/job_execution.cpp 
b/modules/platforms/cpp/ignite/client/compute/job_execution.cpp
index 291e2b3579..3d83e5efdb 100644
--- a/modules/platforms/cpp/ignite/client/compute/job_execution.cpp
+++ b/modules/platforms/cpp/ignite/client/compute/job_execution.cpp
@@ -24,8 +24,8 @@ uuid job_execution::get_id() const {
     return m_impl->get_id();
 }
 
-void 
job_execution::get_status_async(ignite_callback<std::optional<job_status>> 
callback) {
-    m_impl->get_status_async(std::move(callback));
+void job_execution::get_state_async(ignite_callback<std::optional<job_state>> 
callback) {
+    m_impl->get_state_async(std::move(callback));
 }
 
 void job_execution::get_result_async(ignite_callback<std::optional<primitive>> 
callback) {
diff --git a/modules/platforms/cpp/ignite/client/compute/job_execution.h 
b/modules/platforms/cpp/ignite/client/compute/job_execution.h
index 1403895a7e..1159e05680 100644
--- a/modules/platforms/cpp/ignite/client/compute/job_execution.h
+++ b/modules/platforms/cpp/ignite/client/compute/job_execution.h
@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "ignite/client/compute/job_status.h"
+#include "ignite/client/compute/job_state.h"
 #include "ignite/common/detail/config.h"
 #include "ignite/common/ignite_result.h"
 #include "ignite/common/primitive.h"
@@ -69,24 +69,24 @@ public:
     [[nodiscard]] uuid get_id() const;
 
     /**
-     * Gets the job execution status asynchronously. Can be @c nullopt if the 
job status no longer exists due to
+     * Gets the job execution state asynchronously. Can be @c nullopt if the 
job state no longer exists due to
      * exceeding the retention time limit.
      *
-     * @param callback Callback to be called when the operation is complete. 
Called with the job status.
-     *  Can be @c nullopt if the job status no longer exists due to exceeding 
the retention time limit.
+     * @param callback Callback to be called when the operation is complete. 
Called with the job state.
+     *  Can be @c nullopt if the job state no longer exists due to exceeding 
the retention time limit.
      */
-    IGNITE_API void 
get_status_async(ignite_callback<std::optional<job_status>> callback);
+    IGNITE_API void get_state_async(ignite_callback<std::optional<job_state>> 
callback);
 
     /**
-     * Gets the job execution status. Can be @c nullopt if the job status no 
longer exists due to exceeding the
+     * Gets the job execution state. Can be @c nullopt if the job state no 
longer exists due to exceeding the
      * retention time limit.
      *
-     * @return The job status. Can be @c nullopt if the job status no longer 
exists due to exceeding the retention
+     * @return The job state. Can be @c nullopt if the job state no longer 
exists due to exceeding the retention
      *  time limit.
      */
-    IGNITE_API std::optional<job_status> get_status() {
-        return sync<std::optional<job_status>>(
-            [this](auto callback) mutable { 
get_status_async(std::move(callback)); });
+    IGNITE_API std::optional<job_state> get_state() {
+        return sync<std::optional<job_state>>(
+            [this](auto callback) mutable { 
get_state_async(std::move(callback)); });
     }
 
     /**
diff --git a/modules/platforms/cpp/ignite/client/compute/job_state.h 
b/modules/platforms/cpp/ignite/client/compute/job_state.h
index 4cd0a7a218..a2030497c7 100644
--- a/modules/platforms/cpp/ignite/client/compute/job_state.h
+++ b/modules/platforms/cpp/ignite/client/compute/job_state.h
@@ -17,29 +17,32 @@
 
 #pragma once
 
+#include "ignite/client/compute/job_status.h"
+#include "ignite/common/ignite_timestamp.h"
+#include "ignite/common/uuid.h"
+
+#include <optional>
+
 namespace ignite {
 
 /**
  * Compute job state.
  */
-enum class job_state {
-    /// The job is submitted and waiting for an execution start.
-    QUEUED,
-
-    /// The job is being executed.
-    EXECUTING,
+struct job_state {
+    /// Job ID.
+    uuid id{};
 
-    /// The job was unexpectedly terminated during execution.
-    FAILED,
+    /// Status.
+    job_status status{job_status::QUEUED};
 
-    /// The job was executed successfully and the execution result was 
returned.
-    COMPLETED,
+    /// Create time.
+    ignite_timestamp create_time{};
 
-    /// The job has received the cancel command, but is still running.
-    CANCELING,
+    /// Start time (@c std::nullopt when not yet started).
+    std::optional<ignite_timestamp> start_time{};
 
-    /// The job was successfully cancelled.
-    CANCELED
+    /// Finish time (@c std::nullopt when not yet finished).
+    std::optional<ignite_timestamp> finish_time{};
 };
 
 } // namespace ignite
diff --git a/modules/platforms/cpp/ignite/client/compute/job_status.h 
b/modules/platforms/cpp/ignite/client/compute/job_status.h
index e9d0b7a429..389cf450e0 100644
--- a/modules/platforms/cpp/ignite/client/compute/job_status.h
+++ b/modules/platforms/cpp/ignite/client/compute/job_status.h
@@ -17,32 +17,29 @@
 
 #pragma once
 
-#include "ignite/client/compute/job_state.h"
-#include "ignite/common/ignite_timestamp.h"
-#include "ignite/common/uuid.h"
-
-#include <optional>
-
 namespace ignite {
 
 /**
- * Compute job state.
+ * Compute job status.
  */
-struct job_status {
-    /// Job ID.
-    uuid id{};
+enum class job_status {
+    /// The job is submitted and waiting for an execution start.
+    QUEUED,
+
+    /// The job is being executed.
+    EXECUTING,
 
-    /// State.
-    job_state state{job_state::QUEUED};
+    /// The job was unexpectedly terminated during execution.
+    FAILED,
 
-    /// Create time.
-    ignite_timestamp create_time{};
+    /// The job was executed successfully and the execution result was 
returned.
+    COMPLETED,
 
-    /// Start time (@c std::nullopt when not yet started).
-    std::optional<ignite_timestamp> start_time{};
+    /// The job has received the cancel command, but is still running.
+    CANCELING,
 
-    /// Finish time (@c std::nullopt when not yet finished).
-    std::optional<ignite_timestamp> finish_time{};
+    /// The job was successfully cancelled.
+    CANCELED
 };
 
 } // namespace ignite
diff --git 
a/modules/platforms/cpp/ignite/client/detail/compute/compute_impl.cpp 
b/modules/platforms/cpp/ignite/client/detail/compute/compute_impl.cpp
index 9747aa1c04..a41427a4b2 100644
--- a/modules/platforms/cpp/ignite/client/detail/compute/compute_impl.cpp
+++ b/modules/platforms/cpp/ignite/client/detail/compute/compute_impl.cpp
@@ -80,16 +80,16 @@ std::optional<primitive> 
read_primitive_from_binary_tuple_nullable(protocol::rea
 }
 
 /**
- * Read primitive from a stream, which is encoded as a binary tuple.
+ * Read job state from a stream, which is encoded as a binary tuple.
  *
  * @param reader Reader.
  * @return Value.
  */
-job_status read_job_status(protocol::reader &reader) {
-    job_status res;
+job_state read_job_state(protocol::reader &reader) {
+    job_state res;
 
     res.id = reader.read_uuid();
-    res.state = job_state(reader.read_int32());
+    res.status = job_status(reader.read_int32());
 
     auto create_time = reader.read_timestamp_opt();
     res.create_time = create_time ? *create_time : ignite_timestamp{};
@@ -100,16 +100,16 @@ job_status read_job_status(protocol::reader &reader) {
 }
 
 /**
- * Read primitive from a stream, which is encoded as a binary tuple.
+ * Read job state from a stream, which is encoded as a binary tuple.
  *
  * @param reader Reader.
- * @return Value.
+ * @return Value or std::nullopt on nil in stream.
  */
-std::optional<job_status> read_job_status_opt(protocol::reader &reader) {
+std::optional<job_state> read_job_state_opt(protocol::reader &reader) {
     if (reader.try_read_nil())
         return std::nullopt;
 
-    return read_job_status(reader);
+    return read_job_state(reader);
 }
 
 /**
@@ -196,15 +196,15 @@ public:
             this->m_handling_complete = true;
 
             std::optional<primitive> res{};
-            job_status status;
+            job_state state;
 
             auto read_res = result_of_operation<void>([&]() {
                 res = read_primitive_from_binary_tuple_nullable(reader);
-                status = read_job_status(reader);
+                state = read_job_state(reader);
             });
 
             if (!m_execution) {
-                m_execution = std::make_shared<job_execution_impl>(status.id, 
std::move(m_compute));
+                m_execution = std::make_shared<job_execution_impl>(state.id, 
std::move(m_compute));
                 result_of_operation<void>([&]() { 
this->m_callback(job_execution{m_execution}); });
             }
 
@@ -216,7 +216,7 @@ public:
 
             auto handle_res = result_of_operation<void>([&]() {
                 m_execution->set_result(res);
-                m_execution->set_final_status(status);
+                m_execution->set_final_state(state);
             });
 
             return handle_res;
@@ -301,14 +301,14 @@ void compute_impl::submit_colocated_async(const 
std::string &table_name, const i
     m_tables->get_table_async(table_name, std::move(on_table_get));
 }
 
-void compute_impl::get_status_async(uuid id, 
ignite_callback<std::optional<job_status>> callback) {
+void compute_impl::get_state_async(uuid id, 
ignite_callback<std::optional<job_state>> callback) {
     auto writer_func = [id](protocol::writer &writer) { writer.write(id); };
 
-    auto reader_func = [](protocol::reader &reader) -> 
std::optional<job_status> {
-        return read_job_status_opt(reader);
+    auto reader_func = [](protocol::reader &reader) -> 
std::optional<job_state> {
+        return read_job_state_opt(reader);
     };
 
-    m_connection->perform_request<std::optional<job_status>>(
+    m_connection->perform_request<std::optional<job_state>>(
         protocol::client_operation::COMPUTE_GET_STATUS, writer_func, 
std::move(reader_func), std::move(callback));
 }
 
diff --git a/modules/platforms/cpp/ignite/client/detail/compute/compute_impl.h 
b/modules/platforms/cpp/ignite/client/detail/compute/compute_impl.h
index 41b6307efb..68b837a4bc 100644
--- a/modules/platforms/cpp/ignite/client/detail/compute/compute_impl.h
+++ b/modules/platforms/cpp/ignite/client/detail/compute/compute_impl.h
@@ -81,14 +81,14 @@ public:
         ignite_callback<job_execution> callback);
 
     /**
-     * Gets the job execution status. Can be @c nullopt if the job status no 
longer exists due to exceeding the
+     * Gets the job execution state. Can be @c nullopt if the job state no 
longer exists due to exceeding the
      * retention time limit.
      *
      * @param id Job ID.
-     * @param callback Callback to be called when the operation is complete. 
Contains the job status. Can be @c nullopt
-     *  if the job status no longer exists due to exceeding the retention time 
limit.
+     * @param callback Callback to be called when the operation is complete. 
Contains the job state. Can be @c nullopt
+     *  if the job state no longer exists due to exceeding the retention time 
limit.
      */
-    void get_status_async(uuid id, ignite_callback<std::optional<job_status>> 
callback);
+    void get_state_async(uuid id, ignite_callback<std::optional<job_state>> 
callback);
 
     /**
      * Cancels the job execution.
diff --git 
a/modules/platforms/cpp/ignite/client/detail/compute/job_execution_impl.cpp 
b/modules/platforms/cpp/ignite/client/detail/compute/job_execution_impl.cpp
index 418d0bd8b7..3679984854 100644
--- a/modules/platforms/cpp/ignite/client/detail/compute/job_execution_impl.cpp
+++ b/modules/platforms/cpp/ignite/client/detail/compute/job_execution_impl.cpp
@@ -55,23 +55,23 @@ void 
job_execution_impl::set_result(std::optional<primitive> result) {
     }
 }
 
-void 
job_execution_impl::get_status_async(ignite_callback<std::optional<job_status>> 
callback) {
+void 
job_execution_impl::get_state_async(ignite_callback<std::optional<job_state>> 
callback) {
     std::unique_lock<std::mutex> guard(m_mutex);
 
-    if (m_final_status) {
-        auto copy{m_final_status};
+    if (m_final_state) {
+        auto copy{m_final_state};
         guard.unlock();
 
         callback({std::move(copy)});
     } else {
-        m_compute->get_status_async(m_id, std::move(callback));
+        m_compute->get_state_async(m_id, std::move(callback));
     }
 }
 
-void job_execution_impl::set_final_status(const job_status &status) {
+void job_execution_impl::set_final_state(const job_state &status) {
     std::lock_guard<std::mutex> guard(m_mutex);
 
-    m_final_status = status;
+    m_final_state = status;
 }
 
 void job_execution_impl::set_error(ignite_error error) {
@@ -92,7 +92,7 @@ void 
job_execution_impl::cancel_async(ignite_callback<job_execution::operation_r
     bool status_set;
     {
         std::lock_guard<std::mutex> guard(m_mutex);
-        status_set = m_final_status.has_value();
+        status_set = m_final_state.has_value();
     }
 
     if (status_set) {
@@ -109,7 +109,7 @@ void job_execution_impl::change_priority_async(
     bool status_set;
     {
         std::lock_guard<std::mutex> guard(m_mutex);
-        status_set = m_final_status.has_value();
+        status_set = m_final_state.has_value();
     }
 
     if (status_set) {
diff --git 
a/modules/platforms/cpp/ignite/client/detail/compute/job_execution_impl.h 
b/modules/platforms/cpp/ignite/client/detail/compute/job_execution_impl.h
index 6a25cff2e0..5701771371 100644
--- a/modules/platforms/cpp/ignite/client/detail/compute/job_execution_impl.h
+++ b/modules/platforms/cpp/ignite/client/detail/compute/job_execution_impl.h
@@ -18,7 +18,7 @@
 #pragma once
 
 #include "ignite/client/compute/job_execution.h"
-#include "ignite/client/compute/job_status.h"
+#include "ignite/client/compute/job_state.h"
 #include "ignite/client/detail/cluster_connection.h"
 #include "ignite/common/detail/config.h"
 #include "ignite/common/ignite_result.h"
@@ -71,20 +71,20 @@ public:
     void set_result(std::optional<primitive> result);
 
     /**
-     * Gets the job execution status. Can be @c nullopt if the job status no 
longer exists due to exceeding the
+     * Gets the job execution state. Can be @c nullopt if the job state no 
longer exists due to exceeding the
      * retention time limit.
      *
-     * @param callback Callback to be called when the operation is complete. 
Contains the job status. Can be @c nullopt
-     *  if the job status no longer exists due to exceeding the retention time 
limit.
+     * @param callback Callback to be called when the operation is complete. 
Contains the job state. Can be @c nullopt
+     *  if the job state no longer exists due to exceeding the retention time 
limit.
      */
-    void get_status_async(ignite_callback<std::optional<job_status>> callback);
+    void get_state_async(ignite_callback<std::optional<job_state>> callback);
 
     /**
-     * Set final status.
+     * Set final state.
      *
-     * @param status Execution status.
+     * @param state Execution state.
      */
-    void set_final_status(const job_status &status);
+    void set_final_state(const job_state &state);
 
     /**
      * Set error.
@@ -119,8 +119,8 @@ private:
     /** Mutex. Should be held to change any data. */
     std::mutex m_mutex;
 
-    /** Final status. */
-    std::optional<job_status> m_final_status;
+    /** Final state. */
+    std::optional<job_state> m_final_state;
 
     /** Execution result. First optional to understand if the result is 
available. */
     std::optional<std::optional<primitive>> m_result;
diff --git a/modules/platforms/cpp/tests/client-test/compute_test.cpp 
b/modules/platforms/cpp/tests/client-test/compute_test.cpp
index 4435d467b3..2868abe78f 100644
--- a/modules/platforms/cpp/tests/client-test/compute_test.cpp
+++ b/modules/platforms/cpp/tests/client-test/compute_test.cpp
@@ -456,10 +456,10 @@ TEST_F(compute_test, job_execution_status_executing) {
 
     auto execution = m_client.get_compute().submit({get_node(1)}, {}, 
SLEEP_JOB, {sleep_ms}, {});
 
-    auto status = execution.get_status();
+    auto state = execution.get_state();
 
-    ASSERT_TRUE(status.has_value());
-    EXPECT_EQ(job_state::EXECUTING, status->state);
+    ASSERT_TRUE(state.has_value());
+    EXPECT_EQ(job_status::EXECUTING, state->status);
 }
 
 TEST_F(compute_test, DISABLED_job_execution_status_completed) {
@@ -468,10 +468,10 @@ TEST_F(compute_test, 
DISABLED_job_execution_status_completed) {
     auto execution = m_client.get_compute().submit({get_node(1)}, {}, 
SLEEP_JOB, {sleep_ms}, {});
     execution.get_result();
 
-    auto status = execution.get_status();
+    auto state = execution.get_state();
 
-    ASSERT_TRUE(status.has_value());
-    EXPECT_EQ(job_state::COMPLETED, status->state);
+    ASSERT_TRUE(state.has_value());
+    EXPECT_EQ(job_status::COMPLETED, state->status);
 }
 
 TEST_F(compute_test, job_execution_status_failed) {
@@ -488,10 +488,10 @@ TEST_F(compute_test, job_execution_status_failed) {
         },
         ignite_error);
 
-    auto status = execution.get_status();
+    auto state = execution.get_state();
 
-    ASSERT_TRUE(status.has_value());
-    EXPECT_EQ(job_state::FAILED, status->state);
+    ASSERT_TRUE(state.has_value());
+    EXPECT_EQ(job_status::FAILED, state->status);
 }
 
 TEST_F(compute_test, job_execution_cancel) {
@@ -500,10 +500,10 @@ TEST_F(compute_test, job_execution_cancel) {
     auto execution = m_client.get_compute().submit({get_node(1)}, {}, 
SLEEP_JOB, {sleep_ms}, {});
     execution.cancel();
 
-    auto status = execution.get_status();
+    auto state = execution.get_state();
 
-    ASSERT_TRUE(status.has_value());
-    EXPECT_EQ(job_state::CANCELED, status->state);
+    ASSERT_TRUE(state.has_value());
+    EXPECT_EQ(job_status::CANCELED, state->status);
 }
 
 TEST_F(compute_test, job_execution_change_priority) {

Reply via email to