Skip to content

Commit 45cdf6c

Browse files
2b3c5112b3c511
andauthored
Add more params in Session (#67)
* Add more params in Session * update name * spotless:apply --------- Co-authored-by: 2b3c511 <rong.li@timecho.com>
1 parent c2c0e83 commit 45cdf6c

4 files changed

Lines changed: 107 additions & 12 deletions

File tree

examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public void queryTableSessionPool() throws IoTDBConnectionException, StatementEx
5353
}
5454
System.out.println();
5555
}
56+
sessionDataSet.close();
57+
tableSession.close();
5658
}
5759

5860
public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException {
@@ -65,5 +67,6 @@ public void querySessionPool() throws IoTDBConnectionException, StatementExecuti
6567
}
6668
System.out.println();
6769
}
70+
sessionDataSetWrapper.close();
6871
}
6972
}

examples/iotdb-spring-boot-start/src/main/resources/application.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
spring.application.name=iotdb-spring-boot-start
2020

21-
iotdb.session.url=127.0.0.1:6667
21+
iotdb.session.node_urls=172.20.31.56:6668
2222
iotdb.session.password=root
2323
iotdb.session.username=root
2424
iotdb.session.database=wind
25-
iotdb.session.sql-dialect=table
26-
iotdb.session.max-size=10
25+
iotdb.session.sql_dialect=table
26+
iotdb.session.max_size=10

iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/config/IoTDBSessionProperties.java

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717

1818
package org.apache.iotdb.config;
1919

20+
import org.apache.iotdb.isession.SessionConfig;
21+
2022
import org.springframework.boot.context.properties.ConfigurationProperties;
2123

24+
import java.time.ZoneId;
25+
2226
@ConfigurationProperties(prefix = "iotdb.session")
2327
public class IoTDBSessionProperties {
24-
private String url;
28+
private String node_urls;
2529
private String username;
2630
private String password;
2731
private String database;
@@ -30,18 +34,27 @@ public class IoTDBSessionProperties {
3034
private Integer fetch_size = 1024;
3135
private long query_timeout_in_ms = 60000L;
3236
private boolean enable_auto_fetch = true;
33-
private boolean use_ssl = false;
3437
private int max_retry_count = 60;
3538
private long wait_to_get_session_timeout_in_msit = 60000L;
3639
private boolean enable_compression = false;
37-
private long retry_interval_in_ms = 500L;
40+
private long retry_interval_in_ms = SessionConfig.RETRY_INTERVAL_IN_MS;
41+
private boolean use_ssl = false;
42+
private String trust_store;
43+
private String trust_store_pwd;
44+
private int connection_timeout_in_ms;
45+
private ZoneId zone_id;
46+
private int thrift_default_buffer_size = 1024;
47+
private int thrift_max_frame_size = 67108864;
48+
private boolean enable_redirection;
49+
private boolean enable_records_auto_convert_tablet =
50+
SessionConfig.DEFAULT_RECORDS_AUTO_CONVERT_TABLET;
3851

39-
public String getUrl() {
40-
return url;
52+
public String getNode_urls() {
53+
return node_urls;
4154
}
4255

43-
public void setUrl(String url) {
44-
this.url = url;
56+
public void setNode_urls(String node_urls) {
57+
this.node_urls = node_urls;
4558
}
4659

4760
public String getUsername() {
@@ -171,4 +184,68 @@ public long getRetry_interval_in_ms() {
171184
public void setRetry_interval_in_ms(long retry_interval_in_ms) {
172185
this.retry_interval_in_ms = retry_interval_in_ms;
173186
}
187+
188+
public String getTrust_store() {
189+
return trust_store;
190+
}
191+
192+
public void setTrust_store(String trust_store) {
193+
this.trust_store = trust_store;
194+
}
195+
196+
public String getTrust_store_pwd() {
197+
return trust_store_pwd;
198+
}
199+
200+
public void setTrust_store_pwd(String trust_store_pwd) {
201+
this.trust_store_pwd = trust_store_pwd;
202+
}
203+
204+
public int getConnection_timeout_in_ms() {
205+
return connection_timeout_in_ms;
206+
}
207+
208+
public void setConnection_timeout_in_ms(int connection_timeout_in_ms) {
209+
this.connection_timeout_in_ms = connection_timeout_in_ms;
210+
}
211+
212+
public ZoneId getZone_id() {
213+
return zone_id;
214+
}
215+
216+
public void setZone_id(ZoneId zone_id) {
217+
this.zone_id = zone_id;
218+
}
219+
220+
public int getThrift_default_buffer_size() {
221+
return thrift_default_buffer_size;
222+
}
223+
224+
public void setThrift_default_buffer_size(int thrift_default_buffer_size) {
225+
this.thrift_default_buffer_size = thrift_default_buffer_size;
226+
}
227+
228+
public int getThrift_max_frame_size() {
229+
return thrift_max_frame_size;
230+
}
231+
232+
public void setThrift_max_frame_size(int thrift_max_frame_size) {
233+
this.thrift_max_frame_size = thrift_max_frame_size;
234+
}
235+
236+
public boolean isEnable_redirection() {
237+
return enable_redirection;
238+
}
239+
240+
public void setEnable_redirection(boolean enable_redirection) {
241+
this.enable_redirection = enable_redirection;
242+
}
243+
244+
public boolean isEnable_records_auto_convert_tablet() {
245+
return enable_records_auto_convert_tablet;
246+
}
247+
248+
public void setEnable_records_auto_convert_tablet(boolean enable_records_auto_convert_tablet) {
249+
this.enable_records_auto_convert_tablet = enable_records_auto_convert_tablet;
250+
}
174251
}

iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/session/IoTDBSessionPool.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ITableSessionPool tableSessionPool() {
5050
if (tableSessionPool == null) {
5151
tableSessionPool =
5252
new TableSessionPoolBuilder()
53-
.nodeUrls(Arrays.asList(properties.getUrl().split(";")))
53+
.nodeUrls(Arrays.asList(properties.getNode_urls().split(";")))
5454
.user(properties.getUsername())
5555
.password(properties.getPassword())
5656
.database(properties.getDatabase())
@@ -63,6 +63,13 @@ public ITableSessionPool tableSessionPool() {
6363
.waitToGetSessionTimeoutInMs(properties.getQuery_timeout_in_ms())
6464
.enableCompression(properties.isEnable_compression())
6565
.retryIntervalInMs(properties.getRetry_interval_in_ms())
66+
.trustStore(properties.getTrust_store())
67+
.trustStorePwd(properties.getTrust_store_pwd())
68+
.connectionTimeoutInMs(properties.getConnection_timeout_in_ms())
69+
.zoneId(properties.getZone_id())
70+
.thriftDefaultBufferSize(properties.getThrift_default_buffer_size())
71+
.thriftMaxFrameSize(properties.getThrift_max_frame_size())
72+
.enableRedirection(properties.isEnable_redirection())
6673
.build();
6774
}
6875
}
@@ -77,7 +84,7 @@ public ISessionPool treeSessionPool() {
7784
if (treeSessionPool == null) {
7885
treeSessionPool =
7986
new SessionPool.Builder()
80-
.nodeUrls(Arrays.asList(properties.getUrl().split(";")))
87+
.nodeUrls(Arrays.asList(properties.getNode_urls().split(";")))
8188
.user(properties.getUsername())
8289
.password(properties.getPassword())
8390
.maxSize(properties.getMax_size())
@@ -89,6 +96,14 @@ public ISessionPool treeSessionPool() {
8996
.waitToGetSessionTimeoutInMs(properties.getQuery_timeout_in_ms())
9097
.enableCompression(properties.isEnable_compression())
9198
.retryIntervalInMs(properties.getRetry_interval_in_ms())
99+
.trustStore(properties.getTrust_store())
100+
.trustStorePwd(properties.getTrust_store_pwd())
101+
.connectionTimeoutInMs(properties.getConnection_timeout_in_ms())
102+
.zoneId(properties.getZone_id())
103+
.thriftDefaultBufferSize(properties.getThrift_default_buffer_size())
104+
.thriftMaxFrameSize(properties.getThrift_max_frame_size())
105+
.enableRedirection(properties.isEnable_redirection())
106+
.enableRecordsAutoConvertTablet(properties.isEnable_records_auto_convert_tablet())
92107
.build();
93108
}
94109
}

0 commit comments

Comments
 (0)