use of com.netflix.config.DynamicProperty in project incubator-servicecomb-java-chassis by apache.
the class QpsControllerManager method initGlobalQpsController.
private void initGlobalQpsController() {
DynamicProperty globalLimitProperty = DynamicProperty.getInstance(globalLimitKey);
DynamicProperty globalBucketProperty = DynamicProperty.getInstance(globalBucketKey);
DynamicProperty globalStrategyProperty = DynamicProperty.getInstance(Config.STRATEGY_KEY);
globalQpsStrategy = chooseStrategy(globalLimitKey, globalLimitProperty.getLong((long) Integer.MAX_VALUE), globalBucketProperty.getLong(), globalStrategyProperty.getString());
globalStrategyProperty.addCallback(() -> {
globalQpsStrategy = chooseStrategy(globalLimitKey, globalLimitProperty.getLong((long) Integer.MAX_VALUE), globalBucketProperty.getLong(), globalStrategyProperty.getString());
LOGGER.info("Global flow control strategy update, value = [{}]", globalStrategyProperty.getString());
});
globalLimitProperty.addCallback(() -> {
globalQpsStrategy.setQpsLimit(globalLimitProperty.getLong((long) Integer.MAX_VALUE));
LOGGER.info("Global qps limit update, value = [{}]", globalLimitProperty.getLong());
});
globalBucketProperty.addCallback(() -> {
globalQpsStrategy.setBucketLimit(globalBucketProperty.getLong());
LOGGER.info("Global bucket limit update, value = [{}]", globalBucketProperty.getLong());
});
}
use of com.netflix.config.DynamicProperty in project incubator-servicecomb-java-chassis by apache.
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 incubator-servicecomb-java-chassis by apache.
the class TestPriorityPropertyManager method testConfigurationsAreGCCollected.
@Test
public void testConfigurationsAreGCCollected() {
long timeBegin = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
TestConfigObjectFactory.ConfigWithAnnotation configConfigObject = priorityPropertyManager.createConfigObject(TestConfigObjectFactory.ConfigWithAnnotation.class);
Assert.assertEquals("abc", configConfigObject.strDef);
PriorityProperty<Long> configPriorityProperty = propertyFactory.getOrCreate(Long.class, -1L, -2L, keys);
Assert.assertEquals(-2L, (long) configPriorityProperty.getValue());
}
}
waitKeyForGC(priorityPropertyManager);
Assert.assertTrue(priorityPropertyManager.getConfigObjectMap().isEmpty());
for (DynamicProperty property : ConfigUtil.getAllDynamicProperties().values()) {
Assert.assertTrue(ConfigUtil.getCallbacks(property).isEmpty());
}
System.out.println("Token : " + (System.currentTimeMillis() - timeBegin));
}
use of com.netflix.config.DynamicProperty in project incubator-servicecomb-java-chassis by apache.
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());
}
use of com.netflix.config.DynamicProperty in project java-chassis by ServiceComb.
the class ConsumerQpsControllerManager method initConfig.
private void initConfig(OperationMeta operationMeta, String key) {
if (watchedKeySet.contains(key)) {
return;
}
watchedKeySet.add(key);
String configKey = Config.CONSUMER_LIMIT_KEY_PREFIX + key;
DynamicProperty property = DynamicProperty.getInstance(configKey);
initQpsLimit(key, getIntegerLimitProperty(property));
property.addCallback(() -> {
updateQpsLimit(key, getIntegerLimitProperty(property));
QpsController qpsController = findReference(operationMeta);
objMap.put(operationMeta.getMicroserviceQualifiedName(), qpsController);
});
initQpsLimit(key, property.getInteger());
}
Aggregations