Spring Boot + Eureka Server + Hystrix with Turbine:空的turbine.stream [英] Spring Boot + Eureka Server + Hystrix with Turbine: empty turbine.stream

查看:879
本文介绍了Spring Boot + Eureka Server + Hystrix with Turbine:空的turbine.stream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行Spring Boot(使用Spring Cloud)+ Eureka Server + Hystrix仪表板和Turbine流,但遇到了一个问题,至今我找不到任何解决方案。我使用Spring Boot 1.2.1.RELEASE 和Spring Cloud 1.0.0.RC2 。这是我的:

第一个实例运行Eureka服务器和Hystrix仪表板:

  @Configuration 
@EnableAutoConfiguration
@EnableEurekaServer
@EnableHystrixDashboard
@EnableDiscoveryClient
类应用程序{

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

您可以在这里找到 build.gradle - https://gist.github.com/wololock/570272ad7cf2d14a4d3c



尤里卡服务器运行正常,我可以看到已注册的实例尤里卡服务器仪表板,我也可以使用 LoadBalancer 来使用它的id获取注册实例的URL。到目前为止一切正常。



我有几个运行 @EnableHystrix 注释的实例并使用 @HystrixCommand 来定义Hystrix必须监视哪些方法。当我将单个实例的hystrix.stream传递给Hystrix仪表板时,我可以看到它没有任何问题。

我还单独使用了Turbine服务器,并不复杂:

  @EnableAutoConfiguration 
@EnableTurbine
@Configuration
@EnableDiscoveryClient
class Application {

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

在这里您可以找到 build.gradle 用于Turbine服务器实例 - https:// gist .github.com / wololock / ff0d855b8a890232851e



它使用非常简单的配置,主要基于示例涡轮应用提供的配置 - https://github.com/spring-cloud-samples/turbine

 信息:
组件:Turbine

端点:$ b​​ $ b重新启动:
启用:true
关机:启用
:true

涡轮机:
appConfig:pdf-creator-service

InstanceDiscovery:
impl:io.spring.platform.netflix.turbine.EurekaInstanceDiscovery

服务器:
端口:8989

管理:
端口:8990

eureka:
实例:
leaseRenewalIntervalInSeconds:10
client:
serviceUrl:
defaultZone:$ {vcap.services。$ {PREFIX:} eureka.credentials.uri:http:// user:password @ localhost:8761} / eureka /

按顺序运行这些实例后:


  1. eureka服务器

  2. 涡轮服务器

  3. 发现客户端实例,

我有第二和第三个实例注册到尤里卡服务器,涡轮服务器日志说,有一个实例:

  [2015-02-06 12:35:04.162] boot  -  20495 INFO [Timer-0] --- EurekaInstanceDiscovery:获取应用程序的实例列表:[pdf-creator-service] 
[2015-02-06 12:35:04.162] boot - 204 95 INFO [Timer-0] --- EurekaInstanceDiscovery:为app提取实例:pdf-creator-service
[2015-02-06 12:35:04.162] boot - 20495 INFO [Timer-0] --- EurekaInstanceDiscovery:收到的应用程序实例列表:pdf-creator-service = 1
[2015-02-06 12:35:04.162] boot - 20495 INFO [Timer-0] --- InstanceObservable:从InstanceDiscovery中检索到的主机: 1
[2015-02-06 12:35:04.162] boot - 20495 INFO [Timer-0] --- InstanceObservable:找到之前已终止的主机:0
[2015-02-06 12:35:04.162] boot - 20495 INFO [Timer-0] --- InstanceObservable:Hosts up:1,hosts down:0
[2015-02-06 12:36:04.162] boot - 20495 INFO [ Timer-0] --- EurekaInstanceDiscovery:获取应用程序的实例列表:[pdf-creator-service]
[2015-02-06 12:36:04.162] boot - 20495 INFO [Timer-0] --- EurekaInstanceDiscovery:抓取app的实例:pdf-creator-service
[2015-02-06 12:36:04.162] boot - 20495 INFO [Timer-0] --- EurekaInstanceDiscovery:接收到的实例应用程序清单:pdf-creator-service = 1
[2015-02-06 12:36:04.162] boot - 20495 INFO [Timer-0] --- InstanceObservable:从InstanceDiscovery中检索到的主机:1
[2015-02-06 12:36:04.162] boot - 20495 INFO [Timer-0] --- InstanceObservable:发现之前已被终止的主机:0
[2015-02-06 12:36: 04.162] boot - 20495 INFO [Timer-0] --- InstanceObservable:Hosts up:1,hosts hosts:0

从一个实例调用hystrix.stream可以工作,例如 curl http:// localhost:8885 / hystrix.stream 返回:

  data:{type:HystrixCommand,name:post,group:PdfController,currentTime:1423223614259,isCircuitBreakerOpen:false,errorPercentage:0,errorCount: 0 requestCount:0 rollingCountCollapsedRequests:0 rollingCountExceptionsThrown:0 rollingCountFailure:0 rollingCountFallbackFailure:0 rollingCountFallbackRejection:0 rollingCountFallbackSuccess:0 rollingCountResponsesFromCache:0, rollingCountSemaphoreRejected:0 rollingCountShortCircuited:0 rollingCountSuccess:0 rollingCountThreadPoolRejected:0 rollingCountTimeout:0 currentConcurrentExecutionCount: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:假的, propertyValue_circuitBreakerForceClosed:假的, propertyValue_circuitBreakerEnabled:真实的, propertyValue_executionIsolationStrategy: 线程, propertyValue_executionIsolationThreadTimeoutInMilliseconds:8000, propertyValue_executionIsolationThreadInterruptOnTimeout:真实的, propertyValue_executionIsolationThreadPoolKeyOverride :null,propertyValue_executionIsolationSemaphoreMaxConcurrentRequests:10,propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests:10,propertyValue_metricsRollingStatisticalWindowInMilliseconds:10000,propertyValue_requestCacheEnabled:true,propertyValue_requestLogEnabled:true,reportingHosts:1} 

data:{ 类型: HystrixCommand, 名称: 生成, 基团: WkHtmlToPdfGenerator, currentTime的:1423223614259 isCircuitBreakerOpen:假 errorPercentage:0 ERRORCOUNT:0,requestCount :0, rollingCountCollapsedRequests :0, rollingCountExcep tionsThrown :0, rollingCountFailure :0,rollingCountFallbackFailure :0,rollingCountFallbackRejection :0,rollingCountFallbackSuccess :0,rollingCountResponsesFromCache :0,rollingCountSemaphoreRejected :0,rollingCountShortCircuited :0, rollingCountSuccess :0, rollingCountThreadPoolRejected:0 rollingCountTimeout:0 currentConcurrentExecutionCount: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:假 propertyValue_circuitBreakerForceClosed:假 propertyValue_circuitBreakerEnabled:真 propertyValue_executionIsolationStrategy: 线程, propertyValue_executionIsolationThreadTimeoutInMilliseconds :8000 propertyValue_executionIsolationThreadInterruptOnTimeout :真实的, propertyValue_executionIsolationThreadPoolKeyOverride :空, propertyValue_executionIsolationSemaphoreMaxConcurrentRequests :10, propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests :10, propertyValue_metricsRollingStatisticalWindowInMilliseconds :10000, propertyValue_requestCacheEnabled :真实的, propertyValue_requestLogEnabled :真实的, reportingHosts:1}

data:{type:HystrixThreadPool,name:PdfController,currentTime:1423223614259,currentActiveCount:0,currentCompletedTaskCount:4,currentCorePoolSize:10,currentLargestPoolSize :4,currentMaximumPoolSize :10,currentPoolSize :4,currentQueueSize :0,currentTaskCount :4,rollingCountThreadsExecuted :0,rollingMaxActiveThreads :0,propertyValue_queueSizeRejectionThreshold :5,propertyValue_metricsRollingStatisticalWindowInMilliseconds: 10000,reportingHosts:1}

但是当我将turbine.stream连接到hystrix仪表板时,我什么也没得到。日志说:

  [2015-02-06 12:42:48.922] boot  -  24816 INFO [Timer-0]  -  -  EurekaInstanceDiscovery:收到的应用程序实例列表:pdf-creator-service = 1 
[2015-02-06 12:42:48.922] boot - 24816 INFO [Timer-0] --- InstanceObservable:从InstanceDiscovery :1
[2015-02-06 12:42:48.922] boot - 24816 INFO [Timer-0] --- InstanceObservable:找到之前被终止的主机:0
[2015-02- 06:12:42:48.922] boot - 24816 INFO [Timer-0] --- InstanceObservable:Hosts up:1,hosts down:0
[2015-02-06 12:43:26.237] boot - 24816 INFO [XNIO-2 task-4] --- TurbineStreamServlet:FilterCriteria:[]
[2015-02-06 12:43:26.237] boot - 24816 INFO [XNIO-2 task-4] --- TurbineStreamServlet: StatsType过滤器:[]
[2015-02-06 12:43:26.237] boot - 24816 INFO [XNIO-2 task-4] --- TurbineStreamingConnection:相关配置:[]
[2015- 02-06 12:43:26.237] boot - 24816 INFO [XNIO-2 task-4] --- TurbineStreamingConnection:Relevance指标配置:{}
[2015-02-06 12:43:26.237] boot - 24816信息[XNIO-2 task-4] --- ClusterMonitor:为集群监视器注册事件处理程序:StreamingHandler_f1308dda-58c5-47a5 -b1e2-5a0bea32226b
[2015-02-06 12:43:26.237] boot - 24816 INFO [XNIO-2 task-4] --- TurbineDataDispatcher:

刚刚添加并启动处理程序tuple:StreamingHandler_f1308dda-58c5-47a5-b1e2-5a0bea32226b
[2015-02-06 12:43:26.238] boot - 24816 INFO [XNIO-2 task-4] --- AggDataFromCluster:每个处理器dispacher开始于: StreamingHandler_f1308dda-58c5-47a5-b1e2-5a0bea32226b
[2015-02-06 12:43:26.238] boot - 24816 INFO [XNIO-2 task-4] --- ClusterMonitor:集群监视器的所有事件处理程序:[ StreamingHandler_637572ab-ACDA-4bf4-81cd-6a658adb73eb,StreamingHandler_f1308dda-58c5-47a5-b1e2-5a0bea32226b,StaticListener_For_Aggregator,StreamingHandler_5ec12ee8-3fcd-4a6f-9006-d2a6ecc309d0,StreamingHandler_72d7b9e2-ad98-42a0-9ac3-abe4aa57cc7a]
[2015-02 -06 12:43:26.238] boot - 24816 INFO [XNIO-2 task-4] --- ClusterMonitor:启动集群监控器default_agg

如果我做了 curl http:// localhost:8989 / turbine.stream 我只得到:

 :ping 
data:{reportingHostsLast10Seconds:0,name:meta,type:meta,timestamp:1423223006935}

:ping
data:{reportingHostsLast10Seconds:0,name:meta,type:meta,timestamp:1423223010935}

:ping
data:{reportingHostsLast10Seconds:0,name:meta,type:meta,timestamp:1423223013936}

:ping
data: {reportingHostsLast10Seconds:0,name:meta,type:meta,timestamp:1423223017936}

:ping
data:{reportingHostsLast10Seconds: 0,name:meta,type:meta,timestamp:1423223020937}

:ping
:ping
data:{reportingHostsLast10Seconds :0,name:meta,type:meta,timestamp:1423223024937}

:ping
data:{reportingHostsLast10Seconds:0,na me:meta,type:meta,timestamp:1423223028938}

:ping
data:{reportingHostsLast10Seconds:0,name:meta ,type:meta,timestamp:1423223032938}

:ping
:ping
data:{reportingHostsLast10Seconds:0,name: meta,type:meta,timestamp:1423223036938}

:ping
data:{reportingHostsLast10Seconds:0,name:meta,type :meta,timestamp:1423223039939}

:ping
data:{reportingHostsLast10Seconds:0,name:meta,type:meta ,timestamp:1423223043939}

:ping
data:{reportingHostsLast10Seconds:0,name:meta,type:meta,timestamp: 1423223046940}

:ping
data:{reportingHostsLast10Seconds:0,name:meta,type:meta,timestamp:1423223050940}

:ping
:ping
data:{reportingHostsLast10Seconds:0,name:meta,type:meta,timestamp:1423223054941}

我的问题是:是否错过了设置并运行?以前我试图通过单独使用尤里卡和涡轮机服务器来进行管理,但在这种情况下,涡轮机甚至无法使用正确的应用程序名称在尤里卡中找到已注册的应用程序。我在拆分尤里卡和涡轮机后取得了进展,但它仍然无法正常工作。



我会很感激任何建议。如果您需要更多信息,请告诉我,我可能会错过一些重要的事情。

更新20150209



Dave的建议我在 application.yml turbine-server 文件中应用了一些小改动。现在文件只包含:

 信息:
组件:涡轮

涡轮:
appConfig:pdf-creator-service
clusterNameExpression:'default'

服务器:
端口:8989

管理:
端口:8990

eureka:
实例:
leaseRenewalIntervalInSeconds:10
客户端:
serviceUrl:
defaultZone:$ {vcap.services。 $ {PREFIX:} eureka.credentials.uri:http:// user:password @ localhost:8761} / eureka /

但它并不能使turbine.stream工作。在涡轮服务器了解了在尤里卡服务器中注册的客户端之后,它会失败并给出异常:

  [2015-02-09 21 :25:03.516] boot  -  4808 INFO [Timer-0] --- EurekaInstanceDiscovery:获取应用程序实例列表:[pdf-creator-service] 
[2015-02-09 21:25:03.516] boot - 4808 INFO [Timer-0] --- EurekaInstanceDiscovery:获取app的实例:pdf-creator-service
[2015-02-09 21:25:03.516] boot - 4808 INFO [Timer-0] --- EurekaInstanceDiscovery:收到的应用程序实例列表:pdf-creator-service = 1
[2015-02-09 21:25:03.520] boot - 4808错误[Timer-0] --- EurekaInstanceDiscovery:无法获取实例app:pdf-creator-service,再次重试
org.springframework.expression.spel.SpelEvaluationException:EL1008E:(pos 0):在'com.netflix'类型的对象上找不到属性或字段'default'。 appinfo.InstanceInfo' - 可能不公开?在org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:226)

在org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:93)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:81)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120)在org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:242)

在org.springframework.cloud.netflix.turbine.EurekaInstanceDiscovery.getClusterName(EurekaInstanceDiscovery.java:183)在org.springframework.cloud.netflix.turbine.EurekaInstanceDiscovery.marshallInstanceInfo(EurekaInstanceDiscovery.java:141)

在org.springframework.cloud.netflix.turbine.EurekaInstanceDiscovery.getInstancesForApp(EurekaInstanceDiscovery.java:123)
在org.springfra mework.cloud.netflix.turbine.EurekaInstanceDiscovery.getInstanceList(EurekaInstanceDiscovery.java:88)
处com.netflix com.netflix.turbine.discovery.InstanceObservable.getInstanceList(InstanceObservable.java:327)
。 turbine.discovery.InstanceObservable.access $ 500(InstanceObservable.java:66)
at com.netflix.turbine.discovery.InstanceObservable $ 1.run(InstanceObservable.java:258)
在java.util.TimerThread。 mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)

我尝试写入'default'以及 default ,但结果不幸是相同的。

解决方案



感谢Dave Syer寻找合适的解决方案。基本上是什么添加了:

 涡轮:
clusterNameExpression:new String(default)

application.yml 涡轮服务器应用程序实例中的文件。它可能看起来很奇怪,我不相信它会起作用,但确实如此。现在,当我打电话给我的hystrix客户端应用程序时,我会在 hystrix.stream 中获得由此应用程序提供并位于 turbine.stream 也是如此。我在涡轮服务器中的当前 application.yml 如下所示:

  info :
组件:涡轮

涡轮:
clusterNameExpression:new String(default)
appConfig:pdf-creator-service

服务器:
端口:8989

管理:
端口:8990

eureka:
实例:
leaseRenewalIntervalInSeconds:10
客户:
serviceUrl:
defaultZone:$ {vcap.services。$ {PREFIX:} eureka.credentials.uri:http:// user:password @ localhost:8761} / eureka /

turbine.appConfig 包含关于hystrix客户(通过他们的ID)。要添加另一个客户端到你的涡轮服务器,你将不得不简单地把另一个实例ID,与先前的一个昏迷分开。这就是所有人:)

解决方案

它适用于我,如果我为群集添加一些配置,例如

 涡轮:
appConfig:客户,商店
clusterNameExpression:new String('default')

Turbine必须知道如何构建集群名称(应用程序集合的集合键)。默认是使用appname,所以如果你不设置 clusterNameExpression ,你需要在流URL中使用一个查询参数, /turbine.stream?cluster=CUSTOMERS (uppercased appname)。


I'm trying to run Spring Boot (with Spring Cloud) + Eureka Server + Hystrix Dashboard and Turbine stream, but I run into a problem I couldn't find any solution so far. I use Spring Boot 1.2.1.RELEASE and Spring Cloud 1.0.0.RC2. Here is what I have:

The first instance is running Eureka server and Hystrix dashboard:

@Configuration
@EnableAutoConfiguration
@EnableEurekaServer
@EnableHystrixDashboard
@EnableDiscoveryClient
class Application {

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

Here you can find build.gradle for that instance - https://gist.github.com/wololock/570272ad7cf2d14a4d3c

Eureka server is running ok, I can see registered instances on eureka server dashboard, I can also use LoadBalancer to get the URL to registered instance using its id. So far everything is ok.

I have a few instances that are run with @EnableHystrix annotation and use @HystrixCommand to define which methods have to be monitored by Hystrix. When I pass URL to hystrix.stream of single instance to Hystrix dashboard, I can see it running with no problem.

I have also separate Turbine server, not complicated one:

@EnableAutoConfiguration
@EnableTurbine
@Configuration
@EnableDiscoveryClient
class Application {

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

Here you can find build.gradle for Turbine server instance - https://gist.github.com/wololock/ff0d855b8a890232851e

It uses very simple configuration, build mostly on the one provided by sample turbine app - https://github.com/spring-cloud-samples/turbine

info:
  component: Turbine

endpoints:
  restart:
    enabled: true
  shutdown:
    enabled: true

turbine:
  appConfig: pdf-creator-service

InstanceDiscovery:
  impl: io.spring.platform.netflix.turbine.EurekaInstanceDiscovery

server:
  port: 8989

management:
  port: 8990

eureka:
  instance:
    leaseRenewalIntervalInSeconds: 10
  client:
    serviceUrl:
      defaultZone: ${vcap.services.${PREFIX:}eureka.credentials.uri:http://user:password@localhost:8761}/eureka/

After running those instances in order:

  1. eureka server
  2. turbine server
  3. discover client instance,

I have 2nd and 3rd instance registered in eureka server, turbine server log says, that there is one instance up:

[2015-02-06 12:35:04.162] boot - 20495  INFO [Timer-0] --- EurekaInstanceDiscovery: Fetching instance list for apps: [pdf-creator-service]
[2015-02-06 12:35:04.162] boot - 20495  INFO [Timer-0] --- EurekaInstanceDiscovery: Fetching instances for app: pdf-creator-service
[2015-02-06 12:35:04.162] boot - 20495  INFO [Timer-0] --- EurekaInstanceDiscovery: Received instance list for app: pdf-creator-service = 1
[2015-02-06 12:35:04.162] boot - 20495  INFO [Timer-0] --- InstanceObservable: Retrieved hosts from InstanceDiscovery: 1
[2015-02-06 12:35:04.162] boot - 20495  INFO [Timer-0] --- InstanceObservable: Found hosts that have been previously terminated: 0
[2015-02-06 12:35:04.162] boot - 20495  INFO [Timer-0] --- InstanceObservable: Hosts up:1, hosts down: 0
[2015-02-06 12:36:04.162] boot - 20495  INFO [Timer-0] --- EurekaInstanceDiscovery: Fetching instance list for apps: [pdf-creator-service]
[2015-02-06 12:36:04.162] boot - 20495  INFO [Timer-0] --- EurekaInstanceDiscovery: Fetching instances for app: pdf-creator-service
[2015-02-06 12:36:04.162] boot - 20495  INFO [Timer-0] --- EurekaInstanceDiscovery: Received instance list for app: pdf-creator-service = 1
[2015-02-06 12:36:04.162] boot - 20495  INFO [Timer-0] --- InstanceObservable: Retrieved hosts from InstanceDiscovery: 1
[2015-02-06 12:36:04.162] boot - 20495  INFO [Timer-0] --- InstanceObservable: Found hosts that have been previously terminated: 0
[2015-02-06 12:36:04.162] boot - 20495  INFO [Timer-0] --- InstanceObservable: Hosts up:1, hosts down: 0

Calling hystrix.stream from a single instance works, e.g. curl http://localhost:8885/hystrix.stream returns:

data: {"type":"HystrixCommand","name":"post","group":"PdfController","currentTime":1423223614259,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount":0,"requestCount":0,"rollingCountCollapsedRequests":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackFailure":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":0,"currentConcurrentExecutionCount":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":8000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1}

data: {"type":"HystrixCommand","name":"generate","group":"WkHtmlToPdfGenerator","currentTime":1423223614259,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount":0,"requestCount":0,"rollingCountCollapsedRequests":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackFailure":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":0,"currentConcurrentExecutionCount":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":8000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1}

data: {"type":"HystrixThreadPool","name":"PdfController","currentTime":1423223614259,"currentActiveCount":0,"currentCompletedTaskCount":4,"currentCorePoolSize":10,"currentLargestPoolSize":4,"currentMaximumPoolSize":10,"currentPoolSize":4,"currentQueueSize":0,"currentTaskCount":4,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"reportingHosts":1}

But when I attach turbine.stream to hystrix dashboard, I get nothing. Logs say:

[2015-02-06 12:42:48.922] boot - 24816  INFO [Timer-0] --- EurekaInstanceDiscovery: Received instance list for app: pdf-creator-service = 1
[2015-02-06 12:42:48.922] boot - 24816  INFO [Timer-0] --- InstanceObservable: Retrieved hosts from InstanceDiscovery: 1
[2015-02-06 12:42:48.922] boot - 24816  INFO [Timer-0] --- InstanceObservable: Found hosts that have been previously terminated: 0
[2015-02-06 12:42:48.922] boot - 24816  INFO [Timer-0] --- InstanceObservable: Hosts up:1, hosts down: 0
[2015-02-06 12:43:26.237] boot - 24816  INFO [XNIO-2 task-4] --- TurbineStreamServlet: FilterCriteria: []
[2015-02-06 12:43:26.237] boot - 24816  INFO [XNIO-2 task-4] --- TurbineStreamServlet: StatsType filters: []
[2015-02-06 12:43:26.237] boot - 24816  INFO [XNIO-2 task-4] --- TurbineStreamingConnection: Relevance config: []
[2015-02-06 12:43:26.237] boot - 24816  INFO [XNIO-2 task-4] --- TurbineStreamingConnection: Relevance metrics config: {}
[2015-02-06 12:43:26.237] boot - 24816  INFO [XNIO-2 task-4] --- ClusterMonitor: Registering event handler for cluster monitor: StreamingHandler_f1308dda-58c5-47a5-b1e2-5a0bea32226b
[2015-02-06 12:43:26.237] boot - 24816  INFO [XNIO-2 task-4] --- TurbineDataDispatcher: 

Just added and starting handler tuple: StreamingHandler_f1308dda-58c5-47a5-b1e2-5a0bea32226b
[2015-02-06 12:43:26.238] boot - 24816  INFO [XNIO-2 task-4] --- AggDataFromCluster: Per handler dispacher started for: StreamingHandler_f1308dda-58c5-47a5-b1e2-5a0bea32226b
[2015-02-06 12:43:26.238] boot - 24816  INFO [XNIO-2 task-4] --- ClusterMonitor: All event handlers for cluster monitor: [StreamingHandler_637572ab-acda-4bf4-81cd-6a658adb73eb, StreamingHandler_f1308dda-58c5-47a5-b1e2-5a0bea32226b, StaticListener_For_Aggregator, StreamingHandler_5ec12ee8-3fcd-4a6f-9006-d2a6ecc309d0, StreamingHandler_72d7b9e2-ad98-42a0-9ac3-abe4aa57cc7a]
[2015-02-06 12:43:26.238] boot - 24816  INFO [XNIO-2 task-4] --- ClusterMonitor: Starting up the cluster monitor for default_agg

If I do curl http://localhost:8989/turbine.stream I get only:

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223006935}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223010935}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223013936}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223017936}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223020937}

: ping
: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223024937}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223028938}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223032938}

: ping
: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223036938}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223039939}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223043939}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223046940}

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223050940}

: ping
: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1423223054941}

My question is: do I missed something in setting it up and running? Previously I tried to manage this by having eureka and turbine server in single instance, but in that case turbine couldn't even find the registered application in eureka using proper application name. I made a progress after splitting eureka and turbine, but it still does not work correctly.

I will be grateful for any suggestion. If you need more information, just let me know, I might miss something important.

UPDATE 20150209

Following Dave's suggestion I applied small changes in application.yml file of turbine-server. Now the file contains only:

info:
  component: Turbine

turbine:
  appConfig: pdf-creator-service
  clusterNameExpression: 'default'

server:
  port: 8989

management:
  port: 8990

eureka:
  instance:
    leaseRenewalIntervalInSeconds: 10
  client:
    serviceUrl:
      defaultZone: ${vcap.services.${PREFIX:}eureka.credentials.uri:http://user:password@localhost:8761}/eureka/

But it doesn't make turbine.stream working. After turbine-server gets aware of registered client in eureka server, it fails with given exception:

[2015-02-09 21:25:03.516] boot - 4808  INFO [Timer-0] --- EurekaInstanceDiscovery: Fetching instance list for apps: [pdf-creator-service]
[2015-02-09 21:25:03.516] boot - 4808  INFO [Timer-0] --- EurekaInstanceDiscovery: Fetching instances for app: pdf-creator-service
[2015-02-09 21:25:03.516] boot - 4808  INFO [Timer-0] --- EurekaInstanceDiscovery: Received instance list for app: pdf-creator-service = 1
[2015-02-09 21:25:03.520] boot - 4808 ERROR [Timer-0] --- EurekaInstanceDiscovery: Failed to fetch instances for app: pdf-creator-service, retrying once more
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'default' cannot be found on object of type 'com.netflix.appinfo.InstanceInfo' - maybe not public?
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:226)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:93)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:81)
    at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120)
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:242)
    at org.springframework.cloud.netflix.turbine.EurekaInstanceDiscovery.getClusterName(EurekaInstanceDiscovery.java:183)
    at org.springframework.cloud.netflix.turbine.EurekaInstanceDiscovery.marshallInstanceInfo(EurekaInstanceDiscovery.java:141)
    at org.springframework.cloud.netflix.turbine.EurekaInstanceDiscovery.getInstancesForApp(EurekaInstanceDiscovery.java:123)
    at org.springframework.cloud.netflix.turbine.EurekaInstanceDiscovery.getInstanceList(EurekaInstanceDiscovery.java:88)
    at com.netflix.turbine.discovery.InstanceObservable.getInstanceList(InstanceObservable.java:327)
    at com.netflix.turbine.discovery.InstanceObservable.access$500(InstanceObservable.java:66)
    at com.netflix.turbine.discovery.InstanceObservable$1.run(InstanceObservable.java:258)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

I tried writting 'default' as well as default, but the result is unfortunately the same.

Solution

Thanks Dave Syer for finding the proper solution. Basically what did the trick was adding:

turbine:
    clusterNameExpression: new String("default")

to application.yml file in turbine server application instance. It might look weird, I didn't believe it will work, but it does. Now when I call my hystrix client application I get the proper information in hystrix.stream that is served by this application and in turbine.stream of Turbine server as well. My current application.yml in turbine server looks as follows:

info:
  component: Turbine

turbine:
  clusterNameExpression: new String("default")
  appConfig: pdf-creator-service

server:
  port: 8989

management:
  port: 8990

eureka:
  instance:
    leaseRenewalIntervalInSeconds: 10
  client:
    serviceUrl:
      defaultZone: ${vcap.services.${PREFIX:}eureka.credentials.uri:http://user:password@localhost:8761}/eureka/

turbine.appConfig holds the information about the hystrix clients (by their IDs). To add another client to your turbine server you will have to simply put another instance id, coma separated with the previous one. And that's all folks :)

解决方案

It works for me if I add some configuration for the cluster, e.g.

turbine:
  appConfig: customers,stores
  clusterNameExpression: new String('default')

Turbine has to know how to construct the "cluster" name (an aggregation key for sets of applications). The default is to use the appname, so if you don't set the clusterNameExpression you need to use a query param in the stream URL, e.g. /turbine.stream?cluster=CUSTOMERS (uppercased appname).

这篇关于Spring Boot + Eureka Server + Hystrix with Turbine:空的turbine.stream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆