• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #9829

pending completion
#9829

push

travis_ci

web-flow
[To rel/1.2] fix parameter schemaRegionPerNode load error (#10845)

* fix parameter schemaRegionPerNode load error (#10841)

* fix conflict

* fix common.properties

1 of 1 new or added line in 1 file covered. (100.0%)

79706 of 165790 relevant lines covered (48.08%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

4.5
/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.apache.iotdb.confignode.conf;
21

22
import org.apache.iotdb.commons.conf.CommonConfig;
23
import org.apache.iotdb.commons.conf.CommonDescriptor;
24
import org.apache.iotdb.commons.conf.IoTDBConstant;
25
import org.apache.iotdb.commons.exception.BadNodeUrlException;
26
import org.apache.iotdb.commons.utils.NodeUrlUtils;
27
import org.apache.iotdb.confignode.manager.load.balancer.RegionBalancer;
28
import org.apache.iotdb.confignode.manager.load.balancer.router.leader.ILeaderBalancer;
29
import org.apache.iotdb.confignode.manager.load.balancer.router.priority.IPriorityBalancer;
30
import org.apache.iotdb.confignode.manager.partition.RegionGroupExtensionPolicy;
31
import org.apache.iotdb.db.conf.IoTDBConfig;
32
import org.apache.iotdb.metrics.config.MetricConfigDescriptor;
33
import org.apache.iotdb.metrics.utils.NodeType;
34

35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

38
import java.io.File;
39
import java.io.FileNotFoundException;
40
import java.io.IOException;
41
import java.io.InputStream;
42
import java.net.MalformedURLException;
43
import java.net.URL;
44
import java.util.Properties;
45

46
public class ConfigNodeDescriptor {
47
  private static final Logger LOGGER = LoggerFactory.getLogger(ConfigNodeDescriptor.class);
1✔
48

49
  private final CommonDescriptor commonDescriptor = CommonDescriptor.getInstance();
1✔
50

51
  private final ConfigNodeConfig conf = new ConfigNodeConfig();
1✔
52

53
  private ConfigNodeDescriptor() {
1✔
54
    loadProps();
1✔
55
  }
1✔
56

57
  public ConfigNodeConfig getConf() {
58
    return conf;
1✔
59
  }
60

61
  /**
62
   * Get props url location.
63
   *
64
   * @return url object if location exit, otherwise null.
65
   */
66
  public URL getPropsUrl(String configFileName) {
67
    // Check if a config-directory was specified first.
68
    String urlString = System.getProperty(ConfigNodeConstant.CONFIGNODE_CONF, null);
1✔
69
    // If it wasn't, check if a home directory was provided
70
    if (urlString == null) {
1✔
71
      urlString = System.getProperty(ConfigNodeConstant.CONFIGNODE_HOME, null);
1✔
72
      if (urlString != null) {
1✔
73
        urlString = urlString + File.separatorChar + "conf" + File.separatorChar + configFileName;
×
74
      } else {
75
        // When start ConfigNode with the script, the environment variables CONFIGNODE_CONF
76
        // and CONFIGNODE_HOME will be set. But we didn't set these two in developer mode.
77
        // Thus, just return null and use default Configuration in developer mode.
78
        return null;
1✔
79
      }
80
    }
81
    // If a config location was provided, but it doesn't end with a properties file,
82
    // append the default location.
83
    else if (!urlString.endsWith(".properties")) {
×
84
      urlString += (File.separatorChar + configFileName);
×
85
    }
86

87
    // If the url doesn't start with "file:" or "classpath:", it's provided as a no path.
88
    // So we need to add it to make it a real URL.
89
    if (!urlString.startsWith("file:") && !urlString.startsWith("classpath:")) {
×
90
      urlString = "file:" + urlString;
×
91
    }
92
    try {
93
      return new URL(urlString);
×
94
    } catch (MalformedURLException e) {
×
95
      return null;
×
96
    }
97
  }
98

99
  private void loadProps() {
100
    URL url = getPropsUrl(CommonConfig.CONFIG_NAME);
1✔
101
    Properties commonProperties = new Properties();
1✔
102
    if (url != null) {
1✔
103
      try (InputStream inputStream = url.openStream()) {
×
104

105
        LOGGER.info("Start to read config file {}", url);
×
106
        commonProperties.load(inputStream);
×
107

108
      } catch (FileNotFoundException e) {
×
109
        LOGGER.warn("Fail to find config file {}", url, e);
×
110
      } catch (IOException e) {
×
111
        LOGGER.warn("Cannot load config file, use default configuration", e);
×
112
      } catch (Exception e) {
×
113
        LOGGER.warn("Incorrect format in config file, use default configuration", e);
×
114
      }
×
115
    } else {
116
      LOGGER.warn(
1✔
117
          "Couldn't load the configuration {} from any of the known sources.",
118
          CommonConfig.CONFIG_NAME);
119
    }
120

121
    url = getPropsUrl(ConfigNodeConstant.CONF_FILE_NAME);
1✔
122
    if (url != null) {
1✔
123
      try (InputStream inputStream = url.openStream()) {
×
124
        LOGGER.info("start reading ConfigNode conf file: {}", url);
×
125
        Properties properties = new Properties();
×
126
        properties.load(inputStream);
×
127
        commonProperties.putAll(properties);
×
128
        loadProperties(commonProperties);
×
129
      } catch (IOException | BadNodeUrlException e) {
×
130
        LOGGER.warn("Couldn't load ConfigNode conf file, use default config", e);
×
131
      } finally {
132
        conf.updatePath();
×
133
        commonDescriptor
×
134
            .getConfig()
×
135
            .updatePath(System.getProperty(ConfigNodeConstant.CONFIGNODE_HOME, null));
×
136
        MetricConfigDescriptor.getInstance().loadProps(commonProperties);
×
137
        MetricConfigDescriptor.getInstance()
×
138
            .getMetricConfig()
×
139
            .updateRpcInstance(
×
140
                conf.getClusterName(), NodeType.CONFIGNODE, IoTDBConfig.SYSTEM_DATABASE);
×
141
      }
×
142
    } else {
143
      LOGGER.warn(
1✔
144
          "Couldn't load the configuration {} from any of the known sources.",
145
          ConfigNodeConstant.CONF_FILE_NAME);
146
    }
147
  }
1✔
148

149
  private void loadProperties(Properties properties) throws BadNodeUrlException, IOException {
150
    conf.setClusterName(
×
151
        properties.getProperty(IoTDBConstant.CLUSTER_NAME, conf.getClusterName()).trim());
×
152

153
    conf.setInternalAddress(
×
154
        properties
155
            .getProperty(IoTDBConstant.CN_INTERNAL_ADDRESS, conf.getInternalAddress())
×
156
            .trim());
×
157

158
    conf.setInternalPort(
×
159
        Integer.parseInt(
×
160
            properties
161
                .getProperty(IoTDBConstant.CN_INTERNAL_PORT, String.valueOf(conf.getInternalPort()))
×
162
                .trim()));
×
163

164
    conf.setConsensusPort(
×
165
        Integer.parseInt(
×
166
            properties
167
                .getProperty(
×
168
                    IoTDBConstant.CN_CONSENSUS_PORT, String.valueOf(conf.getConsensusPort()))
×
169
                .trim()));
×
170

171
    // TODO: Enable multiple target_config_node_list
172
    String targetConfigNodes =
×
173
        properties.getProperty(IoTDBConstant.CN_TARGET_CONFIG_NODE_LIST, null);
×
174
    if (targetConfigNodes != null) {
×
175
      conf.setTargetConfigNode(NodeUrlUtils.parseTEndPointUrl(targetConfigNodes.trim()));
×
176
    }
177

178
    conf.setSeriesSlotNum(
×
179
        Integer.parseInt(
×
180
            properties
181
                .getProperty("series_slot_num", String.valueOf(conf.getSeriesSlotNum()))
×
182
                .trim()));
×
183

184
    conf.setSeriesPartitionExecutorClass(
×
185
        properties
186
            .getProperty("series_partition_executor_class", conf.getSeriesPartitionExecutorClass())
×
187
            .trim());
×
188

189
    conf.setConfigNodeConsensusProtocolClass(
×
190
        properties
191
            .getProperty(
×
192
                "config_node_consensus_protocol_class", conf.getConfigNodeConsensusProtocolClass())
×
193
            .trim());
×
194

195
    conf.setSchemaRegionConsensusProtocolClass(
×
196
        properties
197
            .getProperty(
×
198
                "schema_region_consensus_protocol_class",
199
                conf.getSchemaRegionConsensusProtocolClass())
×
200
            .trim());
×
201

202
    conf.setSchemaReplicationFactor(
×
203
        Integer.parseInt(
×
204
            properties
205
                .getProperty(
×
206
                    "schema_replication_factor", String.valueOf(conf.getSchemaReplicationFactor()))
×
207
                .trim()));
×
208

209
    conf.setDataRegionConsensusProtocolClass(
×
210
        properties
211
            .getProperty(
×
212
                "data_region_consensus_protocol_class", conf.getDataRegionConsensusProtocolClass())
×
213
            .trim());
×
214

215
    conf.setDataReplicationFactor(
×
216
        Integer.parseInt(
×
217
            properties
218
                .getProperty(
×
219
                    "data_replication_factor", String.valueOf(conf.getDataReplicationFactor()))
×
220
                .trim()));
×
221

222
    conf.setSchemaRegionGroupExtensionPolicy(
×
223
        RegionGroupExtensionPolicy.parse(
×
224
            properties.getProperty(
×
225
                "schema_region_group_extension_policy",
226
                conf.getSchemaRegionGroupExtensionPolicy().getPolicy().trim())));
×
227

228
    conf.setDefaultSchemaRegionGroupNumPerDatabase(
×
229
        Integer.parseInt(
×
230
            properties
231
                .getProperty(
×
232
                    "default_schema_region_group_num_per_database",
233
                    String.valueOf(conf.getDefaultSchemaRegionGroupNumPerDatabase()))
×
234
                .trim()));
×
235

236
    conf.setSchemaRegionPerDataNode(
×
237
        Double.parseDouble(
×
238
            properties
239
                .getProperty(
×
240
                    "schema_region_per_data_node",
241
                    String.valueOf(conf.getSchemaRegionPerDataNode()))
×
242
                .trim()));
×
243

244
    conf.setDataRegionGroupExtensionPolicy(
×
245
        RegionGroupExtensionPolicy.parse(
×
246
            properties.getProperty(
×
247
                "data_region_group_extension_policy",
248
                conf.getDataRegionGroupExtensionPolicy().getPolicy().trim())));
×
249

250
    conf.setDefaultDataRegionGroupNumPerDatabase(
×
251
        Integer.parseInt(
×
252
            properties.getProperty(
×
253
                "default_data_region_group_num_per_database",
254
                String.valueOf(conf.getDefaultDataRegionGroupNumPerDatabase()).trim())));
×
255

256
    conf.setDataRegionPerDataNode(
×
257
        Double.parseDouble(
×
258
            properties
259
                .getProperty(
×
260
                    "data_region_per_data_node", String.valueOf(conf.getDataRegionPerDataNode()))
×
261
                .trim()));
×
262

263
    try {
264
      conf.setRegionAllocateStrategy(
×
265
          RegionBalancer.RegionGroupAllocatePolicy.valueOf(
×
266
              properties
267
                  .getProperty(
×
268
                      "region_group_allocate_policy", conf.getRegionGroupAllocatePolicy().name())
×
269
                  .trim()));
×
270
    } catch (IllegalArgumentException e) {
×
271
      LOGGER.warn(
×
272
          "The configured region allocate strategy does not exist, use the default: GREEDY!");
273
    }
×
274

275
    conf.setCnRpcAdvancedCompressionEnable(
×
276
        Boolean.parseBoolean(
×
277
            properties
278
                .getProperty(
×
279
                    "cn_rpc_advanced_compression_enable",
280
                    String.valueOf(conf.isCnRpcAdvancedCompressionEnable()))
×
281
                .trim()));
×
282

283
    conf.setCnRpcMaxConcurrentClientNum(
×
284
        Integer.parseInt(
×
285
            properties
286
                .getProperty(
×
287
                    "cn_rpc_max_concurrent_client_num",
288
                    String.valueOf(conf.getCnRpcMaxConcurrentClientNum()))
×
289
                .trim()));
×
290

291
    conf.setCnThriftDefaultBufferSize(
×
292
        Integer.parseInt(
×
293
            properties
294
                .getProperty(
×
295
                    "cn_thrift_init_buffer_size",
296
                    String.valueOf(conf.getCnThriftDefaultBufferSize()))
×
297
                .trim()));
×
298

299
    conf.setCnThriftMaxFrameSize(
×
300
        Integer.parseInt(
×
301
            properties
302
                .getProperty(
×
303
                    "cn_thrift_max_frame_size", String.valueOf(conf.getCnThriftMaxFrameSize()))
×
304
                .trim()));
×
305

306
    conf.setCoreClientNumForEachNode(
×
307
        Integer.parseInt(
×
308
            properties
309
                .getProperty(
×
310
                    "cn_core_client_count_for_each_node_in_client_manager",
311
                    String.valueOf(conf.getCoreClientNumForEachNode()))
×
312
                .trim()));
×
313

314
    conf.setMaxClientNumForEachNode(
×
315
        Integer.parseInt(
×
316
            properties
317
                .getProperty(
×
318
                    "cn_max_client_count_for_each_node_in_client_manager",
319
                    String.valueOf(conf.getMaxClientNumForEachNode()))
×
320
                .trim()));
×
321

322
    conf.setSystemDir(properties.getProperty("cn_system_dir", conf.getSystemDir()).trim());
×
323

324
    conf.setConsensusDir(properties.getProperty("cn_consensus_dir", conf.getConsensusDir()).trim());
×
325

326
    conf.setUdfDir(properties.getProperty("udf_lib_dir", conf.getUdfDir()).trim());
×
327

328
    conf.setTriggerDir(properties.getProperty("trigger_lib_dir", conf.getTriggerDir()).trim());
×
329

330
    conf.setPipeDir(properties.getProperty("pipe_lib_dir", conf.getPipeDir()).trim());
×
331

332
    conf.setHeartbeatIntervalInMs(
×
333
        Long.parseLong(
×
334
            properties
335
                .getProperty(
×
336
                    "heartbeat_interval_in_ms", String.valueOf(conf.getHeartbeatIntervalInMs()))
×
337
                .trim()));
×
338

339
    String leaderDistributionPolicy =
×
340
        properties
341
            .getProperty("leader_distribution_policy", conf.getLeaderDistributionPolicy())
×
342
            .trim();
×
343
    if (ILeaderBalancer.GREEDY_POLICY.equals(leaderDistributionPolicy)
×
344
        || ILeaderBalancer.MIN_COST_FLOW_POLICY.equals(leaderDistributionPolicy)) {
×
345
      conf.setLeaderDistributionPolicy(leaderDistributionPolicy);
×
346
    } else {
347
      throw new IOException(
×
348
          String.format(
×
349
              "Unknown leader_distribution_policy: %s, "
350
                  + "please set to \"GREEDY\" or \"MIN_COST_FLOW\"",
351
              leaderDistributionPolicy));
352
    }
353

354
    conf.setEnableAutoLeaderBalanceForRatisConsensus(
×
355
        Boolean.parseBoolean(
×
356
            properties
357
                .getProperty(
×
358
                    "enable_auto_leader_balance_for_ratis_consensus",
359
                    String.valueOf(conf.isEnableAutoLeaderBalanceForRatisConsensus()))
×
360
                .trim()));
×
361

362
    conf.setEnableAutoLeaderBalanceForIoTConsensus(
×
363
        Boolean.parseBoolean(
×
364
            properties
365
                .getProperty(
×
366
                    "enable_auto_leader_balance_for_iot_consensus",
367
                    String.valueOf(conf.isEnableAutoLeaderBalanceForIoTConsensus()))
×
368
                .trim()));
×
369

370
    String routePriorityPolicy =
×
371
        properties.getProperty("route_priority_policy", conf.getRoutePriorityPolicy()).trim();
×
372
    if (IPriorityBalancer.GREEDY_POLICY.equals(routePriorityPolicy)
×
373
        || IPriorityBalancer.LEADER_POLICY.equals(routePriorityPolicy)) {
×
374
      conf.setRoutePriorityPolicy(routePriorityPolicy);
×
375
    } else {
376
      throw new IOException(
×
377
          String.format(
×
378
              "Unknown route_priority_policy: %s, please set to \"LEADER\" or \"GREEDY\"",
379
              routePriorityPolicy));
380
    }
381

382
    String readConsistencyLevel =
×
383
        properties.getProperty("read_consistency_level", conf.getReadConsistencyLevel()).trim();
×
384
    if (readConsistencyLevel.equals("strong") || readConsistencyLevel.equals("weak")) {
×
385
      conf.setReadConsistencyLevel(readConsistencyLevel);
×
386
    } else {
387
      throw new IOException(
×
388
          String.format(
×
389
              "Unknown read_consistency_level: %s, please set to \"strong\" or \"weak\"",
390
              readConsistencyLevel));
391
    }
392

393
    // commons
394
    commonDescriptor.loadCommonProps(properties);
×
395
    commonDescriptor.initCommonConfigDir(conf.getSystemDir());
×
396

397
    conf.setProcedureCompletedEvictTTL(
×
398
        Integer.parseInt(
×
399
            properties
400
                .getProperty(
×
401
                    "procedure_completed_evict_ttl",
402
                    String.valueOf(conf.getProcedureCompletedEvictTTL()))
×
403
                .trim()));
×
404

405
    conf.setProcedureCompletedCleanInterval(
×
406
        Integer.parseInt(
×
407
            properties
408
                .getProperty(
×
409
                    "procedure_completed_clean_interval",
410
                    String.valueOf(conf.getProcedureCompletedCleanInterval()))
×
411
                .trim()));
×
412

413
    conf.setProcedureCoreWorkerThreadsCount(
×
414
        Integer.parseInt(
×
415
            properties
416
                .getProperty(
×
417
                    "procedure_core_worker_thread_count",
418
                    String.valueOf(conf.getProcedureCoreWorkerThreadsCount()))
×
419
                .trim()));
×
420

421
    loadRatisConsensusConfig(properties);
×
422
    loadCQConfig(properties);
×
423
  }
×
424

425
  private void loadRatisConsensusConfig(Properties properties) {
426
    conf.setDataRegionRatisConsensusLogAppenderBufferSize(
×
427
        Long.parseLong(
×
428
            properties
429
                .getProperty(
×
430
                    "data_region_ratis_log_appender_buffer_size_max",
431
                    String.valueOf(conf.getDataRegionRatisConsensusLogAppenderBufferSize()))
×
432
                .trim()));
×
433

434
    conf.setConfigNodeRatisConsensusLogAppenderBufferSize(
×
435
        Long.parseLong(
×
436
            properties
437
                .getProperty(
×
438
                    "config_node_ratis_log_appender_buffer_size_max",
439
                    String.valueOf(conf.getConfigNodeRatisConsensusLogAppenderBufferSize()))
×
440
                .trim()));
×
441

442
    conf.setSchemaRegionRatisConsensusLogAppenderBufferSize(
×
443
        Long.parseLong(
×
444
            properties
445
                .getProperty(
×
446
                    "schema_region_ratis_log_appender_buffer_size_max",
447
                    String.valueOf(conf.getSchemaRegionRatisConsensusLogAppenderBufferSize()))
×
448
                .trim()));
×
449

450
    conf.setDataRegionRatisSnapshotTriggerThreshold(
×
451
        Long.parseLong(
×
452
            properties
453
                .getProperty(
×
454
                    "data_region_ratis_snapshot_trigger_threshold",
455
                    String.valueOf(conf.getDataRegionRatisSnapshotTriggerThreshold()))
×
456
                .trim()));
×
457

458
    conf.setConfigNodeRatisSnapshotTriggerThreshold(
×
459
        Long.parseLong(
×
460
            properties
461
                .getProperty(
×
462
                    "config_node_ratis_snapshot_trigger_threshold",
463
                    String.valueOf(conf.getConfigNodeRatisSnapshotTriggerThreshold()))
×
464
                .trim()));
×
465

466
    conf.setSchemaRegionRatisSnapshotTriggerThreshold(
×
467
        Long.parseLong(
×
468
            properties
469
                .getProperty(
×
470
                    "schema_region_ratis_snapshot_trigger_threshold",
471
                    String.valueOf(conf.getSchemaRegionRatisSnapshotTriggerThreshold()))
×
472
                .trim()));
×
473

474
    conf.setDataRegionRatisLogUnsafeFlushEnable(
×
475
        Boolean.parseBoolean(
×
476
            properties
477
                .getProperty(
×
478
                    "data_region_ratis_log_unsafe_flush_enable",
479
                    String.valueOf(conf.isDataRegionRatisLogUnsafeFlushEnable()))
×
480
                .trim()));
×
481

482
    conf.setDataRegionRatisLogForceSyncNum(
×
483
        Integer.parseInt(
×
484
            properties
485
                .getProperty(
×
486
                    "data_region_ratis_log_force_sync_num",
487
                    String.valueOf(conf.getDataRegionRatisLogForceSyncNum()))
×
488
                .trim()));
×
489

490
    conf.setConfigNodeRatisLogUnsafeFlushEnable(
×
491
        Boolean.parseBoolean(
×
492
            properties
493
                .getProperty(
×
494
                    "config_node_ratis_log_unsafe_flush_enable",
495
                    String.valueOf(conf.isConfigNodeRatisLogUnsafeFlushEnable()))
×
496
                .trim()));
×
497

498
    conf.setSchemaRegionRatisLogUnsafeFlushEnable(
×
499
        Boolean.parseBoolean(
×
500
            properties
501
                .getProperty(
×
502
                    "schema_region_ratis_log_unsafe_flush_enable",
503
                    String.valueOf(conf.isSchemaRegionRatisLogUnsafeFlushEnable()))
×
504
                .trim()));
×
505

506
    conf.setDataRegionRatisLogSegmentSizeMax(
×
507
        Long.parseLong(
×
508
            properties
509
                .getProperty(
×
510
                    "data_region_ratis_log_segment_size_max_in_byte",
511
                    String.valueOf(conf.getDataRegionRatisLogSegmentSizeMax()))
×
512
                .trim()));
×
513

514
    conf.setConfigNodeRatisLogSegmentSizeMax(
×
515
        Long.parseLong(
×
516
            properties
517
                .getProperty(
×
518
                    "config_node_ratis_log_segment_size_max_in_byte",
519
                    String.valueOf(conf.getConfigNodeRatisLogSegmentSizeMax()))
×
520
                .trim()));
×
521

522
    conf.setSchemaRegionRatisLogSegmentSizeMax(
×
523
        Long.parseLong(
×
524
            properties
525
                .getProperty(
×
526
                    "schema_region_ratis_log_segment_size_max_in_byte",
527
                    String.valueOf(conf.getSchemaRegionRatisLogSegmentSizeMax()))
×
528
                .trim()));
×
529

530
    conf.setConfigNodeSimpleConsensusLogSegmentSizeMax(
×
531
        Long.parseLong(
×
532
            properties
533
                .getProperty(
×
534
                    "config_node_simple_consensus_log_segment_size_max_in_byte",
535
                    String.valueOf(conf.getConfigNodeSimpleConsensusLogSegmentSizeMax()))
×
536
                .trim()));
×
537

538
    conf.setDataRegionRatisGrpcFlowControlWindow(
×
539
        Long.parseLong(
×
540
            properties
541
                .getProperty(
×
542
                    "data_region_ratis_grpc_flow_control_window",
543
                    String.valueOf(conf.getDataRegionRatisGrpcFlowControlWindow()))
×
544
                .trim()));
×
545

546
    conf.setConfigNodeRatisGrpcFlowControlWindow(
×
547
        Long.parseLong(
×
548
            properties
549
                .getProperty(
×
550
                    "config_node_ratis_grpc_flow_control_window",
551
                    String.valueOf(conf.getConfigNodeRatisGrpcFlowControlWindow()))
×
552
                .trim()));
×
553

554
    conf.setSchemaRegionRatisGrpcFlowControlWindow(
×
555
        Long.parseLong(
×
556
            properties
557
                .getProperty(
×
558
                    "schema_region_ratis_grpc_flow_control_window",
559
                    String.valueOf(conf.getSchemaRegionRatisGrpcFlowControlWindow()))
×
560
                .trim()));
×
561

562
    conf.setDataRegionRatisGrpcLeaderOutstandingAppendsMax(
×
563
        Integer.parseInt(
×
564
            properties
565
                .getProperty(
×
566
                    "data_region_ratis_grpc_leader_outstanding_appends_max",
567
                    String.valueOf(conf.getDataRegionRatisGrpcLeaderOutstandingAppendsMax()))
×
568
                .trim()));
×
569

570
    conf.setDataRegionRatisRpcLeaderElectionTimeoutMinMs(
×
571
        Long.parseLong(
×
572
            properties
573
                .getProperty(
×
574
                    "data_region_ratis_rpc_leader_election_timeout_min_ms",
575
                    String.valueOf(conf.getDataRegionRatisRpcLeaderElectionTimeoutMinMs()))
×
576
                .trim()));
×
577

578
    conf.setConfigNodeRatisRpcLeaderElectionTimeoutMinMs(
×
579
        Long.parseLong(
×
580
            properties
581
                .getProperty(
×
582
                    "config_node_ratis_rpc_leader_election_timeout_min_ms",
583
                    String.valueOf(conf.getConfigNodeRatisRpcLeaderElectionTimeoutMinMs()))
×
584
                .trim()));
×
585

586
    conf.setSchemaRegionRatisRpcLeaderElectionTimeoutMinMs(
×
587
        Long.parseLong(
×
588
            properties
589
                .getProperty(
×
590
                    "schema_region_ratis_rpc_leader_election_timeout_min_ms",
591
                    String.valueOf(conf.getSchemaRegionRatisRpcLeaderElectionTimeoutMinMs()))
×
592
                .trim()));
×
593

594
    conf.setDataRegionRatisRpcLeaderElectionTimeoutMaxMs(
×
595
        Long.parseLong(
×
596
            properties
597
                .getProperty(
×
598
                    "data_region_ratis_rpc_leader_election_timeout_max_ms",
599
                    String.valueOf(conf.getDataRegionRatisRpcLeaderElectionTimeoutMaxMs()))
×
600
                .trim()));
×
601

602
    conf.setConfigNodeRatisRpcLeaderElectionTimeoutMaxMs(
×
603
        Long.parseLong(
×
604
            properties
605
                .getProperty(
×
606
                    "config_node_ratis_rpc_leader_election_timeout_max_ms",
607
                    String.valueOf(conf.getConfigNodeRatisRpcLeaderElectionTimeoutMaxMs()))
×
608
                .trim()));
×
609

610
    conf.setSchemaRegionRatisRpcLeaderElectionTimeoutMaxMs(
×
611
        Long.parseLong(
×
612
            properties
613
                .getProperty(
×
614
                    "schema_region_ratis_rpc_leader_election_timeout_max_ms",
615
                    String.valueOf(conf.getSchemaRegionRatisRpcLeaderElectionTimeoutMaxMs()))
×
616
                .trim()));
×
617

618
    conf.setConfigNodeRatisRequestTimeoutMs(
×
619
        Long.parseLong(
×
620
            properties
621
                .getProperty(
×
622
                    "config_node_ratis_request_timeout_ms",
623
                    String.valueOf(conf.getConfigNodeRatisRequestTimeoutMs()))
×
624
                .trim()));
×
625
    conf.setSchemaRegionRatisRequestTimeoutMs(
×
626
        Long.parseLong(
×
627
            properties
628
                .getProperty(
×
629
                    "schema_region_ratis_request_timeout_ms",
630
                    String.valueOf(conf.getSchemaRegionRatisRequestTimeoutMs()))
×
631
                .trim()));
×
632
    conf.setDataRegionRatisRequestTimeoutMs(
×
633
        Long.parseLong(
×
634
            properties
635
                .getProperty(
×
636
                    "data_region_ratis_request_timeout_ms",
637
                    String.valueOf(conf.getDataRegionRatisRequestTimeoutMs()))
×
638
                .trim()));
×
639

640
    conf.setConfigNodeRatisMaxRetryAttempts(
×
641
        Integer.parseInt(
×
642
            properties
643
                .getProperty(
×
644
                    "config_node_ratis_max_retry_attempts",
645
                    String.valueOf(conf.getConfigNodeRatisMaxRetryAttempts()))
×
646
                .trim()));
×
647
    conf.setConfigNodeRatisInitialSleepTimeMs(
×
648
        Long.parseLong(
×
649
            properties
650
                .getProperty(
×
651
                    "config_node_ratis_initial_sleep_time_ms",
652
                    String.valueOf(conf.getConfigNodeRatisInitialSleepTimeMs()))
×
653
                .trim()));
×
654
    conf.setConfigNodeRatisMaxSleepTimeMs(
×
655
        Long.parseLong(
×
656
            properties
657
                .getProperty(
×
658
                    "config_node_ratis_max_sleep_time_ms",
659
                    String.valueOf(conf.getConfigNodeRatisMaxSleepTimeMs()))
×
660
                .trim()));
×
661

662
    conf.setDataRegionRatisMaxRetryAttempts(
×
663
        Integer.parseInt(
×
664
            properties
665
                .getProperty(
×
666
                    "data_region_ratis_max_retry_attempts",
667
                    String.valueOf(conf.getDataRegionRatisMaxRetryAttempts()))
×
668
                .trim()));
×
669
    conf.setDataRegionRatisInitialSleepTimeMs(
×
670
        Long.parseLong(
×
671
            properties
672
                .getProperty(
×
673
                    "data_region_ratis_initial_sleep_time_ms",
674
                    String.valueOf(conf.getDataRegionRatisInitialSleepTimeMs()))
×
675
                .trim()));
×
676
    conf.setDataRegionRatisMaxSleepTimeMs(
×
677
        Long.parseLong(
×
678
            properties
679
                .getProperty(
×
680
                    "data_region_ratis_max_sleep_time_ms",
681
                    String.valueOf(conf.getDataRegionRatisMaxSleepTimeMs()))
×
682
                .trim()));
×
683

684
    conf.setSchemaRegionRatisMaxRetryAttempts(
×
685
        Integer.parseInt(
×
686
            properties
687
                .getProperty(
×
688
                    "schema_region_ratis_max_retry_attempts",
689
                    String.valueOf(conf.getSchemaRegionRatisMaxRetryAttempts()))
×
690
                .trim()));
×
691
    conf.setSchemaRegionRatisInitialSleepTimeMs(
×
692
        Long.parseLong(
×
693
            properties
694
                .getProperty(
×
695
                    "schema_region_ratis_initial_sleep_time_ms",
696
                    String.valueOf(conf.getSchemaRegionRatisInitialSleepTimeMs()))
×
697
                .trim()));
×
698
    conf.setSchemaRegionRatisMaxSleepTimeMs(
×
699
        Long.parseLong(
×
700
            properties
701
                .getProperty(
×
702
                    "schema_region_ratis_max_sleep_time_ms",
703
                    String.valueOf(conf.getSchemaRegionRatisMaxSleepTimeMs()))
×
704
                .trim()));
×
705

706
    conf.setConfigNodeRatisPreserveLogsWhenPurge(
×
707
        Long.parseLong(
×
708
            properties
709
                .getProperty(
×
710
                    "config_node_ratis_preserve_logs_num_when_purge",
711
                    String.valueOf(conf.getConfigNodeRatisPreserveLogsWhenPurge()))
×
712
                .trim()));
×
713

714
    conf.setSchemaRegionRatisPreserveLogsWhenPurge(
×
715
        Long.parseLong(
×
716
            properties
717
                .getProperty(
×
718
                    "schema_region_ratis_preserve_logs_num_when_purge",
719
                    String.valueOf(conf.getSchemaRegionRatisPreserveLogsWhenPurge()))
×
720
                .trim()));
×
721

722
    conf.setDataRegionRatisPreserveLogsWhenPurge(
×
723
        Long.parseLong(
×
724
            properties
725
                .getProperty(
×
726
                    "data_region_ratis_preserve_logs_num_when_purge",
727
                    String.valueOf(conf.getDataRegionRatisPreserveLogsWhenPurge()))
×
728
                .trim()));
×
729

730
    conf.setRatisFirstElectionTimeoutMinMs(
×
731
        Long.parseLong(
×
732
            properties
733
                .getProperty(
×
734
                    "ratis_first_election_timeout_min_ms",
735
                    String.valueOf(conf.getRatisFirstElectionTimeoutMinMs()))
×
736
                .trim()));
×
737

738
    conf.setRatisFirstElectionTimeoutMaxMs(
×
739
        Long.parseLong(
×
740
            properties
741
                .getProperty(
×
742
                    "ratis_first_election_timeout_max_ms",
743
                    String.valueOf(conf.getRatisFirstElectionTimeoutMaxMs()))
×
744
                .trim()));
×
745

746
    conf.setConfigNodeRatisLogMax(
×
747
        Long.parseLong(
×
748
            properties
749
                .getProperty(
×
750
                    "config_node_ratis_log_max_size",
751
                    String.valueOf(conf.getConfigNodeRatisLogMax()))
×
752
                .trim()));
×
753

754
    conf.setSchemaRegionRatisLogMax(
×
755
        Long.parseLong(
×
756
            properties
757
                .getProperty(
×
758
                    "schema_region_ratis_log_max_size",
759
                    String.valueOf(conf.getSchemaRegionRatisLogMax()))
×
760
                .trim()));
×
761

762
    conf.setDataRegionRatisLogMax(
×
763
        Long.parseLong(
×
764
            properties
765
                .getProperty(
×
766
                    "data_region_ratis_log_max_size",
767
                    String.valueOf(conf.getDataRegionRatisLogMax()))
×
768
                .trim()));
×
769

770
    conf.setEnablePrintingNewlyCreatedPartition(
×
771
        Boolean.parseBoolean(
×
772
            properties
773
                .getProperty(
×
774
                    "enable_printing_newly_created_partition",
775
                    String.valueOf(conf.isEnablePrintingNewlyCreatedPartition()))
×
776
                .trim()));
×
777

778
    conf.setForceWalPeriodForConfigNodeSimpleInMs(
×
779
        Long.parseLong(
×
780
            properties
781
                .getProperty(
×
782
                    "force_wal_period_for_confignode_simple_in_ms",
783
                    String.valueOf(conf.getForceWalPeriodForConfigNodeSimpleInMs()))
×
784
                .trim()));
×
785
  }
×
786

787
  private void loadCQConfig(Properties properties) {
788
    int cqSubmitThread =
×
789
        Integer.parseInt(
×
790
            properties
791
                .getProperty(
×
792
                    "continuous_query_submit_thread_count",
793
                    String.valueOf(conf.getCqSubmitThread()))
×
794
                .trim());
×
795
    if (cqSubmitThread <= 0) {
×
796
      LOGGER.warn(
×
797
          "continuous_query_submit_thread should be greater than 0, "
798
              + "but current value is {}, ignore that and use the default value {}",
799
          cqSubmitThread,
×
800
          conf.getCqSubmitThread());
×
801
      cqSubmitThread = conf.getCqSubmitThread();
×
802
    }
803
    conf.setCqSubmitThread(cqSubmitThread);
×
804

805
    long cqMinEveryIntervalInMs =
×
806
        Long.parseLong(
×
807
            properties
808
                .getProperty(
×
809
                    "continuous_query_min_every_interval_in_ms",
810
                    String.valueOf(conf.getCqMinEveryIntervalInMs()))
×
811
                .trim());
×
812
    if (cqMinEveryIntervalInMs <= 0) {
×
813
      LOGGER.warn(
×
814
          "continuous_query_min_every_interval_in_ms should be greater than 0, "
815
              + "but current value is {}, ignore that and use the default value {}",
816
          cqMinEveryIntervalInMs,
×
817
          conf.getCqMinEveryIntervalInMs());
×
818
      cqMinEveryIntervalInMs = conf.getCqMinEveryIntervalInMs();
×
819
    }
820

821
    conf.setCqMinEveryIntervalInMs(cqMinEveryIntervalInMs);
×
822
  }
×
823

824
  /**
825
   * Check if the current ConfigNode is SeedConfigNode.
826
   *
827
   * <p>Notice: Only invoke this interface when first startup.
828
   *
829
   * @return True if the target_config_node_list points to itself
830
   */
831
  public boolean isSeedConfigNode() {
832
    return (conf.getInternalAddress().equals(conf.getTargetConfigNode().getIp())
×
833
            || (NodeUrlUtils.isLocalAddress(conf.getInternalAddress())
×
834
                && NodeUrlUtils.isLocalAddress(conf.getTargetConfigNode().getIp())))
×
835
        && conf.getInternalPort() == conf.getTargetConfigNode().getPort();
×
836
  }
837

838
  public static ConfigNodeDescriptor getInstance() {
839
    return ConfigNodeDescriptorHolder.INSTANCE;
1✔
840
  }
841

842
  private static class ConfigNodeDescriptorHolder {
843

844
    private static final ConfigNodeDescriptor INSTANCE = new ConfigNodeDescriptor();
1✔
845

846
    private ConfigNodeDescriptorHolder() {
847
      // empty constructor
848
    }
849
  }
850
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc