欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

springcloud 熔斷監(jiān)控Hystrix Dashboard和Turbine

 更新時(shí)間:2019年08月06日 14:41:56   作者:微笑很純潔  
這篇文章主要介紹了springcloud 熔斷監(jiān)控Hystrix Dashboard和Turbine,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

Hystrix-dashboard是一款針對(duì)Hystrix進(jìn)行實(shí)時(shí)監(jiān)控的工具,通過(guò)Hystrix Dashboard我們可以在直觀(guān)地看到各Hystrix Command的請(qǐng)求響應(yīng)時(shí)間, 請(qǐng)求成功率等數(shù)據(jù)。但是只使用Hystrix Dashboard的話(huà), 你只能看到單個(gè)應(yīng)用內(nèi)的服務(wù)信息, 這明顯不夠. 我們需要一個(gè)工具能讓我們匯總系統(tǒng)內(nèi)多個(gè)服務(wù)的數(shù)據(jù)并顯示到Hystrix Dashboard上, 這個(gè)工具就是Turbine.

Hystrix Dashboard

我們?cè)谌蹟嗍纠?xiàng)目spring-cloud-consumer-hystrix的基礎(chǔ)上更改,重新命名為:spring-cloud-consumer-hystrix-dashboard。

1、添加依賴(lài)

<dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

這三個(gè)包必須添加

2、啟動(dòng)類(lèi)

啟動(dòng)類(lèi)添加啟用Hystrix Dashboard和熔斷器

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrixDashboard
@EnableCircuitBreaker
public class ConsumerApplication {

 public static void main(String[] args) {
 SpringApplication.run(ConsumerApplication.class, args);
 }
}

3、測(cè)試

啟動(dòng)工程后訪(fǎng)問(wèn) http://localhost:9001/hystrix,將會(huì)看到如下界面:

圖中會(huì)有一些提示:

Cluster via Turbine (default cluster): http://turbine-hostname:port/turbine.stream
Cluster via Turbine (custom cluster): http://turbine-hostname:port/turbine.stream?cluster=[clusterName]
Single Hystrix App: http://hystrix-app:port/hystrix.stream

大概意思就是如果查看默認(rèn)集群使用第一個(gè)url,查看指定集群使用第二個(gè)url,單個(gè)應(yīng)用的監(jiān)控使用最后一個(gè),我們暫時(shí)只演示單個(gè)應(yīng)用的所以在輸入框中輸入:
http://localhost:9001/hystrix.stream ,輸入之后點(diǎn)擊 monitor,進(jìn)入頁(yè)面。

如果沒(méi)有請(qǐng)求會(huì)先顯示Loading ...,訪(fǎng)問(wèn)http://localhost:9001/hystrix.stream 也會(huì)不斷的顯示ping。

請(qǐng)求服務(wù)http://localhost:9001/hello/neo,就可以看到監(jiān)控的效果了,首先訪(fǎng)問(wèn)http://localhost:9001/hystrix.stream,顯示如下:

ping:

data: {"type":"HystrixCommand","name":"HelloRemote#hello(String)","group":"spring-cloud-producer","currentTime":1494915453986,"isCircuitBreakerOpen":false,"errorPercentage":100,"errorCount":1,"requestCount":1,"rollingCountBadRequests":0,"rollingCountCollapsedRequests":0,"rollingCountEmit":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackEmit":0,"rollingCountFallbackFailure":0,"rollingCountFallbackMissing":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":1,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":1,"currentConcurrentExecutionCount":0,"rollingMaxConcurrentExecutionCount":0,"latencyExecute_mean":0,"latencyExecute":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"latencyTotal_mean":0,"latencyTotal":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"propertyValue_circuitBreakerRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD","propertyValue_executionIsolationThreadTimeoutInMilliseconds":1000,"propertyValue_executionTimeoutInMilliseconds":1000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1,"threadPool":"spring-cloud-producer"}

data: {"type":"HystrixThreadPool","name":"spring-cloud-producer","currentTime":1494915453986,"currentActiveCount":0,"currentCompletedTaskCount":1,"currentCorePoolSize":10,"currentLargestPoolSize":1,"currentMaximumPoolSize":10,"currentPoolSize":1,"currentQueueSize":0,"currentTaskCount":1,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"rollingCountCommandRejections":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"reportingHosts":1}

說(shuō)明已經(jīng)返回了監(jiān)控的各項(xiàng)結(jié)果

到監(jiān)控頁(yè)面就會(huì)顯示如下圖:

其實(shí)就是http://localhost:9001/hystrix.stream返回結(jié)果的圖形化顯示,Hystrix Dashboard Wiki上詳細(xì)說(shuō)明了圖上每個(gè)指標(biāo)的含義,如下圖:

到此單個(gè)應(yīng)用的熔斷監(jiān)控已經(jīng)完成。

Turbine

在復(fù)雜的分布式系統(tǒng)中,相同服務(wù)的節(jié)點(diǎn)經(jīng)常需要部署上百甚至上千個(gè),很多時(shí)候,運(yùn)維人員希望能夠把相同服務(wù)的節(jié)點(diǎn)狀態(tài)以一個(gè)整體集群的形式展現(xiàn)出來(lái),這樣可以更好的把握整個(gè)系統(tǒng)的狀態(tài)。 為此,Netflix提供了一個(gè)開(kāi)源項(xiàng)目(Turbine)來(lái)提供把多個(gè)hystrix.stream的內(nèi)容聚合為一個(gè)數(shù)據(jù)源供Dashboard展示。

1、添加依賴(lài)

<dependencies>
 <dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-turbine</artifactId>
 </dependency>
 <dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-netflix-turbine</artifactId>
 </dependency>
 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-actuator</artifactId>
 </dependency>
 <dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
 </dependency>
</dependencies>

2、配置文件

spring.application.name=hystrix-dashboard-turbine
server.port=8001
turbine.appConfig=node01,node02
turbine.aggregator.clusterConfig= default
turbine.clusterNameExpression= new String("default")

eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/
  • turbine.appConfig :配置Eureka中的serviceId列表,表明監(jiān)控哪些服務(wù)
  • turbine.aggregator.clusterConfig :指定聚合哪些集群,多個(gè)使用”,”分割,默認(rèn)為default??墒褂?code>http://.../turbine.stream?cluster={clusterConfig之一}訪(fǎng)問(wèn)
  • turbine.clusterNameExpression : 1. clusterNameExpression指定集群名稱(chēng),默認(rèn)表達(dá)式appName;此時(shí):turbine.aggregator.clusterConfig需要配置想要監(jiān)控的應(yīng)用名稱(chēng);2. 當(dāng)clusterNameExpression: default時(shí),turbine.aggregator.clusterConfig可以不寫(xiě),因?yàn)槟J(rèn)就是default;3. 當(dāng)clusterNameExpression: metadata[‘cluster']時(shí),假設(shè)想要監(jiān)控的應(yīng)用配置了eureka.instance.metadata-map.cluster: ABC,則需要配置,同時(shí)turbine.aggregator.clusterConfig: ABC

3、啟動(dòng)類(lèi)

啟動(dòng)類(lèi)添加@EnableTurbine,激活對(duì)Turbine的支持

@SpringBootApplication
@EnableHystrixDashboard
@EnableTurbine
public class DashboardApplication {

 public static void main(String[] args) {
 SpringApplication.run(DashboardApplication.class, args);
 }

}

到此Turbine(hystrix-dashboard-turbine)配置完成

4、測(cè)試

在示例項(xiàng)目spring-cloud-consumer-hystrix基礎(chǔ)上修改為兩個(gè)服務(wù)的調(diào)用者spring-cloud-consumer-node1和spring-cloud-consumer-node2

spring-cloud-consumer-node1項(xiàng)目改動(dòng)如下:
application.properties文件內(nèi)容

spring.application.name=node01
server.port=9001
feign.hystrix.enabled=true

eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/

spring-cloud-consumer-node2項(xiàng)目改動(dòng)如下:
application.properties文件內(nèi)容

spring.application.name=node02
server.port=9002
feign.hystrix.enabled=true

eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/

HelloRemote類(lèi)修改:

@FeignClient(name= "spring-cloud-producer2", fallback = HelloRemoteHystrix.class)
public interface HelloRemote {

 @RequestMapping(value = "/hello")
 public String hello2(@RequestParam(value = "name") String name);

}

對(duì)應(yīng)的HelloRemoteHystrixConsumerController類(lèi)跟隨修改,具體查看代碼

修改完畢后,依次啟動(dòng)spring-cloud-eureka、spring-cloud-consumer-node1、spring-cloud-consumer-node1、hystrix-dashboard-turbine(Turbine)

打開(kāi)eureka后臺(tái)可以看到注冊(cè)了三個(gè)服務(wù):

訪(fǎng)問(wèn) http://localhost:8001/turbine.stream

返回:

: ping
data: {"reportingHostsLast10Seconds":1,"name":"meta","type":"meta","timestamp":1494921985839}

并且會(huì)不斷刷新以獲取實(shí)時(shí)的監(jiān)控?cái)?shù)據(jù),說(shuō)明和單個(gè)的監(jiān)控類(lèi)似,返回監(jiān)控項(xiàng)目的信息。進(jìn)行圖形化監(jiān)控查看,輸入:http://localhost:8001/hystrix,返回酷酷的小熊界面,輸入: http://localhost:8001/turbine.stream,然后點(diǎn)擊 Monitor Stream ,可以看到出現(xiàn)了倆個(gè)監(jiān)控列表

示例代碼

參考:

使用Spring Cloud與Docker實(shí)戰(zhàn)微服務(wù)

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Spring事務(wù)失效場(chǎng)景的詳細(xì)整理

    Spring事務(wù)失效場(chǎng)景的詳細(xì)整理

    Spring 事務(wù)的傳播特性說(shuō)的是,當(dāng)多個(gè)事務(wù)同時(shí)存在的時(shí)候,Spring 如何處理這些事務(wù)的特性,下面這篇文章主要給大家介紹了關(guān)于Spring事務(wù)失效場(chǎng)景的相關(guān)資料,需要的朋友可以參考下
    2022-02-02
  • java實(shí)現(xiàn)響應(yīng)重定向發(fā)送post請(qǐng)求操作示例

    java實(shí)現(xiàn)響應(yīng)重定向發(fā)送post請(qǐng)求操作示例

    這篇文章主要介紹了java實(shí)現(xiàn)響應(yīng)重定向發(fā)送post請(qǐng)求操作,結(jié)合實(shí)例形式分析了java請(qǐng)求響應(yīng)、重定向及數(shù)據(jù)處理相關(guān)操作技巧,需要的朋友可以參考下
    2020-04-04
  • Spring Boot配置元數(shù)據(jù)方法教程

    Spring Boot配置元數(shù)據(jù)方法教程

    這篇文章主要介紹了Spring Boot配置元數(shù)據(jù)方法教程,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-12-12
  • Java實(shí)體映射工具M(jìn)apStruct使用方法詳解

    Java實(shí)體映射工具M(jìn)apStruct使用方法詳解

    MapStruct是用于代碼中JavaBean對(duì)象之間的轉(zhuǎn)換,例如DO轉(zhuǎn)換為DTO,DTO轉(zhuǎn)換為VO,或Entity轉(zhuǎn)換為VO等場(chǎng)景,這篇文章主要給大家介紹了關(guān)于Java實(shí)體映射工具M(jìn)apStruct使用的相關(guān)資料,需要的朋友可以參考下
    2021-11-11
  • Spring2.5.6開(kāi)發(fā)環(huán)境搭建圖文教程

    Spring2.5.6開(kāi)發(fā)環(huán)境搭建圖文教程

    這篇文章主要為大家詳細(xì)介紹了Spring2.5.6開(kāi)發(fā)環(huán)境搭建圖文教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Spring Boot 2.5.0 重新設(shè)計(jì)的spring.sql.init 配置有啥用

    Spring Boot 2.5.0 重新設(shè)計(jì)的spring.sql.init 配置有啥用

    前幾天Spring Boot 2.5.0發(fā)布了,其中提到了關(guān)于Datasource初始化機(jī)制的調(diào)整,有讀者私信想了解這方面做了什么調(diào)整。那么今天就要詳細(xì)說(shuō)說(shuō)這個(gè)重新設(shè)計(jì)的配置內(nèi)容,并結(jié)合實(shí)際情況說(shuō)說(shuō)我的理解和實(shí)踐建議
    2021-05-05
  • Mybatis plus 配置多數(shù)據(jù)源的實(shí)現(xiàn)示例

    Mybatis plus 配置多數(shù)據(jù)源的實(shí)現(xiàn)示例

    這篇文章主要介紹了Mybatis plus 配置多數(shù)據(jù)源的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-08
  • 詳解SpringBoot修改啟動(dòng)端口server.port的四種方式

    詳解SpringBoot修改啟動(dòng)端口server.port的四種方式

    這篇文章主要介紹了詳解SpringBoot修改啟動(dòng)端口server.port的四種方式,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • 設(shè)計(jì)模式在Spring框架中的應(yīng)用匯總

    設(shè)計(jì)模式在Spring框架中的應(yīng)用匯總

    這篇文章主要介紹了設(shè)計(jì)模式在Spring框架中的應(yīng)用匯總,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-11-11
  • java?數(shù)組實(shí)現(xiàn)學(xué)生成績(jī)統(tǒng)計(jì)教程

    java?數(shù)組實(shí)現(xiàn)學(xué)生成績(jī)統(tǒng)計(jì)教程

    這篇文章主要介紹了java?數(shù)組實(shí)現(xiàn)學(xué)生成績(jī)統(tǒng)計(jì)教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-12-12

最新評(píng)論