This is an automated email from the ASF dual-hosted git repository. isapego pushed a commit to branch ignite-17607 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 9212e30294b90792fff56bed918715ccf3b4331b Author: Igor Sapego <[email protected]> AuthorDate: Tue Mar 7 03:00:44 2023 +0300 IGNITE-17607 Compute stub --- modules/platforms/cpp/CMakeLists.txt | 2 +- modules/platforms/cpp/cmake/ignite_test.cmake | 2 +- modules/platforms/cpp/ignite/client/CMakeLists.txt | 3 + .../cpp/ignite/client/compute/compute.cpp | 28 +++++++ .../platforms/cpp/ignite/client/compute/compute.h | 83 +++++++++++++++++++++ .../cpp/ignite/client/network/cluster_node.h | 87 ++++++++++++++++++++++ modules/platforms/cpp/ignite/common/CMakeLists.txt | 1 + .../cpp/ignite/{network => common}/end_point.h | 2 +- .../platforms/cpp/ignite/network/async_handler.h | 2 +- .../network/detail/linux/connecting_context.h | 7 +- .../network/detail/linux/linux_async_client.h | 8 +- .../detail/linux/linux_async_worker_thread.h | 11 ++- .../ignite/network/detail/win/win_async_client.h | 8 +- 13 files changed, 222 insertions(+), 22 deletions(-) diff --git a/modules/platforms/cpp/CMakeLists.txt b/modules/platforms/cpp/CMakeLists.txt index ca7bc3c401..a12077763f 100644 --- a/modules/platforms/cpp/CMakeLists.txt +++ b/modules/platforms/cpp/CMakeLists.txt @@ -15,7 +15,7 @@ # limitations under the License. # -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.18) project(Ignite.C++ VERSION 3 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) diff --git a/modules/platforms/cpp/cmake/ignite_test.cmake b/modules/platforms/cpp/cmake/ignite_test.cmake index d80e604c7f..108fcf704e 100644 --- a/modules/platforms/cpp/cmake/ignite_test.cmake +++ b/modules/platforms/cpp/cmake/ignite_test.cmake @@ -38,5 +38,5 @@ function(ignite_test TEST_NAME TEST_SOURCE) target_link_libraries(${TEST_NAME} ${IGNITE_TEST_LIBS} GTest::GTest GTest::Main) endif() - gtest_discover_tests(${TEST_NAME}) + gtest_discover_tests(${TEST_NAME} XML_OUTPUT_DIR ${CMAKE_BINARY_DIR}/Testing/Result) endfunction() diff --git a/modules/platforms/cpp/ignite/client/CMakeLists.txt b/modules/platforms/cpp/ignite/client/CMakeLists.txt index 53bf6486d8..e84687dce8 100644 --- a/modules/platforms/cpp/ignite/client/CMakeLists.txt +++ b/modules/platforms/cpp/ignite/client/CMakeLists.txt @@ -21,6 +21,7 @@ set(TARGET ${PROJECT_NAME}) set(SOURCES ignite_client.cpp + compute/compute.cpp sql/sql.cpp sql/result_set.cpp table/key_value_view.cpp @@ -41,6 +42,8 @@ set(PUBLIC_HEADERS ignite_client.h ignite_client_configuration.h ignite_logger.h + compute/compute.h + network/cluster_node.h sql/sql.h table/ignite_tuple.h table/key_value_view.h diff --git a/modules/platforms/cpp/ignite/client/compute/compute.cpp b/modules/platforms/cpp/ignite/client/compute/compute.cpp new file mode 100644 index 0000000000..8476afbaab --- /dev/null +++ b/modules/platforms/cpp/ignite/client/compute/compute.cpp @@ -0,0 +1,28 @@ +/* + * 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 "ignite/client/compute/compute.h" +//#include "ignite/client/detail/compute/compute_impl.h" + +namespace ignite { + +void compute::execute_async(std::vector<cluster_node> nodes, std::string_view job_class_name, + std::vector<primitive> args, ignite_callback<std::optional<primitive>> callback) { + // TODO: Implement me +} + +} // namespace ignite diff --git a/modules/platforms/cpp/ignite/client/compute/compute.h b/modules/platforms/cpp/ignite/client/compute/compute.h new file mode 100644 index 0000000000..8f142bb835 --- /dev/null +++ b/modules/platforms/cpp/ignite/client/compute/compute.h @@ -0,0 +1,83 @@ +/* + * 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. + */ + +#pragma once + +#include "ignite/client/network/cluster_node.h" +#include "ignite/client/primitive.h" +#include "ignite/client/transaction/transaction.h" +#include "ignite/common/config.h" +#include "ignite/common/ignite_result.h" + +#include <memory> +#include <utility> + +namespace ignite { + +namespace detail { +class compute_impl; +} + +/** + * Ignite Compute facade. + */ +class compute { + friend class ignite_client; + +public: + // Delete + compute() = delete; + + /** + * Executes single SQL statement asynchronously and returns rows. + * + * @param tx Optional transaction. If nullptr implicit transaction for this single operation is used. + * @param statement Statement to execute. + * @param args Arguments for the statement. + * @param callback A callback called on operation completion with SQL result set. + */ + IGNITE_API void execute_async(std::vector<cluster_node> nodes, std::string_view job_class_name, std::vector<primitive> args, + ignite_callback<std::optional<primitive>> callback); + + /** + * Executes single SQL statement and returns rows. + * + * @param tx Optional transaction. If nullptr implicit transaction for this single operation is used. + * @param statement Statement to execute. + * @param args Arguments for the statement. + * @return SQL result set. + */ + IGNITE_API std::optional<primitive> execute(std::vector<cluster_node> nodes, std::string_view job_class_name, std::vector<primitive> args) { + return sync<std::optional<primitive>>([this, nodes = std::move(nodes), job_class_name, args = std::move(args)](auto callback) mutable { + execute_async(std::move(nodes), job_class_name, std::move(args), std::move(callback)); + }); + } + +private: + /** + * Constructor + * + * @param impl Implementation + */ + explicit compute(std::shared_ptr<detail::compute_impl> impl) + : m_impl(std::move(impl)) {} + + /** Implementation. */ + std::shared_ptr<detail::compute_impl> m_impl; +}; + +} // namespace ignite diff --git a/modules/platforms/cpp/ignite/client/network/cluster_node.h b/modules/platforms/cpp/ignite/client/network/cluster_node.h new file mode 100644 index 0000000000..1392b17d6d --- /dev/null +++ b/modules/platforms/cpp/ignite/client/network/cluster_node.h @@ -0,0 +1,87 @@ +/* + * 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. + */ + +#pragma once + +#include "ignite/common/end_point.h" + +#include <cstdint> +#include <type_traits> +#include <variant> +#include <vector> + +namespace ignite { + +/** + * Ignite cluster node. + */ +class cluster_node { +public: + // Default + cluster_node() = default; + + /** + * Constructor. + * + * @param id Local ID. + * @param name Name. + * @param address Address. + */ + cluster_node(std::string id, std::string name, network::end_point address) + : m_id(std::move(id)) + , m_name(std::move(name)) + , m_address(std::move(address)) {} + + /** + * Gets the local node id. Changes after node restart. + * + * @return Local node id. + */ + [[nodiscard]] const std::string& get_id() const { + return m_id; + } + + /** + * Gets the unique name of the cluster member. Does not change after node restart. + * + * @return Unique name of the cluster member. + */ + [[nodiscard]] const std::string& get_name() const { + return m_name; + } + + /** + * Gets the node address. + * + * @return Node address. + */ + [[nodiscard]] const network::end_point& get_address() const { + return m_address; + } + +private: + /** Local ID. */ + std::string m_id{}; + + /** Name. */ + std::string m_name{}; + + /** Address. */ + network::end_point m_address{}; +}; + +} // namespace ignite diff --git a/modules/platforms/cpp/ignite/common/CMakeLists.txt b/modules/platforms/cpp/ignite/common/CMakeLists.txt index 0f2af03db0..1c5a786c28 100644 --- a/modules/platforms/cpp/ignite/common/CMakeLists.txt +++ b/modules/platforms/cpp/ignite/common/CMakeLists.txt @@ -27,6 +27,7 @@ set(PUBLIC_HEADERS bytes.h bytes_view.h config.h + end_point.h ignite_date.h ignite_date_time.h ignite_error.h diff --git a/modules/platforms/cpp/ignite/network/end_point.h b/modules/platforms/cpp/ignite/common/end_point.h similarity index 99% rename from modules/platforms/cpp/ignite/network/end_point.h rename to modules/platforms/cpp/ignite/common/end_point.h index 22b0ce67b0..3e895987ab 100644 --- a/modules/platforms/cpp/ignite/network/end_point.h +++ b/modules/platforms/cpp/ignite/common/end_point.h @@ -67,7 +67,7 @@ struct end_point { std::string host; /** TCP port. */ - uint16_t port = 0; + uint16_t port{0}; }; /** diff --git a/modules/platforms/cpp/ignite/network/async_handler.h b/modules/platforms/cpp/ignite/network/async_handler.h index 06d5b52fac..9a64c22035 100644 --- a/modules/platforms/cpp/ignite/network/async_handler.h +++ b/modules/platforms/cpp/ignite/network/async_handler.h @@ -17,9 +17,9 @@ #pragma once +#include "ignite/common/end_point.h" #include <ignite/common/ignite_error.h> #include <ignite/network/data_buffer.h> -#include <ignite/network/end_point.h> #include <cstdint> #include <optional> diff --git a/modules/platforms/cpp/ignite/network/detail/linux/connecting_context.h b/modules/platforms/cpp/ignite/network/detail/linux/connecting_context.h index b8ff6f640d..a1a6e28023 100644 --- a/modules/platforms/cpp/ignite/network/detail/linux/connecting_context.h +++ b/modules/platforms/cpp/ignite/network/detail/linux/connecting_context.h @@ -17,10 +17,9 @@ #pragma once -#include "linux_async_client.h" - -#include <ignite/network/end_point.h> -#include <ignite/network/tcp_range.h> +#include "ignite/network/tcp_range.h" +#include "ignite/network/detail/linux/linux_async_client.h" +#include "ignite/common/end_point.h" #include <cstdint> #include <memory> diff --git a/modules/platforms/cpp/ignite/network/detail/linux/linux_async_client.h b/modules/platforms/cpp/ignite/network/detail/linux/linux_async_client.h index 6f100766b1..1bb5b9351c 100644 --- a/modules/platforms/cpp/ignite/network/detail/linux/linux_async_client.h +++ b/modules/platforms/cpp/ignite/network/detail/linux/linux_async_client.h @@ -19,10 +19,10 @@ #include "sockets.h" -#include <ignite/network/async_handler.h> -#include <ignite/network/codec.h> -#include <ignite/network/end_point.h> -#include <ignite/network/tcp_range.h> +#include "ignite/network/async_handler.h" +#include "ignite/network/codec.h" +#include "ignite/network/tcp_range.h" +#include "ignite/common/end_point.h" #include <cstdint> #include <deque> diff --git a/modules/platforms/cpp/ignite/network/detail/linux/linux_async_worker_thread.h b/modules/platforms/cpp/ignite/network/detail/linux/linux_async_worker_thread.h index df441581d0..71a264a068 100644 --- a/modules/platforms/cpp/ignite/network/detail/linux/linux_async_worker_thread.h +++ b/modules/platforms/cpp/ignite/network/detail/linux/linux_async_worker_thread.h @@ -17,12 +17,11 @@ #pragma once -#include "connecting_context.h" -#include "linux_async_client.h" - -#include <ignite/network/async_handler.h> -#include <ignite/network/end_point.h> -#include <ignite/network/tcp_range.h> +#include "ignite/network/detail/linux/connecting_context.h" +#include "ignite/network/detail/linux/linux_async_client.h" +#include "ignite/network/async_handler.h" +#include "ignite/network/tcp_range.h" +#include "ignite/common/end_point.h" #include <cstdint> #include <ctime> diff --git a/modules/platforms/cpp/ignite/network/detail/win/win_async_client.h b/modules/platforms/cpp/ignite/network/detail/win/win_async_client.h index 10e4de0599..741c2a97a9 100644 --- a/modules/platforms/cpp/ignite/network/detail/win/win_async_client.h +++ b/modules/platforms/cpp/ignite/network/detail/win/win_async_client.h @@ -19,10 +19,10 @@ #include "sockets.h" -#include <ignite/network/async_handler.h> -#include <ignite/network/codec.h> -#include <ignite/network/end_point.h> -#include <ignite/network/tcp_range.h> +#include "ignite/network/async_handler.h" +#include "ignite/network/codec.h" +#include "ignite/network/tcp_range.h" +#include "ignite/common/end_point.h" #include <cstdint> #include <deque>
