1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.shardingsphere.infra.instance.mode; 19 20 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; 21 import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; 22 import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaMetaDataPOJO; 23 import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaPOJO; 24 import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion; 25 26 import java.sql.SQLException; 27 import java.util.Collection; 28 import java.util.Map; 29 import java.util.Properties; 30 31 /** 32 * Mode context manager. 33 */ 34 public interface ModeContextManager { 35 36 /** 37 * Create database. 38 * 39 * @param databaseName database name 40 */ 41 void createDatabase(String databaseName); 42 43 /** 44 * Drop database. 45 * 46 * @param databaseName database name 47 */ 48 void dropDatabase(String databaseName); 49 50 /** 51 * Create schema. 52 * 53 * @param databaseName database name 54 * @param schemaName schema name 55 */ 56 void createSchema(String databaseName, String schemaName); 57 58 /** 59 * Alter schema. 60 * 61 * @param alterSchemaPOJO alter schema pojo 62 */ 63 void alterSchema(AlterSchemaPOJO alterSchemaPOJO); 64 65 /** 66 * Drop schema. 67 * 68 * @param databaseName database name 69 * @param schemaNames schema names 70 */ 71 void dropSchema(String databaseName, Collection<String> schemaNames); 72 73 /** 74 * Alter schema metadata. 75 * 76 * @param alterSchemaMetaDataPOJO alter schema metadata pojo 77 */ 78 void alterSchemaMetaData(AlterSchemaMetaDataPOJO alterSchemaMetaDataPOJO); 79 80 /** 81 * Register storage units. 82 * 83 * @param databaseName database name 84 * @param toBeRegisteredProps to be registered storage unit properties 85 * @throws SQLException SQL exception 86 */ 87 void registerStorageUnits(String databaseName, Map<String, DataSourcePoolProperties> toBeRegisteredProps) throws SQLException; 88 89 /** 90 * Alter storage units. 91 * 92 * @param databaseName database name 93 * @param toBeUpdatedProps to be updated storage unit properties 94 * @throws SQLException SQL exception 95 */ 96 void alterStorageUnits(String databaseName, Map<String, DataSourcePoolProperties> toBeUpdatedProps) throws SQLException; 97 98 /** 99 * Unregister storage units. 100 * @param databaseName database name 101 * @param toBeDroppedStorageUnitNames to be dropped storage unit names 102 * @throws SQLException SQL exception 103 */ 104 void unregisterStorageUnits(String databaseName, Collection<String> toBeDroppedStorageUnitNames) throws SQLException; 105 106 /** 107 * Alter single rule configuration. 108 * 109 * @param databaseName database name 110 * @param ruleConfigs rule configs 111 */ 112 void alterSingleRuleConfiguration(String databaseName, Collection<RuleConfiguration> ruleConfigs); 113 114 /** 115 * Alter rule configuration. 116 * 117 * @param databaseName database name 118 * @param toBeAlteredRuleConfig to be altered rule config 119 * @return meta data versions 120 */ 121 Collection<MetaDataVersion> alterRuleConfiguration(String databaseName, RuleConfiguration toBeAlteredRuleConfig); 122 123 /** 124 * Remove rule configuration item. 125 * 126 * @param databaseName database name 127 * @param toBeRemovedRuleConfig to be removed rule config 128 */ 129 void removeRuleConfigurationItem(String databaseName, RuleConfiguration toBeRemovedRuleConfig); 130 131 /** 132 * Remove rule configuration. 133 * 134 * @param databaseName database name 135 * @param ruleName rule name 136 */ 137 void removeRuleConfiguration(String databaseName, String ruleName); 138 139 /** 140 * Alter global rule configuration. 141 * 142 * @param globalRuleConfig global rule config 143 */ 144 void alterGlobalRuleConfiguration(RuleConfiguration globalRuleConfig); 145 146 /** 147 * Alter properties. 148 * 149 * @param props pros 150 */ 151 void alterProperties(Properties props); 152 }