diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 404981daa9a..8f45bf53f53 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -180,8 +180,6 @@ add_subdirectory (obfuscator) add_subdirectory (install) add_subdirectory (git-import) -#add_subdirectory (grpc-client) - if (ENABLE_CLICKHOUSE_ODBC_BRIDGE) add_subdirectory (odbc-bridge) endif () diff --git a/programs/grpc-client/CMakeLists.txt b/programs/grpc-client/CMakeLists.txt deleted file mode 100644 index d848434e918..00000000000 --- a/programs/grpc-client/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -get_filename_component(rpc_proto "${CMAKE_CURRENT_SOURCE_DIR}/../server/grpc_protos/GrpcConnection.proto" ABSOLUTE) -protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${rpc_proto}) -PROTOBUF_GENERATE_GRPC_CPP(GRPC_SRCS GRPC_HDRS ${rpc_proto}) - -add_executable(grpc-client grpc_client.cpp ${PROTO_SRCS} ${PROTO_HDRS} ${GRPC_SRCS} ${GRPC_HDRS}) -target_link_libraries(grpc-client PUBLIC grpc++ PUBLIC libprotobuf PUBLIC daemon) \ No newline at end of file diff --git a/programs/grpc-client/grpc_client.cpp b/programs/grpc-client/grpc_client.cpp deleted file mode 100644 index 5345b3e7d33..00000000000 --- a/programs/grpc-client/grpc_client.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "GrpcConnection.grpc.pb.h" - -class GRPCClient -{ - public: - explicit GRPCClient(std::shared_ptr channel) - : stub_(GRPCConnection::GRPC::NewStub(channel)) - {} - std::string Query(const GRPCConnection::User& userInfo, - const std::string& query, - std::vector insert_data = {}) - { - GRPCConnection::QueryRequest request; - grpc::Status status; - GRPCConnection::QueryResponse reply; - grpc::ClientContext context; - auto deadline = std::chrono::system_clock::now() + std::chrono::milliseconds(10000); - context.set_deadline(deadline); - - auto user = std::make_unique(userInfo); - auto querySettigs = std::make_unique(); - int id = rand(); - request.set_allocated_user_info(user.release()); - // interactive_delay in miliseconds - request.set_interactive_delay(1000); - - querySettigs->set_query(query); - querySettigs->set_format("Values"); - querySettigs->set_query_id(std::to_string(id)); - querySettigs->set_data_stream((insert_data.size() != 0)); - (*querySettigs->mutable_settings())["max_query_size"] ="100"; - - - request.set_allocated_query_info(querySettigs.release()); - - void* got_tag = (void*)1; - bool ok = false; - - std::unique_ptr > reader(stub_->Query(&context)); - reader->Write(request); - - auto write = [&reply, &reader, &insert_data]() - { - GRPCConnection::QueryRequest request_insert; - for (const auto& data : insert_data) - { - request_insert.set_insert_data(data); - if (reply.exception_occured().empty()) - { - reader->Write(request_insert); - } - else - { - break; - } - } - request_insert.set_insert_data(""); - if (reply.exception_occured().empty()) - { - reader->Write(request_insert); - } - // reader->WritesDone(); - }; - std::thread write_thread(write); - write_thread.detach(); - - while (reader->Read(&reply)) - { - - if (!reply.output().empty()) - { - std::cout << "Query Part:\n " << id<< reply.output()<<'\n'; - } - else if (reply.progress().read_rows() - || reply.progress().read_bytes() - || reply.progress().total_rows_to_read() - || reply.progress().written_rows() - || reply.progress().written_bytes()) - { - std::cout << "Progress " << id<< ":{\n" << "read_rows: " << reply.progress().read_rows() << '\n' - << "read_bytes: " << reply.progress().read_bytes() << '\n' - << "total_rows_to_read: " << reply.progress().total_rows_to_read() << '\n' - << "written_rows: " << reply.progress().written_rows() << '\n' - << "written_bytes: " << reply.progress().written_bytes() << '\n'; - - - } - else if (!reply.totals().empty()) - { - std::cout << "Totals:\n " << id << " " << reply.totals() <<'\n'; - } - else if (!reply.extremes().empty()) - { - std::cout << "Extremes:\n " << id << " " << reply.extremes() <<'\n'; - } - } - - if (status.ok() && reply.exception_occured().empty()) - { - return ""; - } - else if (status.ok() && !reply.exception_occured().empty()) - { - return reply.exception_occured(); - } - else - { - return "RPC failed"; - } - } - - private: - std::unique_ptr stub_; -}; - -int main(int argc, char** argv) -{ - GRPCConnection::User userInfo1; - userInfo1.set_user("default"); - userInfo1.set_password(""); - userInfo1.set_quota("default"); - - std::cout << "Try: " << argv[1] << std::endl; - grpc::ChannelArguments ch_args; - ch_args.SetMaxReceiveMessageSize(-1); - GRPCClient client( - grpc::CreateCustomChannel(argv[1], grpc::InsecureChannelCredentials(), ch_args)); - { - std::cout << client.Query(userInfo1, "CREATE TABLE t (a UInt8) ENGINE = Memory") << std::endl; - std::cout << client.Query(userInfo1, "CREATE TABLE t (a UInt8) ENGINE = Memory") << std::endl; - std::cout << client.Query(userInfo1, "INSERT INTO t VALUES", {"(1),(2),(3)", "(4),(6),(5)"}) << std::endl; - std::cout << client.Query(userInfo1, "INSERT INTO t_not_defined VALUES", {"(1),(2),(3)", "(4),(6),(5)"}) << std::endl; - std::cout << client.Query(userInfo1, "SELECT a FROM t ORDER BY a") << std::endl; - std::cout << client.Query(userInfo1, "DROP TABLE t") << std::endl; - } - { - std::cout << client.Query(userInfo1, "SELECT count() FROM numbers(1)") << std::endl; - std::cout << client.Query(userInfo1, "SELECT 100") << std::endl; - std::cout << client.Query(userInfo1, "SELECT count() FROM numbers(10000000000)") << std::endl; - std::cout << client.Query(userInfo1, "SELECT count() FROM numbers(100)") << std::endl; - } - { - std::cout << client.Query(userInfo1, "CREATE TABLE arrays_test (s String, arr Array(UInt8)) ENGINE = Memory;") << std::endl; - std::cout << client.Query(userInfo1, "INSERT INTO arrays_test VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []);") << std::endl; - std::cout << client.Query(userInfo1, "SELECT s FROM arrays_test") << std::endl; - std::cout << client.Query(userInfo1, "DROP TABLE arrays_test") << std::endl; - std::cout << client.Query(userInfo1, "") << std::endl; - } - - {//Check null return from pipe - std::cout << client.Query(userInfo1, "CREATE TABLE table2 (x UInt8, y UInt8) ENGINE = Memory;") << std::endl; - std::cout << client.Query(userInfo1, "SELECT x FROM table2") << std::endl; - std::cout << client.Query(userInfo1, "DROP TABLE table2") << std::endl; - } - {//Check Totals - std::cout << client.Query(userInfo1, "CREATE TABLE tabl (x UInt8, y UInt8) ENGINE = Memory;") << std::endl; - std::cout << client.Query(userInfo1, "INSERT INTO tabl VALUES (1, 2), (2, 4), (3, 2), (3, 3), (3, 4);") << std::endl; - std::cout << client.Query(userInfo1, "SELECT sum(x), y FROM tabl GROUP BY y WITH TOTALS") << std::endl; - std::cout << client.Query(userInfo1, "DROP TABLE tabl") << std::endl; - } - - return 0; -} diff --git a/programs/server/config.xml b/programs/server/config.xml index bfd1cc2395b..783ffd86f97 100644 --- a/programs/server/config.xml +++ b/programs/server/config.xml @@ -135,20 +135,20 @@ 3 - + - + - + - + diff --git a/src/Core/include/config_core.h b/src/Core/include/config_core.h deleted file mode 100644 index 725f9146413..00000000000 --- a/src/Core/include/config_core.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -// .h autogenerated by cmake! - -#define USE_ICU 1 -#define USE_MYSQL 1 -#define USE_RDKAFKA 1 -#define USE_AMQPCPP 1 -#define USE_EMBEDDED_COMPILER 0 -#define USE_INTERNAL_LLVM_LIBRARY 0 -#define USE_SSL 1 -#define USE_OPENCL 0 -#define USE_LDAP 1 diff --git a/tests/integration/test_grpc_protocol/configs/grpc_port.xml b/tests/integration/test_grpc_protocol/configs/grpc_port.xml index 31b6229a3c6..61922140bd3 100644 --- a/tests/integration/test_grpc_protocol/configs/grpc_port.xml +++ b/tests/integration/test_grpc_protocol/configs/grpc_port.xml @@ -1,3 +1,3 @@ - 9001 + 9100 diff --git a/tests/integration/test_grpc_protocol/test.py b/tests/integration/test_grpc_protocol/test.py index 6589e2336d7..5ff1d543f07 100644 --- a/tests/integration/test_grpc_protocol/test.py +++ b/tests/integration/test_grpc_protocol/test.py @@ -29,7 +29,7 @@ import clickhouse_grpc_pb2_grpc config_dir = os.path.join(SCRIPT_DIR, './configs') cluster = ClickHouseCluster(__file__) node = cluster.add_instance('node', main_configs=['configs/grpc_port.xml']) -grpc_port = 9001 +grpc_port = 9100 main_channel = None def create_channel(): diff --git a/tests/integration/test_grpc_protocol_ssl/configs/grpc_config.xml b/tests/integration/test_grpc_protocol_ssl/configs/grpc_config.xml index e9754b7e79b..f40e73c5d99 100644 --- a/tests/integration/test_grpc_protocol_ssl/configs/grpc_config.xml +++ b/tests/integration/test_grpc_protocol_ssl/configs/grpc_config.xml @@ -1,18 +1,18 @@ - 9001 + 9100 true - + /etc/clickhouse-server/config.d/server-cert.pem /etc/clickhouse-server/config.d/server-key.pem - + true - + /etc/clickhouse-server/config.d/ca-cert.pem - + gzip diff --git a/tests/integration/test_grpc_protocol_ssl/test.py b/tests/integration/test_grpc_protocol_ssl/test.py index 339a41c799d..a311dee8781 100644 --- a/tests/integration/test_grpc_protocol_ssl/test.py +++ b/tests/integration/test_grpc_protocol_ssl/test.py @@ -25,7 +25,7 @@ import clickhouse_grpc_pb2_grpc # Utilities node_ip = '10.5.172.77' # It's important for the node to work at this IP because 'server-cert.pem' requires that (see server-ext.cnf). -grpc_port = 9001 +grpc_port = 9100 node_ip_with_grpc_port = node_ip + ':' + str(grpc_port) config_dir = os.path.join(SCRIPT_DIR, './configs') cluster = ClickHouseCluster(__file__) diff --git a/utils/grpc-client/clickhouse-grpc-client.py b/utils/grpc-client/clickhouse-grpc-client.py index ef5f6d1f154..19d213a8e3f 100755 --- a/utils/grpc-client/clickhouse-grpc-client.py +++ b/utils/grpc-client/clickhouse-grpc-client.py @@ -10,10 +10,12 @@ # Most of the command line options are the same, for more information type # ./clickhouse_grpc_client.py --help -import argparse, cmd, os, signal, subprocess, sys, threading, time, uuid, grpc +import grpc # pip3 install grpcio +import grpc_tools # pip3 install grpcio-tools +import argparse, cmd, os, signal, subprocess, sys, threading, time, uuid default_host = 'localhost' -default_port = 9001 +default_port = 9100 default_user_name = 'default' default_output_format_for_interactive_mode = 'PrettyCompact' history_filename = '~/.clickhouse_grpc_history' @@ -196,7 +198,7 @@ class ClickHouseGRPCClient(cmd.Cmd): errors = p.stderr.read().decode().strip('\n').split('\n') only_warnings = all(('Warning' in error) for error in errors) if not only_warnings: - error_print(errors.join('\n')) + error_print('\n'.join(errors)) # Import the generated *pb2.py files. @staticmethod @@ -261,7 +263,7 @@ def main(args): parser = argparse.ArgumentParser(description='ClickHouse client accessing server through gRPC protocol.', add_help=False) parser.add_argument('--help', help='Show this help message and exit', action='store_true') parser.add_argument('--host', '-h', help='The server name, ‘localhost’ by default. You can use either the name or the IPv4 or IPv6 address.', default='localhost') - parser.add_argument('--port', help='The port to connect to. This port should be enabled on the ClickHouse server (see grpc_port in the config).', default=9001) + parser.add_argument('--port', help='The port to connect to. This port should be enabled on the ClickHouse server (see grpc_port in the config).', default=9100) parser.add_argument('--user', '-u', dest='user_name', help='The username. Default value: ‘default’.', default='default') parser.add_argument('--password', help='The password. Default value: empty string.', default='') parser.add_argument('--query', '-q', help='The query to process when using non-interactive mode.', default='')