内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

dubbo中ConfigChangeEvent的作用是什么

本篇文章為大家展示了dubbo中ConfigChangeEvent的作用是什么,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

為榆中等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及榆中網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站制作、榆中網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!

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定義了key、value、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定義了ADDED、MODIFIED、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定義了process方法來處理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<Configurator> 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<Configurator> getConfigurators() {
        return configurators;
    }

    public void setConfigurators(List<Configurator> configurators) {
        this.configurators = configurators;
    }
}
  • AbstractConfiguratorListener聲明實現(xiàn)了ConfigurationListener接口,其process在event的changeType是ConfigChangeType.DELETED時會清空configurators;最后執(zhí)行的notifyOverrides方法留給子類實現(xiàn)

小結(jié)

ConfigChangeEvent定義了key、value、changeType三個屬性;ConfigChangeType定義了ADDED、MODIFIED、DELETED三種類型;ConfigurationListener定義了process方法來處理ConfigChangeEvent

上述內(nèi)容就是dubbo中ConfigChangeEvent的作用是什么,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

文章標題:dubbo中ConfigChangeEvent的作用是什么
新聞來源:http://www.rwnh.cn/article28/jdcjcp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、、網(wǎng)站設(shè)計公司、自適應(yīng)網(wǎng)站、Google、網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司
巴青县| 涟水县| 孟津县| 雷州市| 永定县| 军事| 辽源市| 金溪县| 南开区| 乌鲁木齐县| 巴楚县| 阳泉市| 绍兴市| 吉木乃县| 鹰潭市| 正蓝旗| 曲阳县| 武隆县| 疏勒县| 武川县| 宝丰县| 萨迦县| 兰溪市| 红河县| 金堂县| 沅陵县| 武威市| 河南省| 峨边| 琼海市| 台东市| 青州市| 光山县| 安达市| 甘谷县| 行唐县| 丰宁| 应用必备| 景洪市| 兴化市| 株洲县|