Search in sources :

Example 21 with TableShardingStrategy

use of com.dangdang.ddframe.rdb.sharding.api.strategy.table.TableShardingStrategy in project sharding-jdbc by dangdangdotcom.

the class SingleTableRouter method createTableRuleWithDefaultDataSource.

private TableRule createTableRuleWithDefaultDataSource(final String logicTable, final DataSourceRule defaultDataSourceRule) {
    Map<String, DataSource> defaultDataSourceMap = new HashMap<>(1);
    defaultDataSourceMap.put(defaultDataSourceRule.getDefaultDataSourceName(), defaultDataSourceRule.getDefaultDataSource().get());
    return TableRule.builder(logicTable).dataSourceRule(new DataSourceRule(defaultDataSourceMap)).databaseShardingStrategy(new DatabaseShardingStrategy("", new NoneDatabaseShardingAlgorithm())).tableShardingStrategy(new TableShardingStrategy("", new NoneTableShardingAlgorithm())).build();
}
Also used : DatabaseShardingStrategy(com.dangdang.ddframe.rdb.sharding.api.strategy.database.DatabaseShardingStrategy) HashMap(java.util.HashMap) DataSourceRule(com.dangdang.ddframe.rdb.sharding.api.rule.DataSourceRule) NoneDatabaseShardingAlgorithm(com.dangdang.ddframe.rdb.sharding.api.strategy.database.NoneDatabaseShardingAlgorithm) TableShardingStrategy(com.dangdang.ddframe.rdb.sharding.api.strategy.table.TableShardingStrategy) NoneTableShardingAlgorithm(com.dangdang.ddframe.rdb.sharding.api.strategy.table.NoneTableShardingAlgorithm) DataSource(javax.sql.DataSource)

Aggregations

TableShardingStrategy (com.dangdang.ddframe.rdb.sharding.api.strategy.table.TableShardingStrategy)21 DatabaseShardingStrategy (com.dangdang.ddframe.rdb.sharding.api.strategy.database.DatabaseShardingStrategy)14 BindingTableRule (com.dangdang.ddframe.rdb.sharding.api.rule.BindingTableRule)12 DataSourceRule (com.dangdang.ddframe.rdb.sharding.api.rule.DataSourceRule)12 TableRule (com.dangdang.ddframe.rdb.sharding.api.rule.TableRule)12 ShardingRule (com.dangdang.ddframe.rdb.sharding.api.rule.ShardingRule)10 ShardingDataSource (com.dangdang.ddframe.rdb.sharding.jdbc.ShardingDataSource)9 NoneTableShardingAlgorithm (com.dangdang.ddframe.rdb.sharding.api.strategy.table.NoneTableShardingAlgorithm)7 Test (org.junit.Test)5 MultipleKeysModuloDatabaseShardingAlgorithm (com.dangdang.ddframe.rdb.integrate.fixture.MultipleKeysModuloDatabaseShardingAlgorithm)3 SingleKeyModuloDatabaseShardingAlgorithm (com.dangdang.ddframe.rdb.integrate.fixture.SingleKeyModuloDatabaseShardingAlgorithm)3 SingleKeyModuloTableShardingAlgorithm (com.dangdang.ddframe.rdb.integrate.fixture.SingleKeyModuloTableShardingAlgorithm)3 NoneDatabaseShardingAlgorithm (com.dangdang.ddframe.rdb.sharding.api.strategy.database.NoneDatabaseShardingAlgorithm)3 HashMap (java.util.HashMap)3 DataSource (javax.sql.DataSource)3 SingleKeyDynamicModuloTableShardingAlgorithm (com.dangdang.ddframe.rdb.integrate.fixture.SingleKeyDynamicModuloTableShardingAlgorithm)1 ShardingValue (com.dangdang.ddframe.rdb.sharding.api.ShardingValue)1 MultipleKeysDatabaseShardingAlgorithm (com.dangdang.ddframe.rdb.sharding.api.strategy.database.MultipleKeysDatabaseShardingAlgorithm)1 SingleKeyDatabaseShardingAlgorithm (com.dangdang.ddframe.rdb.sharding.api.strategy.database.SingleKeyDatabaseShardingAlgorithm)1 MultipleKeysTableShardingAlgorithm (com.dangdang.ddframe.rdb.sharding.api.strategy.table.MultipleKeysTableShardingAlgorithm)1