In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you what the role of ConfigChangeEvent in dubbo is, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
ConfigChangeEvent
Dubbo-2.7.3/dubbo-configcenter/dubbo-configcenter-api/src/main/java/org/apache/dubbo/configcenter/ConfigChangeEvent.java
Public class ConfigChangeEvent {private final String key; private final String value; private final ConfigChangeType changeType; public ConfigChangeEvent (String key, String value) {this (key, value, ConfigChangeType.MODIFIED);} public ConfigChangeEvent (String key, String value, ConfigChangeType changeType) {this.key = key; this.value = value; this.changeType = changeType;} public String getKey () {return key } public String getValue () {return value;} public ConfigChangeType getChangeType () {return changeType;} @ Override public String toString () {return "ConfigChangeEvent {" + "key='" + key +'\'+ ", value='" + value +'\'+ ", changeType=" + changeType +'}' }}
ConfigChangeEvent defines three attributes: key, value and changeType.
ConfigChangeType
Dubbo-2.7.3/dubbo-configcenter/dubbo-configcenter-api/src/main/java/org/apache/dubbo/configcenter/ConfigChangeType.java
Public enum ConfigChangeType {/ * * A config is created. * / ADDED, / * * A config is updated. * / MODIFIED, / * * A config is deleted. * / DELETED}
ConfigChangeType defines three types: ADDED, MODIFIED and DELETED.
ConfigurationListener
Dubbo-2.7.3/dubbo-configcenter/dubbo-configcenter-api/src/main/java/org/apache/dubbo/configcenter/ConfigurationListener.java
Public interface ConfigurationListener {/ * * Listener call back method. Listener gets notified by this method once there's any change happens on the config * the listener listens on. * * @ param event config change event * / void process (ConfigChangeEvent event);}
ConfigurationListener defines a process method to handle ConfigChangeEvent
AbstractConfiguratorListener
Dubbo-2.7.3/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java
Public abstract class AbstractConfiguratorListener implements ConfigurationListener {private static final Logger logger = LoggerFactory.getLogger (AbstractConfiguratorListener.class); protected List configurators = Collections.emptyList (); protected final void initWith (String key) {DynamicConfiguration dynamicConfiguration = DynamicConfiguration.getDynamicConfiguration (); dynamicConfiguration.addListener (key, this); String rawConfig = dynamicConfiguration.getRule (key, DynamicConfiguration.DEFAULT_GROUP); if (! StringUtils.isEmpty (rawConfig)) {genConfiguratorsFromRawRule (rawConfig) } @ Override public void process (ConfigChangeEvent event) {if (logger.isInfoEnabled ()) {logger.info ("Notification of overriding rule, change type is:" + event.getChangeType () + ", raw config content is:\ n" + event.getValue ());} if (event.getChangeType (). Equals (ConfigChangeType.DELETED)) {configurators.clear () } else {if (! genConfiguratorsFromRawRule (event.getValue () {return;}} notifyOverrides ();} private boolean genConfiguratorsFromRawRule (String rawConfig) {boolean parseSuccess = true; try {/ / parseConfigurators will recognize app/service config automatically. Configurators = Configurator.toConfigurators (ConfigParser.parseConfigurators (rawConfig)) .orElse (configurators);} catch (Exception e) {logger.error ("Failed to parse raw dynamic config and it will not take effect, the raw config is:" + rawConfig, e); parseSuccess = false;} return parseSuccess;} protected abstract void notifyOverrides () Public List getConfigurators () {return configurators;} public void setConfigurators (List configurators) {this.configurators = configurators;}}
AbstractConfiguratorListener declares to implement the ConfigurationListener interface, and its process clears the last executed notifyOverrides method of the configurators; to the subclass implementation when the changeType of the event is ConfigChangeType.DELETED
Summary
ConfigChangeEvent defines three attributes: key, value and changeType; ConfigChangeType defines three types: ADDED, MODIFIED and DELETED; and ConfigurationListener defines process methods to handle ConfigChangeEvent
The above content is what is the role of ConfigChangeEvent in dubbo. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.