Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iotdb.relational.it.schema;

import org.apache.iotdb.consensus.ConsensusFactory;
import org.apache.iotdb.db.it.utils.TestUtils;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.TableClusterIT;
import org.apache.iotdb.itbase.env.BaseEnv;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collections;

@RunWith(IoTDBTestRunner.class)
@Category({TableClusterIT.class})
public class IoTDBDatabaseAutoDataRegionGroupQuotaIT {

private static final int CONFIG_NODE_NUM = 1;
private static final int DATA_NODE_NUM = 3;
private static final int SCHEMA_REPLICATION_FACTOR = 3;
private static final int DATA_REPLICATION_FACTOR = 1;
private static final int DATA_REGION_PER_DATA_NODE = 2;

@Before
public void setUp() throws Exception {
EnvFactory.getEnv()
.getConfig()
.getCommonConfig()
.setSchemaRegionGroupExtensionPolicy("CUSTOM")
.setDataRegionGroupExtensionPolicy("AUTO")
.setSchemaRegionConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS)
.setDefaultSchemaRegionGroupNumPerDatabase(1)
.setDefaultDataRegionGroupNumPerDatabase(1)
.setSchemaReplicationFactor(SCHEMA_REPLICATION_FACTOR)
.setDataReplicationFactor(DATA_REPLICATION_FACTOR)
.setDataRegionPerDataNode(DATA_REGION_PER_DATA_NODE);
EnvFactory.getEnv().initClusterEnvironment(CONFIG_NODE_NUM, DATA_NODE_NUM);
}

@After
public void tearDown() throws Exception {
EnvFactory.getEnv().cleanClusterEnvironment();
}

@Test
public void testMaxDataRegionGroupNumUsesDataReplicationFactor() throws SQLException {
try (final Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
final int expectedMaxDataRegionGroupNum =
(int)
Math.ceil(
(double) DATA_REGION_PER_DATA_NODE * DATA_NODE_NUM / DATA_REPLICATION_FACTOR);

statement.execute("create database test_data_region_rf with(max_schema_region_group_num=2)");

TestUtils.assertResultSetEqual(
statement.executeQuery(
"select database, max_schema_region_group_num, max_data_region_group_num "
+ "from information_schema.databases where database = 'test_data_region_rf'"),
"database,max_schema_region_group_num,max_data_region_group_num,",
Collections.singleton("test_data_region_rf,2," + expectedMaxDataRegionGroupNum + ","));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,9 @@ public int adjustRegionGroupNum(
? dataNodeNum
: (CONF.getDataRegionPerDataNode() == 0 ? totalCpuCoreNum : dataNodeNum),
databaseNum,
databaseSchema.getSchemaReplicationFactor(),
(consensusGroupType == TConsensusGroupType.SchemaRegion)
? databaseSchema.getSchemaReplicationFactor()
: databaseSchema.getDataReplicationFactor(),
allocatedRegionGroupCount);
LOGGER.info(
(consensusGroupType == TConsensusGroupType.SchemaRegion)
Expand Down
Loading