-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(partition-plan): add api and storage layer (#1374)
* fix issue #1337 * update submodule * add api for partition plan * add storage layer * rename field * rename class * corrent i18n * corrent i18n * corrent method name * fix several errors * remove timeunit * add more time unit * rename script * rename unique index * move partition plan type to task plugin * response to cr comments * trigger git action * response to cr comments * response to cr comments
- Loading branch information
Showing
32 changed files
with
1,357 additions
and
10 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...est/src/test/java/com/oceanbase/odc/metadb/partitionplan/PartitionPlanRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2023 OceanBase. | ||
* | ||
* Licensed 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 com.oceanbase.odc.metadb.partitionplan; | ||
|
||
import java.util.Optional; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import com.oceanbase.odc.ServiceTestEnv; | ||
import com.oceanbase.odc.test.tool.TestRandom; | ||
|
||
/** | ||
* Test cases for {@link PartitionPlanRepository} | ||
* | ||
* @author yh263208 | ||
* @date 2024-01-10 16:57 | ||
* @since ODC-release_4.2.4 | ||
*/ | ||
public class PartitionPlanRepositoryTest extends ServiceTestEnv { | ||
|
||
@Autowired | ||
private PartitionPlanRepository repository; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
repository.deleteAll(); | ||
} | ||
|
||
@Test | ||
public void save_saveOne_saveSucceed() { | ||
PartitionPlanEntity actual = createRoleEntity(); | ||
actual.setId(null); | ||
actual = this.repository.save(actual); | ||
Optional<PartitionPlanEntity> expect = this.repository.findById(actual.getId()); | ||
Assert.assertEquals(expect.get(), actual); | ||
} | ||
|
||
private PartitionPlanEntity createRoleEntity() { | ||
return TestRandom.nextObject(PartitionPlanEntity.class); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
.../com/oceanbase/odc/metadb/partitionplan/PartitionPlanTablePartitionKeyRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2023 OceanBase. | ||
* | ||
* Licensed 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 com.oceanbase.odc.metadb.partitionplan; | ||
|
||
import java.util.Optional; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import com.oceanbase.odc.ServiceTestEnv; | ||
import com.oceanbase.odc.test.tool.TestRandom; | ||
|
||
/** | ||
* Test cases for {@link PartitionPlanTablePartitionKeyRepository} | ||
* | ||
* @author yh263208 | ||
* @date 2024-01-10 17:08 | ||
* @since ODC_release_4.2.4 | ||
*/ | ||
public class PartitionPlanTablePartitionKeyRepositoryTest extends ServiceTestEnv { | ||
|
||
@Autowired | ||
private PartitionPlanTablePartitionKeyRepository repository; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
repository.deleteAll(); | ||
} | ||
|
||
@Test | ||
public void save_saveOne_saveSucceed() { | ||
PartitionPlanTablePartitionKeyEntity actual = createRoleEntity(); | ||
actual.setId(null); | ||
actual = this.repository.save(actual); | ||
Optional<PartitionPlanTablePartitionKeyEntity> expect = this.repository.findById(actual.getId()); | ||
Assert.assertEquals(expect.get(), actual); | ||
} | ||
|
||
private PartitionPlanTablePartitionKeyEntity createRoleEntity() { | ||
return TestRandom.nextObject(PartitionPlanTablePartitionKeyEntity.class); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...rc/test/java/com/oceanbase/odc/metadb/partitionplan/PartitionPlanTableRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2023 OceanBase. | ||
* | ||
* Licensed 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 com.oceanbase.odc.metadb.partitionplan; | ||
|
||
import java.util.Optional; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import com.oceanbase.odc.ServiceTestEnv; | ||
import com.oceanbase.odc.test.tool.TestRandom; | ||
|
||
/** | ||
* Test cases for {@link PartitionPlanTableRepositoryTest} | ||
* | ||
* @author yh263208 | ||
* @date 2024-01-10 17:08 | ||
* @since ODC_release_4.2.4 | ||
*/ | ||
public class PartitionPlanTableRepositoryTest extends ServiceTestEnv { | ||
|
||
@Autowired | ||
private PartitionPlanTableRepository repository; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
repository.deleteAll(); | ||
} | ||
|
||
@Test | ||
public void save_saveOne_saveSucceed() { | ||
PartitionPlanTableEntity actual = createRoleEntity(); | ||
actual.setId(null); | ||
actual = this.repository.save(actual); | ||
Optional<PartitionPlanTableEntity> expect = this.repository.findById(actual.getId()); | ||
Assert.assertEquals(expect.get(), actual); | ||
} | ||
|
||
private PartitionPlanTableEntity createRoleEntity() { | ||
return TestRandom.nextObject(PartitionPlanTableEntity.class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
server/odc-migrate/src/main/resources/migrate/common/V_4_2_4_4__alter_partitionplan.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
CREATE TABLE IF NOT EXISTS `partitionplan` ( | ||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Id for partition plan task', | ||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Record insertion time', | ||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Record modification time', | ||
`flow_instance_id` bigint(20) NOT NULL COMMENT 'Related flow instance id, reference flow_instance(id)', | ||
`is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Flag bit, mark whether the partition plan task is enabled', | ||
`creator_id` bigint(20) NOT NULL COMMENT 'Creator id, references odc_user_info(id)', | ||
`last_modifier_id` bigint(20) DEFAULT NULL COMMENT 'Last modifier id, references odc_user_info(id)', | ||
`database_id` bigint(20) NOT NULL COMMENT 'Related database id, reference connect_database(id)', | ||
CONSTRAINT `pk_partitionplan_id` PRIMARY KEY (`id`), | ||
UNIQUE KEY `uk_partitionplan_flow_instance_id` (`flow_instance_id`) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS `partitionplan_table` ( | ||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Id for partition plan table', | ||
`table_name` varchar(512) NOT NULL COMMENT 'Target table name', | ||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Record insertion time', | ||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Record modification time', | ||
`is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Flag bit, mark whether the partition plan task is enabled', | ||
`partition_name_invoker` varchar(64) NOT NULL COMMENT 'The name of the specific executor of the partition strategy needs to match invoker_input', | ||
`partition_name_invoker_parameters` varchar(1024) NOT NULL COMMENT 'The input of the specific executor of the partition strategy invoker', | ||
`schedule_id` bigint(20) NOT NULL COMMENT 'Related schedule id, reference schedule_schedule(id)', | ||
`partitionplan_id` bigint(20) NOT NULL COMMENT 'Related partition plan id, reference partitionplan(id)', | ||
CONSTRAINT `pk_partitionplan_table_id` PRIMARY KEY (`id`), | ||
UNIQUE KEY `uk_partitionplan_table_schedule_id_partitionplan_id_table_name` (`schedule_id`, `partitionplan_id`, `table_name`) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS `partitionplan_table_partitionkey` ( | ||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Id for partition plan table', | ||
`partition_key` varchar(2048) NOT NULL COMMENT 'Target partition key', | ||
`strategy` varchar(64) NOT NULL COMMENT 'Partition strategy type, enumeration values: CREATE, DROP', | ||
`partition_key_invoker` varchar(64) NOT NULL COMMENT 'The name of the specific executor of the partition strategy needs to match invoker_input', | ||
`partition_key_invoker_parameters` varchar(1024) NOT NULL COMMENT 'The input of the specific executor of the partition strategy invoker', | ||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Record insertion time', | ||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Record modification time', | ||
`partitionplan_table_id` bigint(20) NOT NULL COMMENT 'Related partition plan table id, reference partitionplan_table(id)', | ||
CONSTRAINT `pk_partitionplan_table_partitionkey` PRIMARY KEY (`id`), | ||
UNIQUE KEY `uk_ptp_ptid_strategy_partition_key` (`partitionplan_table_id`, `strategy`, `partition_key`) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.