public SessionFactoryBuilder dbCluster(List<Shard> cluster) { vaildateCluster(cluster); configuration.cluster = cluster; 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."); } }