use of org.apache.servicecomb.qps.strategy.IStrategyFactory in project java-chassis by ServiceComb.
the class QpsControllerManager method chooseStrategy.
private AbstractQpsStrategy chooseStrategy(String configKey, Long limit, Long bucket, String strategyName) {
if (StringUtils.isEmpty(strategyName)) {
strategyName = "FixedWindow";
}
AbstractQpsStrategy strategy = null;
List<IStrategyFactory> strategyFactories = SPIServiceUtils.getOrLoadSortedService(IStrategyFactory.class);
for (IStrategyFactory strategyFactory : strategyFactories) {
strategy = strategyFactory.createStrategy(strategyName);
if (strategy != null) {
break;
}
}
if (strategy == null) {
throw new ServiceCombException("the qps strategy name " + strategyName + " is not exist , please check.");
}
strategy.setKey(configKey);
strategy.setQpsLimit(limit);
strategy.setBucketLimit(bucket);
return strategy;
}
Aggregations