-
Notifications
You must be signed in to change notification settings - Fork 512
/
ClickHouseDefaults.java
155 lines (143 loc) · 5.1 KB
/
ClickHouseDefaults.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package com.clickhouse.client.config;
import java.io.Serializable;
import com.clickhouse.client.ClickHouseProtocol;
import com.clickhouse.config.ClickHouseOption;
import com.clickhouse.data.ClickHouseChecker;
import com.clickhouse.data.ClickHouseDataConfig;
/**
* System-wide default options. System properties and environment variables can
* be set to change default value.
*
* <p>
* For example, by default {@link #ASYNC} is set to {@code true}. However, you
* can change it to {@code false} by either specifying
* {@code -Ddefault_async=false} on the Java command line, or setting
* environment variable {@code DEFAULT_ASYNC=false}.
*/
public enum ClickHouseDefaults implements ClickHouseOption {
/**
* Default execution mode.
*/
ASYNC("async", ClickHouseDataConfig.DEFAULT_ASYNC, "Whether the client should run in async mode."),
/**
* Whether to create session automatically when there are multiple queries.
*/
AUTO_SESSION("auto_session", true, "Whether to create session automatically when there are multiple queries."),
/**
* Default buffering mode.
*/
BUFFERING("buffering", ClickHouseDataConfig.DEFAULT_BUFFERING_MODE, "Buffering mode."),
/**
* Default server host.
*/
HOST("host", "localhost", "Host to connect to."),
/**
* Default protocol.
*/
PROTOCOL("protocol", ClickHouseProtocol.ANY, "Protocol to use."),
/**
* Default database.
*/
DATABASE("database", "default", "Database to connect to."),
/**
* Default user.
*/
USER("user", "default", "User name for authentication."),
/**
* Default password.
*/
PASSWORD("password", "", "Password for authentication.", true),
/**
* Default format.
*/
FORMAT("format", ClickHouseDataConfig.DEFAULT_FORMAT,
"Preferred data format for serialization and deserialization."),
/**
* Maximum number of threads that the scheduler(shared by all client instances)
* can use to run the adhoc/scheduled tasks like discovery and health check.
*/
MAX_SCHEDULER_THREADS("max_scheduler_threads", 1,
"Maximum number of threads that the scheduler(shared by all client instances) can use to run the adhoc/scheduled tasks like discovery and health check.."),
/**
* Max threads.
*/
MAX_THREADS("max_threads", 0, "Maximum size of shared thread pool, 0 or negative number means same as CPU cores."),
/**
* Max requests.
*/
MAX_REQUESTS("max_requests", 0, "Maximum size of shared thread pool, 0 means no limit."),
/**
* Rounding mode for type conversion.
*/
ROUNDING_MODE("rounding_mode", ClickHouseDataConfig.DEFAULT_ROUNDING_MODE, "Default rounding mode for BigDecimal."),
/**
* Thread keep alive timeout in milliseconds.
*/
THREAD_KEEPALIVE_TIMEOUT("thread_keepalive_timeout", 0L,
"Thread keep alive timeout in milliseconds. 0 or negative number means additional thread will be closed immediately after execution completed."),
/**
* Server time zone, defaults to {@code UTC}.
*/
SERVER_TIME_ZONE("time_zone", "UTC", "Server time zone."),
/**
* Server version, defaults to {@code latest}.
*/
SERVER_VERSION("version", "latest", "Server version"),
/**
* SSL certificiate type.
*/
SSL_CERTIFICATE_TYPE("sslcerttype", "X.509", "SSL/TLS certificate type."),
/**
* SSL key algorithm.
*/
SSL_KEY_ALGORITHM("sslkeyalg", "RSA", "Key algorithm."),
/**
* SSL key.
*/
SSL_PROTOCOL("sslprotocol", "TLS", "SSL protocol."),
/**
* Whether to resolve DNS SRV name using
* {@link com.clickhouse.client.naming.SrvResolver}(e.g. resolve SRV record to
* extract both host and port from a given name).
*/
SRV_RESOLVE("srv_resolve", false, "Whether to resolve DNS SRV name.");
private final String key;
private final Serializable defaultValue;
private final Class<? extends Serializable> clazz;
private final String description;
private final boolean sensitive;
<T extends Serializable> ClickHouseDefaults(String key, T defaultValue, String description) {
this(key, defaultValue, description, false);
}
<T extends Serializable> ClickHouseDefaults(String key, T defaultValue, String description, boolean sensitive) {
this.key = ClickHouseChecker.nonNull(key, "key");
this.defaultValue = ClickHouseChecker.nonNull(defaultValue, "defaultValue");
this.clazz = defaultValue.getClass();
this.description = ClickHouseChecker.nonNull(description, "description");
this.sensitive = sensitive;
}
@Override
public Serializable getDefaultValue() {
return defaultValue;
}
@Override
public String getDescription() {
return description;
}
@Override
public String getKey() {
return key;
}
@Override
public String getPrefix() {
return "DEFAULT";
}
@Override
public Class<? extends Serializable> getValueType() {
return clazz;
}
@Override
public boolean isSensitive() {
return sensitive;
}
}