public SessionFactoryBuilder addTableRule(ShardedTableRule table) { validateTableRule(table); configuration.tableRules.add(table); return this; }
public SessionFactoryBuilder addTableRule(TableRule table) { validateTableRule(table); configuration.tableRules.add(table); return this; }
public SessionFactoryBuilder addTableRule(GlobalTableRule table) { validateTableRule(table); configuration.tableRules.add(table); return this; }
public SessionFactoryBuilder addTableRuleGrop(TableRuleGroup group) { validateTableRule(group); List<ShardedTableRule> tableRules = group.getTableRules(); configuration.tableRules.addAll(tableRules); return this; }
private void beforeBuild() { vaildateCluster(configuration.cluster); for (TableRule table : configuration.tableRules) { validateTableRule(table); if (table instanceof ShardedTableRule) { ShardedTableRule shardedTable = (ShardedTableRule) table; Object po = shardedTable.getPartitioner(); try { if(po instanceof Partitioner) { Partitioner partitioner = (Partitioner)po; partitioner.initialize(shardedTable.getObjectNodes()); } else if(po instanceof MultColumnPartitioner) { MultColumnPartitioner partitioner = (MultColumnPartitioner)po; partitioner.initialize(shardedTable.getObjectNodes()); } } catch (Exception e) { String name = table.getName(); throw new IllegalStateException("initialize partitioner for table " + name + " error.", e); } } } if (configuration.provider == null) { throw new IllegalArgumentException("DataSourceProvider is required."); } }