提交 2e8fda9e 编写于 作者: T terrymanu

rename ShardingConfigurationException to ShardingSphereConfigurationException

上级 a11c6a95
......@@ -21,7 +21,7 @@ import com.google.common.base.Function;
import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import java.util.Collection;
import java.util.List;
......@@ -71,14 +71,14 @@ public final class BindingTableRule {
}
}
if (-1 == index) {
throw new ShardingConfigurationException("Actual table [%s].[%s] is not in table config", dataSource, otherActualTable);
throw new ShardingSphereConfigurationException("Actual table [%s].[%s] is not in table config", dataSource, otherActualTable);
}
for (TableRule each : tableRules) {
if (each.getLogicTable().equals(logicTable.toLowerCase())) {
return each.getActualDataNodes().get(index).getTableName().toLowerCase();
}
}
throw new ShardingConfigurationException("Cannot find binding actual table, data source: %s, logic table: %s, other actual table: %s", dataSource, logicTable, otherActualTable);
throw new ShardingSphereConfigurationException("Cannot find binding actual table, data source: %s, logic table: %s, other actual table: %s", dataSource, logicTable, otherActualTable);
}
Collection<String> getAllLogicTables() {
......
......@@ -22,7 +22,7 @@ import com.google.common.base.Splitter;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import java.util.List;
......@@ -49,7 +49,7 @@ public final class DataNode {
*/
public DataNode(final String dataNode) {
if (!isValidDataNode(dataNode)) {
throw new ShardingConfigurationException("Invalid format for actual data nodes: '%s'", dataNode);
throw new ShardingSphereConfigurationException("Invalid format for actual data nodes: '%s'", dataNode);
}
List<String> segments = Splitter.on(DELIMITER).splitToList(dataNode);
dataSourceName = segments.get(0);
......
......@@ -28,7 +28,7 @@ import org.apache.shardingsphere.api.config.sharding.KeyGeneratorConfiguration;
import org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration;
import org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration;
import org.apache.shardingsphere.api.config.sharding.strategy.ShardingStrategyConfiguration;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import org.apache.shardingsphere.core.strategy.route.ShardingStrategy;
import org.apache.shardingsphere.core.strategy.route.ShardingStrategyFactory;
import org.apache.shardingsphere.core.strategy.route.none.NoneShardingStrategy;
......@@ -188,7 +188,7 @@ public class ShardingRule implements BaseRule {
if (!Strings.isNullOrEmpty(shardingDataSourceNames.getDefaultDataSourceName())) {
return new TableRule(shardingDataSourceNames.getDefaultDataSourceName(), logicTableName);
}
throw new ShardingConfigurationException("Cannot find table rule and default data source with logic table: '%s'", logicTableName);
throw new ShardingSphereConfigurationException("Cannot find table rule and default data source with logic table: '%s'", logicTableName);
}
/**
......@@ -373,7 +373,7 @@ public class ShardingRule implements BaseRule {
public Comparable<?> generateKey(final String logicTableName) {
Optional<TableRule> tableRule = findTableRule(logicTableName);
if (!tableRule.isPresent()) {
throw new ShardingConfigurationException("Cannot find strategy for generate keys.");
throw new ShardingSphereConfigurationException("Cannot find strategy for generate keys.");
}
ShardingKeyGenerator shardingKeyGenerator = null == tableRule.get().getShardingKeyGenerator() ? defaultShardingKeyGenerator : tableRule.get().getShardingKeyGenerator();
return shardingKeyGenerator.generateKey();
......@@ -420,7 +420,7 @@ public class ShardingRule implements BaseRule {
return each;
}
}
throw new ShardingConfigurationException("Cannot find actual data node for data source name: '%s' and logic table name: '%s'", dataSourceName, logicTableName);
throw new ShardingSphereConfigurationException("Cannot find actual data node for data source name: '%s' and logic table name: '%s'", dataSourceName, logicTableName);
}
/**
......
......@@ -23,7 +23,7 @@ import lombok.Getter;
import lombok.ToString;
import org.apache.shardingsphere.api.config.sharding.KeyGeneratorConfiguration;
import org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import org.apache.shardingsphere.underlying.common.exception.ShardingException;
import org.apache.shardingsphere.core.strategy.route.none.NoneShardingStrategy;
import org.apache.shardingsphere.spi.algorithm.keygen.ShardingKeyGeneratorServiceLoader;
......@@ -233,7 +233,7 @@ public final class TableRule {
private void checkRule(final List<String> dataNodes) {
if (isEmptyDataNodes(dataNodes) && null != tableShardingStrategy && !(tableShardingStrategy instanceof NoneShardingStrategy)) {
throw new ShardingConfigurationException("ActualDataNodes must be configured if want to shard tables for logicTable [%s]", logicTable);
throw new ShardingSphereConfigurationException("ActualDataNodes must be configured if want to shard tables for logicTable [%s]", logicTable);
}
}
}
......@@ -19,7 +19,7 @@ package org.apache.shardingsphere.core.rule;
import org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration;
import org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import org.junit.Test;
import java.util.Arrays;
......@@ -47,12 +47,12 @@ public final class BindingTableRuleTest {
assertThat(createBindingTableRule().getBindingActualTable("ds1", "Sub_Logic_Table", "table_1"), is("sub_table_1"));
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertGetBindingActualTablesFailureWhenNotFound() {
createBindingTableRule().getBindingActualTable("no_ds", "Sub_Logic_Table", "table_1");
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertGetBindingActualTablesFailureWhenLogicTableNotFound() {
createBindingTableRule().getBindingActualTable("ds0", "No_Logic_Table", "table_1");
}
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.core.rule;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
......@@ -34,17 +34,17 @@ public final class DataNodeTest {
assertThat(dataNode.getTableName(), is("tbl_0"));
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertNewInValidDataNodeWithoutDelimiter() {
new DataNode("ds_0tbl_0");
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertNewInValidDataNodeWithTwoDelimiters() {
new DataNode("ds_0.tbl_0.tbl_1");
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertNewValidDataNodeWithInvalidDelimiter() {
new DataNode("ds_0,tbl_0");
}
......
......@@ -24,7 +24,7 @@ import org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration;
import org.apache.shardingsphere.api.config.sharding.strategy.InlineShardingStrategyConfiguration;
import org.apache.shardingsphere.api.config.sharding.strategy.NoneShardingStrategyConfiguration;
import org.apache.shardingsphere.api.config.sharding.strategy.StandardShardingStrategyConfiguration;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import org.apache.shardingsphere.core.fixture.PreciseShardingAlgorithmFixture;
import org.apache.shardingsphere.core.strategy.keygen.SnowflakeShardingKeyGenerator;
import org.apache.shardingsphere.core.strategy.keygen.fixture.IncrementShardingKeyGenerator;
......@@ -121,7 +121,7 @@ public final class ShardingRuleTest {
assertThat(shardingRule.getTableRule("Default_Table").getLogicTable(), is("default_table"));
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertGetTableRuleFailure() {
createMinimumShardingRule().getTableRule("New_Table");
}
......@@ -283,7 +283,7 @@ public final class ShardingRuleTest {
assertFalse(createMinimumShardingRule().findGenerateKeyColumnName("sub_logic_table").isPresent());
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertGenerateKeyFailure() {
createMaximumShardingRule().generateKey("table_0");
}
......@@ -347,7 +347,7 @@ public final class ShardingRuleTest {
assertThat(createMaximumShardingRule().getDataNode("ds_1", "logic_table"), is(new DataNode("ds_1.table_0")));
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertGetDataNodeByLogicTableFailureWithDataSourceName() {
createMaximumShardingRule().getDataNode("ds_3", "logic_table");
}
......
......@@ -23,7 +23,7 @@ import org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration;
import org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration;
import org.apache.shardingsphere.api.config.sharding.strategy.InlineShardingStrategyConfiguration;
import org.apache.shardingsphere.api.config.sharding.strategy.NoneShardingStrategyConfiguration;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import org.apache.shardingsphere.core.strategy.keygen.fixture.IncrementShardingKeyGenerator;
import org.junit.Test;
......@@ -113,7 +113,7 @@ public final class TableRuleTest {
assertFalse(actual.isExisted("table_3"));
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertActualDataNodesNotConfigured() {
TableRuleConfiguration tableRuleConfiguration = new TableRuleConfiguration("LOGIC_TABLE", "");
tableRuleConfiguration.setTableShardingStrategyConfig(new InlineShardingStrategyConfiguration("shardingColumn", "table_${shardingColumn % 3}"));
......
......@@ -19,7 +19,7 @@ package org.apache.shardingsphere.core.route.type.unicast;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import org.apache.shardingsphere.core.route.type.RoutingEngine;
import org.apache.shardingsphere.core.route.type.RoutingResult;
import org.apache.shardingsphere.core.route.type.RoutingUnit;
......@@ -90,7 +90,7 @@ public final class UnicastRoutingEngine implements RoutingEngine {
}
}
if (availableDatasourceNames.isEmpty()) {
throw new ShardingConfigurationException("Cannot find actual datasource intersection for logic tables: %s", logicTables);
throw new ShardingSphereConfigurationException("Cannot find actual datasource intersection for logic tables: %s", logicTables);
}
RoutingUnit routingUnit = new RoutingUnit(shardingRule.getShardingDataSourceNames().getRandomDataSourceName(availableDatasourceNames));
routingUnit.getTableUnits().addAll(tableUnits);
......
......@@ -19,7 +19,7 @@ package org.apache.shardingsphere.core.route.type.unicast;
import org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration;
import org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration;
import org.apache.shardingsphere.underlying.common.config.ShardingConfigurationException;
import org.apache.shardingsphere.underlying.common.config.ShardingSphereConfigurationException;
import org.apache.shardingsphere.core.route.type.RoutingResult;
import org.apache.shardingsphere.core.rule.ShardingRule;
import org.junit.Before;
......@@ -82,7 +82,7 @@ public final class UnicastRoutingEngineTest {
assertThat(routingResult.getRoutingUnits().size(), is(1));
}
@Test(expected = ShardingConfigurationException.class)
@Test(expected = ShardingSphereConfigurationException.class)
public void assertRouteForWithNoIntersection() {
Set<String> sets = new HashSet<>();
sets.add("t_order");
......
......@@ -18,11 +18,11 @@
package org.apache.shardingsphere.underlying.common.config;
/**
* Sharding rule exception.
* Configuration exception.
*
* @author zhangliang
*/
public final class ShardingConfigurationException extends RuntimeException {
public final class ShardingSphereConfigurationException extends RuntimeException {
private static final long serialVersionUID = -1360264079938958332L;
......@@ -32,7 +32,7 @@ public final class ShardingConfigurationException extends RuntimeException {
* @param errorMessage formatted error message
* @param args arguments of error message
*/
public ShardingConfigurationException(final String errorMessage, final Object... args) {
public ShardingSphereConfigurationException(final String errorMessage, final Object... args) {
super(String.format(errorMessage, args));
}
......@@ -41,7 +41,7 @@ public final class ShardingConfigurationException extends RuntimeException {
*
* @param cause cause exception
*/
public ShardingConfigurationException(final Exception cause) {
public ShardingSphereConfigurationException(final Exception cause) {
super(cause);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册