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); }); }
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; }
private static void addCallback(Runnable callback, PropertyWrapper<?> wrapper) { if (callback != null) { wrapper.prop.addCallback(callback); } }
private static void addCallback(Runnable callback, PropertyWrapper<?> wrapper) { if (callback != null) { wrapper.prop.addCallback(callback); } }
/** * Add the callback to be triggered when the value of the property is changed * * @param callback */ @Override public void addCallback(Runnable callback) { if (callback != null) { prop.addCallback(callback); callbackList.add(callback); } }
/** * Add the callback to be triggered when the value of the property is changed * * @param callback */ @Override public void addCallback(Runnable callback) { if (callback != null) { prop.addCallback(callback); callbackList.add(callback); } }
public static void addCallback(String property, Runnable callback) { final DynamicProperty dynamicProperty = DynamicProperty.getInstance(property); dynamicProperty.addCallback(callback); } }
public DynamicPropertyBasedPoolStrategy(final int maxConnections, String propertyName) { super(maxConnections); poolSizeProperty = DynamicProperty.getInstance(propertyName); setMaxConnections(poolSizeProperty.getInteger(maxConnections)); poolSizeProperty.addCallback(new Runnable() { @Override public void run() { setMaxConnections(poolSizeProperty.getInteger(maxConnections)); }; }); }
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); }); }
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); }); }
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); }); }
this.prop.addCallback(callback); callbackList.add(callback); this.prop.addValidator(new PropertyChangeValidator() {
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; }
this.prop.addCallback(callback); callbackList.add(callback); this.prop.addValidator(new PropertyChangeValidator() {
@Override public QpsController getOrCreate(String keyOwner) { if (keyOwner == null) { if (globalQpsController == null) { synchronized (lockObj) { if (globalQpsController == null) { DynamicProperty property = DynamicProperty.getInstance(Config.PROVIDER_LIMIT_KEY_GLOBAL); globalQpsController = new QpsController(keyOwner, getIntegerLimitProperty(property)); property.addCallback(() -> { globalQpsController.setQpsLimit(getIntegerLimitProperty(property)); }); } } } return globalQpsController; } else { return super.getOrCreate(keyOwner); } }