Skip to content

Commit 466c0d9

Browse files
authored
fix trim (apache#14130)
* fix trim * fix some problem
1 parent e85a7ea commit 466c0d9

File tree

2 files changed

+112
-38
lines changed

2 files changed

+112
-38
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -586,16 +586,23 @@ public void loadProperties(Properties properties) throws BadNodeUrlException, IO
586586

587587
int subtaskNum =
588588
Integer.parseInt(
589-
properties.getProperty(
590-
"sub_compaction_thread_count", Integer.toString(conf.getSubCompactionTaskNum())));
589+
Optional.ofNullable(
590+
properties.getProperty(
591+
"sub_compaction_thread_count",
592+
Integer.toString(conf.getSubCompactionTaskNum())))
593+
.map(String::trim)
594+
.orElse(Integer.toString(conf.getSubCompactionTaskNum())));
591595
subtaskNum = subtaskNum <= 0 ? 1 : subtaskNum;
592596
conf.setSubCompactionTaskNum(subtaskNum);
593597

594598
int compactionScheduleThreadNum =
595599
Integer.parseInt(
596-
properties.getProperty(
597-
"compaction_schedule_thread_num",
598-
Integer.toString(conf.getCompactionScheduleThreadNum())));
600+
Optional.ofNullable(
601+
properties.getProperty(
602+
"compaction_schedule_thread_num",
603+
Integer.toString(conf.getCompactionScheduleThreadNum())))
604+
.map(String::trim)
605+
.orElse(Integer.toString(conf.getCompactionScheduleThreadNum())));
599606
compactionScheduleThreadNum =
600607
compactionScheduleThreadNum <= 0 ? 1 : compactionScheduleThreadNum;
601608
conf.setCompactionScheduleThreadNum(compactionScheduleThreadNum);
@@ -1993,10 +2000,15 @@ private boolean loadCompactionTaskHotModifiedProps(Properties properties) throws
19932000
int compactionMaxAlignedSeriesNumInOneBatch = conf.getCompactionMaxAlignedSeriesNumInOneBatch();
19942001
int newCompactionMaxAlignedSeriesNumInOneBatch =
19952002
Integer.parseInt(
1996-
properties.getProperty(
1997-
"compaction_max_aligned_series_num_in_one_batch",
1998-
ConfigurationFileUtils.getConfigurationDefaultValue(
1999-
"compaction_max_aligned_series_num_in_one_batch")));
2003+
Optional.ofNullable(
2004+
properties.getProperty(
2005+
"compaction_max_aligned_series_num_in_one_batch",
2006+
ConfigurationFileUtils.getConfigurationDefaultValue(
2007+
"compaction_max_aligned_series_num_in_one_batch")))
2008+
.map(String::trim)
2009+
.orElse(
2010+
ConfigurationFileUtils.getConfigurationDefaultValue(
2011+
"compaction_max_aligned_series_num_in_one_batch")));
20002012
conf.setCompactionMaxAlignedSeriesNumInOneBatch(
20012013
newCompactionMaxAlignedSeriesNumInOneBatch > 0
20022014
? newCompactionMaxAlignedSeriesNumInOneBatch
@@ -2011,9 +2023,15 @@ private boolean loadCompactionThreadCountHotModifiedProps(Properties properties)
20112023
throws IOException {
20122024
int newConfigCompactionThreadCount =
20132025
Integer.parseInt(
2014-
properties.getProperty(
2015-
"compaction_thread_count",
2016-
ConfigurationFileUtils.getConfigurationDefaultValue("compaction_thread_count")));
2026+
Optional.ofNullable(
2027+
properties.getProperty(
2028+
"compaction_thread_count",
2029+
ConfigurationFileUtils.getConfigurationDefaultValue(
2030+
"compaction_thread_count")))
2031+
.map(String::trim)
2032+
.orElse(
2033+
ConfigurationFileUtils.getConfigurationDefaultValue(
2034+
"compaction_thread_count")));
20172035
if (newConfigCompactionThreadCount <= 0) {
20182036
LOGGER.error("compaction_thread_count must greater than 0");
20192037
return false;
@@ -2039,10 +2057,15 @@ private boolean loadCompactionSubTaskCountHotModifiedProps(Properties properties
20392057
throws IOException {
20402058
int newConfigSubtaskNum =
20412059
Integer.parseInt(
2042-
properties.getProperty(
2043-
"sub_compaction_thread_count",
2044-
ConfigurationFileUtils.getConfigurationDefaultValue(
2045-
"sub_compaction_thread_count")));
2060+
Optional.ofNullable(
2061+
properties.getProperty(
2062+
"sub_compaction_thread_count",
2063+
ConfigurationFileUtils.getConfigurationDefaultValue(
2064+
"sub_compaction_thread_count")))
2065+
.map(String::trim)
2066+
.orElse(
2067+
ConfigurationFileUtils.getConfigurationDefaultValue(
2068+
"sub_compaction_thread_count")));
20462069
if (newConfigSubtaskNum <= 0) {
20472070
LOGGER.error("sub_compaction_thread_count must greater than 0");
20482071
return false;
@@ -3442,8 +3465,11 @@ private void loadPipeProps(Properties properties) {
34423465
.toArray(String[]::new));
34433466

34443467
conf.setIotConsensusV2DeletionFileDir(
3445-
properties.getProperty(
3446-
"iot_consensus_v2_deletion_file_dir", conf.getIotConsensusV2DeletionFileDir()));
3468+
Optional.ofNullable(
3469+
properties.getProperty(
3470+
"iot_consensus_v2_deletion_file_dir", conf.getIotConsensusV2DeletionFileDir()))
3471+
.map(String::trim)
3472+
.orElse(conf.getIotConsensusV2DeletionFileDir()));
34473473
}
34483474

34493475
private void loadCQProps(Properties properties) {

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java

Lines changed: 68 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.net.MalformedURLException;
3434
import java.net.URL;
3535
import java.nio.charset.StandardCharsets;
36+
import java.util.Optional;
3637
import java.util.Properties;
3738

3839
public class IoTDBRestServiceDescriptor {
@@ -80,45 +81,92 @@ private Properties loadProps(String configName) {
8081
private void loadProps(Properties properties) {
8182
conf.setEnableRestService(
8283
Boolean.parseBoolean(
83-
properties.getProperty(
84-
"enable_rest_service", Boolean.toString(conf.isEnableRestService()))));
84+
Optional.ofNullable(
85+
properties.getProperty(
86+
"enable_rest_service", Boolean.toString(conf.isEnableRestService())))
87+
.map(String::trim)
88+
.orElse(Boolean.toString(conf.isEnableRestService()))));
8589
conf.setRestServicePort(
8690
Integer.parseInt(
87-
properties.getProperty(
88-
"rest_service_port", Integer.toString(conf.getRestServicePort()))));
91+
Optional.ofNullable(
92+
properties.getProperty(
93+
"rest_service_port", Integer.toString(conf.getRestServicePort())))
94+
.map(String::trim)
95+
.orElse(Integer.toString(conf.getRestServicePort()))));
8996
conf.setRestQueryDefaultRowSizeLimit(
9097
Integer.parseInt(
91-
properties.getProperty(
92-
"rest_query_default_row_size_limit",
93-
Integer.toString(conf.getRestQueryDefaultRowSizeLimit()))));
98+
Optional.ofNullable(
99+
properties.getProperty(
100+
"rest_query_default_row_size_limit",
101+
Integer.toString(conf.getRestQueryDefaultRowSizeLimit())))
102+
.map(String::trim)
103+
.orElse(Integer.toString(conf.getRestQueryDefaultRowSizeLimit()))));
94104
conf.setEnableSwagger(
95105
Boolean.parseBoolean(
96-
properties.getProperty("enable_swagger", Boolean.toString(conf.isEnableSwagger()))));
106+
Optional.ofNullable(
107+
properties.getProperty(
108+
"enable_swagger", Boolean.toString(conf.isEnableSwagger())))
109+
.map(String::trim)
110+
.orElse(Boolean.toString(conf.isEnableSwagger()))));
97111

98112
conf.setEnableHttps(
99113
Boolean.parseBoolean(
100-
properties.getProperty("enable_https", Boolean.toString(conf.isEnableHttps()))));
114+
Optional.ofNullable(
115+
properties.getProperty("enable_https", Boolean.toString(conf.isEnableHttps())))
116+
.map(String::trim)
117+
.orElse(Boolean.toString(conf.isEnableHttps()))));
101118
conf.setClientAuth(
102119
Boolean.parseBoolean(
103-
properties.getProperty("client_auth", Boolean.toString(conf.isClientAuth()))));
104-
conf.setKeyStorePath(properties.getProperty("key_store_path", conf.getKeyStorePath()));
105-
conf.setKeyStorePwd(properties.getProperty("key_store_pwd", conf.getKeyStorePwd()));
106-
conf.setTrustStorePath(properties.getProperty("trust_store_path", conf.getTrustStorePath()));
107-
conf.setTrustStorePwd(properties.getProperty("trust_store_pwd", conf.getTrustStorePwd()));
120+
Optional.ofNullable(
121+
properties.getProperty("client_auth", Boolean.toString(conf.isClientAuth())))
122+
.map(String::trim)
123+
.orElse(Boolean.toString(conf.isClientAuth()))));
124+
conf.setKeyStorePath(
125+
Optional.ofNullable(properties.getProperty("key_store_path", conf.getKeyStorePath()))
126+
.map(String::trim)
127+
.orElse(conf.getKeyStorePath()));
128+
conf.setKeyStorePwd(
129+
Optional.ofNullable(properties.getProperty("key_store_pwd", conf.getKeyStorePwd()))
130+
.map(String::trim)
131+
.orElse(conf.getKeyStorePwd()));
132+
conf.setTrustStorePath(
133+
Optional.ofNullable(properties.getProperty("trust_store_path", conf.getTrustStorePath()))
134+
.map(String::trim)
135+
.orElse(conf.getTrustStorePath()));
136+
conf.setTrustStorePwd(
137+
Optional.ofNullable(properties.getProperty("trust_store_pwd", conf.getTrustStorePwd()))
138+
.map(String::trim)
139+
.orElse(conf.getTrustStorePwd()));
108140
conf.setIdleTimeoutInSeconds(
109141
Integer.parseInt(
110-
properties.getProperty(
111-
"idle_timeout_in_seconds", Integer.toString(conf.getIdleTimeoutInSeconds()))));
142+
Optional.ofNullable(
143+
properties.getProperty(
144+
"idle_timeout_in_seconds",
145+
Integer.toString(conf.getIdleTimeoutInSeconds())))
146+
.map(String::trim)
147+
.orElse(Integer.toString(conf.getIdleTimeoutInSeconds()))));
112148
conf.setCacheExpireInSeconds(
113149
Integer.parseInt(
114-
properties.getProperty(
115-
"cache_expire_in_seconds", Integer.toString(conf.getCacheExpireInSeconds()))));
150+
Optional.ofNullable(
151+
properties.getProperty(
152+
"cache_expire_in_seconds",
153+
Integer.toString(conf.getCacheExpireInSeconds())))
154+
.map(String::trim)
155+
.orElse(Integer.toString(conf.getCacheExpireInSeconds()))));
116156
conf.setCacheInitNum(
117157
Integer.parseInt(
118-
properties.getProperty("cache_init_num", Integer.toString(conf.getCacheInitNum()))));
158+
Optional.ofNullable(
159+
properties.getProperty(
160+
"cache_init_num", Integer.toString(conf.getCacheInitNum())))
161+
.map(String::trim)
162+
.orElse(Integer.toString(conf.getCacheInitNum()))));
119163
conf.setCacheMaxNum(
120164
Integer.parseInt(
121-
properties.getProperty("cache_max_num", Integer.toString(conf.getCacheMaxNum()))));
165+
Optional.ofNullable(
166+
properties.getProperty(
167+
"cache_max_num", Integer.toString(conf.getCacheMaxNum())))
168+
.map(String::trim)
169+
.orElse(Integer.toString(conf.getCacheMaxNum()))));
122170
}
123171

124172
/**

0 commit comments

Comments
 (0)