From cd7f3e319f6a870c490fea958c52e031fba840ba Mon Sep 17 00:00:00 2001 From: 2b3c511 Date: Tue, 6 May 2025 18:55:07 +0800 Subject: [PATCH 1/3] Add more params in Session --- .../iotdb/config/IoTDBSessionProperties.java | 362 +++++++++++------- .../iotdb/session/IoTDBSessionPool.java | 119 +++--- 2 files changed, 285 insertions(+), 196 deletions(-) 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..665446ff 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,158 +17,236 @@ 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 username; - private String password; - private String database; - private String sql_dialect = "table"; - private Integer max_size = 5; - 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; - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getDatabase() { - return database; - } - - public void setDatabase(String database) { - this.database = database; - } - - public String getSql_dialect() { - return sql_dialect; - } - - public void setSql_dialect(String sql_dialect) { - this.sql_dialect = sql_dialect; - } - - public Integer getMax_size() { - return max_size; - } - - public void setMax_size(Integer max_size) { - this.max_size = max_size; - } - - public Integer getFetch_size() { - return fetch_size; - } - - public void setFetch_size(Integer fetch_size) { - this.fetch_size = fetch_size; - } - - public Long getQuery_timeout_in_ms() { - return query_timeout_in_ms; - } - - public void setQuery_timeout_in_ms(Long query_timeout_in_ms) { - this.query_timeout_in_ms = query_timeout_in_ms; - } - - public Boolean getEnable_auto_fetch() { - return enable_auto_fetch; - } - - public void setEnable_auto_fetch(Boolean enable_auto_fetch) { - this.enable_auto_fetch = enable_auto_fetch; - } - - public Boolean getUse_ssl() { - return use_ssl; - } - - public void setUse_ssl(Boolean use_ssl) { - this.use_ssl = use_ssl; - } - - public Integer getMax_retry_count() { - return max_retry_count; - } - - public void setMax_retry_count(Integer max_retry_count) { - this.max_retry_count = max_retry_count; - } - - public void setQuery_timeout_in_ms(long query_timeout_in_ms) { - this.query_timeout_in_ms = query_timeout_in_ms; - } - - public boolean isEnable_auto_fetch() { - return enable_auto_fetch; - } - - public void setEnable_auto_fetch(boolean enable_auto_fetch) { - this.enable_auto_fetch = enable_auto_fetch; - } + private String url; + private String username; + private String password; + private String database; + private String sql_dialect = "table"; + private Integer max_size = 5; + private Integer fetch_size = 1024; + private long query_timeout_in_ms = 60000L; + private boolean enable_auto_fetch = true; + 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 = 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; + private int thrift_max_frame_size; + private boolean enable_redirection; + private boolean enable_records_auto_convert_tablet = + SessionConfig.DEFAULT_RECORDS_AUTO_CONVERT_TABLET; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getDatabase() { + return database; + } + + public void setDatabase(String database) { + this.database = database; + } + + public String getSql_dialect() { + return sql_dialect; + } + + public void setSql_dialect(String sql_dialect) { + this.sql_dialect = sql_dialect; + } + + public Integer getMax_size() { + return max_size; + } + + public void setMax_size(Integer max_size) { + this.max_size = max_size; + } + + public Integer getFetch_size() { + return fetch_size; + } + + public void setFetch_size(Integer fetch_size) { + this.fetch_size = fetch_size; + } + + public Long getQuery_timeout_in_ms() { + return query_timeout_in_ms; + } + + public void setQuery_timeout_in_ms(Long query_timeout_in_ms) { + this.query_timeout_in_ms = query_timeout_in_ms; + } + + public Boolean getEnable_auto_fetch() { + return enable_auto_fetch; + } + + public void setEnable_auto_fetch(Boolean enable_auto_fetch) { + this.enable_auto_fetch = enable_auto_fetch; + } + + public Boolean getUse_ssl() { + return use_ssl; + } + + public void setUse_ssl(Boolean use_ssl) { + this.use_ssl = use_ssl; + } + + public Integer getMax_retry_count() { + return max_retry_count; + } + + public void setMax_retry_count(Integer max_retry_count) { + this.max_retry_count = max_retry_count; + } + + public void setQuery_timeout_in_ms(long query_timeout_in_ms) { + this.query_timeout_in_ms = query_timeout_in_ms; + } + + public boolean isEnable_auto_fetch() { + return enable_auto_fetch; + } + + public void setEnable_auto_fetch(boolean enable_auto_fetch) { + this.enable_auto_fetch = enable_auto_fetch; + } + + public boolean isUse_ssl() { + return use_ssl; + } + + public void setUse_ssl(boolean use_ssl) { + this.use_ssl = use_ssl; + } + + public void setMax_retry_count(int max_retry_count) { + this.max_retry_count = max_retry_count; + } + + public long getWait_to_get_session_timeout_in_msit() { + return wait_to_get_session_timeout_in_msit; + } + + public void setWait_to_get_session_timeout_in_msit(long wait_to_get_session_timeout_in_msit) { + this.wait_to_get_session_timeout_in_msit = wait_to_get_session_timeout_in_msit; + } + + public boolean isEnable_compression() { + return enable_compression; + } + + public void setEnable_compression(boolean enable_compression) { + this.enable_compression = enable_compression; + } + + public long getRetry_interval_in_ms() { + return retry_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 boolean isUse_ssl() { - return use_ssl; - } + public int getThrift_default_buffer_size() { + return thrift_default_buffer_size; + } - public void setUse_ssl(boolean use_ssl) { - this.use_ssl = use_ssl; - } + public void setThrift_default_buffer_size(int thrift_default_buffer_size) { + this.thrift_default_buffer_size = thrift_default_buffer_size; + } - public void setMax_retry_count(int max_retry_count) { - this.max_retry_count = max_retry_count; - } + public int getThrift_max_frame_size() { + return thrift_max_frame_size; + } - public long getWait_to_get_session_timeout_in_msit() { - return wait_to_get_session_timeout_in_msit; - } + public void setThrift_max_frame_size(int thrift_max_frame_size) { + this.thrift_max_frame_size = thrift_max_frame_size; + } - public void setWait_to_get_session_timeout_in_msit(long wait_to_get_session_timeout_in_msit) { - this.wait_to_get_session_timeout_in_msit = wait_to_get_session_timeout_in_msit; - } + public boolean isEnable_redirection() { + return enable_redirection; + } - public boolean isEnable_compression() { - return enable_compression; - } + public void setEnable_redirection(boolean enable_redirection) { + this.enable_redirection = enable_redirection; + } - public void setEnable_compression(boolean enable_compression) { - this.enable_compression = enable_compression; - } + public boolean isEnable_records_auto_convert_tablet() { + return enable_records_auto_convert_tablet; + } - public long getRetry_interval_in_ms() { - return retry_interval_in_ms; - } + public void setEnable_records_auto_convert_tablet(boolean enable_records_auto_convert_tablet) { + this.enable_records_auto_convert_tablet = enable_records_auto_convert_tablet; + } - public void setRetry_interval_in_ms(long retry_interval_in_ms) { - this.retry_interval_in_ms = retry_interval_in_ms; - } -} +} \ No newline at end of file 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..d4320fc0 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 @@ -22,7 +22,6 @@ import org.apache.iotdb.isession.pool.ITableSessionPool; import org.apache.iotdb.session.pool.SessionPool; import org.apache.iotdb.session.pool.TableSessionPoolBuilder; - import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -35,64 +34,76 @@ @EnableConfigurationProperties(IoTDBSessionProperties.class) public class IoTDBSessionPool { - private final IoTDBSessionProperties properties; - private ITableSessionPool tableSessionPool; - private ISessionPool treeSessionPool; + private final IoTDBSessionProperties properties; + private ITableSessionPool tableSessionPool; + private ISessionPool treeSessionPool; - public IoTDBSessionPool(IoTDBSessionProperties properties) { - this.properties = properties; - } + public IoTDBSessionPool(IoTDBSessionProperties properties) { + this.properties = properties; + } - @Bean - public ITableSessionPool tableSessionPool() { - if (tableSessionPool == null) { - synchronized (IoTDBSessionPool.class) { - if (tableSessionPool == null) { - tableSessionPool = - new TableSessionPoolBuilder() - .nodeUrls(Arrays.asList(properties.getUrl().split(";"))) - .user(properties.getUsername()) - .password(properties.getPassword()) - .database(properties.getDatabase()) - .maxSize(properties.getMax_size()) - .fetchSize(properties.getFetch_size()) - .enableAutoFetch(properties.getEnable_auto_fetch()) - .useSSL(properties.getUse_ssl()) - .queryTimeoutInMs(properties.getQuery_timeout_in_ms()) - .maxRetryCount(properties.getMax_retry_count()) - .waitToGetSessionTimeoutInMs(properties.getQuery_timeout_in_ms()) - .enableCompression(properties.isEnable_compression()) - .retryIntervalInMs(properties.getRetry_interval_in_ms()) - .build(); + @Bean + public ITableSessionPool tableSessionPool() { + if(tableSessionPool == null) { + synchronized (IoTDBSessionPool.class) { + if(tableSessionPool == null) { + tableSessionPool = new TableSessionPoolBuilder(). + nodeUrls(Arrays.asList(properties.getUrl().split(";"))). + user(properties.getUsername()). + password(properties.getPassword()). + database(properties.getDatabase()). + maxSize(properties.getMax_size()). + fetchSize(properties.getFetch_size()). + enableAutoFetch(properties.getEnable_auto_fetch()). + useSSL(properties.getUse_ssl()). + queryTimeoutInMs(properties.getQuery_timeout_in_ms()). + maxRetryCount(properties.getMax_retry_count()). + 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(); + } + } } - } + return tableSessionPool; } - return tableSessionPool; - } - @Bean - public ISessionPool treeSessionPool() { - if (treeSessionPool == null) { - synchronized (IoTDBSessionPool.class) { - if (treeSessionPool == null) { - treeSessionPool = - new SessionPool.Builder() - .nodeUrls(Arrays.asList(properties.getUrl().split(";"))) - .user(properties.getUsername()) - .password(properties.getPassword()) - .maxSize(properties.getMax_size()) - .fetchSize(properties.getFetch_size()) - .enableAutoFetch(properties.getEnable_auto_fetch()) - .useSSL(properties.getUse_ssl()) - .queryTimeoutInMs(properties.getQuery_timeout_in_ms()) - .maxRetryCount(properties.getMax_retry_count()) - .waitToGetSessionTimeoutInMs(properties.getQuery_timeout_in_ms()) - .enableCompression(properties.isEnable_compression()) - .retryIntervalInMs(properties.getRetry_interval_in_ms()) - .build(); + @Bean + public ISessionPool treeSessionPool() { + if(treeSessionPool == null) { + synchronized (IoTDBSessionPool.class) { + if(treeSessionPool == null) { + treeSessionPool = new SessionPool.Builder(). + nodeUrls(Arrays.asList(properties.getUrl().split(";"))). + user(properties.getUsername()). + password(properties.getPassword()). + maxSize(properties.getMax_size()). + fetchSize(properties.getFetch_size()). + enableAutoFetch(properties.getEnable_auto_fetch()). + useSSL(properties.getUse_ssl()). + queryTimeoutInMs(properties.getQuery_timeout_in_ms()). + maxRetryCount(properties.getMax_retry_count()). + 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(); + } + } } - } + return treeSessionPool; } - return treeSessionPool; - } } From a6a8a8ebba1ea5d47518a575453cde041974afbc Mon Sep 17 00:00:00 2001 From: 2b3c511 Date: Thu, 8 May 2025 18:35:08 +0800 Subject: [PATCH 2/3] update name --- .../service/IoTDBService.java | 3 +++ .../src/main/resources/application.properties | 6 +++--- .../iotdb/config/IoTDBSessionProperties.java | 14 +++++++------- .../org/apache/iotdb/session/IoTDBSessionPool.java | 7 ++++--- 4 files changed, 17 insertions(+), 13 deletions(-) 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 665446ff..4969836d 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 @@ -24,7 +24,7 @@ @ConfigurationProperties(prefix = "iotdb.session") public class IoTDBSessionProperties { - private String url; + private String node_urls; private String username; private String password; private String database; @@ -42,18 +42,18 @@ public class IoTDBSessionProperties { private String trust_store_pwd; private int connection_timeout_in_ms; private ZoneId zone_id; - private int thrift_default_buffer_size; - private int thrift_max_frame_size; + 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() { 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 d4320fc0..1b68af61 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 @@ -48,7 +48,7 @@ public ITableSessionPool tableSessionPool() { synchronized (IoTDBSessionPool.class) { 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()). @@ -67,7 +67,8 @@ public ITableSessionPool tableSessionPool() { zoneId(properties.getZone_id()). thriftDefaultBufferSize(properties.getThrift_default_buffer_size()). thriftMaxFrameSize(properties.getThrift_max_frame_size()). - enableRedirection(properties.isEnable_redirection()).build(); + enableRedirection(properties.isEnable_redirection()). + build(); } } } @@ -80,7 +81,7 @@ public ISessionPool treeSessionPool() { synchronized (IoTDBSessionPool.class) { 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()). From 9abca0273e0ea7446d92a147c2794432dfe89019 Mon Sep 17 00:00:00 2001 From: 2b3c511 Date: Fri, 9 May 2025 09:46:40 +0800 Subject: [PATCH 3/3] spotless:apply --- .../iotdb/config/IoTDBSessionProperties.java | 399 +++++++++--------- .../iotdb/session/IoTDBSessionPool.java | 135 +++--- 2 files changed, 268 insertions(+), 266 deletions(-) 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 4969836d..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 @@ -18,235 +18,234 @@ 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 node_urls; - private String username; - private String password; - private String database; - private String sql_dialect = "table"; - private Integer max_size = 5; - private Integer fetch_size = 1024; - private long query_timeout_in_ms = 60000L; - private boolean enable_auto_fetch = true; - 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 = 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 getNode_urls() { - return node_urls; - } - - public void setNode_urls(String node_urls) { - this.node_urls = node_urls; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getDatabase() { - return database; - } - - public void setDatabase(String database) { - this.database = database; - } - - public String getSql_dialect() { - return sql_dialect; - } - - public void setSql_dialect(String sql_dialect) { - this.sql_dialect = sql_dialect; - } - - public Integer getMax_size() { - return max_size; - } - - public void setMax_size(Integer max_size) { - this.max_size = max_size; - } - - public Integer getFetch_size() { - return fetch_size; - } - - public void setFetch_size(Integer fetch_size) { - this.fetch_size = fetch_size; - } - - public Long getQuery_timeout_in_ms() { - return query_timeout_in_ms; - } - - public void setQuery_timeout_in_ms(Long query_timeout_in_ms) { - this.query_timeout_in_ms = query_timeout_in_ms; - } - - public Boolean getEnable_auto_fetch() { - return enable_auto_fetch; - } - - public void setEnable_auto_fetch(Boolean enable_auto_fetch) { - this.enable_auto_fetch = enable_auto_fetch; - } - - public Boolean getUse_ssl() { - return use_ssl; - } - - public void setUse_ssl(Boolean use_ssl) { - this.use_ssl = use_ssl; - } - - public Integer getMax_retry_count() { - return max_retry_count; - } - - public void setMax_retry_count(Integer max_retry_count) { - this.max_retry_count = max_retry_count; - } - - public void setQuery_timeout_in_ms(long query_timeout_in_ms) { - this.query_timeout_in_ms = query_timeout_in_ms; - } - - public boolean isEnable_auto_fetch() { - return enable_auto_fetch; - } - - public void setEnable_auto_fetch(boolean enable_auto_fetch) { - this.enable_auto_fetch = enable_auto_fetch; - } - - public boolean isUse_ssl() { - return use_ssl; - } + private String node_urls; + private String username; + private String password; + private String database; + private String sql_dialect = "table"; + private Integer max_size = 5; + private Integer fetch_size = 1024; + private long query_timeout_in_ms = 60000L; + private boolean enable_auto_fetch = true; + 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 = 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 getNode_urls() { + return node_urls; + } + + public void setNode_urls(String node_urls) { + this.node_urls = node_urls; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getDatabase() { + return database; + } + + public void setDatabase(String database) { + this.database = database; + } + + public String getSql_dialect() { + return sql_dialect; + } + + public void setSql_dialect(String sql_dialect) { + this.sql_dialect = sql_dialect; + } + + public Integer getMax_size() { + return max_size; + } + + public void setMax_size(Integer max_size) { + this.max_size = max_size; + } + + public Integer getFetch_size() { + return fetch_size; + } + + public void setFetch_size(Integer fetch_size) { + this.fetch_size = fetch_size; + } + + public Long getQuery_timeout_in_ms() { + return query_timeout_in_ms; + } + + public void setQuery_timeout_in_ms(Long query_timeout_in_ms) { + this.query_timeout_in_ms = query_timeout_in_ms; + } + + public Boolean getEnable_auto_fetch() { + return enable_auto_fetch; + } + + public void setEnable_auto_fetch(Boolean enable_auto_fetch) { + this.enable_auto_fetch = enable_auto_fetch; + } + + public Boolean getUse_ssl() { + return use_ssl; + } + + public void setUse_ssl(Boolean use_ssl) { + this.use_ssl = use_ssl; + } + + public Integer getMax_retry_count() { + return max_retry_count; + } + + public void setMax_retry_count(Integer max_retry_count) { + this.max_retry_count = max_retry_count; + } + + public void setQuery_timeout_in_ms(long query_timeout_in_ms) { + this.query_timeout_in_ms = query_timeout_in_ms; + } + + public boolean isEnable_auto_fetch() { + return enable_auto_fetch; + } - public void setUse_ssl(boolean use_ssl) { - this.use_ssl = use_ssl; - } + public void setEnable_auto_fetch(boolean enable_auto_fetch) { + this.enable_auto_fetch = enable_auto_fetch; + } - public void setMax_retry_count(int max_retry_count) { - this.max_retry_count = max_retry_count; - } + public boolean isUse_ssl() { + return use_ssl; + } - public long getWait_to_get_session_timeout_in_msit() { - return wait_to_get_session_timeout_in_msit; - } + public void setUse_ssl(boolean use_ssl) { + this.use_ssl = use_ssl; + } - public void setWait_to_get_session_timeout_in_msit(long wait_to_get_session_timeout_in_msit) { - this.wait_to_get_session_timeout_in_msit = wait_to_get_session_timeout_in_msit; - } + public void setMax_retry_count(int max_retry_count) { + this.max_retry_count = max_retry_count; + } - public boolean isEnable_compression() { - return enable_compression; - } + public long getWait_to_get_session_timeout_in_msit() { + return wait_to_get_session_timeout_in_msit; + } - public void setEnable_compression(boolean enable_compression) { - this.enable_compression = enable_compression; - } + public void setWait_to_get_session_timeout_in_msit(long wait_to_get_session_timeout_in_msit) { + this.wait_to_get_session_timeout_in_msit = wait_to_get_session_timeout_in_msit; + } - public long getRetry_interval_in_ms() { - return retry_interval_in_ms; - } + public boolean isEnable_compression() { + return enable_compression; + } - public void setRetry_interval_in_ms(long retry_interval_in_ms) { - this.retry_interval_in_ms = retry_interval_in_ms; - } + public void setEnable_compression(boolean enable_compression) { + this.enable_compression = enable_compression; + } - public String getTrust_store() { - return trust_store; - } + public long getRetry_interval_in_ms() { + return retry_interval_in_ms; + } - public void setTrust_store(String trust_store) { - this.trust_store = trust_store; - } + public void setRetry_interval_in_ms(long retry_interval_in_ms) { + this.retry_interval_in_ms = retry_interval_in_ms; + } - public String getTrust_store_pwd() { - return trust_store_pwd; - } + public String getTrust_store() { + return trust_store; + } - public void setTrust_store_pwd(String trust_store_pwd) { - this.trust_store_pwd = trust_store_pwd; - } + public void setTrust_store(String trust_store) { + this.trust_store = trust_store; + } + public String getTrust_store_pwd() { + return trust_store_pwd; + } - public int getConnection_timeout_in_ms() { - return connection_timeout_in_ms; - } + public void setTrust_store_pwd(String trust_store_pwd) { + this.trust_store_pwd = trust_store_pwd; + } - public void setConnection_timeout_in_ms(int connection_timeout_in_ms) { - this.connection_timeout_in_ms = connection_timeout_in_ms; - } + public int getConnection_timeout_in_ms() { + return connection_timeout_in_ms; + } - public ZoneId getZone_id() { - return zone_id; - } + public void setConnection_timeout_in_ms(int connection_timeout_in_ms) { + this.connection_timeout_in_ms = connection_timeout_in_ms; + } - public void setZone_id(ZoneId zone_id) { - this.zone_id = zone_id; - } + public ZoneId getZone_id() { + return zone_id; + } - public int getThrift_default_buffer_size() { - return thrift_default_buffer_size; - } + public void setZone_id(ZoneId zone_id) { + this.zone_id = zone_id; + } - public void setThrift_default_buffer_size(int thrift_default_buffer_size) { - this.thrift_default_buffer_size = thrift_default_buffer_size; - } + public int getThrift_default_buffer_size() { + return thrift_default_buffer_size; + } - public int getThrift_max_frame_size() { - return thrift_max_frame_size; - } + public void setThrift_default_buffer_size(int thrift_default_buffer_size) { + this.thrift_default_buffer_size = thrift_default_buffer_size; + } - public void setThrift_max_frame_size(int thrift_max_frame_size) { - this.thrift_max_frame_size = thrift_max_frame_size; - } + public int getThrift_max_frame_size() { + return thrift_max_frame_size; + } - public boolean isEnable_redirection() { - return enable_redirection; - } + public void setThrift_max_frame_size(int thrift_max_frame_size) { + this.thrift_max_frame_size = thrift_max_frame_size; + } - public void setEnable_redirection(boolean enable_redirection) { - this.enable_redirection = enable_redirection; - } + public boolean isEnable_redirection() { + return enable_redirection; + } - public boolean isEnable_records_auto_convert_tablet() { - return enable_records_auto_convert_tablet; - } + public void setEnable_redirection(boolean enable_redirection) { + this.enable_redirection = enable_redirection; + } - public void setEnable_records_auto_convert_tablet(boolean enable_records_auto_convert_tablet) { - this.enable_records_auto_convert_tablet = enable_records_auto_convert_tablet; - } + public boolean isEnable_records_auto_convert_tablet() { + return enable_records_auto_convert_tablet; + } -} \ No newline at end of file + 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 1b68af61..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 @@ -22,6 +22,7 @@ import org.apache.iotdb.isession.pool.ITableSessionPool; import org.apache.iotdb.session.pool.SessionPool; import org.apache.iotdb.session.pool.TableSessionPoolBuilder; + import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -34,77 +35,79 @@ @EnableConfigurationProperties(IoTDBSessionProperties.class) public class IoTDBSessionPool { - private final IoTDBSessionProperties properties; - private ITableSessionPool tableSessionPool; - private ISessionPool treeSessionPool; + private final IoTDBSessionProperties properties; + private ITableSessionPool tableSessionPool; + private ISessionPool treeSessionPool; - public IoTDBSessionPool(IoTDBSessionProperties properties) { - this.properties = properties; - } + public IoTDBSessionPool(IoTDBSessionProperties properties) { + this.properties = properties; + } - @Bean - public ITableSessionPool tableSessionPool() { - if(tableSessionPool == null) { - synchronized (IoTDBSessionPool.class) { - if(tableSessionPool == null) { - tableSessionPool = new TableSessionPoolBuilder(). - nodeUrls(Arrays.asList(properties.getNode_urls().split(";"))). - user(properties.getUsername()). - password(properties.getPassword()). - database(properties.getDatabase()). - maxSize(properties.getMax_size()). - fetchSize(properties.getFetch_size()). - enableAutoFetch(properties.getEnable_auto_fetch()). - useSSL(properties.getUse_ssl()). - queryTimeoutInMs(properties.getQuery_timeout_in_ms()). - maxRetryCount(properties.getMax_retry_count()). - 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(); - } - } + @Bean + public ITableSessionPool tableSessionPool() { + if (tableSessionPool == null) { + synchronized (IoTDBSessionPool.class) { + if (tableSessionPool == null) { + tableSessionPool = + new TableSessionPoolBuilder() + .nodeUrls(Arrays.asList(properties.getNode_urls().split(";"))) + .user(properties.getUsername()) + .password(properties.getPassword()) + .database(properties.getDatabase()) + .maxSize(properties.getMax_size()) + .fetchSize(properties.getFetch_size()) + .enableAutoFetch(properties.getEnable_auto_fetch()) + .useSSL(properties.getUse_ssl()) + .queryTimeoutInMs(properties.getQuery_timeout_in_ms()) + .maxRetryCount(properties.getMax_retry_count()) + .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(); } - return tableSessionPool; + } } + return tableSessionPool; + } - @Bean - public ISessionPool treeSessionPool() { - if(treeSessionPool == null) { - synchronized (IoTDBSessionPool.class) { - if(treeSessionPool == null) { - treeSessionPool = new SessionPool.Builder(). - nodeUrls(Arrays.asList(properties.getNode_urls().split(";"))). - user(properties.getUsername()). - password(properties.getPassword()). - maxSize(properties.getMax_size()). - fetchSize(properties.getFetch_size()). - enableAutoFetch(properties.getEnable_auto_fetch()). - useSSL(properties.getUse_ssl()). - queryTimeoutInMs(properties.getQuery_timeout_in_ms()). - maxRetryCount(properties.getMax_retry_count()). - 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(); - } - } + @Bean + public ISessionPool treeSessionPool() { + if (treeSessionPool == null) { + synchronized (IoTDBSessionPool.class) { + if (treeSessionPool == null) { + treeSessionPool = + new SessionPool.Builder() + .nodeUrls(Arrays.asList(properties.getNode_urls().split(";"))) + .user(properties.getUsername()) + .password(properties.getPassword()) + .maxSize(properties.getMax_size()) + .fetchSize(properties.getFetch_size()) + .enableAutoFetch(properties.getEnable_auto_fetch()) + .useSSL(properties.getUse_ssl()) + .queryTimeoutInMs(properties.getQuery_timeout_in_ms()) + .maxRetryCount(properties.getMax_retry_count()) + .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(); } - return treeSessionPool; + } } + return treeSessionPool; + } }