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.metadata.persist.service.database; 19 20 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema; 21 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable; 22 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereView; 23 import org.apache.shardingsphere.metadata.persist.service.schema.SchemaMetaDataPersistService; 24 25 import java.util.Collection; 26 import java.util.Map; 27 28 /** 29 * Database meta data based registry service. 30 */ 31 public interface DatabaseMetaDataBasedPersistService { 32 33 /** 34 * Add database name. 35 * 36 * @param databaseName database name 37 */ 38 void addDatabase(String databaseName); 39 40 /** 41 * Drop database. 42 * 43 * @param databaseName database name to be deleted 44 */ 45 void dropDatabase(String databaseName); 46 47 /** 48 * Load all database names. 49 * 50 * @return all database names 51 */ 52 Collection<String> loadAllDatabaseNames(); 53 54 /** 55 * Add schema. 56 * 57 * @param databaseName database name 58 * @param schemaName schema name 59 */ 60 void addSchema(String databaseName, String schemaName); 61 62 /** 63 * Drop schema. 64 * 65 * @param databaseName database name 66 * @param schemaName schema name 67 */ 68 void dropSchema(String databaseName, String schemaName); 69 70 /** 71 * Compare and persist schema meta data. 72 * 73 * @param databaseName database name 74 * @param schemaName schema name 75 * @param schema schema meta data 76 */ 77 void compareAndPersist(String databaseName, String schemaName, ShardingSphereSchema schema); 78 79 /** 80 * Persist schema meta data by alter configuration. 81 * 82 * @param databaseName database name 83 * @param schemaName schema name 84 * @param schema schema meta data 85 */ 86 void persistByAlterConfiguration(String databaseName, String schemaName, ShardingSphereSchema schema); 87 88 /** 89 * Persist schema meta data by drop configuration. 90 * 91 * @param databaseName database name 92 * @param schemaName schema name 93 * @param schema schema meta data 94 */ 95 void persistByDropConfiguration(String databaseName, String schemaName, ShardingSphereSchema schema); 96 97 /** 98 * Delete schema meta data. 99 * 100 * @param databaseName database name 101 * @param schemaName schema name 102 * @param schema schema meta data 103 */ 104 void delete(String databaseName, String schemaName, ShardingSphereSchema schema); 105 106 /** 107 * Load schema meta data. 108 * 109 * @param databaseName database name 110 * @return schema meta data 111 */ 112 Map<String, ShardingSphereSchema> loadSchemas(String databaseName); 113 114 /** 115 * Get table meta data persist service. 116 * 117 * @return persist service 118 */ 119 SchemaMetaDataPersistService<Map<String, ShardingSphereTable>> getTableMetaDataPersistService(); 120 121 /** 122 * Get view meta data persist service. 123 * 124 * @return persist service 125 */ 126 SchemaMetaDataPersistService<Map<String, ShardingSphereView>> getViewMetaDataPersistService(); 127 }