Package com.clickhouse.client
Class ClickHouseClientBuilder
java.lang.Object
com.clickhouse.client.ClickHouseClientBuilder
Builder class for creating
ClickHouseClient. Please use
ClickHouseClient.builder() for instantiation, and avoid
multi-threading as it's NOT thread-safe.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected ClickHouseConfigprotected ClickHouseCredentialsprotected Objectprotected ClickHouseNodeSelectorprotected final Map<ClickHouseOption,Serializable> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionagent(boolean agent) Sets whether agent should be used for advanced feature like failover and retry.build()Builds an instance ofClickHouseClient.Removes all options.config(ClickHouseConfig config) Sets configuration.defaultCredentials(ClickHouseCredentials credentials) Sets default credentials, which will be used to connect to aClickHouseNodeonly when it has no credentials defined.Gets client configuration.metricRegistry(Object metricRegistry) Sets metric registry.nodeSelector(ClickHouseNodeSelector nodeSelector) Sets node selector.option(ClickHouseOption option, Serializable value) Adds an option, which is usually an Enum type that implementsClickHouseOption.options(Map<ClickHouseOption, Serializable> options) Sets options.removeOption(ClickHouseOption option) Removes an option.protected voidResets client configuration to null.
-
Field Details
-
agent
protected boolean agent -
config
-
credentials
-
metricRegistry
-
nodeSelector
-
options
-
-
Constructor Details
-
ClickHouseClientBuilder
protected ClickHouseClientBuilder()Default constructor.
-
-
Method Details
-
resetConfig
protected void resetConfig()Resets client configuration to null. -
getConfig
Gets client configuration.- Returns:
- non-null client configuration
-
build
Builds an instance ofClickHouseClient. This method will useServiceLoaderto load a suitable implementation based on preferred protocol(s), or just the first one if no preference given.ClickHouseClient.accept(ClickHouseProtocol)will be invoked during the process to test if the implementation is compatible with the preferred protocol(s) or not. At the end of process, if a suitable implementation is found,ClickHouseClient.init(ClickHouseConfig)will be invoked for initialization.- Returns:
- suitable client to handle preferred protocols
- Throws:
IllegalStateException- when no suitable client found in classpath
-
agent
Sets whether agent should be used for advanced feature like failover and retry.- Parameters:
agent- whether to use agent- Returns:
- this builder
-
config
Sets configuration.- Parameters:
config- non-null configuration- Returns:
- this builder
-
option
Adds an option, which is usually an Enum type that implementsClickHouseOption.- Parameters:
option- non-null optionvalue- value- Returns:
- this builder
-
removeOption
Removes an option.- Parameters:
option- non-null option- Returns:
- this builder
-
clearOptions
Removes all options.- Returns:
- this builder
-
options
Sets options.- Parameters:
options- map containing all options- Returns:
- this builder
-
defaultCredentials
Sets default credentials, which will be used to connect to aClickHouseNodeonly when it has no credentials defined.- Parameters:
credentials- default credentials- Returns:
- this builder
-
nodeSelector
Sets node selector.- Parameters:
nodeSelector- non-null node selector- Returns:
- this builder
-
metricRegistry
Sets metric registry.- Parameters:
metricRegistry- metric registry, could be null- Returns:
- this builder
-