タービンは、サーバーを集約してイベントストリームデータを送信するためのツールです。 Hystrixモニタリングでは、単一のノードのみを監視でき、実際の生産ではクラスターです。したがって、タービンを使用してクラスター内のHystrixのメトリックを監視でき、HystrixサービスはEurekaを通じて発見できます。
新しいタービンプロジェクトを作成します
Turbineapplication.java
パッケージタービン; Import org.springframework.boot.springApplication; Import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.cloud.netflix.hystrix.enablehystrix; Import org.springframework.cloud.netflix.hystrix.dashboard.enablehystrixdashboard; import org.springframework.cloud.netflix.turbine.enableturbine;/***は、Sai.luoが2017/4/26に作成しました。 */@SpringBootApplication@enableTurbine@enableHystrix@enableHystrixDashDashBoardPublic TurbineApplication {public static void main(string [] args){springApplication.run(turbineapplication.class、args); }}pom.xml
<?xml version = "1.0" encoding = "utf-8"?> <project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns:xsi = "http://www.w3.org/2001/xmlschema-instance <http://www.w3.org/2001 xsi:schemalocation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.0.sdsd"> <modelversion> 4.0.0 </modelversion> <artifactid> </artifactid> <proties> <project.build.sourceencoding> utf-8 </project.build.sourceencoding> <java.version> 1.8 </java.version> </properties> <parent> <parent> <parent> <parent> <parent> <parent> <parent> <バージョン> 1.5.2.Release </version> <RecationPath/> <! - lookup parent from Repository - > </parent> <dependencies> <! - > <dependency> groupid> org.springframework.cloud </groupid> <artifactid> spring-cloud-hystrix </artifactid> </artifactid> </artifactid> </artifactid> < <groupid> org.springframework.cloud </groupid> <artifactid> spring-cloud-starter-hystrix-dashboard </artifactid> </dependency> <! - ターンバイン依存関係 - > <依存> </Dependency> </Dependency> <DependencyManagement> <Dependency> <Dependency> <shipidence> org.springframework.cloud </groupid> <artifactid> camden.sr5 </version> <type> pom </deponecy> scope> scope> deponecy> deponecy> deponecy> deponem </DependencyManagement> <build> <blugins> <Plugin> <groupId> org.springframework.boot </groupid> <artifactid> spring-boot-maven-plugin </artifactid> </plugin> </plugins> </build> </project>
Application.yml
スプリング:アプリケーション:名前:Turbinesserver:Port:8000-Turbine:App-Config:Hello、Helloclient ##サービス名監視する必要があるアグリゲーター:ClusterConfig:メイン##監視されたClusterAmeExpression:Metadata ['Cluster'] Eureka:Instads:forpaddress:forpaddress:forpaddress:epreaddress: serviceurl:defaultzone:http:// localhost:8761/eureka/
サービスを開始します
HelloServiceeureka Project Application.ymlは、クラスター構成を追加します
に変更します
スプリング:アプリケーション:名前:HelloServer:ポート:9001Eureka:インスタンス:リースレンワルインターバルインセコンド:3リース - エッピング - 秒単位:5メタデータマップ:クラスター:メインクライアント:defaultzone:http:// localhost:8761/eureka/registry-fettiry-fettistry-fettistry-fettistry-fettistry-fettistry-fettistry-fettistry-fettir Netflix:Eureka:Off Discovery:Off
pom.xmlは、Hystrix依存関係パッケージを追加します
<Dependency> groupId> org.springframework.cloud </groupid> <artifactid> spring-cloud-starter-hystrix </artifactid> </dependency>
同様に、Ribboneureka Project Application.ymlはクラスター構成を追加します
変更後、以下
スプリング:アプリケーション:名前:helloclientserver:port:20000eureka:instance:lease-renewal-interval-in-seconds:3リース - エッピング - 秒単位:5メタデータマップ:5メタデータマップ:クラスター:メインクライアント:defaultzone:http:// localhost:8761/eureka/registry-fechtingssp com:netflix:eureka:off discovery:off
pom.xmlは、Hystrix依存関係パッケージを追加します
ribboneurekaapplication.javaアノテーションを追加します
@EnableHyStrix
プロジェクトを開始します
LocalHost:8000/Hystrixxにアクセスして、ページをご覧ください
注:タービンは、HystrixサービスではなくHystrixサービスのみを監視でき、監視できません。たとえば、Helloサービスはクラスターで構成されていますが、Hystrixを使用しないため、監視されません。
プロジェクトアドレスhttps://github.com/luosai001/spring-cloud-sample/tree/master
上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。誰もがwulin.comをもっとサポートすることを願っています。