diff --git a/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java index c9a5163b..1fe51abc 100644 --- a/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java +++ b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java @@ -53,6 +53,8 @@ public void queryTableSessionPool() throws IoTDBConnectionException, StatementEx } System.out.println(); } + sessionDataSet.close(); + tableSession.close(); } public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException { @@ -65,5 +67,6 @@ public void querySessionPool() throws IoTDBConnectionException, StatementExecuti } System.out.println(); } + sessionDataSetWrapper.close(); } } diff --git a/examples/iotdb-spring-boot-start/src/main/resources/application.properties b/examples/iotdb-spring-boot-start/src/main/resources/application.properties index 19e61953..354d7d7e 100644 --- a/examples/iotdb-spring-boot-start/src/main/resources/application.properties +++ b/examples/iotdb-spring-boot-start/src/main/resources/application.properties @@ -18,9 +18,9 @@ spring.application.name=iotdb-spring-boot-start -iotdb.session.url=127.0.0.1:6667 +iotdb.session.node_urls=172.20.31.56:6668 iotdb.session.password=root iotdb.session.username=root iotdb.session.database=wind -iotdb.session.sql-dialect=table -iotdb.session.max-size=10 \ No newline at end of file +iotdb.session.sql_dialect=table +iotdb.session.max_size=10 \ No newline at end of file diff --git a/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/config/IoTDBSessionProperties.java b/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/config/IoTDBSessionProperties.java index 25c22120..54e22dc6 100644 --- a/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/config/IoTDBSessionProperties.java +++ b/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/config/IoTDBSessionProperties.java @@ -17,11 +17,15 @@ package org.apache.iotdb.config; +import org.apache.iotdb.isession.SessionConfig; + import org.springframework.boot.context.properties.ConfigurationProperties; +import java.time.ZoneId; + @ConfigurationProperties(prefix = "iotdb.session") public class IoTDBSessionProperties { - private String url; + private String node_urls; private String username; private String password; private String database; @@ -30,18 +34,27 @@ public class IoTDBSessionProperties { private Integer fetch_size = 1024; private long query_timeout_in_ms = 60000L; private boolean enable_auto_fetch = true; - private boolean use_ssl = false; private int max_retry_count = 60; private long wait_to_get_session_timeout_in_msit = 60000L; private boolean enable_compression = false; - private long retry_interval_in_ms = 500L; + private long retry_interval_in_ms = SessionConfig.RETRY_INTERVAL_IN_MS; + private boolean use_ssl = false; + private String trust_store; + private String trust_store_pwd; + private int connection_timeout_in_ms; + private ZoneId zone_id; + private int thrift_default_buffer_size = 1024; + private int thrift_max_frame_size = 67108864; + private boolean enable_redirection; + private boolean enable_records_auto_convert_tablet = + SessionConfig.DEFAULT_RECORDS_AUTO_CONVERT_TABLET; - public String getUrl() { - return url; + public String getNode_urls() { + return node_urls; } - public void setUrl(String url) { - this.url = url; + public void setNode_urls(String node_urls) { + this.node_urls = node_urls; } public String getUsername() { @@ -171,4 +184,68 @@ public long getRetry_interval_in_ms() { public void setRetry_interval_in_ms(long retry_interval_in_ms) { this.retry_interval_in_ms = retry_interval_in_ms; } + + public String getTrust_store() { + return trust_store; + } + + public void setTrust_store(String trust_store) { + this.trust_store = trust_store; + } + + public String getTrust_store_pwd() { + return trust_store_pwd; + } + + public void setTrust_store_pwd(String trust_store_pwd) { + this.trust_store_pwd = trust_store_pwd; + } + + public int getConnection_timeout_in_ms() { + return connection_timeout_in_ms; + } + + public void setConnection_timeout_in_ms(int connection_timeout_in_ms) { + this.connection_timeout_in_ms = connection_timeout_in_ms; + } + + public ZoneId getZone_id() { + return zone_id; + } + + public void setZone_id(ZoneId zone_id) { + this.zone_id = zone_id; + } + + public int getThrift_default_buffer_size() { + return thrift_default_buffer_size; + } + + public void setThrift_default_buffer_size(int thrift_default_buffer_size) { + this.thrift_default_buffer_size = thrift_default_buffer_size; + } + + public int getThrift_max_frame_size() { + return thrift_max_frame_size; + } + + public void setThrift_max_frame_size(int thrift_max_frame_size) { + this.thrift_max_frame_size = thrift_max_frame_size; + } + + public boolean isEnable_redirection() { + return enable_redirection; + } + + public void setEnable_redirection(boolean enable_redirection) { + this.enable_redirection = enable_redirection; + } + + public boolean isEnable_records_auto_convert_tablet() { + return enable_records_auto_convert_tablet; + } + + public void setEnable_records_auto_convert_tablet(boolean enable_records_auto_convert_tablet) { + this.enable_records_auto_convert_tablet = enable_records_auto_convert_tablet; + } } diff --git a/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/session/IoTDBSessionPool.java b/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/session/IoTDBSessionPool.java index 5267c924..09ceb53f 100644 --- a/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/session/IoTDBSessionPool.java +++ b/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/session/IoTDBSessionPool.java @@ -50,7 +50,7 @@ public ITableSessionPool tableSessionPool() { if (tableSessionPool == null) { tableSessionPool = new TableSessionPoolBuilder() - .nodeUrls(Arrays.asList(properties.getUrl().split(";"))) + .nodeUrls(Arrays.asList(properties.getNode_urls().split(";"))) .user(properties.getUsername()) .password(properties.getPassword()) .database(properties.getDatabase()) @@ -63,6 +63,13 @@ public ITableSessionPool tableSessionPool() { .waitToGetSessionTimeoutInMs(properties.getQuery_timeout_in_ms()) .enableCompression(properties.isEnable_compression()) .retryIntervalInMs(properties.getRetry_interval_in_ms()) + .trustStore(properties.getTrust_store()) + .trustStorePwd(properties.getTrust_store_pwd()) + .connectionTimeoutInMs(properties.getConnection_timeout_in_ms()) + .zoneId(properties.getZone_id()) + .thriftDefaultBufferSize(properties.getThrift_default_buffer_size()) + .thriftMaxFrameSize(properties.getThrift_max_frame_size()) + .enableRedirection(properties.isEnable_redirection()) .build(); } } @@ -77,7 +84,7 @@ public ISessionPool treeSessionPool() { if (treeSessionPool == null) { treeSessionPool = new SessionPool.Builder() - .nodeUrls(Arrays.asList(properties.getUrl().split(";"))) + .nodeUrls(Arrays.asList(properties.getNode_urls().split(";"))) .user(properties.getUsername()) .password(properties.getPassword()) .maxSize(properties.getMax_size()) @@ -89,6 +96,14 @@ public ISessionPool treeSessionPool() { .waitToGetSessionTimeoutInMs(properties.getQuery_timeout_in_ms()) .enableCompression(properties.isEnable_compression()) .retryIntervalInMs(properties.getRetry_interval_in_ms()) + .trustStore(properties.getTrust_store()) + .trustStorePwd(properties.getTrust_store_pwd()) + .connectionTimeoutInMs(properties.getConnection_timeout_in_ms()) + .zoneId(properties.getZone_id()) + .thriftDefaultBufferSize(properties.getThrift_default_buffer_size()) + .thriftMaxFrameSize(properties.getThrift_max_frame_size()) + .enableRedirection(properties.isEnable_redirection()) + .enableRecordsAutoConvertTablet(properties.isEnable_records_auto_convert_tablet()) .build(); } }