本文整理汇总了Java中com.netflix.hystrix.HystrixCommand.Setter方法的典型用法代码示例。如果您正苦于以下问题:Java HystrixCommand.Setter方法的具体用法?Java HystrixCommand.Setter怎么用?Java HystrixCommand.Setter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.hystrix.HystrixCommand
的用法示例。
在下文中一共展示了HystrixCommand.Setter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bottle
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
/**
* [SLEUTH] TraceCommand
*/
@Override
public void bottle(Wort wort, String processId, String testCommunicationType) {
log.info("I'm in the bottling service");
log.info("Process ID from headers {}", processId);
String groupKey = "bottling";
String commandKey = "bottle";
HystrixCommand.Setter setter = HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
TestConfigurationHolder testConfigurationHolder = TestConfigurationHolder.TEST_CONFIG.get();
new TraceCommand<Void>(tracer, traceKeys, setter) {
@Override
public Void doRun() throws Exception {
TestConfigurationHolder.TEST_CONFIG.set(testConfigurationHolder);
log.info("Sending info to bottling service about process id [{}]", processId);
bottlerService.bottle(wort, processId);
return null;
}
}.execute();
}
示例2: commandKeyIsRequestLineSetterFactory
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
@Bean
public SetterFactory commandKeyIsRequestLineSetterFactory() {
return new SetterFactory() {
@Override public HystrixCommand.Setter create(Target<?> target,
Method method) {
String groupKey = SETTER_PREFIX + target.name();
RequestMapping requestMapping = method
.getAnnotation(RequestMapping.class);
String commandKey =
SETTER_PREFIX + requestMapping.method()[0] + " " + requestMapping
.path()[0];
return HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
}
};
}
示例3: create
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
@Override
public HystrixCommand.Setter create(Target<?> target, Method method) {
String groupKey = target.name();
String commandKey = Feign.configKey(target.type(), method);
return HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
}
示例4: should_pass_tracing_information_when_using_Hystrix_commands
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
@Test
public void should_pass_tracing_information_when_using_Hystrix_commands() {
Tracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(),
new DefaultSpanNamer(), new NoOpSpanLogger(), new NoOpSpanReporter());
TraceKeys traceKeys = new TraceKeys();
HystrixCommand.Setter setter = HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("group"))
.andCommandKey(HystrixCommandKey.Factory.asKey("command"));
// tag::hystrix_command[]
HystrixCommand<String> hystrixCommand = new HystrixCommand<String>(setter) {
@Override
protected String run() throws Exception {
return someLogic();
}
};
// end::hystrix_command[]
// tag::trace_hystrix_command[]
TraceCommand<String> traceCommand = new TraceCommand<String>(tracer, traceKeys, setter) {
@Override
public String doRun() throws Exception {
return someLogic();
}
};
// end::trace_hystrix_command[]
String resultFromHystrixCommand = hystrixCommand.execute();
String resultFromTraceCommand = traceCommand.execute();
then(resultFromHystrixCommand).isEqualTo(resultFromTraceCommand);
then(tracer.getCurrentSpan()).isNull();
}
示例5: HystrixProcessor
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
public HystrixProcessor(HystrixCommandGroupKey groupKey, HystrixCommandKey commandKey, HystrixCommandKey fallbackCommandKey,
HystrixCommand.Setter setter, HystrixCommand.Setter fallbackSetter,
Processor processor, Processor fallback, boolean fallbackViaNetwork) {
this.groupKey = groupKey;
this.commandKey = commandKey;
this.fallbackCommandKey = fallbackCommandKey;
this.setter = setter;
this.fallbackSetter = fallbackSetter;
this.processor = processor;
this.fallback = fallback;
this.fallbackViaNetwork = fallbackViaNetwork;
}
示例6: shouldBuildHystrixCommandKeysUsingMethodMetadata
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
@Test
public void shouldBuildHystrixCommandKeysUsingMethodMetadata() throws Exception {
factory = new HystrixCommandMetadataFactory(new SimpleEndpointMethod(MyApiWithCircuitBreaker.class.getMethod("simple")));
HystrixCommand.Setter hystrixMetadata = factory.create();
EmptyHystrixCommand command = new EmptyHystrixCommand(hystrixMetadata);
assertEquals("MyApiWithCircuitBreaker", command.getCommandGroup().name());
assertEquals("MyApiWithCircuitBreaker.simple", command.getCommandKey().name());
assertEquals("MyApiWithCircuitBreaker", command.getThreadPoolKey().name());
}
示例7: HystrixCircuitBreakerEndpointCallExecutable
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
public HystrixCircuitBreakerEndpointCallExecutable(HystrixCommand.Setter hystrixMetadata, EndpointMethod endpointMethod,
EndpointCallExecutable<T, R> delegate, Object fallback) {
this.hystrixMetadata = hystrixMetadata;
this.endpointMethod = endpointMethod;
this.delegate = delegate;
this.fallback = fallback;
}
示例8: shouldBuildHystrixCommandKeysUsingMethodAnnotation
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
@Test
public void shouldBuildHystrixCommandKeysUsingMethodAnnotation() throws Exception {
factory = new HystrixCommandMetadataFactory(new SimpleEndpointMethod(MyApiWithCircuitBreaker.class.getMethod("customizedKeys")));
HystrixCommand.Setter hystrixMetadata = factory.create();
EmptyHystrixCommand command = new EmptyHystrixCommand(hystrixMetadata);
assertEquals("myGroupKey", command.getCommandGroup().name());
assertEquals("myTestCommandKey", command.getCommandKey().name());
assertEquals("myTestThreadPoolKey", command.getThreadPoolKey().name());
}
示例9: shouldBuildHystrixCommandPropertiesUsingMethodAnnotation
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
@Test
public void shouldBuildHystrixCommandPropertiesUsingMethodAnnotation() throws Exception {
factory = new HystrixCommandMetadataFactory(new SimpleEndpointMethod(MyApiWithCircuitBreaker.class.getMethod("customizedProperties")));
HystrixCommand.Setter hystrixMetadata = factory.create();
EmptyHystrixCommand command = new EmptyHystrixCommand(hystrixMetadata);
assertEquals("MyApiWithCircuitBreaker", command.getCommandGroup().name());
assertEquals("MyApiWithCircuitBreaker.customizedProperties", command.getCommandKey().name());
assertEquals("MyApiWithCircuitBreaker", command.getThreadPoolKey().name());
assertEquals(ExecutionIsolationStrategy.SEMAPHORE, command.getProperties().executionIsolationStrategy().get());
assertEquals(Integer.valueOf(2500), command.getProperties().executionTimeoutInMilliseconds().get());
}
示例10: create
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
public HystrixCommand.Setter create() {
HystrixCommand.Setter setter = HystrixCommand.Setter
.withGroupKey(groupKey())
.andCommandKey(commandKey())
.andThreadPoolKey(threadPoolKey())
.andCommandPropertiesDefaults(commandProperties())
.andThreadPoolPropertiesDefaults(threadPoolProperties());
return setter;
}
示例11: should_pass_tracing_information_when_using_Hystrix_commands
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
@Test
public void should_pass_tracing_information_when_using_Hystrix_commands() {
Tracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(),
new DefaultSpanNamer(), new NoOpSpanLogger(), new NoOpSpanReporter(), new TraceKeys());
TraceKeys traceKeys = new TraceKeys();
HystrixCommand.Setter setter = withGroupKey(asKey("group"))
.andCommandKey(HystrixCommandKey.Factory.asKey("command"));
// tag::hystrix_command[]
HystrixCommand<String> hystrixCommand = new HystrixCommand<String>(setter) {
@Override
protected String run() throws Exception {
return someLogic();
}
};
// end::hystrix_command[]
// tag::trace_hystrix_command[]
TraceCommand<String> traceCommand = new TraceCommand<String>(tracer, traceKeys, setter) {
@Override
public String doRun() throws Exception {
return someLogic();
}
};
// end::trace_hystrix_command[]
String resultFromHystrixCommand = hystrixCommand.execute();
String resultFromTraceCommand = traceCommand.execute();
then(resultFromHystrixCommand).isEqualTo(resultFromTraceCommand);
then(tracer.getCurrentSpan()).isNull();
}
示例12: Setter
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
public static HystrixCommand.Setter Setter(Class x, String groupName) {
HystrixConfiguration config = configs.get(x);
if (config == null) {
config = new HystrixConfiguration(x);
configs.put(x, config);
}
return config.setter(x, groupName);
}
示例13: setter
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
private HystrixCommand.Setter setter(Class clazz, String groupName) {
String name = clazz.getSimpleName() + ":" + groupName;
return HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(name))
.andCommandKey(HystrixCommandKey.Factory.asKey(name))
.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey(name))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.valueOf(executionIsolationStrategy.get()))
.withExecutionIsolationSemaphoreMaxConcurrentRequests(executionIsolationSemaphoreMaxConcurrentRequests.get())
.withExecutionIsolationThreadInterruptOnTimeout(executionIsolationThreadInterruptOnTimeout.get())
.withExecutionIsolationThreadTimeoutInMilliseconds(executionIsolationThreadTimeoutInMilliseconds.get())
.withFallbackIsolationSemaphoreMaxConcurrentRequests(fallbackIsolationSemaphoreMaxConcurrentRequests.get())
);
}
示例14: getHystrixCommandSetter
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
public HystrixCommand.Setter getHystrixCommandSetter() {
return HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(hystrixCommandGroupKey))
.andCommandPropertiesDefaults(getHystrixCommandProperties())
.andThreadPoolPropertiesDefaults(threadpool.getHystrixThreadPoolPropertiesSetter());
}
示例15: BaseHystrixCommandEndpointCallExecutableFactory
import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
protected BaseHystrixCommandEndpointCallExecutableFactory(HystrixCommand.Setter hystrixMetadata) {
this(hystrixMetadata, null);
}