use of com.netflix.config.DynamicProperty in project java-chassis by ServiceComb.
the class ProviderQpsControllerManager method initConfig.
private void initConfig(String key) {
if (watchedKeySet.contains(key)) {
return;
}
watchedKeySet.add(key);
String configKey = Config.PROVIDER_LIMIT_KEY_PREFIX + key;
DynamicProperty property = DynamicProperty.getInstance(configKey);
initQpsLimit(key, getIntegerLimitProperty(property));
property.addCallback(() -> {
updateQpsLimit(key, getIntegerLimitProperty(property));
QpsController qpsController = findReference(key);
objMap.put(key, qpsController);
});
}
use of com.netflix.config.DynamicProperty in project java-chassis by ServiceComb.
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 java-chassis by ServiceComb.
the class InspectorImpl method dynamicProperties.
@Path("/dynamicProperties")
@GET
public List<DynamicPropertyView> dynamicProperties() {
List<DynamicPropertyView> views = new ArrayList<>();
for (DynamicProperty property : ConfigUtil.getAllDynamicProperties().values()) {
views.add(createDynamicPropertyView(property));
}
// show more callback first, because maybe there is memory leak problem
// show recently changed second
// and sort by key
views.sort(Comparator.comparing(DynamicPropertyView::getCallbackCount).thenComparing(DynamicPropertyView::getChangedTime).reversed().thenComparing(DynamicPropertyView::getKey));
return views;
}
use of com.netflix.config.DynamicProperty in project java-chassis by ServiceComb.
the class InspectorImpl method createPriorityPropertyView.
private PriorityPropertyView createPriorityPropertyView(PriorityProperty<?> priorityProperty) {
PriorityPropertyView view = new PriorityPropertyView();
view.setDynamicProperties(new ArrayList<>());
for (DynamicProperty property : priorityProperty.getProperties()) {
view.getDynamicProperties().add(createDynamicPropertyView(property));
}
view.setDefaultValue(String.valueOf(priorityProperty.getDefaultValue()));
view.setValue(String.valueOf(priorityProperty.getValue()));
return view;
}
use of com.netflix.config.DynamicProperty in project java-chassis by ServiceComb.
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());
});
}
Aggregations