Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BalancedClickhouseDataSource; 负载均衡在0.3.2版本怎么支持以及后面版本怎么规划的的这个功能是? #834

Closed
kiwimg opened this issue Feb 14, 2022 · 4 comments
Labels

Comments

@kiwimg
Copy link

kiwimg commented Feb 14, 2022

ru.yandex.clickhouse.BalancedClickhouseDataSource; 负载均衡在0.3.2版本怎么支持以及后面版本怎么规划的的这个功能是?

@zhicwu
Copy link
Contributor

zhicwu commented Feb 14, 2022

ru.yandex.clickhouse.BalancedClickhouseDataSource; 负载均衡在0.3.2版本怎么支持以及后面版本怎么规划的的这个功能是?

Since the driver uses http protocol by default, I'd suggest you using middleware like chproxy, nginx or traefik etc. for load balancing.

As to the driver itself, I hope to re-write ClickHouseCluster in 0.3.3, which will simplify the way to connect to multiple nodes, for example:

// Java client
ClickHouseNode server1 = ClickHouseNode.of(...);
ClickHouseCluster cluster1 = ClickHouseCluster.of("cluster1", server1); // discover the rest nodes of cluster1
ClickHouseNodes nodes = ClickHouseNodes.of(server1, cluster1, ...); // list of nodes may or may not belong to a cluster

ClickHouseResponse resp = client.connect(nodes) // intention to connect to a node within the list
  .query("select 1")
  .execute() // pick one node from nodes and execute from there
  .get();

// JDBC driver will support multiple hosts(and protocols) in connection string like:
// jdbc:ch://ip1:port1,ip2:port2,.../database

@kiwimg
Copy link
Author

kiwimg commented Feb 14, 2022

thanks

@zhicwu zhicwu closed this as completed Feb 21, 2022
@kiwimg
Copy link
Author

kiwimg commented Jun 2, 2022

现在 0.3.1 使用的 BalancedClickhouseDataSource。如果升级到 0.3.2版本,对应的 BalancedClickhouseDataSource应该替换成什么?是替换成clickhouse-client 模块下面ClickHouseCluster 对吧。
ClickHouseCluster 在这个clickhouse-client 模块下面。我理解 clickhouse-jdbc 、clickhouse-tcp-client、 clickhouse-http-client 这几个模块的作用,是不是 clickhouse-client 是一个通用的入口,然后指定不同协议就可以调用不同协议模块、

@zhicwu
Copy link
Contributor

zhicwu commented Jun 5, 2022

Sorry I'll write a guide for upgrading legacy JDBC driver to new one.

如果升级到 0.3.2版本,对应的 BalancedClickhouseDataSource应该替换成什么?

As I mentioned here, we'll only need to specify multiple hosts in connection string.

我理解 clickhouse-jdbc 、clickhouse-tcp-client、 clickhouse-http-client 这几个模块的作用,是不是 clickhouse-client 是一个通用的入口,然后指定不同协议就可以调用不同协议模块、

Correct. You may refer to the class diagram at here. By the way, clickhouse-cli-client is available on develop branch. It implemented clickhouse-client interfaces like clickhouse-http-client and clickhouse-grpc-client, but it's actually a wrapper of ClickHouse native command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants