本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例8: setUp
import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Before
public void setUp() {
Hystrix.reset();
HystrixPlugins.reset();
HystrixRequestContext.initializeContext();
HystrixPlugins.getInstance().registerMetricsPublisher(notifier);
}
示例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);
}
}
示例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);
}
}
示例11: setup
import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Before
@After
public void setup() {
ExceptionUtils.setFail(true);
HystrixPlugins.reset();
this.spanReporter.getSpans().clear();
}
示例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();
}
示例13: reset
import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Before
public void reset() {
HystrixPlugins.reset();
mocks.forEach(Mockito::reset);
}
示例14: before
import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Override
public void before() throws IOException {
HystrixPlugins.reset();
TracingConcurrencyStrategy.register(mockTracer);
super.before();
}
示例15: setup
import com.netflix.hystrix.strategy.HystrixPlugins; //导入方法依赖的package包/类
@Before
public void setup() {
HystrixPlugins.reset();
TestSpanContextHolder.removeCurrentSpan();
}