Search in sources :

Example 16 with StandardShardingStrategyConfiguration

use of io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration in project sharding-jdbc by shardingjdbc.

the class ShardingRuleTest method createTableRuleConfigWithAllStrategies.

private TableRuleConfiguration createTableRuleConfigWithAllStrategies() {
    TableRuleConfiguration result = new TableRuleConfiguration();
    result.setLogicTable("LOGIC_TABLE");
    result.setActualDataNodes("ds${0..1}.table_${0..2}");
    result.setDatabaseShardingStrategyConfig(new StandardShardingStrategyConfiguration("column", new TestPreciseShardingAlgorithm()));
    result.setTableShardingStrategyConfig(new NoneShardingStrategyConfiguration());
    return result;
}
Also used : StandardShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration) TestPreciseShardingAlgorithm(io.shardingjdbc.core.api.algorithm.fixture.TestPreciseShardingAlgorithm) NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) TableRuleConfiguration(io.shardingjdbc.core.api.config.TableRuleConfiguration)

Example 17 with StandardShardingStrategyConfiguration

use of io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration in project sharding-jdbc by shardingjdbc.

the class ShardingNamespaceTest method assertRangeStandardStrategy.

@Test
public void assertRangeStandardStrategy() {
    StandardShardingStrategyConfiguration rangeStandardStrategy = this.applicationContext.getBean("rangeStandardStrategy", StandardShardingStrategyConfiguration.class);
    assertThat(rangeStandardStrategy.getShardingColumn(), is("order_id"));
    assertThat(rangeStandardStrategy.getPreciseShardingAlgorithm(), instanceOf(PreciseModuloTableShardingAlgorithm.class));
    assertThat(rangeStandardStrategy.getRangeShardingAlgorithm(), instanceOf(RangeModuloTableShardingAlgorithm.class));
}
Also used : RangeModuloTableShardingAlgorithm(io.shardingjdbc.spring.algorithm.RangeModuloTableShardingAlgorithm) StandardShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration) PreciseModuloTableShardingAlgorithm(io.shardingjdbc.spring.algorithm.PreciseModuloTableShardingAlgorithm) Test(org.junit.Test)

Aggregations

StandardShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration)17 Test (org.junit.Test)9 ShardingRuleConfiguration (io.shardingjdbc.core.api.config.ShardingRuleConfiguration)7 TableRuleConfiguration (io.shardingjdbc.core.api.config.TableRuleConfiguration)6 TestPreciseShardingAlgorithm (io.shardingjdbc.core.api.algorithm.fixture.TestPreciseShardingAlgorithm)5 NoneShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration)4 DatabaseType (io.shardingjdbc.core.constant.DatabaseType)4 ShardingDataSource (io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource)4 ShardingRule (io.shardingjdbc.core.rule.ShardingRule)4 LinkedList (java.util.LinkedList)4 Map (java.util.Map)4 SQLShardingRule (io.shardingjdbc.core.integrate.jaxb.SQLShardingRule)3 ComplexShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.ComplexShardingStrategyConfiguration)2 HintShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.HintShardingStrategyConfiguration)2 InlineShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.InlineShardingStrategyConfiguration)2 PreciseModuloDatabaseShardingAlgorithm (io.shardingjdbc.core.integrate.fixture.PreciseModuloDatabaseShardingAlgorithm)2 PreciseModuloTableShardingAlgorithm (io.shardingjdbc.core.integrate.fixture.PreciseModuloTableShardingAlgorithm)2 RangeModuloDatabaseShardingAlgorithm (io.shardingjdbc.core.integrate.fixture.RangeModuloDatabaseShardingAlgorithm)2 RangeModuloTableShardingAlgorithm (io.shardingjdbc.core.integrate.fixture.RangeModuloTableShardingAlgorithm)2 Column (io.shardingjdbc.core.parsing.parser.context.condition.Column)2