-
Notifications
You must be signed in to change notification settings - Fork 560
/
Copy pathClickHouseHttpOption.java
156 lines (139 loc) · 6.08 KB
/
ClickHouseHttpOption.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
156
package com.clickhouse.client.http.config;
import com.clickhouse.config.ClickHouseOption;
import com.clickhouse.data.ClickHouseChecker;
import java.io.Serializable;
import java.net.UnknownHostException;
/**
* Http client options.
*/
public enum ClickHouseHttpOption implements ClickHouseOption {
/**
* HTTP connection provider.
*/
CONNECTION_PROVIDER("http_connection_provider", HttpConnectionProvider.APACHE_HTTP_CLIENT,
"APACHE HTTP CLIENT connection provider. HTTP_CLIENT is only supported in JDK 11 or above."),
/**
* Custom HTTP headers.
*/
CUSTOM_HEADERS("custom_http_headers", "", "Custom HTTP headers."),
/**
* Custom HTTP query parameters. Consider
* {@link com.clickhouse.client.config.ClickHouseClientOption#CUSTOM_SETTINGS}
* if you don't want your implementation ties to http protocol.
*/
CUSTOM_PARAMS("custom_http_params", "", "Custom HTTP query parameters."),
/**
* Default server response.
*/
DEFAULT_RESPONSE("http_server_default_response", "Ok.\n",
"Default server response, which is used for validating connection."),
/**
* Whether to enable keep-alive or not.
*/
KEEP_ALIVE("http_keep_alive", true, "Whether to use keep-alive or not"),
/**
* Max open connections apply with Apache HttpClient only.
*/
MAX_OPEN_CONNECTIONS("max_open_connections", 10, "Max open connections apply with Apache HttpClient only."),
/**
* Whether to receive information about the progress of a query in response
* headers.
*/
RECEIVE_QUERY_PROGRESS("receive_query_progress", true,
"Whether to receive information about the progress of a query in response headers."),
/**
* Indicates whether http client would send its identification through Referer header to server.
* Valid values:
* 1. empty string - nothing is sent
* 2. IP_ADDRESS - client's IP address is used
* 3. HOST_NAME - host name is used
*/
SEND_HTTP_CLIENT_ID("send_http_client_id", "", "Indicates whether http client would send its identification through Referer header to server. " +
"Valid values: empty string - nothing is sent. IP_ADDRESS - client's IP address is used. HOST_NAME - host name is used."),
// SEND_PROGRESS("send_progress_in_http_headers", false,
// "Enables or disables X-ClickHouse-Progress HTTP response headers in
// clickhouse-server responses."),
// SEND_PROGRESS_INTERVAL("http_headers_progress_interval_ms", 3000, ""),
WAIT_END_OF_QUERY("wait_end_of_query", false, ""),
/**
* Whether to remember last set role and send them in every next requests as query parameters.
* Only one role can be set at a time.
*/
REMEMBER_LAST_SET_ROLES("remember_last_set_roles", false,
"Whether to remember last set role and send them in every next requests as query parameters."),
/**
* The time in milliseconds after which the connection is validated after inactivity.
* Default value is 5000 ms. If set to negative value, the connection is never validated.
* It is used only for Apache Http Client connection provider.
*/
AHC_VALIDATE_AFTER_INACTIVITY("ahc_validate_after_inactivity", 5000L,
"The time in milliseconds after which the connection is validated after inactivity."),
/**
* Whether to retry on failure with AsyncHttpClient. Failure includes some 'critical' IO exceptions:
* <ul>
* <li>{@code org.apache.hc.core5.http.ConnectionClosedException}</li>
* <li>{@code org.apache.hc.core5.http.NoHttpResponseException}</li>
* </ul>
*
* And next status codes:
* <ul>
* <li>{@code 503 Service Unavailable}</li>
* </ul>
*/
AHC_RETRY_ON_FAILURE("ahc_retry_on_failure", false, "Whether to retry on failure with AsyncHttpClient."),
/**
* Configuration for AsyncHttpClient connection pool. It defines how to reuse connections.
* If {@code "FIFO"} is set, the connections are reused in the order they were created.
* If {@code "LIFO"} is set, the connections are reused as soon they are available.
* Default value is {@code "LIFO"}.
*/
CONNECTION_REUSE_STRATEGY("connection_reuse_strategy", "LIFO",
"Connection reuse strategy for AsyncHttpClient. Valid values: LIFO, FIFO"),
/**
* Configures client with preferred connection keep alive timeout if keep alive is enabled.
* Usually servers tells a client how long it can keep a connection alive. This option can be used
* when connection should be ended earlier. If value less or equal to 0, the server's timeout is used.
* Default value is -1.
* Time unit is milliseconds.
*
* Supported only for Apache Http Client connection provider currently.
*/
KEEP_ALIVE_TIMEOUT("alive_timeout", -1L,
"Default keep-alive timeout in milliseconds."),
;
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> ClickHouseHttpOption(String key, T defaultValue, String description) {
this(key, defaultValue, description, false);
}
<T extends Serializable> ClickHouseHttpOption(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 Class<? extends Serializable> getValueType() {
return clazz;
}
@Override
public boolean isSensitive() {
return sensitive;
}
}