wgy8283335 opened a new issue #3227: Parameter "masterDataSourceName" in 
"MasterSlaveLoadBalanceAlgorithm.getDataSource()" is not used in implementation 
class.
URL: https://github.com/apache/incubator-shardingsphere/issues/3227
 
 
   ## Parameter "masterDataSourceName" in 
"MasterSlaveLoadBalanceAlgorithm.getDataSource()" is not used in implementation 
class.
   
   ```
   @Getter
   @Setter
   public final class RoundRobinMasterSlaveLoadBalanceAlgorithm implements 
MasterSlaveLoadBalanceAlgorithm {
       
       private static final ConcurrentHashMap<String, AtomicInteger> COUNTS = 
new ConcurrentHashMap<>();
       
       private Properties properties = new Properties();
       
       @Override
       public String getType() {
           return "ROUND_ROBIN";
       }
       
       @Override
       public String getDataSource(final String name, final String 
masterDataSourceName, final List<String> slaveDataSourceNames) {
           AtomicInteger count = COUNTS.containsKey(name) ? COUNTS.get(name) : 
new AtomicInteger(0);
           COUNTS.putIfAbsent(name, count);
           count.compareAndSet(slaveDataSourceNames.size(), 0);
           return slaveDataSourceNames.get(Math.abs(count.getAndIncrement()) % 
slaveDataSourceNames.size());
       }
   }
   ```
   
   ```
   @Getter
   @Setter
   public final class RandomMasterSlaveLoadBalanceAlgorithm implements 
MasterSlaveLoadBalanceAlgorithm {
       
       private Properties properties = new Properties();
       
       @Override
       public String getType() {
           return "RANDOM";
       }
       
       @Override
       public String getDataSource(final String name, final String 
masterDataSourceName, final List<String> slaveDataSourceNames) {
           return 
slaveDataSourceNames.get(ThreadLocalRandom.current().nextInt(slaveDataSourceNames.size()));
       }
   }
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to