You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/12/24 10:09:51 UTC
[GitHub] [incubator-shardingsphere] tmjGitAccount edited a comment on issue
#3774: How Can I config To Use DatabaseHintRoutingEngine
tmjGitAccount edited a comment on issue #3774: How Can I config To Use DatabaseHintRoutingEngine
URL: https://github.com/apache/incubator-shardingsphere/issues/3774#issuecomment-568713163
> @tmjGitAccount What's more, `DatabaseHintRoutingEngine` isn't used in any routing case and modules. Therefore, the `DatabaseHintRoutingEngine` is necessary to remove. Where load your algorithm is that `StandardRoutingEngine` calls method `route()` to load user-defined algorithm.
@SteNicholas
Thx for your reply, but there is still something wrong for me,
As you can see My perpose is to get sth from session to hint the datasource.
1. if my conf is like what i offered before, it will new a DefaultDatabaseRoutingEngine as follows, it always hint my defaultDatabase.
RoutingEngineFactory:83
```
if (shardingRule.isAllInDefaultDataSource(tableNames)) {
return new DefaultDatabaseRoutingEngine(shardingRule, tableNames);
}
```
2.then i add some confs for tables,confs are as follows:
```
tables:
my_table:
database-strategy:
hint:
algorithm-class-name: a.b.c.OrderShardingAlgorithm
table-strategy:
hint:
algorithm-class-name: a.b.c.OrderShardingAlgorithm
```
then the factory can create a StandardRoutingEngine instance,
and the codes execute as
**route() ->
getDataNodes() ->
routeByHint() ->
route0() ->
getDatabaseShardingValuesFromHint() ->
routeDataSources() ->
myalgorithm.dosharding()**
i don't know if it's the correct way , but currently the method **getDatabaseShardingValuesFromHint()** always retruns an empty list and then the method **routeDataSources()** won't execute my algorithm, it returns directly.
```
public static Collection<Comparable<?>> getDatabaseShardingValues(final String logicTable) {
return null == HINT_MANAGER_HOLDER.get() ? Collections.<Comparable<?>>emptyList() : HINT_MANAGER_HOLDER.get().databaseShardingValues.get(logicTable);
}
```
this code compares my databases with table's name , so it always retruns empty.
```
HINT_MANAGER_HOLDER.get().databaseShardingValues.get(logicTable)
```
so i don't know if i lost some conf or others , could u please help me for this. 😃
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services