我正在尝试设置带有涡轮的hystrix仪表板。我没有使用Eureka,而是想使用FileBasedInstanceDiscovery。我正在尝试配置它,但是遵循在线文档似乎不起作用。它始终尝试使用Eureka发现客户端。我尝试从pom中排除eureka,但随后又退回到另一个发现客户端CommonsInstanceDiscovery
这是我的application.properties:
turbine.aggregator.clusterConf=mycluster
turbine.instanceUrlSuffix.mycluster=8080/hystrix.stream
turbine.FileBasedInstanceDiscovery.filePath=turbine.hostnames.txt
turbine.InstanceMonitor.eventStream.skipLineLogic.enabled=false
InstanceDiscovery.impl=com.netflix.turbine.discovery.FileBasedInstanceDiscovery
还有另一种方法吗?另外,对于我的涡轮主机名的filePath,它从哪里开始寻找?我可以在jar的资源目录下找到该文件吗?
这是我的pom文件依赖项:
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
答案 0 :(得分:0)
一些文档对于涡轮机尚不明确且存在冲突,我认为这是因为存在spring-cloud-netflix项目和独立的涡轮机项目。无论如何,如果您要构建spring-boot应用程序,则此属性无用:
InstanceDiscovery.impl=com.netflix.turbine.discovery.FileBasedInstanceDiscovery
如果要更改InstanceDiscovery的实现非常简单,只需创建一个实现InstanceDiscovery的bean,如下所示:
@Bean
public InstanceDiscovery instanceDiscovery() {
//choose either one of the provided implementations from spring or
//create your own
return new ConfigPropertyBasedDiscovery();
//return new FileBasedInstanceDiscovery();
}
确保将其放在@Configuration类中。我最初只是在SpringBootApplication类中拥有我的类,但这不允许您覆盖默认实现。
答案 1 :(得分:0)
我已经使用了ConfigPropertyBasedDiscovery,但即时通讯低于异常
2020-03-30 13:19:14.360 INFO 17060 --- [ Timer-0] c.n.t.discovery.InstanceObservable : Hosts up:1, hosts down: 0
2020-03-30 13:19:14.371错误17060 --- [Timer-0] cntmonitor.cluster.ClusterMonitor:无法在hostUp上启动监视器:StatsInstance [hostname = localhost:8080,群集:VIBuilder,isUp :是的,attrs = {}]
java.lang.RuntimeException:配置为使用端口,但是端口或securePort不在主机属性中 在org.springframework.cloud.netflix.turbine.SpringClusterMonitor $ 1.getUrlPath(SpringClusterMonitor.java:114)〜[spring-cloud-netflix-turbine-2.2.2.RELEASE.jar:2.2.2.RELEASE] 在com.netflix.turbine.monitor.instance.InstanceMonitor。(InstanceMonitor.java:185)〜[turbine-core-1.0.0.jar:na] 在com.netflix.turbine.monitor.instance.InstanceMonitor。(InstanceMonitor.java:173)〜[turbine-core-1.0.0.jar:na] 在com.netflix.turbine.monitor.cluster.ClusterMonitor $ ClusterMonitorInstanceManager.getMonitor(ClusterMonitor.java:300)〜[turbine-core-1.0.0.jar:na] 在com.netflix.turbine.monitor.cluster.ClusterMonitor $ ClusterMonitorInstanceManager.hostUp(ClusterMonitor.java:268)〜[turbine-core-1.0.0.jar:na] 在com.netflix.turbine.monitor.cluster.ClusterMonitor $ ClusterMonitorInstanceManager.hostsUp(ClusterMonitor.java:312)〜[turbine-core-1.0.0.jar:na] 在com.netflix.turbine.discovery.InstanceObservable $ 1.run(InstanceObservable.java:298)〜[turbine-core-1.0.0.jar:na] 在java.base / java.util.TimerThread.mainLoop(Timer.java:556)〜[na:na] 在java.base / java.util.TimerThread.run(Timer.java:506)〜[na:na]