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); }
@Override public void onApplicationEvent(EnvironmentChangeEvent event) { AbstractConfiguration manager = ConfigurationManager.getConfigInstance(); for (String key : event.getKeys()) { for (ConfigurationListener listener : manager .getConfigurationListeners()) { Object source = event.getSource(); // TODO: Handle add vs set vs delete? int type = AbstractConfiguration.EVENT_SET_PROPERTY; String value = this.env.getProperty(key); boolean beforeUpdate = false; listener.configurationChanged(new ConfigurationEvent(source, type, key, value, beforeUpdate)); } } }
@Test public void environmentChangeEventPropagated() { this.context = new AnnotationConfigApplicationContext( ArchaiusAutoConfiguration.class); ConfigurationManager.getConfigInstance().addConfigurationListener( new ConfigurationListener() { @Override public void configurationChanged(ConfigurationEvent event) { if (event.getPropertyName().equals("my.prop")) { ArchaiusAutoConfigurationTests.this.propertyValue = event .getPropertyValue(); } } }); EnvironmentTestUtils.addEnvironment(this.context, "my.prop=my.newval"); this.context.publishEvent(new EnvironmentChangeEvent(Collections .singleton("my.prop"))); assertEquals("my.newval", this.propertyValue); }
private void invokeListeners() { if (m_configurationListeners != null) { try { ConfigurationEvent event = new ConfigurationEvent(this,AbstractConfiguration.EVENT_SET_PROPERTY,null,this, false); for (ConfigurationListener listener:m_configurationListeners) { listener.configurationChanged(event); } } catch (Exception e) { throw new RuntimeException(e); } } }
@Override public void configurationChanged(ConfigurationEvent e) { if (e.getPropertyName() != null && e.getPropertyName().equalsIgnoreCase("gui.markColor")) { final Object propertyValue = e.getPropertyValue(); if (propertyValue instanceof MarkerColors) { markerColors = (MarkerColors) propertyValue; } else if (propertyValue instanceof String) { String value = (String) propertyValue; markerColors = MarkerColors.fromString(value); } } }
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()); } } }
@Override public void configurationChanged(ConfigurationEvent event) { if (!event.isBeforeUpdate()) { // only display events after the modification was done projectState.markModified(); // get the root node from LogicalViewProvider and update the project display name BMProjectLogicalView lvp = BMProject.this.getLookup().lookup(BMProjectLogicalView.class); BMProjectLogicalView.BMProjectNode rootNode = lvp.getRootNode(); rootNode.setDisplayName(rootNode.getDisplayName()); // NotifyDescriptor.Message msg = new NotifyDescriptor.Message("in ConfigChangeListener.configurationChanged()"); // DialogDisplayer.getDefault().notify(msg); } }
@Override public synchronized void configurationChanged(ConfigurationEvent event) { if (!event.isBeforeUpdate()) { stopAndClearReporter(); start(); } }
private void addConfigurationListener() { final MetricsCloudWatchConfiguration springConfig = this; ConfigurationManager.getConfigInstance().addConfigurationListener(new ConfigurationListener() { @Override public synchronized void configurationChanged(ConfigurationEvent event) { if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY || event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY)) { return; } if (event.isBeforeUpdate()) { return; } String name = event.getPropertyName(); if (!(name.equals(METRICS_AWS_ENABLED) || name.equals(METRICS_AWS_FILTER) || name.equals(METRICS_AWS_PUBLISH_INTERVAL) || name.equals(METRICS_AWS_PUBLISH_INTERVAL_UNIT))) { return; } springConfig.enabled = name.equals(METRICS_AWS_ENABLED) ? Boolean.parseBoolean(event.getPropertyValue() + "") : springConfig.enabled; destroyReporter(); if (springConfig.enabled) { createReporter(); } } }); }
private void addConfigurationListener() { final MetricsGraphiteConfiguration springConfig = this; ConfigurationManager.getConfigInstance().addConfigurationListener(new ConfigurationListener() { @Override public synchronized void configurationChanged(ConfigurationEvent event) { if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY || event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY)) { return; } if (event.isBeforeUpdate()) { return; } String name = event.getPropertyName(); if (!(name.equals(METRICS_GRAPHITE_ENABLED) || name.equals(METRICS_GRAPHITE_SERVER) || name.equals(METRICS_GRAPHITE_PORT) || name.equals(METRICS_GRAPHITE_FILTER) || name.equals(METRICS_GRAPHITE_PUBLISH_INTERVAL) || name.equals(METRICS_GRAPHITE_PUBLISH_INTERVAL_UNIT))) { return; } springConfig.enabled = name.equals(METRICS_GRAPHITE_ENABLED) ? Boolean.parseBoolean(event.getPropertyValue() + "") : springConfig.enabled; destroyReporterLoader(); if (springConfig.enabled) { createReporterLoader(); } } }); }
/** * {@inheritDoc} */ @Override public void configurationChanged(final ConfigurationEvent pEvent) { if (!pEvent.isBeforeUpdate()) { eventType = pEvent.getType(); path = (String) pEvent.getPropertyValue(); System.out.println(path); } }
@Override public void configurationChanged(ConfigurationEvent event) { if (event.isBeforeUpdate()) { return; } logger.log(OpLevel.DEBUG, "configurationChanged: type={0}, {1}:{2}", event.getType(), event.getPropertyName(), event.getPropertyValue()); switch (event.getType()) { case AbstractConfiguration.EVENT_ADD_PROPERTY: repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_ADD_KEY, event.getPropertyName(), event.getPropertyValue(), null)); break; case AbstractConfiguration.EVENT_SET_PROPERTY: repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_SET_KEY, event.getPropertyName(), event.getPropertyValue(), null)); break; case AbstractConfiguration.EVENT_CLEAR_PROPERTY: repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_CLEAR_KEY, event.getPropertyName(), event.getPropertyValue(), null)); break; case AbstractConfiguration.EVENT_CLEAR: repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_CLEAR, event.getPropertyName(), event.getPropertyValue(), null)); break; case AbstractFileConfiguration.EVENT_RELOAD: repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_RELOAD, event.getPropertyName(), event.getPropertyValue(), null)); break; } }
/** * @see org.apache.commons.configuration.event.ConfigurationListener#configurationChanged(org.apache.commons.configuration.event.ConfigurationEvent) */ @Override public void configurationChanged(ConfigurationEvent event) { // if (!event.isBeforeUpdate()) { // this.config = ((CompositeConfiguration) this.config).interpolatedConfiguration(); // } }
@Override public void configurationChanged(ConfigurationEvent event) { Object prop = conf.getProperty(event.getPropertyName()); //Add to the list of changed settings. if (event.isBeforeUpdate() && conf.containsKey(event.getPropertyName())) { if (event.getPropertyValue() instanceof Integer) { if (prop instanceof String) { if (!(((String) prop).equals(((Integer) event.getPropertyValue()) + ""))) { changedSettings.add(event.getPropertyName()); } } else { if (!(((Integer) prop).equals(((Integer) event.getPropertyValue())))) { changedSettings.add(event.getPropertyName()); } } } else if (event.getPropertyValue() instanceof Double) { if (prop instanceof String) { if (!(((String) prop).equals(((Double) event.getPropertyValue()) + ""))) { changedSettings.add(event.getPropertyName()); } } else { if (!(((Double) prop).equals(((Double) event.getPropertyValue())))) { changedSettings.add(event.getPropertyName()); } } } else if (event.getPropertyValue() instanceof String) { if (!(((String) prop).equals(((String) event.getPropertyValue())))) { changedSettings.add(event.getPropertyName()); } } } }
/** * If anything changed, reload the configuration values. */ public void configurationChanged(ConfigurationEvent event) { if ( (event.getPropertyName()!=null) && (event.getPropertyName().startsWith("beankeeper.n")) ) configurationReload(); }
public void configurationChanged(ConfigurationEvent arg0) { System.out.println("identifier: "+m_identifier); Configuration configuration = (Configuration)arg0.getPropertyValue(); String s = configuration.getString(m_identifier); s.toString(); }
public void configurationChanged(ConfigurationEvent event) { if (!event.isBeforeUpdate() && event.getType() == AbstractFileConfiguration.EVENT_RELOAD) { if (m_applicationContext instanceof AbstractRefreshableApplicationContext) { ((AbstractRefreshableApplicationContext)m_applicationContext).refresh(); } } }
public void configurationChanged(ConfigurationEvent arg0) { SessionListener.reloadMessageResources(basePath); }
@Test(timeout = 60000) public void testExceptionInConfigLoad() throws Exception { PropertiesWriter writer = new PropertiesWriter(); writer.setProperty("prop1", "1"); writer.save(); DeterministicScheduler mockScheduler = new DeterministicScheduler(); FileConfigurationBuilder builder = new PropertiesConfigurationBuilder(writer.getFile().toURI().toURL()); ConcurrentConstConfiguration conf = new ConcurrentConstConfiguration(new DistributedLogConfiguration()); List<FileConfigurationBuilder> fileConfigBuilders = Lists.newArrayList(builder); ConfigurationSubscription confSub = new ConfigurationSubscription(conf, fileConfigBuilders, mockScheduler, 100, TimeUnit.MILLISECONDS); final AtomicInteger count = new AtomicInteger(1); conf.addConfigurationListener(new ConfigurationListener() { @Override public void configurationChanged(ConfigurationEvent event) { LOG.info("config changed {}", event); // Throw after so we actually see the update anyway. if (!event.isBeforeUpdate()) { count.getAndIncrement(); throw new RuntimeException("config listener threw and exception"); } } }); int i = 0; int initial = 0; while (count.get() == initial) { writer.setProperty("prop1", Integer.toString(i++)); writer.save(); mockScheduler.tick(100, TimeUnit.MILLISECONDS); } initial = count.get(); while (count.get() == initial) { writer.setProperty("prop1", Integer.toString(i++)); writer.save(); mockScheduler.tick(100, TimeUnit.MILLISECONDS); } }
@Override public void configurationChanged(ConfigurationEvent event) { needsReload = true; LOG.debug("Configuration reloaded, notification should happen soon."); }
@Override public void configurationChanged(ConfigurationEvent event) { LOG.debug(String.format("configurationChanged(%s)", event.getPropertyValue())); processProperties(ConfigurationConverter.getProperties((Configuration) event.getSource())); }
@Override public final void configurationChanged(ConfigurationEvent arg0) { logger.debug("Received configuration change '{}' for plugin '{}' attribute '{}' => '{}'", arg0.getType(), getPluginName(), arg0.getPropertyName(), arg0.getPropertyValue()); reloadConfiguration(); }
public void configurationChanged(ConfigurationEvent event) { if ( (event.getPropertyName()!=null) && (event.getPropertyName().startsWith("beankeeper.cache.modification_")) ) configurationReload(); }
public void configurationChanged(ConfigurationEvent event) { if ( "beankeeper.pool.connection_timeout".equals(event.getPropertyName()) ) configurationReload(); }
public void configurationChanged(ConfigurationEvent event) { if ( (event.getPropertyName()!=null) && (event.getPropertyName().startsWith("beankeeper.cache")) ) configurationReload(); }