Spring Cloud Netflix のガイドに従ってTurbine を構成しました。2 つのマイクロサービスで Hystrix を有効にした後、/hystrix.stream エンドポイントが正しい出力を生成することを確認しました。
hystrix ダッシュボード プロジェクトで、すべてのサービスの集計結果を取得するように Turbine を構成しました。しかし、私が得るのは次の連続です:
: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1448552456486}
これは私の設定です:
HystrixDashboard + タービン アプリケーション:
@EnableHystrixDashboard
@EnableTurbine
@SpringBootApplication
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class, args);
}
}
HystrixDashboard + タービン application.yml:
spring:
application:
name: hystrix-dashboard
server:
port: 10000
turbine:
appConfig: random-story-microservice,storyteller-api
instanceUrlSuffix: /hystrix.stream
logging:
level:
com.netflix.turbine: 'TRACE'
アップデート
kreel の指示に従って、Turbine を次のように構成しました。
turbine:
appConfig: random-story-microservice,storyteller-api
instanceUrlSuffix: /hystrix.stream
clusterNameExpression: new String("default")
例外で失敗することはもうありません。ログを見ると、Turbine が 2 つの候補ホスト/マイクロサービスを見つけていることがわかります。
[ Timer-0] c.n.t.discovery.InstanceObservable : Retrieved hosts from InstanceDiscovery: 2
ただし、最終的に登録されるのはそのうちの 1 つだけです。ホストの 1 つだけが追加されます。これInstanceObservable.run()
は、ハッシュコードが同じであるため、newState.hostsUp に追加されたときに同じと見なされるためです。com.netflix.turbine.discovery.Instance
ハッシュコードは、ホスト名 (どちらの場合も「myhost」) とクラスター (「デフォルト」) に基づいて計算されます。
// set the current state
for(Instance host: newList) {
if(host.isUp()) {
newState.hostsUp.add(host);
} else {
newState.hostsDown.add(host);
}
}
同じホストが 2 つの異なるマイクロサービスを提供している場合、どうすればよいでしょうか? この場合、最初のインスタンスのみが登録されます。