public final class BalancedClickhouseDataSource extends Object implements DataSource, SQLWrapper
Database for clickhouse jdbc connections.
It has list of database urls.
For every getConnection invocation, it returns connection to random host from the list.
Furthermore, this class has method { #scheduleActualization(int, TimeUnit) scheduleActualization}
which test hosts for availability. By default, this option is turned off.
| Constructor and Description |
|---|
BalancedClickhouseDataSource(String url)
create Datasource for clickhouse JDBC connections
|
BalancedClickhouseDataSource(String url,
Map<SettingKey,Serializable> settings)
create Datasource for clickhouse JDBC connections
|
BalancedClickhouseDataSource(String url,
Properties properties)
create Datasource for clickhouse JDBC connections
|
| Modifier and Type | Method and Description |
|---|---|
List<String> |
getAllClickhouseUrls() |
ClickHouseConfig |
getCfg() |
ClickHouseConnection |
getConnection() |
ClickHouseConnection |
getConnection(String user,
String password) |
List<String> |
getDisabledUrls() |
List<String> |
getEnabledClickHouseUrls() |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger() |
boolean |
hasDisabledUrls() |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(PrintWriter printWriter) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisWrapperFor, unwrappublic BalancedClickhouseDataSource(String url)
url - address for connection to the database, must have the next format
jdbc:clickhouse://<first-host>:<port>,<second-host>:<port>/<database>?param1=value1¶m2=value2
for example, jdbc:clickhouse://localhost:9000,localhost:9000/database?compress=1&decompress=2 IllegalArgumentException - if param have not correct format,
or error happens when checking host availabilitypublic BalancedClickhouseDataSource(String url, Properties properties)
url - address for connection to the databaseproperties - database propertiesBalancedClickhouseDataSource(String)public BalancedClickhouseDataSource(String url, Map<SettingKey,Serializable> settings)
url - address for connection to the databasesettings - clickhouse settingsBalancedClickhouseDataSource(String)public ClickHouseConnection getConnection() throws SQLException
getConnection in interface DataSourceSQLExceptionpublic ClickHouseConnection getConnection(String user, String password) throws SQLException
getConnection in interface DataSourceSQLExceptionpublic PrintWriter getLogWriter() throws SQLException
getLogWriter in interface CommonDataSourceSQLExceptionpublic void setLogWriter(PrintWriter printWriter) throws SQLException
setLogWriter in interface CommonDataSourceSQLExceptionpublic void setLoginTimeout(int seconds)
throws SQLException
setLoginTimeout in interface CommonDataSourceSQLExceptionpublic int getLoginTimeout()
throws SQLException
getLoginTimeout in interface CommonDataSourceSQLExceptionpublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionpublic boolean hasDisabledUrls()
public ClickHouseConfig getCfg()
Copyright © 2021. All rights reserved.