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.proxy.backend.config.yaml;
19  
20  import lombok.Getter;
21  import lombok.Setter;
22  import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
23  import org.apache.shardingsphere.globalclock.yaml.config.YamlGlobalClockRuleConfiguration;
24  import org.apache.shardingsphere.infra.util.yaml.YamlConfiguration;
25  import org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfiguration;
26  import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
27  import org.apache.shardingsphere.logging.yaml.config.YamlLoggingRuleConfiguration;
28  import org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration;
29  import org.apache.shardingsphere.sqlfederation.yaml.config.YamlSQLFederationRuleConfiguration;
30  import org.apache.shardingsphere.sqltranslator.yaml.config.YamlSQLTranslatorRuleConfiguration;
31  import org.apache.shardingsphere.traffic.yaml.config.YamlTrafficRuleConfiguration;
32  import org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration;
33  
34  import java.util.Collection;
35  import java.util.HashMap;
36  import java.util.LinkedList;
37  import java.util.Map;
38  import java.util.Properties;
39  
40  /**
41   * YAML server configuration for ShardingSphere-Proxy.
42   */
43  @Getter
44  @Setter
45  public final class YamlProxyServerConfiguration implements YamlConfiguration {
46      
47      private YamlModeConfiguration mode;
48      
49      private YamlAuthorityRuleConfiguration authority;
50      
51      private YamlTransactionRuleConfiguration transaction;
52      
53      private YamlSQLParserRuleConfiguration sqlParser;
54      
55      private YamlSQLTranslatorRuleConfiguration sqlTranslator;
56      
57      private YamlTrafficRuleConfiguration traffic;
58      
59      private YamlLoggingRuleConfiguration logging;
60      
61      private YamlGlobalClockRuleConfiguration globalClock;
62      
63      private YamlSQLFederationRuleConfiguration sqlFederation;
64      
65      private Map<String, YamlProxyDataSourceConfiguration> dataSources = new HashMap<>();
66      
67      private Collection<YamlRuleConfiguration> rules = new LinkedList<>();
68      
69      private Properties props = new Properties();
70      
71      private Collection<String> labels;
72      
73      /**
74       * Set rules if the param rules is not null.
75       *
76       * @param rules the rules to set
77       */
78      public void setRules(final Collection<YamlRuleConfiguration> rules) {
79          if (null != rules) {
80              this.rules = rules;
81          }
82      }
83      
84      /**
85       * Set props if the param props is not null.
86       *
87       * @param props the props to set
88       */
89      public void setProps(final Properties props) {
90          if (null != props) {
91              this.props = props;
92          }
93      }
94  }