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


Java HystrixPlugins.reset方法代码示例

本文整理汇总了Java中com.netflix.hystrix.strategy.HystrixPlugins.reset方法的典型用法代码示例。如果您正苦于以下问题:Java HystrixPlugins.reset方法的具体用法?Java HystrixPlugins.reset怎么用?Java HystrixPlugins.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.netflix.hystrix.strategy.HystrixPlugins的用法示例。


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

示例1: init

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
/**
 * registers the {@link ExecutionContextAwareHystrixStrategy}
 */
public static void init() {
    // keeps references of existing Hystrix plugins.
    HystrixConcurrencyStrategy existingConcurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
    HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
    HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
    HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
    HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();
    // reset the Hystrix plugin
    HystrixPlugins.reset();
    // configure the  plugin
    HystrixPlugins.getInstance().registerConcurrencyStrategy(new ExecutionContextAwareHystrixStrategy(existingConcurrencyStrategy));
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
    log.info("Context propagation enabled for Hystrix.");
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:21,代码来源:PreservesExecutionContextHystrixStrategy.java

示例2: bindTo

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Override
public void bindTo(MeterRegistry registry) {
    // Keeps references of existing Hystrix plugins.
    HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
    HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
    HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();
    HystrixConcurrencyStrategy concurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();

    HystrixPlugins.reset();

    // Registers existing plugins except the new MicroMeter Strategy plugin.
    HystrixPlugins.getInstance().registerMetricsPublisher(new MicrometerMetricsPublisher(registry));
    HystrixPlugins.getInstance().registerConcurrencyStrategy(concurrencyStrategy);
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:18,代码来源:HystrixMetricsBinder.java

示例3: init

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@PostConstruct
public void init() {
	// Keeps references of existing Hystrix plugins.
	HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance()
			.getEventNotifier();
	HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance()
			.getMetricsPublisher();
	HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance()
			.getPropertiesStrategy();
	HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance()
			.getCommandExecutionHook();

	HystrixPlugins.reset();

	// Registers existing plugins excepts the Concurrent Strategy plugin.
	HystrixPlugins.getInstance().registerConcurrencyStrategy(
			new SecurityContextConcurrencyStrategy(existingConcurrencyStrategy));
	HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
	HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
	HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
	HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:23,代码来源:HystrixSecurityAutoConfiguration.java

示例4: testCreateBizkeeperCommand

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Test
public void testCreateBizkeeperCommand() {
  HystrixPlugins.reset();
  ConsumerBizkeeperHandler consumerBizkeeperHandler = new ConsumerBizkeeperHandler();

  Invocation invocation = Mockito.mock(Invocation.class);
  Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
  Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");

  CommandKey.toHystrixCommandGroupKey("groupname", invocation);
  CommandKey.toHystrixCommandKey("groupname", invocation);
  BizkeeperCommand command = consumerBizkeeperHandler.createBizkeeperCommand(invocation);
  Assert.assertNotNull(command);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:TestConsumerBizkeeperHandler.java

示例5: testCreateBizkeeperCommand

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Test
public void testCreateBizkeeperCommand() {
  HystrixPlugins.reset();
  ProviderBizkeeperHanlder providerBizkeeperHanlder = new ProviderBizkeeperHanlder();

  Invocation invocation = Mockito.mock(Invocation.class);
  Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
  Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");

  CommandKey.toHystrixCommandGroupKey("groupname", invocation);
  CommandKey.toHystrixCommandKey("groupname", invocation);
  BizkeeperCommand command = providerBizkeeperHanlder.createBizkeeperCommand(invocation);
  Assert.assertNotNull(command);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:TestProviderBizkeeperHandler.java

示例6: testHandleWithException

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Test
public void testHandleWithException() {
  boolean validAssert;
  HystrixPlugins.reset();
  try {
    validAssert = true;
    bizkeeperHandler.handle(invocation, asyncResp);
  } catch (Exception e) {
    validAssert = false;
  }
  Assert.assertFalse(validAssert);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:13,代码来源:TestBizkeeperHandler.java

示例7: testSetCommonProperties

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Test
public void testSetCommonProperties() {
  boolean validAssert;
  try {
    validAssert = true;
    HystrixPlugins.reset();
    HystrixCommandProperties.Setter setter = Mockito.mock(HystrixCommandProperties.Setter.class);
    bizkeeperHandler.setCommonProperties(invocation, setter);
  } catch (Exception e) {
    validAssert = false;
  }
  Assert.assertTrue(validAssert);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:14,代码来源:TestBizkeeperHandler.java

示例8: setUp

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

示例9: TracingConcurrencyStrategy

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
private TracingConcurrencyStrategy(Tracer tracer) {
    this.tracer = tracer;
    try {
        this.delegateStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
        if (this.delegateStrategy instanceof TracingConcurrencyStrategy) {
            return;
        }

        HystrixCommandExecutionHook commandExecutionHook =
            HystrixPlugins.getInstance().getCommandExecutionHook();
        HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
        HystrixMetricsPublisher metricsPublisher =
            HystrixPlugins.getInstance().getMetricsPublisher();
        HystrixPropertiesStrategy propertiesStrategy =
            HystrixPlugins.getInstance().getPropertiesStrategy();

        HystrixPlugins.reset();
        HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
        HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
        HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
        HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
        HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    } catch (Exception ex) {
        log.log(Level.SEVERE, "Failed to register " + TracingConcurrencyStrategy.class +
            ", to HystrixPlugins", ex);
    }
}
 
开发者ID:OpenFeign,项目名称:feign-opentracing,代码行数:28,代码来源:TracingConcurrencyStrategy.java

示例10: SleuthHystrixConcurrencyStrategy

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
public SleuthHystrixConcurrencyStrategy(Tracer tracer, TraceKeys traceKeys) {
	this.tracer = tracer;
	this.traceKeys = traceKeys;
	try {
		this.delegate = HystrixPlugins.getInstance().getConcurrencyStrategy();
		if (this.delegate instanceof SleuthHystrixConcurrencyStrategy) {
			// Welcome to singleton hell...
			return;
		}
		HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins
				.getInstance().getCommandExecutionHook();
		HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance()
				.getEventNotifier();
		HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance()
				.getMetricsPublisher();
		HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance()
				.getPropertiesStrategy();
		logCurrentStateOfHysrixPlugins(eventNotifier, metricsPublisher,
				propertiesStrategy);
		HystrixPlugins.reset();
		HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
		HystrixPlugins.getInstance()
				.registerCommandExecutionHook(commandExecutionHook);
		HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
		HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
		HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
	}
	catch (Exception e) {
		log.error("Failed to register Sleuth Hystrix Concurrency Strategy", e);
	}
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:32,代码来源:SleuthHystrixConcurrencyStrategy.java

示例11: setup

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Before
@After
public void setup() {
	ExceptionUtils.setFail(true);
	HystrixPlugins.reset();
	this.spanReporter.getSpans().clear();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:8,代码来源:SleuthHystrixConcurrencyStrategyTest.java

示例12: beforeClass

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
  //reset because concurrent strategy is registered with different tracer
  HystrixPlugins.reset();
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-cloud,代码行数:6,代码来源:TracedHystrixCommandTest.java

示例13: reset

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Before
public void reset() {
    HystrixPlugins.reset();
    mocks.forEach(Mockito::reset);
}
 
开发者ID:ringcentral,项目名称:hystrix-addons,代码行数:6,代码来源:HystrixMetricsInitializationNotifierTest.java

示例14: before

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Override
public void before() throws IOException {
    HystrixPlugins.reset();
    TracingConcurrencyStrategy.register(mockTracer);
    super.before();
}
 
开发者ID:OpenFeign,项目名称:feign-opentracing,代码行数:7,代码来源:HystrixFeignTracingTest.java

示例15: setup

import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Before
public void setup() {
	HystrixPlugins.reset();
	TestSpanContextHolder.removeCurrentSpan();
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:6,代码来源:TraceCommandTests.java


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