View Javadoc
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;
19  
20  import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration;
21  import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
22  import org.apache.shardingsphere.infra.datasource.pool.config.DataSourceConfiguration;
23  import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties;
24  import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
25  import org.apache.shardingsphere.metadata.persist.data.ShardingSphereDataBasedPersistService;
26  import org.apache.shardingsphere.metadata.persist.service.config.database.DatabaseBasedPersistService;
27  import org.apache.shardingsphere.metadata.persist.service.config.global.GlobalPersistService;
28  import org.apache.shardingsphere.metadata.persist.service.database.DatabaseMetaDataBasedPersistService;
29  import org.apache.shardingsphere.metadata.persist.service.version.MetaDataVersionBasedPersistService;
30  import org.apache.shardingsphere.mode.spi.PersistRepository;
31  
32  import javax.sql.DataSource;
33  import java.util.Collection;
34  import java.util.Map;
35  import java.util.Properties;
36  
37  /**
38   * Abstract meta data persist service.
39   */
40  public interface MetaDataBasedPersistService {
41      
42      /**
43       * Get repository.
44       * 
45       * @return repository
46       */
47      PersistRepository getRepository();
48      
49      /**
50       * Get data source unit service.
51       * 
52       * @return persist service
53       */
54      DatabaseBasedPersistService<Map<String, DataSourcePoolProperties>> getDataSourceUnitService();
55      
56      /**
57       * Get database meta data service.
58       * 
59       * @return persist service
60       */
61      DatabaseMetaDataBasedPersistService getDatabaseMetaDataService();
62      
63      /**
64       * Get database rule persist service.
65       * 
66       * @return persist service
67       */
68      DatabaseBasedPersistService<Collection<RuleConfiguration>> getDatabaseRulePersistService();
69      
70      /**
71       * Get global rule service.
72       * 
73       * @return repository
74       */
75      GlobalPersistService<Collection<RuleConfiguration>> getGlobalRuleService();
76      
77      /**
78       * Get props service.
79       * 
80       * @return persist service
81       */
82      GlobalPersistService<Properties> getPropsService();
83      
84      /**
85       * Get meta data version persist service.
86       * 
87       * @return persist service
88       */
89      MetaDataVersionBasedPersistService getMetaDataVersionPersistService();
90      
91      /**
92       * Get ShardingSphere data persist service.
93       * 
94       * @return persist service
95       */
96      ShardingSphereDataBasedPersistService getShardingSphereDataPersistService();
97      
98      /**
99       * Persist global rule configurations.
100      * 
101      * @param globalRuleConfigs global rule configurations
102      * @param props properties
103      */
104     void persistGlobalRuleConfiguration(Collection<RuleConfiguration> globalRuleConfigs, Properties props);
105     
106     /**
107      * Persist configurations.
108      * 
109      * @param databaseName database name
110      * @param databaseConfigs database configurations
111      * @param dataSources data sources
112      * @param rules rules
113      */
114     void persistConfigurations(String databaseName, DatabaseConfiguration databaseConfigs, Map<String, DataSource> dataSources, Collection<ShardingSphereRule> rules);
115     
116     /**
117      * Get effective data sources.
118      *
119      * @param databaseName database name
120      * @return effective data sources
121      */
122     Map<String, DataSourceConfiguration> loadDataSourceConfigurations(String databaseName);
123 }