Skip to content

Commit f1714d0

Browse files
Adjust default data region num per node from 5 to to cpu core / 2 (apache#14348)
* finish Signed-off-by: OneSizeFitQuorum <[email protected]> * fix it & ut Signed-off-by: OneSizeFitQuorum <[email protected]> --------- Signed-off-by: OneSizeFitQuorum <[email protected]>
1 parent ad09bd3 commit f1714d0

File tree

11 files changed

+54
-53
lines changed

11 files changed

+54
-53
lines changed

integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterNodeGetterIT.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,10 @@ public void showClusterAndNodesTest() throws Exception {
162162
clusterParameters.getSchemaReplicationFactor());
163163
Assert.assertEquals(
164164
expectedParameters.getDataRegionPerDataNode(),
165-
clusterParameters.getDataRegionPerDataNode(),
166-
0.01);
165+
clusterParameters.getDataRegionPerDataNode());
167166
Assert.assertEquals(
168167
expectedParameters.getSchemaRegionPerDataNode(),
169-
clusterParameters.getSchemaRegionPerDataNode(),
170-
0.01);
168+
clusterParameters.getSchemaRegionPerDataNode());
171169
Assert.assertEquals(
172170
expectedParameters.getDiskSpaceWarningThreshold(),
173171
clusterParameters.getDiskSpaceWarningThreshold(),

integration-test/src/test/java/org/apache/iotdb/confignode/it/utils/ConfigNodeTestUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ public static TClusterParameters generateClusterParameters() {
323323
clusterParameters.setTimePartitionInterval(604800000);
324324
clusterParameters.setDataReplicationFactor(1);
325325
clusterParameters.setSchemaReplicationFactor(1);
326-
clusterParameters.setDataRegionPerDataNode(5.0);
327-
clusterParameters.setSchemaRegionPerDataNode(1.0);
326+
clusterParameters.setDataRegionPerDataNode(0);
327+
clusterParameters.setSchemaRegionPerDataNode(1);
328328
clusterParameters.setDiskSpaceWarningThreshold(0.01);
329329
clusterParameters.setReadConsistencyLevel("strong");
330330
clusterParameters.setTimestampPrecision("ms");

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class ConfigNodeConfig {
9191
private int defaultSchemaRegionGroupNumPerDatabase = 1;
9292

9393
/** The maximum number of SchemaRegions expected to be managed by each DataNode. */
94-
private double schemaRegionPerDataNode = schemaReplicationFactor;
94+
private int schemaRegionPerDataNode = 1;
9595

9696
/** The policy of extension DataRegionGroup for each Database. */
9797
private RegionGroupExtensionPolicy dataRegionGroupExtensionPolicy =
@@ -104,8 +104,14 @@ public class ConfigNodeConfig {
104104
*/
105105
private int defaultDataRegionGroupNumPerDatabase = 2;
106106

107-
/** The maximum number of DataRegions expected to be managed by each DataNode. */
108-
private double dataRegionPerDataNode = 5.0;
107+
/**
108+
* The maximum number of DataRegions expected to be managed by each DataNode. Set to 0 means that
109+
* each dataNode automatically has the number of CPU cores / 2 regions.
110+
*/
111+
private int dataRegionPerDataNode = 0;
112+
113+
/** each dataNode automatically has the number of CPU cores / 2 regions. */
114+
private double dataRegionPerDataNodeProportion = 0.5;
109115

110116
/** RegionGroup allocate policy. */
111117
private RegionBalancer.RegionGroupAllocatePolicy regionGroupAllocatePolicy =
@@ -479,11 +485,11 @@ public void setDefaultDataRegionGroupNumPerDatabase(int defaultDataRegionGroupNu
479485
this.defaultDataRegionGroupNumPerDatabase = defaultDataRegionGroupNumPerDatabase;
480486
}
481487

482-
public double getSchemaRegionPerDataNode() {
488+
public int getSchemaRegionPerDataNode() {
483489
return schemaRegionPerDataNode;
484490
}
485491

486-
public void setSchemaRegionPerDataNode(double schemaRegionPerDataNode) {
492+
public void setSchemaRegionPerDataNode(int schemaRegionPerDataNode) {
487493
this.schemaRegionPerDataNode = schemaRegionPerDataNode;
488494
}
489495

@@ -495,14 +501,18 @@ public void setDataRegionConsensusProtocolClass(String dataRegionConsensusProtoc
495501
this.dataRegionConsensusProtocolClass = dataRegionConsensusProtocolClass;
496502
}
497503

498-
public double getDataRegionPerDataNode() {
504+
public int getDataRegionPerDataNode() {
499505
return dataRegionPerDataNode;
500506
}
501507

502-
public void setDataRegionPerDataNode(double dataRegionPerDataNode) {
508+
public void setDataRegionPerDataNode(int dataRegionPerDataNode) {
503509
this.dataRegionPerDataNode = dataRegionPerDataNode;
504510
}
505511

512+
public double getDataRegionPerDataNodeProportion() {
513+
return dataRegionPerDataNodeProportion;
514+
}
515+
506516
public RegionBalancer.RegionGroupAllocatePolicy getRegionGroupAllocatePolicy() {
507517
return regionGroupAllocatePolicy;
508518
}

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,13 @@ private void loadProperties(TrimProperties properties) throws BadNodeUrlExceptio
238238
.trim()));
239239

240240
conf.setSchemaRegionPerDataNode(
241-
Double.parseDouble(
242-
properties
243-
.getProperty(
244-
"schema_region_per_data_node",
245-
String.valueOf(conf.getSchemaRegionPerDataNode()))
246-
.trim()));
241+
(int)
242+
Double.parseDouble(
243+
properties
244+
.getProperty(
245+
"schema_region_per_data_node",
246+
String.valueOf(conf.getSchemaRegionPerDataNode()))
247+
.trim()));
247248

248249
conf.setDataRegionGroupExtensionPolicy(
249250
RegionGroupExtensionPolicy.parse(
@@ -258,11 +259,13 @@ private void loadProperties(TrimProperties properties) throws BadNodeUrlExceptio
258259
String.valueOf(conf.getDefaultDataRegionGroupNumPerDatabase()).trim())));
259260

260261
conf.setDataRegionPerDataNode(
261-
Double.parseDouble(
262-
properties
263-
.getProperty(
264-
"data_region_per_data_node", String.valueOf(conf.getDataRegionPerDataNode()))
265-
.trim()));
262+
(int)
263+
Double.parseDouble(
264+
properties
265+
.getProperty(
266+
"data_region_per_data_node",
267+
String.valueOf(conf.getDataRegionPerDataNode()))
268+
.trim()));
266269

267270
try {
268271
conf.setRegionAllocateStrategy(

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/region/PartiteGraphPlacementRegionGroupAllocator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ public TRegionReplicaSet generateOptimalRegionReplicasDistribution(
6767
int replicationFactor,
6868
TConsensusGroupId consensusGroupId) {
6969
this.regionPerDataNode =
70-
(int)
71-
(consensusGroupId.getType().equals(TConsensusGroupType.DataRegion)
72-
? ConfigNodeDescriptor.getInstance().getConf().getDataRegionPerDataNode()
73-
: ConfigNodeDescriptor.getInstance().getConf().getSchemaRegionPerDataNode());
70+
consensusGroupId.getType().equals(TConsensusGroupType.DataRegion)
71+
? ConfigNodeDescriptor.getInstance().getConf().getDataRegionPerDataNode()
72+
: ConfigNodeDescriptor.getInstance().getConf().getSchemaRegionPerDataNode();
7473
prepare(replicationFactor, availableDataNodeMap, allocatedRegionGroups);
7574

7675
// Select alpha nodes set

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ public class ClusterSchemaManager {
123123
private static final Logger LOGGER = LoggerFactory.getLogger(ClusterSchemaManager.class);
124124

125125
private static final ConfigNodeConfig CONF = ConfigNodeDescriptor.getInstance().getConf();
126-
private static final double SCHEMA_REGION_PER_DATA_NODE = CONF.getSchemaRegionPerDataNode();
127-
private static final double DATA_REGION_PER_DATA_NODE = CONF.getDataRegionPerDataNode();
126+
private static final int SCHEMA_REGION_PER_DATA_NODE = CONF.getSchemaRegionPerDataNode();
127+
private static final int DATA_REGION_PER_DATA_NODE = CONF.getDataRegionPerDataNode();
128128

129129
private final IManager configManager;
130130
private final ClusterSchemaInfo clusterSchemaInfo;
@@ -466,6 +466,7 @@ public synchronized void adjustMaxRegionGroupNum() {
466466
}
467467

468468
int dataNodeNum = getNodeManager().getRegisteredDataNodeCount();
469+
int totalCpuCoreNum = getNodeManager().getDataNodeCpuCoreCount();
469470
int databaseNum = databaseSchemaMap.size();
470471

471472
for (TDatabaseSchema databaseSchema : databaseSchemaMap.values()) {
@@ -519,8 +520,10 @@ public synchronized void adjustMaxRegionGroupNum() {
519520
int maxDataRegionGroupNum =
520521
calcMaxRegionGroupNum(
521522
databaseSchema.getMinDataRegionGroupNum(),
522-
DATA_REGION_PER_DATA_NODE,
523-
dataNodeNum,
523+
DATA_REGION_PER_DATA_NODE == 0
524+
? CONF.getDataRegionPerDataNodeProportion()
525+
: DATA_REGION_PER_DATA_NODE,
526+
DATA_REGION_PER_DATA_NODE == 0 ? totalCpuCoreNum : dataNodeNum,
524527
databaseNum,
525528
databaseSchema.getDataReplicationFactor(),
526529
allocatedDataRegionGroupCount);

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/node/NodeInfo.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,6 @@ public int getRegisteredDataNodeCount() {
290290
return result;
291291
}
292292

293-
public int getDataNodeCpuCoreCount(int dataNodeId) {
294-
try {
295-
return registeredDataNodes.get(dataNodeId).getResource().getCpuCoreNum();
296-
} catch (Exception e) {
297-
LOGGER.warn("Get DataNode {} cpu core fail, will be treated as zero.", dataNodeId, e);
298-
return 0;
299-
}
300-
}
301-
302293
/** Return the number of total cpu cores in online DataNodes. */
303294
public int getDataNodeTotalCpuCoreCount() {
304295
int result = 0;

iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/load/balancer/region/AllocatorScatterWidthManualTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
2525
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
2626
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
27-
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
2827

2928
import org.junit.Assert;
3029
import org.junit.BeforeClass;
@@ -51,8 +50,7 @@ public class AllocatorScatterWidthManualTest {
5150
private static final IRegionGroupAllocator ALLOCATOR = new GreedyRegionGroupAllocator();
5251

5352
private static final int TEST_DATA_NODE_NUM = 50;
54-
private static final int DATA_REGION_PER_DATA_NODE =
55-
(int) ConfigNodeDescriptor.getInstance().getConf().getDataRegionPerDataNode();
53+
private static final int DATA_REGION_PER_DATA_NODE = 5;
5654
private static final int DATA_REPLICATION_FACTOR = 3;
5755

5856
private static final Map<Integer, TDataNodeConfiguration> AVAILABLE_DATA_NODE_MAP =

iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/load/balancer/region/GreedyCopySetRegionGroupAllocatorTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
2525
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
2626
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
27-
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
2827

2928
import org.junit.Assert;
3029
import org.junit.BeforeClass;
@@ -54,8 +53,7 @@ public class GreedyCopySetRegionGroupAllocatorTest {
5453
private static final Random RANDOM = new Random();
5554
private static final int TEST_DATABASE_NUM = 3;
5655
private static final int TEST_DATA_NODE_NUM = 21;
57-
private static final int DATA_REGION_PER_DATA_NODE =
58-
(int) ConfigNodeDescriptor.getInstance().getConf().getDataRegionPerDataNode();
56+
private static final int DATA_REGION_PER_DATA_NODE = 5;
5957
private static final Map<Integer, TDataNodeConfiguration> AVAILABLE_DATA_NODE_MAP =
6058
new HashMap<>();
6159
private static final Map<Integer, Double> FREE_SPACE_MAP = new HashMap<>();

iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,8 @@ default_schema_region_group_num_per_database=1
620620
# Notice: Since each Database requires at least one SchemaRegionGroup to manage its schema,
621621
# this parameter doesn't limit the upper bound of cluster SchemaRegions when there are too many Databases.
622622
# effectiveMode: restart
623-
# Datatype: Double
624-
schema_region_per_data_node=1.0
623+
# Datatype: Integer
624+
schema_region_per_data_node=1
625625

626626
# The policy of extension DataRegionGroup for each Database.
627627
# These policies are currently supported:
@@ -641,11 +641,12 @@ default_data_region_group_num_per_database=2
641641

642642
# Only take effect when set data_region_group_extension_policy=AUTO.
643643
# This parameter is the maximum number of DataRegions expected to be managed by each DataNode.
644+
# Set to 0 means that each node automatically has the number of CPU cores / 2 regions
644645
# Notice: Since each Database requires at least two DataRegionGroups to manage its data,
645646
# this parameter doesn't limit the upper bound of cluster DataRegions when there are too many Databases.
646647
# effectiveMode: restart
647-
# Datatype: Double
648-
data_region_per_data_node=5.0
648+
# Datatype: Integer
649+
data_region_per_data_node=0
649650

650651
# Whether to enable auto leader balance for Ratis consensus protocol.
651652
# The ConfigNode-leader will balance the leader of Ratis-RegionGroups by leader_distribution_policy if set true.

0 commit comments

Comments
 (0)