ShardingRule implements DataNodeRoutedRule { public DataNode getDataNode(final String logicTableName) { TableRule tableRule = getTableRule(logicTableName); return tableRule.getActualDataNodes().get(0); } ShardingRule(final ShardingRuleConfiguration config, final Collection<String> dataSourceNames);  ShardingRule(final AlgorithmProvidedShardingRuleConfiguration config, final Collection<String> dataSourceNames); Optional<TableRule> findTableRule(final String logicTableName); Optional<TableRule> findTableRuleByActualTable(final String actualTableName); TableRule getTableRule(final String logicTableName); ShardingStrategy getDatabaseShardingStrategy(final TableRule tableRule); ShardingStrategy getTableShardingStrategy(final TableRule tableRule); boolean isAllBindingTables(final Collection<String> logicTableNames); Optional<BindingTableRule> findBindingTableRule(final String logicTableName); boolean isAllBroadcastTables(final Collection<String> logicTableNames); boolean isBroadcastTable(final String logicTableName); boolean tableRuleExists(final Collection<String> logicTableNames); boolean isShardingColumn(final String columnName, final String tableName); boolean isGenerateKeyColumn(final String columnName, final String tableName); Optional<String> findGenerateKeyColumnName(final String logicTableName); Comparable<?> generateKey(final String logicTableName); DataNode getDataNode(final String logicTableName); DataNode getDataNode(final String dataSourceName, final String logicTableName); Collection<String> getShardingLogicTableNames(final Collection<String> logicTableNames); Map<String, String> getLogicAndActualTablesFromBindingTable(final String dataSourceName,
                                                                       final String logicTable, final String actualTable, final Collection<String> availableLogicBindingTables); @Override Map<String, Collection<DataNode>> getAllDataNodes(); @Override Collection<String> getAllActualTables(); @Override Optional<String> findFirstActualTable(final String logicTable); @Override boolean isNeedAccumulate(final Collection<String> tables); @Override Optional<String> findLogicTableByActualTable(final String actualTable);  }
@Test public void assertGetDataNodeByLogicTable() { assertThat(createMaximumShardingRule().getDataNode("logic_table"), is(new DataNode("ds_0.table_0"))); }
@Test public void assertGetDataNodeByDataSourceAndLogicTable() { assertThat(createMaximumShardingRule().getDataNode("ds_1", "logic_table"), is(new DataNode("ds_1.table_0"))); }
@Test(expected = ShardingSphereConfigurationException.class) public void assertGetDataNodeByLogicTableFailureWithDataSourceName() { createMaximumShardingRule().getDataNode("ds_3", "logic_table"); }