public final class ShardingRule extends Object
Constructor and Description |
---|
ShardingRule(ShardingRuleConfiguration shardingRuleConfig,
Collection<String> dataSourceNames) |
Modifier and Type | Method and Description |
---|---|
com.google.common.base.Optional<BindingTableRule> |
findBindingTableRule(String logicTable)
Get binding table rule via logic table name.
|
DataNode |
findDataNode(String logicTableName)
Find data node by logic table.
|
DataNode |
findDataNode(String dataSourceName,
String logicTableName)
Find data node by data source and logic table.
|
Number |
generateKey(String logicTableName)
Generate key.
|
ShardingStrategy |
getDatabaseShardingStrategy(TableRule tableRule)
Get database sharding strategy.
|
com.google.common.base.Optional<Column> |
getGenerateKeyColumn(String logicTableName)
get generated key's column.
|
String |
getLogicTableName(String logicIndexName)
Get logic table name base on logic index name.
|
TableRule |
getTableRule(String logicTableName)
Find table rule though logic table name.
|
ShardingStrategy |
getTableShardingStrategy(TableRule tableRule)
Get table sharding strategy.
|
boolean |
isAllBindingTables(Collection<String> logicTables)
Adjust logic tables is all belong to binding tables.
|
boolean |
isAllInDefaultDataSource(Collection<String> logicTables)
Adjust logic tables is all belong to default data source.
|
boolean |
isLogicIndex(String logicIndexName,
String logicTableName)
Adjust is logic index or not.
|
boolean |
isShardingColumn(Column column)
Adjust is sharding column or not.
|
com.google.common.base.Optional<TableRule> |
tryFindTableRuleByActualTable(String actualTableName)
Try to find table rule though actual table name.
|
com.google.common.base.Optional<TableRule> |
tryFindTableRuleByLogicTable(String logicTableName)
Try to find table rule though logic table name.
|
public ShardingRule(ShardingRuleConfiguration shardingRuleConfig, Collection<String> dataSourceNames)
public com.google.common.base.Optional<TableRule> tryFindTableRuleByLogicTable(String logicTableName)
logicTableName
- logic table namepublic com.google.common.base.Optional<TableRule> tryFindTableRuleByActualTable(String actualTableName)
actualTableName
- actual table namepublic TableRule getTableRule(String logicTableName)
logicTableName
- logic table namepublic ShardingStrategy getDatabaseShardingStrategy(TableRule tableRule)
Use default database sharding strategy if not found.
tableRule
- table rulepublic ShardingStrategy getTableShardingStrategy(TableRule tableRule)
Use default table sharding strategy if not found.
tableRule
- table rulepublic boolean isAllBindingTables(Collection<String> logicTables)
logicTables
- names of logic tablespublic boolean isAllInDefaultDataSource(Collection<String> logicTables)
logicTables
- names of logic tablespublic com.google.common.base.Optional<BindingTableRule> findBindingTableRule(String logicTable)
logicTable
- logic table namepublic boolean isShardingColumn(Column column)
column
- column objectpublic com.google.common.base.Optional<Column> getGenerateKeyColumn(String logicTableName)
logicTableName
- logic table namepublic Number generateKey(String logicTableName)
logicTableName
- logic table namepublic String getLogicTableName(String logicIndexName)
logicIndexName
- logic index namepublic DataNode findDataNode(String logicTableName)
logicTableName
- logic table namepublic DataNode findDataNode(String dataSourceName, String logicTableName)
dataSourceName
- data source namelogicTableName
- logic table nameCopyright © 2018. All rights reserved.