use of com.netflix.config.DynamicProperty in project incubator-servicecomb-java-chassis by apache.
the class QpsControllerManager method setGlobalQpsController.
public QpsControllerManager setGlobalQpsController(String globalConfigKey) {
DynamicProperty globalQpsProperty = DynamicProperty.getInstance(globalConfigKey);
QpsController qpsController = new QpsController(globalConfigKey, globalQpsProperty.getInteger());
globalQpsProperty.addCallback(() -> {
qpsController.setQpsLimit(globalQpsProperty.getInteger());
LOGGER.info("Global qps limit update, value = [{}]", globalQpsProperty.getInteger());
});
this.globalQpsController = qpsController;
return this;
}
use of com.netflix.config.DynamicProperty in project incubator-servicecomb-java-chassis by apache.
the class QpsControllerManager method createQpsControllerIfNotExist.
private void createQpsControllerIfNotExist(String configKey) {
if (configQpsControllerMap.keySet().contains(configKey)) {
return;
}
LOGGER.info("Create qpsController, configKey = [{}]", configKey);
DynamicProperty property = getDynamicProperty(configKey);
QpsController qpsController = new QpsController(configKey, property.getInteger());
configQpsControllerMap.put(configKey, qpsController);
property.addCallback(() -> {
qpsController.setQpsLimit(property.getInteger());
LOGGER.info("Qps limit updated, configKey = [{}], value = [{}]", configKey, property.getString());
updateObjMap(configKey);
});
}
use of com.netflix.config.DynamicProperty in project java-chassis by ServiceComb.
the class PriorityProperty method doUpdateFinalValue.
/**
* @return if value changed, return effectiveKey, otherwise null
*/
private String doUpdateFinalValue() {
T lastValue = finalValue;
String effectiveKey = "default value";
T value = propertyType.getDefaultValue();
for (DynamicProperty property : properties) {
T propValue = internalValueReader.apply(property);
if (propValue == null || propValue.equals(propertyType.getInvalidValue())) {
continue;
}
effectiveKey = property.getName();
value = propValue;
break;
}
if (Objects.equals(lastValue, value)) {
return null;
}
finalValue = value;
return effectiveKey;
}
use of com.netflix.config.DynamicProperty in project java-chassis by ServiceComb.
the class QpsControllerManager method createQpsControllerIfNotExist.
private void createQpsControllerIfNotExist(String configKey) {
if (configQpsControllerMap.containsKey(configKey)) {
return;
}
LOGGER.info("Create qpsController, configKey = [{}]", configKey);
DynamicProperty limitProperty = DynamicProperty.getInstance(limitKeyPrefix + configKey);
DynamicProperty bucketProperty = DynamicProperty.getInstance(bucketKeyPrefix + configKey);
DynamicProperty strategyProperty = DynamicProperty.getInstance(Config.STRATEGY_KEY);
AbstractQpsStrategy qpsStrategy = chooseStrategy(configKey, limitProperty.getLong(), bucketProperty.getLong(), strategyProperty.getString());
strategyProperty.addCallback(() -> {
AbstractQpsStrategy innerQpsStrategy = chooseStrategy(configKey, limitProperty.getLong(), bucketProperty.getLong(), strategyProperty.getString());
configQpsControllerMap.put(configKey, innerQpsStrategy);
LOGGER.info("Global flow control strategy update, value = [{}]", strategyProperty.getString());
updateObjMap(configKey);
});
limitProperty.addCallback(() -> {
qpsStrategy.setQpsLimit(limitProperty.getLong());
LOGGER.info("Qps limit updated, configKey = [{}], value = [{}]", configKey, limitProperty.getString());
updateObjMap(configKey);
});
bucketProperty.addCallback(() -> {
qpsStrategy.setBucketLimit(bucketProperty.getLong());
LOGGER.info("bucket limit updated, configKey = [{}], value = [{}]", configKey, bucketProperty.getString());
updateObjMap(configKey);
});
configQpsControllerMap.put(configKey, qpsStrategy);
}
use of com.netflix.config.DynamicProperty in project java-chassis by ServiceComb.
the class JaxrsSpringIntegrationTest method testGetConfigFromSpringBoot.
@Test
public void testGetConfigFromSpringBoot() {
DynamicProperty dynamicProperty = DynamicProperty.getInstance("property.test0");
assertEquals("from_properties", dynamicProperty.getString());
dynamicProperty = DynamicProperty.getInstance("property.test1");
assertEquals("from_yml", dynamicProperty.getString());
dynamicProperty = DynamicProperty.getInstance("property.test2");
assertEquals("from_yaml_from_yml", dynamicProperty.getString());
dynamicProperty = DynamicProperty.getInstance("property.test3");
assertEquals("from_yaml_dev_from_properties", dynamicProperty.getString());
dynamicProperty = DynamicProperty.getInstance("property.test4");
assertEquals("from_microservice_yaml", dynamicProperty.getString());
dynamicProperty = DynamicProperty.getInstance("property.test5");
assertEquals("from_system_property", dynamicProperty.getString());
}
Aggregations