Package com.clickhouse.client
Class ClickHouseNode.Builder
- java.lang.Object
-
- com.clickhouse.client.ClickHouseNode.Builder
-
- Enclosing class:
- ClickHouseNode
public static class ClickHouseNode.Builder extends Object
Mutable and non-thread safe builder.
-
-
Field Summary
Fields Modifier and Type Field Description protected ClickHouseCredentialscredentialsprotected Stringhostprotected Map<String,String>optionsprotected Integerportprotected ClickHouseProtocolprotocolprotected Set<String>tags
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder()Default constructor.
-
Method Summary
-
-
-
Field Detail
-
host
protected String host
-
protocol
protected ClickHouseProtocol protocol
-
port
protected Integer port
-
credentials
protected ClickHouseCredentials credentials
-
-
Method Detail
-
getHost
protected String getHost()
-
getProtocol
protected ClickHouseProtocol getProtocol()
-
getPort
protected int getPort()
-
getCredentials
protected ClickHouseCredentials getCredentials()
-
cluster
public ClickHouseNode.Builder cluster(String cluster)
Sets cluster name.- Parameters:
cluster- cluster name, null meansClickHouseDefaults.CLUSTER- Returns:
- this builder
-
host
public ClickHouseNode.Builder host(String host)
Sets host name.- Parameters:
host- host name, null meansClickHouseDefaults.HOST- Returns:
- this builder
-
port
public ClickHouseNode.Builder port(Integer port)
Sets port number.- Parameters:
port- port number, null meansClickHouseDefaults.PORT- Returns:
- this builder
-
port
public ClickHouseNode.Builder port(ClickHouseProtocol protocol)
Sets protocol used by the port.- Parameters:
protocol- protocol, null meansClickHouseDefaults.PROTOCOL- Returns:
- this builder
-
port
public ClickHouseNode.Builder port(ClickHouseProtocol protocol, Integer port)
Sets protocol and port number.- Parameters:
protocol- protocol, null meansClickHouseDefaults.PROTOCOLport- number, null meansClickHouseDefaults.PORT- Returns:
- this builder
-
address
public ClickHouseNode.Builder address(InetSocketAddress address)
Sets socket address.- Parameters:
address- socket address, null meansClickHouseDefaults.HOSTandClickHouseDefaults.PORT- Returns:
- this builder
-
address
public ClickHouseNode.Builder address(ClickHouseProtocol protocol, InetSocketAddress address)
Sets protocol and socket address.- Parameters:
protocol- protocol, null meansClickHouseDefaults.PROTOCOLaddress- socket address, null meansClickHouseDefaults.HOSTandClickHouseDefaults.PORT- Returns:
- this builder
-
database
public ClickHouseNode.Builder database(String database)
Sets database name.- Parameters:
database- database name, null meansClickHouseDefaults.DATABASE- Returns:
- this builder
-
credentials
public ClickHouseNode.Builder credentials(ClickHouseCredentials credentials)
Sets credentials will be used when connecting to this node. This is optional as client will useClickHouseConfig.getDefaultCredentials()to connect to all nodes.- Parameters:
credentials- credentials, null meansClickHouseConfig.getDefaultCredentials()- Returns:
- this builder
-
addOption
public ClickHouseNode.Builder addOption(String option, String value)
Adds an option for this node.- Parameters:
option- option name, null value will be ignoredvalue- option value- Returns:
- this builder
-
options
public ClickHouseNode.Builder options(Map<String,String> options)
Sets all options for this node. Use null or empty value to clear all existing options.- Parameters:
options- options for the node- Returns:
- this builder
-
addTag
public ClickHouseNode.Builder addTag(String tag)
Adds a tag for this node.- Parameters:
tag- tag for the node, null or duplicate tag will be ignored- Returns:
- this builder
-
removeTag
public ClickHouseNode.Builder removeTag(String tag)
Removes a tag from this node.- Parameters:
tag- tag to be removed, null value will be ignored- Returns:
- this builder
-
tags
public ClickHouseNode.Builder tags(String tag, String... more)
Sets all tags for this node. Use null or empty value to clear all existing tags.- Parameters:
tag- tag for the node, null will be ignoredmore- more tags for the node, null tag will be ignored- Returns:
- this builder
-
tags
public ClickHouseNode.Builder tags(Collection<String> tags)
Sets all tags for this node. Use null or empty value to clear all existing tags.- Parameters:
tags- list of tags for the node, null tag will be ignored- Returns:
- this builder
-
replica
public ClickHouseNode.Builder replica(Integer num)
-
shard
public ClickHouseNode.Builder shard(Integer num, Integer weight)
-
weight
public ClickHouseNode.Builder weight(Integer weight)
Sets weight of this node.- Parameters:
weight- weight of the node, null meansClickHouseDefaults.WEIGHT- Returns:
- this builder
-
timeZone
public ClickHouseNode.Builder timeZone(String tz)
Sets time zone of this node.- Parameters:
tz- time zone ID, could be null- Returns:
- this builder
-
timeZone
public ClickHouseNode.Builder timeZone(TimeZone tz)
Sets time zone of this node.- Parameters:
tz- time zone, could be null- Returns:
- this builder
-
version
public ClickHouseNode.Builder version(String version)
Sets vesion of this node.- Parameters:
version- version string, could be null- Returns:
- this builder
-
version
public ClickHouseNode.Builder version(ClickHouseVersion version)
Sets vesion of this node.- Parameters:
version- version, could be null- Returns:
- this builder
-
build
public ClickHouseNode build()
Creates a new node.- Returns:
- new node
-
-