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


Java HystrixCommand.Setter方法代码示例

本文整理汇总了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();
}
 
开发者ID:spring-cloud-samples,项目名称:brewery,代码行数:24,代码来源:Bottler.java

示例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));
		}
	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:FeignClientTests.java

示例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));
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:9,代码来源:SetterFactory.java

示例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();
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:32,代码来源:TraceCommandTests.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:HystrixProcessor.java

示例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());
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:13,代码来源:HystrixCommandMetadataFactoryTest.java

示例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;
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:9,代码来源:HystrixCircuitBreakerEndpointCallExecutable.java

示例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());
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:13,代码来源:HystrixCommandMetadataFactoryTest.java

示例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());
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:16,代码来源:HystrixCommandMetadataFactoryTest.java

示例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;
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:11,代码来源:HystrixCommandMetadataFactory.java

示例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();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:31,代码来源:TraceCommandTests.java

示例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);
}
 
开发者ID:jewzaam,项目名称:hystrixexample,代码行数:9,代码来源:HystrixConfiguration.java

示例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())
            );
}
 
开发者ID:jewzaam,项目名称:hystrixexample,代码行数:14,代码来源:HystrixConfiguration.java

示例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());
}
 
开发者ID:dehora,项目名称:outland,代码行数:7,代码来源:HystrixConfiguration.java

示例15: BaseHystrixCommandEndpointCallExecutableFactory

import com.netflix.hystrix.HystrixCommand; //导入方法依赖的package包/类
protected BaseHystrixCommandEndpointCallExecutableFactory(HystrixCommand.Setter hystrixMetadata) {
	this(hystrixMetadata, null);
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:4,代码来源:BaseHystrixCommandEndpointCallExecutableFactory.java


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