当前位置: 首页>>代码示例>>Java>>正文


Java Hystrix类代码示例

本文整理汇总了Java中com.netflix.hystrix.Hystrix的典型用法代码示例。如果您正苦于以下问题:Java Hystrix类的具体用法?Java Hystrix怎么用?Java Hystrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Hystrix类属于com.netflix.hystrix包,在下文中一共展示了Hystrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@Before
public void setUp() {
    Hystrix.reset();
    HystrixPlugins.reset();
    HystrixRequestContext.initializeContext();
    HystrixPlugins.getInstance().registerMetricsPublisher(notifier);
}
 
开发者ID:ringcentral,项目名称:hystrix-addons,代码行数:8,代码来源:AggregatedHystrixCommandCompletionStreamTest.java

示例2: reset

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@After
public void reset() {
  ConfigurationManager.getConfigInstance()
    .setProperty("hystrix.command.default.circuitBreaker.forceOpen",
      false);

  Hystrix.reset();
}
 
开发者ID:orctom,项目名称:gradle-archetype-plugin,代码行数:9,代码来源:ExampleServiceGetApiTest.java

示例3: initHystrixPlugins

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
private static void initHystrixPlugins() {
	try {
		registerDispatcherStrategies();
	} catch (Exception e) {
		log.warn("Failed to init Hystrix with custom Astrix strategies. Hystrix configuration will be reset and one more registreation attempt will be performed", e);
		Hystrix.reset();
		registerDispatcherStrategies();
	}
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:10,代码来源:HystrixStrategyDispatcher.java

示例4: before

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@Before
public void before() throws InterruptedException {
	Hystrix.reset();
	context = new TestAstrixConfigurer().enableFaultTolerance(true)
										.registerApiProvider(PingApi.class)
										.set(AstrixBeanSettings.TIMEOUT, AstrixBeanKey.create(Ping.class), 250)
										.set(AstrixBeanSettings.CORE_SIZE, AstrixBeanKey.create(Ping.class), 1)
										.set(AstrixThreadPoolProperties.MAX_QUEUE_SIZE, AstrixBeanKey.create(Ping.class), -1) // NO QUEUE
										.set("pingUri", DirectComponent.registerAndGetUri(Ping.class, pingServer))
										.configure();
	ping = context.getBean(Ping.class);
	initMetrics(ping);
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:14,代码来源:HystrixCommandFacadeTest.java

示例5: before

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@Before
public void before() throws InterruptedException {
	Hystrix.reset();
	context = new TestAstrixConfigurer().enableFaultTolerance(true)
										.registerApiProvider(PingApi.class)
										.set(AstrixBeanSettings.TIMEOUT, AstrixBeanKey.create(Ping.class), 25)
										.set(AstrixBeanSettings.MAX_CONCURRENT_REQUESTS, AstrixBeanKey.create(Ping.class), 1)
										.set("pingUri", DirectComponent.registerAndGetUri(Ping.class, pingServer))
										.configure();
	ping = context.getBean(Ping.class);
	initMetrics(ping);
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:13,代码来源:HystrixObservableCommandFacadeTest.java

示例6: setup

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@Before
public void setup() throws InterruptedException {
	Hystrix.reset();
	counter.incrementAndGet();
	astrixConfigurer.registerApiProvider(PingApiProvider.class);
	astrixConfigurer.registerApiProvider(CorruptPingApiProvider.class);
	astrixConfigurer.enableFaultTolerance(true);
	context = (AstrixApplicationContext) astrixConfigurer.configure();
	ping = context.getBean(Ping.class);
	initMetrics(ping);
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:12,代码来源:HystrixFaulttoleranceIntegrationTest.java

示例7: contextDestroyed

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
/**
 * Notification that the servlet context is about to be shut down.
 * @param event ServletContextEvent
 */
public void contextDestroyed(ServletContextEvent event) {
    LOG.debug("HystrixWebListener - contextDestroyed");
    LOG.debug("Invoke Hystrix.reset()");
    Hystrix.reset();
    LOG.debug("Completed Hystrix.reset()");
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:11,代码来源:HystrixWebListener.java

示例8: destroy

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@Override
public void destroy() throws Exception {
    LOG.info("Shutting down Hystrix...");
    // shutdown all thread pools; waiting a little time for shutdown
    Hystrix.reset(1, TimeUnit.SECONDS);
    LOG.info("Shut down Hystrix done.");
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:8,代码来源:Application.java

示例9: deactivate

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
/**
 * Component deactivation callback which is used to reset Hystrix.
 */
@Deactivate
protected void deactivate() {
	Hystrix.reset();
}
 
开发者ID:fassmus,项目名称:liferay-devcon-2016-hystrix,代码行数:8,代码来源:HystrixDemoLocalServiceImpl.java

示例10: tearDown

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@After
public void tearDown() throws Exception {
    Hystrix.reset();
}
 
开发者ID:lreimer,项目名称:cloud-native-javaee,代码行数:5,代码来源:HystrixPluginsIntegrationTest.java

示例11: before

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@Before
public void before() {
	Hystrix.reset();
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:5,代码来源:FaultToleranceMetricsTest.java

示例12: destroy

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@Override
public void destroy() {
    super.destroy();
    Hystrix.reset(5, TimeUnit.SECONDS);
    wrappedServlet.destroy();
}
 
开发者ID:signicat,项目名称:hystrix-servlet,代码行数:7,代码来源:AsyncWrapperServlet.java

示例13: teardown

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@After
public void teardown() {
    Hystrix.reset();
    CollectorRegistry.defaultRegistry.clear();
}
 
开发者ID:ahus1,项目名称:prometheus-hystrix,代码行数:6,代码来源:MetricsPublisherRegistrationTest.java

示例14: teardown

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
@After
public void teardown() {
    CollectorRegistry.defaultRegistry.clear();
    Hystrix.reset();
}
 
开发者ID:ahus1,项目名称:prometheus-hystrix,代码行数:6,代码来源:HystrixCommandTest.java

示例15: doInitialize

import com.netflix.hystrix.Hystrix; //导入依赖的package包/类
private static synchronized void doInitialize(final Type... types) {
    if (initialized) {
        return;
    }

    // Fix Java 7 problem that initialized Hystrix/Servo before the it has been even called
    Hystrix.reset();
    HystrixPlugins.reset();

    // register hystrix servo metrics publisher, required for collecting hystrix metrics
    HystrixPlugins.getInstance().registerMetricsPublisher(HystrixServoMetricsPublisher.getInstance());
    // if IllegalStateException is thrown it means there is a hytrix command being used prior to this setup.
    // SEE: https://github.com/lightblue-platform/lightblue-rest/issues/58
    //      https://github.com/Netflix/Hystrix/issues/150

    List<MetricObserver> observers = new ArrayList<>();

    for (Type type : types) {
        switch (type) {
            case GRAPHITE:
                registerGraphiteMetricObserver(observers, findVariable(ENV_GRAPHITE_PREFIX),
                        findVariable(ENV_GRAPHITE_HOSTNAME), findVariable(ENV_GRAPHITE_PORT));
                break;
            case STATSD:
                registerStatsdMetricObserver(observers, findVariable(ENV_STATSD_PREFIX),
                        findVariable(ENV_STATSD_HOSTNAME), findVariable(ENV_STATSD_PORT));
                break;
            default:
                throw new RuntimeException("Unsupported Type: " + type);
        }
    }

    // start poll scheduler
    PollScheduler.getInstance().start();

    // create and register registery poller
    PollRunnable registeryTask = new PollRunnable(new MonitorRegistryMetricPoller(), BasicMetricFilter.MATCH_ALL, observers);
    PollScheduler.getInstance().addPoller(registeryTask, 5, TimeUnit.SECONDS);

    // create and register jvm poller
    PollRunnable jvmTask = new PollRunnable(new JvmMetricPoller(), BasicMetricFilter.MATCH_ALL, observers);
    PollScheduler.getInstance().addPoller(jvmTask, 5, TimeUnit.SECONDS);

    initialized = true;
    LOGGER.debug("doInitialize() completed, initialized = " + initialized);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:47,代码来源:ServoGraphiteSetup.java


注:本文中的com.netflix.hystrix.Hystrix类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。