如何配置ClusterMonitorFactory用于涡轮机的插件?

时间:2016-01-20 19:15:06

标签: spring-boot netflix hystrix turbine

我开始使用netflix涡轮机。

我有一个小的弹簧启动应用程序,需要用作涡轮机服务器:

#Outside the trial loop
imgList = glob.glob(os.path.join('stim', '*.png'))
random.shuffle(imgList)

#Inside the trial loop
targetset = []
for i in range(0,3):
    targetset.append(imgList.pop())
#Do your display stuff with targetset
if random.randint(0,1) == 0:
   pics = targetset
else:
   pics = []
   pics.append(targetset[random.randint(0,2)])
   pics.append(imgList.pop())
   pics.append(imgList.pop())
random.shuffle(pics)
#Do your display stuff with pics 

具有以下依赖关系

import com.netflix.turbine.streaming.servlet.TurbineStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class TurbineServer {

    @Bean
    public ServletRegistrationBean hystrixStream(){
        return new ServletRegistrationBean(new TurbineStreamServlet(), "/turbine.stream");
    }

    public static void main(String args[]) {

        SpringApplication.run(TurbineServer.class, args);

    }
}

以及config.properties中的以下配置:

 <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>1.3.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.netflix.turbine</groupId>
            <artifactId>turbine-core</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>

但是当我在网络浏览器中打开我的turbine.stream时,我收到以下错误:

turbine.aggregator.clusterConfig=movieClientCluster
turbine.instanceUrlSuffix=:8081/hystrix.stream
turbine.ConfigPropertyBasedDiscovery.default.instances=localhost
turbine.ConfigPropertyBasedDiscovery.movieClientCluster.instances=localhost

知道我忘记了什么吗?

1 个答案:

答案 0 :(得分:1)

找到解决方案。 缺少以下代码:

TurbineInit.init();

这是我的完整申请:

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class TurbineServer {

    @Bean
    public ServletRegistrationBean hystrixStream(){
        return new ServletRegistrationBean(new TurbineStreamServlet(), "/turbine.stream");
    }

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