18835572909 commented on issue #37081:
URL: 
https://github.com/apache/shardingsphere/issues/37081#issuecomment-3530593345

       
org.apache.shardingsphere.shadow.route.engine.ShadowRouteEngine#decorateRouteContext
        
        default void decorateRouteContext(final RouteContext routeContext, 
final ShadowRule shadowRule, final Map<String, String> 
shadowDataSourceMappings) {
           Collection<RouteUnit> toBeRemovedRouteUnit = new LinkedList<>();
           Collection<RouteUnit> toBeAddedRouteUnit = new LinkedList<>();
           for (RouteUnit each : routeContext.getRouteUnits()) {
               String logicName = each.getDataSourceMapper().getLogicName();
               String actualName = each.getDataSourceMapper().getActualName();
               Optional<String> sourceDataSourceName = 
shadowRule.getSourceDataSourceName(actualName);
               if (sourceDataSourceName.isPresent()) {
                   String shadowDataSourceName = 
shadowDataSourceMappings.get(sourceDataSourceName.get());
                   toBeRemovedRouteUnit.add(each);
                   toBeAddedRouteUnit.add(null == shadowDataSourceName
                           ? new RouteUnit(new RouteMapper(logicName, 
sourceDataSourceName.get()), each.getTableMappers())
                           : new RouteUnit(new RouteMapper(logicName, 
shadowDataSourceName), each.getTableMappers()));
               }
           }
           routeContext.getRouteUnits().removeAll(toBeRemovedRouteUnit);
           routeContext.getRouteUnits().addAll(toBeAddedRouteUnit);
       }
        
        This is the source code:
        
        shadowRule.getSourceDataSourceName(actualName);// 
        
        I don't quite understand this part of him. Is the variable 
'practiceName' the result of shardingRule? 


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to