欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

dubbo中DubboHealthIndicator的作用是什么

這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)dubbo中DubboHealthIndicator的作用是什么,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

成都創(chuàng)新互聯(lián)公司主營賓縣網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都APP應(yīng)用開發(fā),賓縣h5小程序制作搭建,賓縣網(wǎng)站營銷推廣歡迎賓縣等地區(qū)企業(yè)咨詢

DubboHealthIndicator

dubbo-spring-boot-project-2.7.3/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicator.java

public class DubboHealthIndicator extends AbstractHealthIndicator {

    @Autowired
    private DubboHealthIndicatorProperties dubboHealthIndicatorProperties;

    @Autowired(required = false)
    private Map<String, ProtocolConfig> protocolConfigs = Collections.emptyMap();

    @Autowired(required = false)
    private Map<String, ProviderConfig> providerConfigs = Collections.emptyMap();

    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {

        ExtensionLoader<StatusChecker> extensionLoader = getExtensionLoader(StatusChecker.class);

        Map<String, String> statusCheckerNamesMap = resolveStatusCheckerNamesMap();

        boolean hasError = false;

        boolean hasUnknown = false;

        // Up first
        builder.up();

        for (Map.Entry<String, String> entry : statusCheckerNamesMap.entrySet()) {

            String statusCheckerName = entry.getKey();

            String source = entry.getValue();

            StatusChecker checker = extensionLoader.getExtension(statusCheckerName);

            org.apache.dubbo.common.status.Status status = checker.check();

            org.apache.dubbo.common.status.Status.Level level = status.getLevel();

            if (!hasError && level.equals(org.apache.dubbo.common.status.Status.Level.ERROR)) {
                hasError = true;
                builder.down();
            }

            if (!hasError && !hasUnknown && level.equals(org.apache.dubbo.common.status.Status.Level.UNKNOWN)) {
                hasUnknown = true;
                builder.unknown();
            }

            Map<String, Object> detail = new LinkedHashMap<>();

            detail.put("source", source);
            detail.put("status", status);

            builder.withDetail(statusCheckerName, detail);

        }


    }

    /**
     * Resolves the map of {@link StatusChecker}'s name and its' source.
     *
     * @return non-null {@link Map}
     */
    protected Map<String, String> resolveStatusCheckerNamesMap() {

        Map<String, String> statusCheckerNamesMap = new LinkedHashMap<>();

        statusCheckerNamesMap.putAll(resolveStatusCheckerNamesMapFromDubboHealthIndicatorProperties());

        statusCheckerNamesMap.putAll(resolveStatusCheckerNamesMapFromProtocolConfigs());

        statusCheckerNamesMap.putAll(resolveStatusCheckerNamesMapFromProviderConfig());

        return statusCheckerNamesMap;

    }

    private Map<String, String> resolveStatusCheckerNamesMapFromDubboHealthIndicatorProperties() {

        DubboHealthIndicatorProperties.Status status =
                dubboHealthIndicatorProperties.getStatus();

        Map<String, String> statusCheckerNamesMap = new LinkedHashMap<>();

        for (String statusName : status.getDefaults()) {

            statusCheckerNamesMap.put(statusName, DubboHealthIndicatorProperties.PREFIX + ".status.defaults");

        }

        for (String statusName : status.getExtras()) {

            statusCheckerNamesMap.put(statusName, DubboHealthIndicatorProperties.PREFIX + ".status.extras");

        }

        return statusCheckerNamesMap;

    }


    private Map<String, String> resolveStatusCheckerNamesMapFromProtocolConfigs() {

        Map<String, String> statusCheckerNamesMap = new LinkedHashMap<>();

        for (Map.Entry<String, ProtocolConfig> entry : protocolConfigs.entrySet()) {

            String beanName = entry.getKey();

            ProtocolConfig protocolConfig = entry.getValue();

            Set<String> statusCheckerNames = getStatusCheckerNames(protocolConfig);

            for (String statusCheckerName : statusCheckerNames) {

                String source = buildSource(beanName, protocolConfig);

                statusCheckerNamesMap.put(statusCheckerName, source);

            }

        }

        return statusCheckerNamesMap;

    }

    private Map<String, String> resolveStatusCheckerNamesMapFromProviderConfig() {

        Map<String, String> statusCheckerNamesMap = new LinkedHashMap<>();

        for (Map.Entry<String, ProviderConfig> entry : providerConfigs.entrySet()) {

            String beanName = entry.getKey();

            ProviderConfig providerConfig = entry.getValue();

            Set<String> statusCheckerNames = getStatusCheckerNames(providerConfig);

            for (String statusCheckerName : statusCheckerNames) {

                String source = buildSource(beanName, providerConfig);

                statusCheckerNamesMap.put(statusCheckerName, source);

            }

        }

        return statusCheckerNamesMap;

    }

    private Set<String> getStatusCheckerNames(ProtocolConfig protocolConfig) {
        String status = protocolConfig.getStatus();
        return StringUtils.commaDelimitedListToSet(status);
    }

    private Set<String> getStatusCheckerNames(ProviderConfig providerConfig) {
        String status = providerConfig.getStatus();
        return StringUtils.commaDelimitedListToSet(status);
    }

    private String buildSource(String beanName, Object bean) {
        return beanName + "@" + bean.getClass().getSimpleName() + ".getStatus()";
    }

}
  • DubboHealthIndicator繼承了AbstractHealthIndicator,這里注入了dubboHealthIndicatorProperties、protocolConfigs、providerConfigs

  • doHealthCheck方法會先獲取StatusChecker的ExtensionLoader,然后通過resolveStatusCheckerNamesMap方法獲取statusCheckerNamesMap,之后遍歷該map根據(jù)statusCheckerName獲取checker,然后執(zhí)行check獲取status及l(fā)evel,構(gòu)建detail

  • resolveStatusCheckerNamesMap方法分別通過resolveStatusCheckerNamesMapFromDubboHealthIndicatorProperties、resolveStatusCheckerNamesMapFromProtocolConfigs、resolveStatusCheckerNamesMapFromProviderConfig來組裝statusCheckerNamesMap

DubboHealthIndicatorTest

dubbo-spring-boot-project-2.7.3/dubbo-spring-boot-compatible/actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorTest.java

@RunWith(SpringRunner.class)
@TestPropertySource(properties = {
        "dubbo.protocol.id = dubbo-protocol",
        "dubbo.protocol.name = dubbo",
        "dubbo.protocol.port = 12345",
        "dubbo.protocol.status = registry",
        "dubbo.provider.id = dubbo-provider",
        "dubbo.provider.status = server",
        "management.health.dubbo.status.defaults = memory",
        "management.health.dubbo.status.extras = load,threadpool"
})
@SpringBootTest(
        classes = {
                DubboHealthIndicator.class,
                DubboHealthIndicatorTest.class
        }
)
@EnableConfigurationProperties(DubboHealthIndicatorProperties.class)
@EnableDubboConfig
public class DubboHealthIndicatorTest {

    @Autowired
    private DubboHealthIndicator dubboHealthIndicator;

    @Test
    public void testResolveStatusCheckerNamesMap() {

        Map<String, String> statusCheckerNamesMap = dubboHealthIndicator.resolveStatusCheckerNamesMap();

        Assert.assertEquals(5, statusCheckerNamesMap.size());

        Assert.assertEquals("dubbo-protocol@ProtocolConfig.getStatus()", statusCheckerNamesMap.get("registry"));
        Assert.assertEquals("dubbo-provider@ProviderConfig.getStatus()", statusCheckerNamesMap.get("server"));
        Assert.assertEquals("management.health.dubbo.status.defaults", statusCheckerNamesMap.get("memory"));
        Assert.assertEquals("management.health.dubbo.status.extras", statusCheckerNamesMap.get("load"));
        Assert.assertEquals("management.health.dubbo.status.extras", statusCheckerNamesMap.get("threadpool"));

    }

    @Test
    public void testHealth() {

        Health health = dubboHealthIndicator.health();

        Assert.assertEquals(Status.UNKNOWN, health.getStatus());

    }
}
  • DubboHealthIndicatorTest驗證了resolveStatusCheckerNamesMap及dubboHealthIndicator.health()方法

DubboHealthIndicatorProperties

dubbo-spring-boot-project-2.7.3/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorProperties.java

@ConfigurationProperties(prefix = PREFIX, ignoreUnknownFields = false)
public class DubboHealthIndicatorProperties {

    /**
     * The prefix of {@link DubboHealthIndicatorProperties}
     */
    public static final String PREFIX = "management.health.dubbo";

    private Status status = new Status();

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    /**
     * The nested class for {@link StatusChecker}'s names
     * <pre>
     * registry= org.apache.dubbo.registry.status.RegistryStatusChecker
     * spring= org.apache.dubbo.config.spring.status.SpringStatusChecker
     * datasource= org.apache.dubbo.config.spring.status.DataSourceStatusChecker
     * memory= org.apache.dubbo.common.status.support.MemoryStatusChecker
     * load= org.apache.dubbo.common.status.support.LoadStatusChecker
     * server= org.apache.dubbo.rpc.protocol.dubbo.status.ServerStatusChecker
     * threadpool= org.apache.dubbo.rpc.protocol.dubbo.status.ThreadPoolStatusChecker
     * </pre>
     *
     * @see StatusChecker
     */
    public static class Status {

        /**
         * The defaults names of {@link StatusChecker}
         * <p>
         * The defaults : "memory", "load"
         */
        private Set<String> defaults = new LinkedHashSet<>(Arrays.asList("memory", "load"));

        /**
         * The extra names of {@link StatusChecker}
         */
        private Set<String> extras = new LinkedHashSet<>();

        public Set<String> getDefaults() {
            return defaults;
        }

        public void setDefaults(Set<String> defaults) {
            this.defaults = defaults;
        }

        public Set<String> getExtras() {
            return extras;
        }

        public void setExtras(Set<String> extras) {
            this.extras = extras;
        }
    }

}
  • DubboHealthIndicatorProperties定義了Status,其定義了defaults、extras字段

小結(jié)

  • DubboHealthIndicator繼承了AbstractHealthIndicator,這里注入了dubboHealthIndicatorProperties、protocolConfigs、providerConfigs

  • doHealthCheck方法會先獲取StatusChecker的ExtensionLoader,然后通過resolveStatusCheckerNamesMap方法獲取statusCheckerNamesMap,之后遍歷該map根據(jù)statusCheckerName獲取checker,然后執(zhí)行check獲取status及l(fā)evel,構(gòu)建detail

  • resolveStatusCheckerNamesMap方法分別通過resolveStatusCheckerNamesMapFromDubboHealthIndicatorProperties、resolveStatusCheckerNamesMapFromProtocolConfigs、resolveStatusCheckerNamesMapFromProviderConfig來組裝statusCheckerNamesMap

上述就是小編為大家分享的dubbo中DubboHealthIndicator的作用是什么了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

文章題目:dubbo中DubboHealthIndicator的作用是什么
本文鏈接:http://www.aaarwkj.com/article30/iijoso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機網(wǎng)站建設(shè)、網(wǎng)站制作、定制開發(fā)、商城網(wǎng)站企業(yè)網(wǎng)站制作、品牌網(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)

外貿(mào)網(wǎng)站制作
一本综合九九国产二区| 亚洲精品人妻av在线| 99精品热视频在线观看| 亚洲激情久热中文字幕| av天堂网站在线观看| 少妇又色又爽又高潮欧美| 青青草原三区在线播放| 国产成人综合亚洲国产| 欧美视频在线免费观看黄片| 国产经典三级在线看| 日韩av人妻一区二区三区| 午夜毛片免费在线播放| 欧美黄片网站免费观看| 在线麻豆国产传媒免费| 亚洲精品视频一区二区| 99中文字幕国产精品| 九九精品在线观看视频| 中文字幕免费不卡一区| 国产一区二区黄色网页| 久久精品中文字幕人妻| 色综合婷婷九月中文字幕| 日本高清一区二区网站| 麻豆剧传媒国产精选av| 操小姑娘国产精品视频| 人妻少妇麻豆中文字幕久久精品| 国产成人免费公开视频| 国产女技师口爆在线观看| 日本三级黄色免费的网站| 国产精品成人亚洲一区二区| 成人黄色av在线看| 亚洲成人日韩成人av| 亚洲国产精品伦理在线看| 久久国产亚洲欧美一区| 中文字幕国产精品专区| 亚洲中文字幕在线乱码| 免费观看在线视频午夜| av天堂久久这里只有精品美国| 伊人久久九九精品综合| 欧美激情网页一区三区| 日本乱码一区二区三区在线观看| 久久一区二区三区播放|