This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new e354a77 default single table rule routing and configuration support
(#13640)
e354a77 is described below
commit e354a77d8ed9ee1fe47d43d10ca740f410691364
Author: lanchengx <[email protected]>
AuthorDate: Wed Nov 17 07:55:41 2021 -0600
default single table rule routing and configuration support (#13640)
* DefaultDataSource routing support
* DefaultDataSource routing config support.
* Add test, adjust format and name.
* Modify test order.
* Modify order.
* Use the constructor to replace the set method.
* Use the constructor to replace the set method.
* Reformat.
---
.../engine/fixture/AbstractRoutingEngineTest.java | 3 +-
.../ReadWriteSplittingDataNodeBuilderFixture.java | 2 +-
.../YamlRuleConfigurationSwapperFixture.java | 2 +-
.../fixture/merger/ResultMergerEngineFixture.java | 2 +-
.../config/SingleTableRuleConfiguration.java | 4 ++
.../singletable/route/SingleTableRouteEngine.java | 8 ++-
.../singletable/rule/SingleTableRule.java | 20 ++++++-
.../rule/builder/SingleTableRuleBuilder.java | 2 +-
.../pojo/YamlSingleTableRuleConfiguration.java} | 23 ++++----
.../SingleTableRuleConfigurationYamlSwapper.java} | 36 +++++++-----
...aml.config.swapper.YamlRuleConfigurationSwapper | 18 ++++++
.../metadata/SingleTableMetaDataBuilderTest.java | 4 +-
.../metadata/SingleTableSchemaBuilderTest.java | 4 +-
.../route/SingleTableRouteEngineTest.java | 27 ++++++++-
.../singletable/rule/SingleTableRuleTest.java | 8 ++-
.../rule/builder/SingleTableRuleBuilderTest.java | 26 ++++++++-
...ingleTableRuleConfigurationYamlSwapperTest.java | 68 ++++++++++++++++++++++
.../YamlRuleConfigurationSwapperFixture.java | 2 +-
.../YamlRuleConfigurationSwapperFixture.java | 2 +-
.../spi/fixture/ordered/OrderedSPIFixtureImpl.java | 2 +-
20 files changed, 214 insertions(+), 49 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/fixture/AbstractRoutingEngineTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/fixture/AbstractRoutingEngineTest.java
index 6d26e3f..157f695 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/fixture/AbstractRoutingEngineTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/fixture/AbstractRoutingEngineTest.java
@@ -32,6 +32,7 @@ import
org.apache.shardingsphere.sharding.route.engine.condition.ShardingConditi
import
org.apache.shardingsphere.sharding.route.engine.condition.value.ListShardingConditionValue;
import
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import
org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
import org.apache.shardingsphere.singletable.rule.SingleTableRule;
import javax.sql.DataSource;
@@ -242,7 +243,7 @@ public abstract class AbstractRoutingEngineTest {
protected SingleTableRule createAllSingleTableRule(final
Collection<ShardingSphereRule> rules) {
Map<String, DataSource> dataSourceMap = createDataSourceMapWithMain();
- SingleTableRule singleTableRule = new
SingleTableRule(mock(DatabaseType.class), dataSourceMap, rules, new
ConfigurationProperties(new Properties()));
+ SingleTableRule singleTableRule = new SingleTableRule(new
SingleTableRuleConfiguration(), mock(DatabaseType.class), dataSourceMap, rules,
new ConfigurationProperties(new Properties()));
singleTableRule.addDataNode("t_category",
dataSourceMap.keySet().iterator().next());
return singleTableRule;
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/ReadWriteSplittingDataNodeBuilderFixture.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/ReadWriteSplittingDataNodeBuilderFixture.java
index 4d4fc64..a14c927 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/ReadWriteSplittingDataNodeBuilderFixture.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/ReadWriteSplittingDataNodeBuilderFixture.java
@@ -40,7 +40,7 @@ public final class ReadWriteSplittingDataNodeBuilderFixture
implements DataNodeB
@Override
public int getOrder() {
- return 0;
+ return 3;
}
@Override
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
index a4a7207..074d3db 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
@@ -47,6 +47,6 @@ public final class YamlRuleConfigurationSwapperFixture
implements YamlRuleConfig
@Override
public int getOrder() {
- return 0;
+ return 3;
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/merger/ResultMergerEngineFixture.java
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/merger/ResultMergerEngineFixture.java
index dacb178..2d69620 100644
---
a/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/merger/ResultMergerEngineFixture.java
+++
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/merger/ResultMergerEngineFixture.java
@@ -34,7 +34,7 @@ public final class ResultMergerEngineFixture implements
ResultMergerEngine<Merge
@Override
public int getOrder() {
- return 0;
+ return 3;
}
@Override
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-api/src/main/java/org/apache/shardingsphere/singletable/config/SingleTableRuleConfiguration.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-api/src/main/java/org/apache/shardingsphere/singletable/config/SingleTableRuleConfiguration.java
index e41e28f..f7f8285 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-api/src/main/java/org/apache/shardingsphere/singletable/config/SingleTableRuleConfiguration.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-api/src/main/java/org/apache/shardingsphere/singletable/config/SingleTableRuleConfiguration.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.singletable.config;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
import lombok.Setter;
import
org.apache.shardingsphere.infra.config.function.EnhancedRuleConfiguration;
import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
@@ -27,6 +29,8 @@ import java.util.Optional;
* Single table rule configuration.
*/
@Setter
+@AllArgsConstructor
+@NoArgsConstructor
public final class SingleTableRuleConfiguration implements
SchemaRuleConfiguration, EnhancedRuleConfiguration {
private String defaultDataSource;
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/SingleTableRouteEngine.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/SingleTableRouteEngine.java
index eccbd73..a377e40 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/SingleTableRouteEngine.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/SingleTableRouteEngine.java
@@ -83,7 +83,8 @@ public final class SingleTableRouteEngine {
if (!existSingleTables.isEmpty()) {
fillRouteContext(rule, routeContext, existSingleTables);
} else {
- routeContext.getRouteUnits().add(getRandomRouteUnit(rule));
+ RouteUnit routeUnit = rule.getDefaultDataSource().isPresent()
? getDefaultRouteUnit(rule.getDefaultDataSource().get()) :
getRandomRouteUnit(rule);
+ routeContext.getRouteUnits().add(routeUnit);
}
} else {
decorateRouteContextForFederate(routeContext);
@@ -114,6 +115,11 @@ public final class SingleTableRouteEngine {
return new RouteUnit(new RouteMapper(dataSource, dataSource),
Collections.singleton(new RouteMapper(table, table)));
}
+ private RouteUnit getDefaultRouteUnit(final String dataSource) {
+ String table = singleTableNames.iterator().next();
+ return new RouteUnit(new RouteMapper(dataSource, dataSource),
Collections.singleton(new RouteMapper(table, table)));
+ }
+
private void fillRouteContext(final SingleTableRule singleTableRule, final
RouteContext routeContext, final Collection<String> logicTables) {
Map<String, SingleTableDataNode> singleTableDataNodes =
singleTableRule.getSingleTableDataNodes();
for (String each : logicTables) {
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/SingleTableRule.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/SingleTableRule.java
index d9fd557..bcdd6ed 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/SingleTableRule.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/SingleTableRule.java
@@ -29,6 +29,7 @@ import
org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRul
import
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
import javax.sql.DataSource;
import java.util.Collection;
@@ -49,14 +50,18 @@ import java.util.stream.Collectors;
@Getter
public final class SingleTableRule implements SchemaRule,
DataNodeContainedRule, TableContainedRule, MutableDataNodeRule {
+ private String defaultDataSource;
+
private final Collection<String> dataSourceNames;
private final Map<String, SingleTableDataNode> singleTableDataNodes;
- public SingleTableRule(final DatabaseType databaseType, final Map<String,
DataSource> dataSourceMap, final Collection<ShardingSphereRule> builtRules,
final ConfigurationProperties props) {
+ public SingleTableRule(final SingleTableRuleConfiguration config, final
DatabaseType databaseType,
+ final Map<String, DataSource> dataSourceMap, final
Collection<ShardingSphereRule> builtRules, final ConfigurationProperties props)
{
Map<String, DataSource> aggregateDataSourceMap =
getAggregateDataSourceMap(dataSourceMap, builtRules);
dataSourceNames = aggregateDataSourceMap.keySet();
singleTableDataNodes = SingleTableDataNodeLoader.load(databaseType,
aggregateDataSourceMap, getExcludedTables(builtRules), props);
+ config.getDefaultDataSource().ifPresent(op -> defaultDataSource = op);
}
private Map<String, DataSource> getAggregateDataSourceMap(final
Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule>
builtRules) {
@@ -114,6 +119,15 @@ public final class SingleTableRule implements SchemaRule,
DataNodeContainedRule,
}
/**
+ * Get default data source.
+ *
+ * @return default data source
+ */
+ public Optional<String> getDefaultDataSource() {
+ return Optional.ofNullable(defaultDataSource);
+ }
+
+ /**
* Get sharding logic table names.
*
* @param logicTableNames logic table names
@@ -136,8 +150,8 @@ public final class SingleTableRule implements SchemaRule,
DataNodeContainedRule,
}
private Collection<String> getExcludedTables(final
Collection<ShardingSphereRule> rules) {
- return rules.stream().filter(each -> each instanceof
DataNodeContainedRule).flatMap(each
- -> ((DataNodeContainedRule)
each).getAllTables().stream()).collect(Collectors.toCollection(() -> new
TreeSet<>(String.CASE_INSENSITIVE_ORDER)));
+ return rules.stream().filter(each -> each instanceof
DataNodeContainedRule)
+ .flatMap(each -> ((DataNodeContainedRule)
each).getAllTables().stream()).collect(Collectors.toCollection(() -> new
TreeSet<>(String.CASE_INSENSITIVE_ORDER)));
}
@Override
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilder.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilder.java
index aa433f2..a53b139 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilder.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilder.java
@@ -33,7 +33,7 @@ public final class SingleTableRuleBuilder implements
SchemaRuleBuilder<SingleTab
@Override
public SingleTableRule build(final SchemaRulesBuilderMaterials materials,
final SingleTableRuleConfiguration config, final Collection<ShardingSphereRule>
builtRules) {
- return new SingleTableRule(materials.getDatabaseType(),
materials.getDataSourceMap(), builtRules, materials.getProps());
+ return new SingleTableRule(config, materials.getDatabaseType(),
materials.getDataSourceMap(), builtRules, materials.getProps());
}
@Override
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-api/src/main/java/org/apache/shardingsphere/singletable/config/SingleTableRuleConfiguration.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/yaml/config/pojo/YamlSingleTableRuleConfiguration.java
similarity index 62%
copy from
shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-api/src/main/java/org/apache/shardingsphere/singletable/config/SingleTableRuleConfiguration.java
copy to
shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/yaml/config/pojo/YamlSingleTableRuleConfiguration.java
index e41e28f..e86806e 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-api/src/main/java/org/apache/shardingsphere/singletable/config/SingleTableRuleConfiguration.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/yaml/config/pojo/YamlSingleTableRuleConfiguration.java
@@ -15,27 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.singletable.config;
+package org.apache.shardingsphere.singletable.yaml.config.pojo;
+import lombok.Getter;
import lombok.Setter;
-import
org.apache.shardingsphere.infra.config.function.EnhancedRuleConfiguration;
-import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
-
-import java.util.Optional;
+import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRuleConfiguration;
+import
org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
/**
- * Single table rule configuration.
+ * Single table rule configuration for YAML.
*/
+@Getter
@Setter
-public final class SingleTableRuleConfiguration implements
SchemaRuleConfiguration, EnhancedRuleConfiguration {
+public final class YamlSingleTableRuleConfiguration implements
YamlRuleConfiguration {
private String defaultDataSource;
- /**
- * Get default data source.
- * @return default data source
- */
- public Optional<String> getDefaultDataSource() {
- return Optional.ofNullable(defaultDataSource);
+ @Override
+ public Class<SingleTableRuleConfiguration> getRuleConfigurationType() {
+ return SingleTableRuleConfiguration.class;
}
}
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilder.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/yaml/config/swapper/SingleTableRuleConfigurationYamlSwapper.java
similarity index 51%
copy from
shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilder.java
copy to
shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/yaml/config/swapper/SingleTableRuleConfigurationYamlSwapper.java
index aa433f2..77032de 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilder.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/yaml/config/swapper/SingleTableRuleConfigurationYamlSwapper.java
@@ -15,25 +15,26 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.singletable.rule.builder;
+package org.apache.shardingsphere.singletable.yaml.config.swapper;
+import
org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper;
import
org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
import org.apache.shardingsphere.singletable.constant.SingleTableOrder;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import
org.apache.shardingsphere.infra.rule.builder.schema.SchemaRulesBuilderMaterials;
-import org.apache.shardingsphere.infra.rule.builder.schema.SchemaRuleBuilder;
-import org.apache.shardingsphere.singletable.rule.SingleTableRule;
-
-import java.util.Collection;
+import
org.apache.shardingsphere.singletable.yaml.config.pojo.YamlSingleTableRuleConfiguration;
/**
- * Single table rule builder.
+ * Single table rule configuration YAML swapper.
*/
-public final class SingleTableRuleBuilder implements
SchemaRuleBuilder<SingleTableRuleConfiguration> {
+public final class SingleTableRuleConfigurationYamlSwapper implements
YamlRuleConfigurationSwapper<YamlSingleTableRuleConfiguration,
SingleTableRuleConfiguration> {
+
+ @Override
+ public Class<SingleTableRuleConfiguration> getTypeClass() {
+ return SingleTableRuleConfiguration.class;
+ }
@Override
- public SingleTableRule build(final SchemaRulesBuilderMaterials materials,
final SingleTableRuleConfiguration config, final Collection<ShardingSphereRule>
builtRules) {
- return new SingleTableRule(materials.getDatabaseType(),
materials.getDataSourceMap(), builtRules, materials.getProps());
+ public String getRuleTagName() {
+ return "SINGLE";
}
@Override
@@ -42,7 +43,16 @@ public final class SingleTableRuleBuilder implements
SchemaRuleBuilder<SingleTab
}
@Override
- public Class<SingleTableRuleConfiguration> getTypeClass() {
- return SingleTableRuleConfiguration.class;
+ public YamlSingleTableRuleConfiguration swapToYamlConfiguration(final
SingleTableRuleConfiguration data) {
+ YamlSingleTableRuleConfiguration result = new
YamlSingleTableRuleConfiguration();
+ data.getDefaultDataSource().ifPresent(result::setDefaultDataSource);
+ return result;
+ }
+
+ @Override
+ public SingleTableRuleConfiguration swapToObject(final
YamlSingleTableRuleConfiguration yamlConfig) {
+ SingleTableRuleConfiguration result = new
SingleTableRuleConfiguration();
+ result.setDefaultDataSource(yamlConfig.getDefaultDataSource());
+ return result;
}
}
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
new file mode 100644
index 0000000..4531e78
--- /dev/null
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+org.apache.shardingsphere.singletable.yaml.config.swapper.SingleTableRuleConfigurationYamlSwapper
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/metadata/SingleTableMetaDataBuilderTest.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/metadata/SingleTableMetaDataBuilderTest.java
index 2b4a849..13bf56e 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/metadata/SingleTableMetaDataBuilderTest.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/metadata/SingleTableMetaDataBuilderTest.java
@@ -25,6 +25,7 @@ import
org.apache.shardingsphere.infra.metadata.schema.model.ColumnMetaData;
import org.apache.shardingsphere.infra.metadata.schema.model.IndexMetaData;
import org.apache.shardingsphere.infra.metadata.schema.model.TableMetaData;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import
org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
import org.apache.shardingsphere.singletable.rule.SingleTableRule;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.ordered.OrderedSPIRegistry;
@@ -76,7 +77,8 @@ public final class SingleTableMetaDataBuilderTest {
Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
when(dataSource.getConnection()).thenReturn(connection);
mockSingleTableLoad(connection);
- singleTableRule = new SingleTableRule(databaseType,
Collections.singletonMap("ds", dataSource), Collections.emptyList(), new
ConfigurationProperties(new Properties()));
+ singleTableRule = new SingleTableRule(new
SingleTableRuleConfiguration(), databaseType,
+ Collections.singletonMap("ds", dataSource),
Collections.emptyList(), new ConfigurationProperties(new Properties()));
when(databaseType.formatTableNamePattern("tbl")).thenReturn("tbl");
mockTableIsExist(connection);
mockTables(connection);
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/metadata/SingleTableSchemaBuilderTest.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/metadata/SingleTableSchemaBuilderTest.java
index d83568d..d554b5b 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/metadata/SingleTableSchemaBuilderTest.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/metadata/SingleTableSchemaBuilderTest.java
@@ -26,6 +26,7 @@ import
org.apache.shardingsphere.infra.metadata.schema.builder.SchemaBuilderMate
import
org.apache.shardingsphere.infra.metadata.schema.builder.TableMetaDataBuilder;
import org.apache.shardingsphere.infra.metadata.schema.model.TableMetaData;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import
org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
import org.apache.shardingsphere.singletable.rule.SingleTableRule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -118,7 +119,8 @@ public final class SingleTableSchemaBuilderTest {
when(connection.getMetaData().getTables(any(), any(), eq(null),
any())).thenReturn(resultSet);
when(resultSet.next()).thenReturn(true, true, true, true, true, true,
false);
when(resultSet.getString(TABLE_NAME)).thenReturn(singleTableNames[0],
singleTableNames[1]);
- return new SingleTableRule(databaseType,
Collections.singletonMap("logic_db", dataSource), Collections.emptyList(), new
ConfigurationProperties(new Properties()));
+ return new SingleTableRule(new SingleTableRuleConfiguration(),
databaseType, Collections.singletonMap("logic_db", dataSource),
+ Collections.emptyList(), new ConfigurationProperties(new
Properties()));
}
private void assertActualOfSingleTables(final Collection<TableMetaData>
actual) {
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/SingleTableRouteEngineTest.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/SingleTableRouteEngineTest.java
index 335b041..74103c6 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/SingleTableRouteEngineTest.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/SingleTableRouteEngineTest.java
@@ -22,6 +22,7 @@ import
org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
+import
org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
import org.apache.shardingsphere.singletable.rule.SingleTableDataNode;
import org.apache.shardingsphere.singletable.rule.SingleTableRule;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.ddl.MySQLCreateTableStatement;
@@ -49,7 +50,8 @@ public final class SingleTableRouteEngineTest {
@Test
public void assertRouteInSameDataSource() {
SingleTableRouteEngine singleTableRouteEngine = new
SingleTableRouteEngine(Arrays.asList("t_order", "t_order_item"), null);
- SingleTableRule singleTableRule = new
SingleTableRule(mock(DatabaseType.class), createDataSourceMap(),
Collections.emptyList(), new ConfigurationProperties(new Properties()));
+ SingleTableRule singleTableRule = new SingleTableRule(new
SingleTableRuleConfiguration(), mock(DatabaseType.class),
+ createDataSourceMap(), Collections.emptyList(), new
ConfigurationProperties(new Properties()));
singleTableRule.getSingleTableDataNodes().put("t_order", new
SingleTableDataNode("t_order", "ds_0"));
singleTableRule.getSingleTableDataNodes().put("t_order_item", new
SingleTableDataNode("t_order_item", "ds_0"));
RouteContext routeContext = new RouteContext();
@@ -71,7 +73,8 @@ public final class SingleTableRouteEngineTest {
@Test
public void assertRouteInDifferentDataSource() {
SingleTableRouteEngine singleTableRouteEngine = new
SingleTableRouteEngine(Arrays.asList("t_order", "t_order_item"), null);
- SingleTableRule singleTableRule = new
SingleTableRule(mock(DatabaseType.class), createDataSourceMap(),
Collections.emptyList(), new ConfigurationProperties(new Properties()));
+ SingleTableRule singleTableRule = new SingleTableRule(new
SingleTableRuleConfiguration(), mock(DatabaseType.class),
+ createDataSourceMap(), Collections.emptyList(), new
ConfigurationProperties(new Properties()));
singleTableRule.getSingleTableDataNodes().put("t_order", new
SingleTableDataNode("t_order", "ds_0"));
singleTableRule.getSingleTableDataNodes().put("t_order_item", new
SingleTableDataNode("t_order_item", "ds_1"));
RouteContext routeContext = new RouteContext();
@@ -94,7 +97,8 @@ public final class SingleTableRouteEngineTest {
@Test
public void assertRouteWithoutSingleTableRule() {
SingleTableRouteEngine singleTableRouteEngine = new
SingleTableRouteEngine(Arrays.asList("t_order", "t_order_item"), new
MySQLCreateTableStatement());
- SingleTableRule singleTableRule = new
SingleTableRule(mock(DatabaseType.class), createDataSourceMap(),
Collections.emptyList(), new ConfigurationProperties(new Properties()));
+ SingleTableRule singleTableRule = new SingleTableRule(new
SingleTableRuleConfiguration(), mock(DatabaseType.class),
+ createDataSourceMap(), Collections.emptyList(), new
ConfigurationProperties(new Properties()));
RouteContext routeContext = new RouteContext();
singleTableRouteEngine.route(routeContext, singleTableRule);
List<RouteUnit> routeUnits = new
ArrayList<>(routeContext.getRouteUnits());
@@ -106,6 +110,23 @@ public final class SingleTableRouteEngineTest {
assertThat(tableMapper0.getLogicName(), is("t_order"));
}
+ @Test
+ public void assertRouteWithDefaultSingleTableRule() {
+ SingleTableRouteEngine singleTableRouteEngine = new
SingleTableRouteEngine(Arrays.asList("t_order", "t_order_item"), new
MySQLCreateTableStatement());
+ SingleTableRule singleTableRule = new SingleTableRule(new
SingleTableRuleConfiguration("ds_0"), mock(DatabaseType.class),
+ createDataSourceMap(), Collections.emptyList(), new
ConfigurationProperties(new Properties()));
+ RouteContext routeContext = new RouteContext();
+ singleTableRouteEngine.route(routeContext, singleTableRule);
+ List<RouteUnit> routeUnits = new
ArrayList<>(routeContext.getRouteUnits());
+ assertThat(routeContext.getRouteUnits().size(), is(1));
+ assertThat(routeUnits.get(0).getDataSourceMapper().getActualName(),
is("ds_0"));
+ assertThat(routeUnits.get(0).getTableMappers().size(), is(1));
+ Iterator<RouteMapper> tableMappers =
routeUnits.get(0).getTableMappers().iterator();
+ RouteMapper tableMapper0 = tableMappers.next();
+ assertThat(tableMapper0.getActualName(), is("t_order"));
+ assertThat(tableMapper0.getLogicName(), is("t_order"));
+ }
+
private Map<String, DataSource> createDataSourceMap() {
Map<String, DataSource> result = new HashMap<>(2, 1);
result.put("ds_0", mock(DataSource.class, RETURNS_DEEP_STUBS));
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/SingleTableRuleTest.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/SingleTableRuleTest.java
index 8b7210f..79a2794 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/SingleTableRuleTest.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/SingleTableRuleTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.singletable.rule;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
+import
org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
import org.junit.Before;
import org.junit.Test;
@@ -80,7 +81,8 @@ public final class SingleTableRuleTest {
@Test
public void assertGetRuleType() {
- SingleTableRule singleTableRule = new
SingleTableRule(mock(DatabaseType.class), Collections.emptyMap(),
Collections.emptyList(), new ConfigurationProperties(new Properties()));
+ SingleTableRule singleTableRule = new SingleTableRule(new
SingleTableRuleConfiguration(), mock(DatabaseType.class),
+ Collections.emptyMap(), Collections.emptyList(), new
ConfigurationProperties(new Properties()));
assertThat(singleTableRule.getType(),
is(SingleTableRule.class.getSimpleName()));
}
@@ -88,7 +90,7 @@ public final class SingleTableRuleTest {
public void assertGetSingleTableDataNodes() {
DataNodeContainedRule dataNodeContainedRule =
mock(DataNodeContainedRule.class);
when(dataNodeContainedRule.getAllTables()).thenReturn(Arrays.asList("t_order",
"t_order_0", "t_order_1"));
- SingleTableRule singleTableRule = new
SingleTableRule(mock(DatabaseType.class), dataSourceMap,
+ SingleTableRule singleTableRule = new SingleTableRule(new
SingleTableRuleConfiguration(), mock(DatabaseType.class), dataSourceMap,
Collections.singletonList(dataNodeContainedRule), new
ConfigurationProperties(new Properties()));
Map<String, SingleTableDataNode> actual =
singleTableRule.getSingleTableDataNodes();
assertThat(actual.size(), is(2));
@@ -101,7 +103,7 @@ public final class SingleTableRuleTest {
public void assertGetSingleTableDataNodesWithUpperCase() {
DataNodeContainedRule dataNodeContainedRule =
mock(DataNodeContainedRule.class);
when(dataNodeContainedRule.getAllTables()).thenReturn(Arrays.asList("T_ORDER",
"T_ORDER_0", "T_ORDER_1"));
- SingleTableRule singleTableRule = new
SingleTableRule(mock(DatabaseType.class), dataSourceMap,
+ SingleTableRule singleTableRule = new SingleTableRule(new
SingleTableRuleConfiguration(), mock(DatabaseType.class), dataSourceMap,
Collections.singletonList(dataNodeContainedRule), new
ConfigurationProperties(new Properties()));
Map<String, SingleTableDataNode> actual =
singleTableRule.getSingleTableDataNodes();
assertThat(actual.size(), is(2));
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilderTest.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilderTest.java
index 9ac283f..84e7c1d 100644
---
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilderTest.java
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/builder/SingleTableRuleBuilderTest.java
@@ -17,9 +17,6 @@
package org.apache.shardingsphere.singletable.rule.builder;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Properties;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
@@ -34,7 +31,13 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Properties;
+
import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -58,5 +61,22 @@ public final class SingleTableRuleBuilderTest {
ShardingSphereRule shardingSphereRule = mock(ShardingSphereRule.class);
SchemaRule schemaRule = builder.build(materials, configuration,
Arrays.asList(shardingSphereRule));
assertThat(schemaRule, instanceOf(SingleTableRule.class));
+ assertFalse(((SingleTableRule)
schemaRule).getDefaultDataSource().isPresent());
+ }
+
+ @Test
+ public void assertBuildWithDefaultDataSource() {
+ Properties properties = new Properties();
+
properties.setProperty(ConfigurationPropertyKey.CHECK_DUPLICATE_TABLE_ENABLED.getKey(),
"false");
+ SchemaRulesBuilderMaterials materials =
mock(SchemaRulesBuilderMaterials.class);
+ when(materials.getProps()).thenReturn(new
ConfigurationProperties(properties));
+ ShardingSphereRule shardingSphereRule = mock(ShardingSphereRule.class);
+ Collection<SchemaRuleBuilder> registeredServiceBuilders =
OrderedSPIRegistry.getRegisteredServices(SchemaRuleBuilder.class);
+ SchemaRuleBuilder builder =
registeredServiceBuilders.iterator().next();
+ SingleTableRuleConfiguration configuration = new
SingleTableRuleConfiguration();
+ configuration.setDefaultDataSource("ds_0");
+ SchemaRule schemaRule = builder.build(materials, configuration,
Arrays.asList(shardingSphereRule));
+ assertThat(schemaRule, instanceOf(SingleTableRule.class));
+ assertThat(((SingleTableRule)
schemaRule).getDefaultDataSource().get(), is("ds_0"));
}
}
diff --git
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/swapper/SingleTableRuleConfigurationYamlSwapperTest.java
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/swapper/SingleTableRuleConfigurationYamlSwapperTest.java
new file mode 100644
index 0000000..4b31f62
--- /dev/null
+++
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/swapper/SingleTableRuleConfigurationYamlSwapperTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.singletable.swapper;
+
+import
org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration;
+import
org.apache.shardingsphere.singletable.yaml.config.pojo.YamlSingleTableRuleConfiguration;
+import
org.apache.shardingsphere.singletable.yaml.config.swapper.SingleTableRuleConfigurationYamlSwapper;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class SingleTableRuleConfigurationYamlSwapperTest {
+
+ private final SingleTableRuleConfigurationYamlSwapper swapper = new
SingleTableRuleConfigurationYamlSwapper();
+
+ @Test
+ public void assertSwapToObject() {
+ YamlSingleTableRuleConfiguration yamlConfiguration = new
YamlSingleTableRuleConfiguration();
+ yamlConfiguration.setDefaultDataSource("ds_0");
+ SingleTableRuleConfiguration configuration =
swapper.swapToObject(yamlConfiguration);
+ assertTrue(configuration.getDefaultDataSource().isPresent());
+ assertThat(configuration.getDefaultDataSource().get(), is("ds_0"));
+ }
+
+ @Test
+ public void assertSwapToObjectWithoutDataSource() {
+ YamlSingleTableRuleConfiguration yamlConfiguration = new
YamlSingleTableRuleConfiguration();
+ SingleTableRuleConfiguration configuration =
swapper.swapToObject(yamlConfiguration);
+ assertFalse(configuration.getDefaultDataSource().isPresent());
+ }
+
+ @Test
+ public void assertSwapToYaml() {
+ SingleTableRuleConfiguration configuration = new
SingleTableRuleConfiguration();
+ configuration.setDefaultDataSource("ds_0");
+ YamlSingleTableRuleConfiguration yamlSingleTableRuleConfiguration =
swapper.swapToYamlConfiguration(configuration);
+ assertThat(yamlSingleTableRuleConfiguration.getDefaultDataSource(),
is("ds_0"));
+ }
+
+ @Test
+ public void assertSwapToYamlWithoutDataSource() {
+ SingleTableRuleConfiguration configuration = new
SingleTableRuleConfiguration();
+ YamlSingleTableRuleConfiguration yamlSingleTableRuleConfiguration =
swapper.swapToYamlConfiguration(configuration);
+ assertNull(yamlSingleTableRuleConfiguration.getDefaultDataSource());
+ }
+}
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/fixture/YamlRuleConfigurationSwapperFixture.java
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/fixture/YamlRuleConfigurationSwapperFixture.java
index 868d67e..2963c43 100644
---
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/fixture/YamlRuleConfigurationSwapperFixture.java
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/fixture/YamlRuleConfigurationSwapperFixture.java
@@ -47,6 +47,6 @@ public final class YamlRuleConfigurationSwapperFixture
implements YamlRuleConfig
@Override
public int getOrder() {
- return 0;
+ return 3;
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/fixture/YamlRuleConfigurationSwapperFixture.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/fixture/YamlRuleConfigurationSwapperFixture.java
index b78a2be..2fc494d 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/fixture/YamlRuleConfigurationSwapperFixture.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/fixture/YamlRuleConfigurationSwapperFixture.java
@@ -47,6 +47,6 @@ public final class YamlRuleConfigurationSwapperFixture
implements YamlRuleConfig
@Override
public int getOrder() {
- return 0;
+ return 3;
}
}
diff --git
a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/ordered/OrderedSPIFixtureImpl.java
b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/ordered/OrderedSPIFixtureImpl.java
index e3f7c7d..d2d62cb 100644
---
a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/ordered/OrderedSPIFixtureImpl.java
+++
b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/ordered/OrderedSPIFixtureImpl.java
@@ -23,7 +23,7 @@ public final class OrderedSPIFixtureImpl implements
OrderedSPIFixture<FixtureCus
@Override
public int getOrder() {
- return 0;
+ return 3;
}
@Override