Java Code Examples for org.apache.commons.configuration.event.ConfigurationEvent#isBeforeUpdate()
The following examples show how to use
org.apache.commons.configuration.event.ConfigurationEvent#isBeforeUpdate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PriorityPropertyManager.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
public synchronized void configurationListener(ConfigurationEvent event) { if (event.isBeforeUpdate()) { return; } if (keyCache == null) { keyCache = new ConcurrentHashMapEx<>(); updateCache(new Object(), priorityPropertySet); configObjectMap.forEach((k, v) -> updateCache(k, v)); } if (event.getPropertyName() != null) { keyCache.forEach((k, v) -> v.getOrDefault(event.getPropertyName(), Collections.emptyList()).stream() .forEach(p -> p.updateFinalValue(false, k))); return; } // event like add configuration source, need to make a global refresh keyCache.forEach( (k, v) -> v.values().stream().flatMap(Collection::stream).forEach( p -> p.updateFinalValue(false, k))); }
Example 2
Source File: DynamicRequestLimiter.java From distributedlog with Apache License 2.0 | 6 votes |
public DynamicRequestLimiter(DynamicDistributedLogConfiguration dynConf, StatsLogger statsLogger, Feature rateLimitDisabledFeature) { final StatsLogger limiterStatsLogger = statsLogger.scope("dynamic"); this.dynConf = dynConf; this.rateLimitDisabledFeature = rateLimitDisabledFeature; this.listener = new ConfigurationListener() { @Override public void configurationChanged(ConfigurationEvent event) { // Note that this method may be called several times if several config options // are changed. The effect is harmless except that we create and discard more // objects than we need to. LOG.debug("Config changed callback invoked with event {} {} {} {}", new Object[] { event.getPropertyName(), event.getPropertyValue(), event.getType(), event.isBeforeUpdate()}); if (!event.isBeforeUpdate()) { limiterStatsLogger.getCounter("config_changed").inc(); LOG.debug("Rebuilding limiter"); limiter = build(); } } }; LOG.debug("Registering config changed callback"); dynConf.addConfigurationListener(listener); }
Example 3
Source File: DynamicRequestLimiter.java From distributedlog with Apache License 2.0 | 6 votes |
public DynamicRequestLimiter(DynamicDistributedLogConfiguration dynConf, StatsLogger statsLogger, Feature rateLimitDisabledFeature) { final StatsLogger limiterStatsLogger = statsLogger.scope("dynamic"); this.dynConf = dynConf; this.rateLimitDisabledFeature = rateLimitDisabledFeature; this.listener = new ConfigurationListener() { @Override public void configurationChanged(ConfigurationEvent event) { // Note that this method may be called several times if several config options // are changed. The effect is harmless except that we create and discard more // objects than we need to. LOG.debug("Config changed callback invoked with event {} {} {} {}", new Object[] { event.getPropertyName(), event.getPropertyValue(), event.getType(), event.isBeforeUpdate()}); if (!event.isBeforeUpdate()) { limiterStatsLogger.getCounter("config_changed").inc(); LOG.debug("Rebuilding limiter"); limiter = build(); } } }; LOG.debug("Registering config changed callback"); dynConf.addConfigurationListener(listener); }
Example 4
Source File: ConfTest.java From otroslogviewer with Apache License 2.0 | 5 votes |
public void configurationChanged(ConfigurationEvent event) { if (!event.isBeforeUpdate()) { // only display events after the modification was done System.out.println(name + " Received event!"); System.out.println(name + " Type = " + event.getType()); if (event.getPropertyName() != null) { System.out.println(name + " Property name = " + event.getPropertyName()); } if (event.getPropertyValue() != null) { System.out.println(name + " Property value = " + event.getPropertyValue()); } } }
Example 5
Source File: TajoSystemMetrics.java From tajo with Apache License 2.0 | 5 votes |
@Override public synchronized void configurationChanged(ConfigurationEvent event) { if (!event.isBeforeUpdate()) { stopAndClearReporter(); start(); } }
Example 6
Source File: TajoSystemMetrics.java From incubator-tajo with Apache License 2.0 | 5 votes |
@Override public synchronized void configurationChanged(ConfigurationEvent event) { if (!event.isBeforeUpdate()) { stopAndClearReporter(); start(); } }