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

apache / iotdb / #10032

08 Sep 2023 06:40AM UTC coverage: 47.635% (-0.003%) from 47.638%
#10032

push

travis_ci

web-flow
[To rel/1.2] Remove some copyright info (#11096)

80288 of 168549 relevant lines covered (47.63%)

0.48 hits per line

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

4.32
/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.setConfigNodeRatisLogUnsafeFlushEnable(
×
483
        Boolean.parseBoolean(
×
484
            properties
485
                .getProperty(
×
486
                    "config_node_ratis_log_unsafe_flush_enable",
487
                    String.valueOf(conf.isConfigNodeRatisLogUnsafeFlushEnable()))
×
488
                .trim()));
×
489

490
    conf.setSchemaRegionRatisLogUnsafeFlushEnable(
×
491
        Boolean.parseBoolean(
×
492
            properties
493
                .getProperty(
×
494
                    "schema_region_ratis_log_unsafe_flush_enable",
495
                    String.valueOf(conf.isSchemaRegionRatisLogUnsafeFlushEnable()))
×
496
                .trim()));
×
497

498
    conf.setDataRegionRatisLogSegmentSizeMax(
×
499
        Long.parseLong(
×
500
            properties
501
                .getProperty(
×
502
                    "data_region_ratis_log_segment_size_max_in_byte",
503
                    String.valueOf(conf.getDataRegionRatisLogSegmentSizeMax()))
×
504
                .trim()));
×
505

506
    conf.setConfigNodeRatisLogSegmentSizeMax(
×
507
        Long.parseLong(
×
508
            properties
509
                .getProperty(
×
510
                    "config_node_ratis_log_segment_size_max_in_byte",
511
                    String.valueOf(conf.getConfigNodeRatisLogSegmentSizeMax()))
×
512
                .trim()));
×
513

514
    conf.setSchemaRegionRatisLogSegmentSizeMax(
×
515
        Long.parseLong(
×
516
            properties
517
                .getProperty(
×
518
                    "schema_region_ratis_log_segment_size_max_in_byte",
519
                    String.valueOf(conf.getSchemaRegionRatisLogSegmentSizeMax()))
×
520
                .trim()));
×
521

522
    conf.setConfigNodeSimpleConsensusLogSegmentSizeMax(
×
523
        Long.parseLong(
×
524
            properties
525
                .getProperty(
×
526
                    "config_node_simple_consensus_log_segment_size_max_in_byte",
527
                    String.valueOf(conf.getConfigNodeSimpleConsensusLogSegmentSizeMax()))
×
528
                .trim()));
×
529

530
    conf.setDataRegionRatisGrpcFlowControlWindow(
×
531
        Long.parseLong(
×
532
            properties
533
                .getProperty(
×
534
                    "data_region_ratis_grpc_flow_control_window",
535
                    String.valueOf(conf.getDataRegionRatisGrpcFlowControlWindow()))
×
536
                .trim()));
×
537

538
    conf.setConfigNodeRatisGrpcFlowControlWindow(
×
539
        Long.parseLong(
×
540
            properties
541
                .getProperty(
×
542
                    "config_node_ratis_grpc_flow_control_window",
543
                    String.valueOf(conf.getConfigNodeRatisGrpcFlowControlWindow()))
×
544
                .trim()));
×
545

546
    conf.setSchemaRegionRatisGrpcFlowControlWindow(
×
547
        Long.parseLong(
×
548
            properties
549
                .getProperty(
×
550
                    "schema_region_ratis_grpc_flow_control_window",
551
                    String.valueOf(conf.getSchemaRegionRatisGrpcFlowControlWindow()))
×
552
                .trim()));
×
553

554
    conf.setDataRegionRatisGrpcLeaderOutstandingAppendsMax(
×
555
        Integer.parseInt(
×
556
            properties
557
                .getProperty(
×
558
                    "data_region_ratis_grpc_leader_outstanding_appends_max",
559
                    String.valueOf(conf.getDataRegionRatisGrpcLeaderOutstandingAppendsMax()))
×
560
                .trim()));
×
561

562
    conf.setConfigNodeRatisGrpcLeaderOutstandingAppendsMax(
×
563
        Integer.parseInt(
×
564
            properties
565
                .getProperty(
×
566
                    "config_node_ratis_grpc_leader_outstanding_appends_max",
567
                    String.valueOf(conf.getConfigNodeRatisGrpcLeaderOutstandingAppendsMax()))
×
568
                .trim()));
×
569

570
    conf.setSchemaRegionRatisGrpcLeaderOutstandingAppendsMax(
×
571
        Integer.parseInt(
×
572
            properties
573
                .getProperty(
×
574
                    "schema_region_ratis_grpc_leader_outstanding_appends_max",
575
                    String.valueOf(conf.getSchemaRegionRatisGrpcLeaderOutstandingAppendsMax()))
×
576
                .trim()));
×
577

578
    conf.setDataRegionRatisLogForceSyncNum(
×
579
        Integer.parseInt(
×
580
            properties
581
                .getProperty(
×
582
                    "data_region_ratis_log_force_sync_num",
583
                    String.valueOf(conf.getDataRegionRatisLogForceSyncNum()))
×
584
                .trim()));
×
585

586
    conf.setConfigNodeRatisLogForceSyncNum(
×
587
        Integer.parseInt(
×
588
            properties
589
                .getProperty(
×
590
                    "config_node_ratis_log_force_sync_num",
591
                    String.valueOf(conf.getConfigNodeRatisLogForceSyncNum()))
×
592
                .trim()));
×
593

594
    conf.setSchemaRegionRatisLogForceSyncNum(
×
595
        Integer.parseInt(
×
596
            properties
597
                .getProperty(
×
598
                    "schema_region_ratis_log_force_sync_num",
599
                    String.valueOf(conf.getSchemaRegionRatisLogForceSyncNum()))
×
600
                .trim()));
×
601

602
    conf.setDataRegionRatisRpcLeaderElectionTimeoutMinMs(
×
603
        Long.parseLong(
×
604
            properties
605
                .getProperty(
×
606
                    "data_region_ratis_rpc_leader_election_timeout_min_ms",
607
                    String.valueOf(conf.getDataRegionRatisRpcLeaderElectionTimeoutMinMs()))
×
608
                .trim()));
×
609

610
    conf.setConfigNodeRatisRpcLeaderElectionTimeoutMinMs(
×
611
        Long.parseLong(
×
612
            properties
613
                .getProperty(
×
614
                    "config_node_ratis_rpc_leader_election_timeout_min_ms",
615
                    String.valueOf(conf.getConfigNodeRatisRpcLeaderElectionTimeoutMinMs()))
×
616
                .trim()));
×
617

618
    conf.setSchemaRegionRatisRpcLeaderElectionTimeoutMinMs(
×
619
        Long.parseLong(
×
620
            properties
621
                .getProperty(
×
622
                    "schema_region_ratis_rpc_leader_election_timeout_min_ms",
623
                    String.valueOf(conf.getSchemaRegionRatisRpcLeaderElectionTimeoutMinMs()))
×
624
                .trim()));
×
625

626
    conf.setDataRegionRatisRpcLeaderElectionTimeoutMaxMs(
×
627
        Long.parseLong(
×
628
            properties
629
                .getProperty(
×
630
                    "data_region_ratis_rpc_leader_election_timeout_max_ms",
631
                    String.valueOf(conf.getDataRegionRatisRpcLeaderElectionTimeoutMaxMs()))
×
632
                .trim()));
×
633

634
    conf.setConfigNodeRatisRpcLeaderElectionTimeoutMaxMs(
×
635
        Long.parseLong(
×
636
            properties
637
                .getProperty(
×
638
                    "config_node_ratis_rpc_leader_election_timeout_max_ms",
639
                    String.valueOf(conf.getConfigNodeRatisRpcLeaderElectionTimeoutMaxMs()))
×
640
                .trim()));
×
641

642
    conf.setSchemaRegionRatisRpcLeaderElectionTimeoutMaxMs(
×
643
        Long.parseLong(
×
644
            properties
645
                .getProperty(
×
646
                    "schema_region_ratis_rpc_leader_election_timeout_max_ms",
647
                    String.valueOf(conf.getSchemaRegionRatisRpcLeaderElectionTimeoutMaxMs()))
×
648
                .trim()));
×
649

650
    conf.setConfigNodeRatisRequestTimeoutMs(
×
651
        Long.parseLong(
×
652
            properties
653
                .getProperty(
×
654
                    "config_node_ratis_request_timeout_ms",
655
                    String.valueOf(conf.getConfigNodeRatisRequestTimeoutMs()))
×
656
                .trim()));
×
657
    conf.setSchemaRegionRatisRequestTimeoutMs(
×
658
        Long.parseLong(
×
659
            properties
660
                .getProperty(
×
661
                    "schema_region_ratis_request_timeout_ms",
662
                    String.valueOf(conf.getSchemaRegionRatisRequestTimeoutMs()))
×
663
                .trim()));
×
664
    conf.setDataRegionRatisRequestTimeoutMs(
×
665
        Long.parseLong(
×
666
            properties
667
                .getProperty(
×
668
                    "data_region_ratis_request_timeout_ms",
669
                    String.valueOf(conf.getDataRegionRatisRequestTimeoutMs()))
×
670
                .trim()));
×
671

672
    conf.setConfigNodeRatisMaxRetryAttempts(
×
673
        Integer.parseInt(
×
674
            properties
675
                .getProperty(
×
676
                    "config_node_ratis_max_retry_attempts",
677
                    String.valueOf(conf.getConfigNodeRatisMaxRetryAttempts()))
×
678
                .trim()));
×
679
    conf.setConfigNodeRatisInitialSleepTimeMs(
×
680
        Long.parseLong(
×
681
            properties
682
                .getProperty(
×
683
                    "config_node_ratis_initial_sleep_time_ms",
684
                    String.valueOf(conf.getConfigNodeRatisInitialSleepTimeMs()))
×
685
                .trim()));
×
686
    conf.setConfigNodeRatisMaxSleepTimeMs(
×
687
        Long.parseLong(
×
688
            properties
689
                .getProperty(
×
690
                    "config_node_ratis_max_sleep_time_ms",
691
                    String.valueOf(conf.getConfigNodeRatisMaxSleepTimeMs()))
×
692
                .trim()));
×
693

694
    conf.setDataRegionRatisMaxRetryAttempts(
×
695
        Integer.parseInt(
×
696
            properties
697
                .getProperty(
×
698
                    "data_region_ratis_max_retry_attempts",
699
                    String.valueOf(conf.getDataRegionRatisMaxRetryAttempts()))
×
700
                .trim()));
×
701
    conf.setDataRegionRatisInitialSleepTimeMs(
×
702
        Long.parseLong(
×
703
            properties
704
                .getProperty(
×
705
                    "data_region_ratis_initial_sleep_time_ms",
706
                    String.valueOf(conf.getDataRegionRatisInitialSleepTimeMs()))
×
707
                .trim()));
×
708
    conf.setDataRegionRatisMaxSleepTimeMs(
×
709
        Long.parseLong(
×
710
            properties
711
                .getProperty(
×
712
                    "data_region_ratis_max_sleep_time_ms",
713
                    String.valueOf(conf.getDataRegionRatisMaxSleepTimeMs()))
×
714
                .trim()));
×
715

716
    conf.setSchemaRegionRatisMaxRetryAttempts(
×
717
        Integer.parseInt(
×
718
            properties
719
                .getProperty(
×
720
                    "schema_region_ratis_max_retry_attempts",
721
                    String.valueOf(conf.getSchemaRegionRatisMaxRetryAttempts()))
×
722
                .trim()));
×
723
    conf.setSchemaRegionRatisInitialSleepTimeMs(
×
724
        Long.parseLong(
×
725
            properties
726
                .getProperty(
×
727
                    "schema_region_ratis_initial_sleep_time_ms",
728
                    String.valueOf(conf.getSchemaRegionRatisInitialSleepTimeMs()))
×
729
                .trim()));
×
730
    conf.setSchemaRegionRatisMaxSleepTimeMs(
×
731
        Long.parseLong(
×
732
            properties
733
                .getProperty(
×
734
                    "schema_region_ratis_max_sleep_time_ms",
735
                    String.valueOf(conf.getSchemaRegionRatisMaxSleepTimeMs()))
×
736
                .trim()));
×
737

738
    conf.setConfigNodeRatisPreserveLogsWhenPurge(
×
739
        Long.parseLong(
×
740
            properties
741
                .getProperty(
×
742
                    "config_node_ratis_preserve_logs_num_when_purge",
743
                    String.valueOf(conf.getConfigNodeRatisPreserveLogsWhenPurge()))
×
744
                .trim()));
×
745

746
    conf.setSchemaRegionRatisPreserveLogsWhenPurge(
×
747
        Long.parseLong(
×
748
            properties
749
                .getProperty(
×
750
                    "schema_region_ratis_preserve_logs_num_when_purge",
751
                    String.valueOf(conf.getSchemaRegionRatisPreserveLogsWhenPurge()))
×
752
                .trim()));
×
753

754
    conf.setDataRegionRatisPreserveLogsWhenPurge(
×
755
        Long.parseLong(
×
756
            properties
757
                .getProperty(
×
758
                    "data_region_ratis_preserve_logs_num_when_purge",
759
                    String.valueOf(conf.getDataRegionRatisPreserveLogsWhenPurge()))
×
760
                .trim()));
×
761

762
    conf.setRatisFirstElectionTimeoutMinMs(
×
763
        Long.parseLong(
×
764
            properties
765
                .getProperty(
×
766
                    "ratis_first_election_timeout_min_ms",
767
                    String.valueOf(conf.getRatisFirstElectionTimeoutMinMs()))
×
768
                .trim()));
×
769

770
    conf.setRatisFirstElectionTimeoutMaxMs(
×
771
        Long.parseLong(
×
772
            properties
773
                .getProperty(
×
774
                    "ratis_first_election_timeout_max_ms",
775
                    String.valueOf(conf.getRatisFirstElectionTimeoutMaxMs()))
×
776
                .trim()));
×
777

778
    conf.setConfigNodeRatisLogMax(
×
779
        Long.parseLong(
×
780
            properties
781
                .getProperty(
×
782
                    "config_node_ratis_log_max_size",
783
                    String.valueOf(conf.getConfigNodeRatisLogMax()))
×
784
                .trim()));
×
785

786
    conf.setSchemaRegionRatisLogMax(
×
787
        Long.parseLong(
×
788
            properties
789
                .getProperty(
×
790
                    "schema_region_ratis_log_max_size",
791
                    String.valueOf(conf.getSchemaRegionRatisLogMax()))
×
792
                .trim()));
×
793

794
    conf.setDataRegionRatisLogMax(
×
795
        Long.parseLong(
×
796
            properties
797
                .getProperty(
×
798
                    "data_region_ratis_log_max_size",
799
                    String.valueOf(conf.getDataRegionRatisLogMax()))
×
800
                .trim()));
×
801

802
    conf.setEnablePrintingNewlyCreatedPartition(
×
803
        Boolean.parseBoolean(
×
804
            properties
805
                .getProperty(
×
806
                    "enable_printing_newly_created_partition",
807
                    String.valueOf(conf.isEnablePrintingNewlyCreatedPartition()))
×
808
                .trim()));
×
809

810
    conf.setForceWalPeriodForConfigNodeSimpleInMs(
×
811
        Long.parseLong(
×
812
            properties
813
                .getProperty(
×
814
                    "force_wal_period_for_confignode_simple_in_ms",
815
                    String.valueOf(conf.getForceWalPeriodForConfigNodeSimpleInMs()))
×
816
                .trim()));
×
817
  }
×
818

819
  private void loadCQConfig(Properties properties) {
820
    int cqSubmitThread =
×
821
        Integer.parseInt(
×
822
            properties
823
                .getProperty(
×
824
                    "continuous_query_submit_thread_count",
825
                    String.valueOf(conf.getCqSubmitThread()))
×
826
                .trim());
×
827
    if (cqSubmitThread <= 0) {
×
828
      LOGGER.warn(
×
829
          "continuous_query_submit_thread should be greater than 0, "
830
              + "but current value is {}, ignore that and use the default value {}",
831
          cqSubmitThread,
×
832
          conf.getCqSubmitThread());
×
833
      cqSubmitThread = conf.getCqSubmitThread();
×
834
    }
835
    conf.setCqSubmitThread(cqSubmitThread);
×
836

837
    long cqMinEveryIntervalInMs =
×
838
        Long.parseLong(
×
839
            properties
840
                .getProperty(
×
841
                    "continuous_query_min_every_interval_in_ms",
842
                    String.valueOf(conf.getCqMinEveryIntervalInMs()))
×
843
                .trim());
×
844
    if (cqMinEveryIntervalInMs <= 0) {
×
845
      LOGGER.warn(
×
846
          "continuous_query_min_every_interval_in_ms should be greater than 0, "
847
              + "but current value is {}, ignore that and use the default value {}",
848
          cqMinEveryIntervalInMs,
×
849
          conf.getCqMinEveryIntervalInMs());
×
850
      cqMinEveryIntervalInMs = conf.getCqMinEveryIntervalInMs();
×
851
    }
852

853
    conf.setCqMinEveryIntervalInMs(cqMinEveryIntervalInMs);
×
854
  }
×
855

856
  /**
857
   * Check if the current ConfigNode is SeedConfigNode.
858
   *
859
   * <p>Notice: Only invoke this interface when first startup.
860
   *
861
   * @return True if the target_config_node_list points to itself
862
   */
863
  public boolean isSeedConfigNode() {
864
    return (conf.getInternalAddress().equals(conf.getTargetConfigNode().getIp())
×
865
            || (NodeUrlUtils.isLocalAddress(conf.getInternalAddress())
×
866
                && NodeUrlUtils.isLocalAddress(conf.getTargetConfigNode().getIp())))
×
867
        && conf.getInternalPort() == conf.getTargetConfigNode().getPort();
×
868
  }
869

870
  public static ConfigNodeDescriptor getInstance() {
871
    return ConfigNodeDescriptorHolder.INSTANCE;
1✔
872
  }
873

874
  private static class ConfigNodeDescriptorHolder {
875

876
    private static final ConfigNodeDescriptor INSTANCE = new ConfigNodeDescriptor();
1✔
877

878
    private ConfigNodeDescriptorHolder() {
879
      // empty constructor
880
    }
881
  }
882
}
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