use of org.apache.servicecomb.qps.strategy.AbstractQpsStrategy in project java-chassis by ServiceComb.
the class QpsControllerManager method searchQpsController.
/**
* <p> Use qualifiedNameKey to search {@link QpsStrategy}.
* Firstly try to search "microservice.schema.operation". If no valid result found, then try "microservice.schema",
* and then "microservice" or global qpsController(If there is a global qpsController).</p>
* <p> This method ensures that there is always an existing qpsController returned, as the relevant qpsController has
* been created and stored in {@link #create(String, String, Invocation)}</p>
*
* @param qualifiedNameKey qualifiedNameKey in {@link #qualifiedNameControllerMap}
* @return a qps controller, lower level controllers with valid qpsLimit have priority.
*/
private AbstractQpsStrategy searchQpsController(String qualifiedNameKey) {
AbstractQpsStrategy qpsStrategy = configQpsControllerMap.get(qualifiedNameKey);
if (isValidQpsController(qpsStrategy)) {
return qpsStrategy;
}
int index = qualifiedNameKey.lastIndexOf(SEPARATOR);
while (index > 0) {
qpsStrategy = configQpsControllerMap.get(qualifiedNameKey.substring(0, index));
if (isValidQpsController(qpsStrategy)) {
return qpsStrategy;
}
index = qualifiedNameKey.lastIndexOf(SEPARATOR, index - 1);
}
if (isValidQpsController(qpsStrategy)) {
return qpsStrategy;
}
return null;
}
use of org.apache.servicecomb.qps.strategy.AbstractQpsStrategy in project java-chassis by ServiceComb.
the class QpsControllerManager method updateObjMap.
protected void updateObjMap(String configKey) {
Iterator<Entry<String, AbstractQpsStrategy>> it = qualifiedNameControllerMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, AbstractQpsStrategy> entry = it.next();
if (keyMatch(configKey, entry)) {
AbstractQpsStrategy qpsStrategy = searchQpsController(entry.getKey());
if (qpsStrategy != null) {
entry.setValue(qpsStrategy);
LOGGER.info("QpsController updated, operationId = [{}], configKey = [{}], qpsLimit = [{}]", entry.getKey(), qpsStrategy.getKey(), qpsStrategy.getQpsLimit());
} else {
it.remove();
}
}
}
}
Aggregations