本文整理汇总了Java中com.netflix.hystrix.HystrixThreadPoolProperties类的典型用法代码示例。如果您正苦于以下问题:Java HystrixThreadPoolProperties类的具体用法?Java HystrixThreadPoolProperties怎么用?Java HystrixThreadPoolProperties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HystrixThreadPoolProperties类属于com.netflix.hystrix包,在下文中一共展示了HystrixThreadPoolProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setter
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
private static Setter setter() {
HystrixCommandGroupKey groupkey = HystrixCommandGroupKey.Factory.asKey("rpc");
HystrixCommandKey commandkey = HystrixCommandKey.Factory.asKey("say");
HystrixThreadPoolKey threadpoolkey = HystrixThreadPoolKey.Factory.asKey("hello-1");
HystrixThreadPoolProperties.Setter threadproperties = HystrixThreadPoolProperties.Setter()//
.withCoreSize(20).withKeepAliveTimeMinutes(5).withMaxQueueSize(1000).withQueueSizeRejectionThreshold(100);
HystrixCommandProperties.Setter commandproperty = HystrixCommandProperties.Setter()//
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD)//
.withFallbackEnabled(true).withFallbackIsolationSemaphoreMaxConcurrentRequests(100)//
.withExecutionIsolationThreadInterruptOnFutureCancel(true)//
.withExecutionIsolationThreadInterruptOnTimeout(true)//
.withExecutionTimeoutEnabled(true).withExecutionTimeoutInMilliseconds(1000);
return HystrixCommand.Setter.withGroupKey(groupkey).andCommandKey(commandkey)//
.andThreadPoolKey(threadpoolkey).andThreadPoolPropertiesDefaults(threadproperties)//
.andCommandPropertiesDefaults(commandproperty);
}
示例2: setter
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
private static Setter setter() {
HystrixCommandGroupKey groupkey = HystrixCommandGroupKey.Factory.asKey("rpc");
HystrixCommandKey commandkey = HystrixCommandKey.Factory.asKey("say");
HystrixThreadPoolKey threadpoolkey = HystrixThreadPoolKey.Factory.asKey("hello-1");
HystrixThreadPoolProperties.Setter threadproperties = HystrixThreadPoolProperties.Setter()//
.withCoreSize(20).withKeepAliveTimeMinutes(5).withMaxQueueSize(1000).withQueueSizeRejectionThreshold(100);
HystrixCommandProperties.Setter commandproperty = HystrixCommandProperties.Setter()//
.withCircuitBreakerEnabled(true).withCircuitBreakerForceClosed(false)//
.withCircuitBreakerForceOpen(false).withCircuitBreakerErrorThresholdPercentage(50)//
.withCircuitBreakerRequestVolumeThreshold(20)//
.withCircuitBreakerSleepWindowInMilliseconds(5000);
return HystrixCommand.Setter.withGroupKey(groupkey).andCommandKey(commandkey)//
.andThreadPoolKey(threadpoolkey).andThreadPoolPropertiesDefaults(threadproperties)//
.andCommandPropertiesDefaults(commandproperty);
}
示例3: GrpcHystrixCommand
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
public GrpcHystrixCommand(String serviceName, String methodName, Boolean isEnabledFallBack) {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(serviceName))//
.andCommandKey(HystrixCommandKey.Factory.asKey(serviceName + ":" + methodName))//
.andCommandPropertiesDefaults(
HystrixCommandProperties.Setter().withCircuitBreakerRequestVolumeThreshold(20)// 10秒钟内至少19此请求失败,熔断器才发挥起作用
.withCircuitBreakerSleepWindowInMilliseconds(30000)// 熔断器中断请求30秒后会进入半打开状态,放部分流量过去重试
.withCircuitBreakerErrorThresholdPercentage(50)// 错误率达到50开启熔断保护
.withExecutionTimeoutEnabled(false)// 禁用这里的超时
.withFallbackEnabled(isEnabledFallBack))//
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(100)
.withAllowMaximumSizeToDivergeFromCoreSize(true).withMaximumSize(Integer.MAX_VALUE)));
this.serviceName = serviceName;
this.methodName = methodName;
this.start = System.currentTimeMillis();
this.rpcContext = new ImmutableTriple<Map<String, String>, Map<String, Object>, Set<Class>>(
RpcContext.getContext().getAttachments(), RpcContext.getContext().get(),
RpcContext.getContext().getHoldenGroups());
RpcContext.removeContext();
}
示例4: DubboHystrixCommand
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
public DubboHystrixCommand(Invoker<?> invoker, final Invocation invocation, final Map<String,String> hystrixMap){
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(invoker.getInterface().getName()))
.andCommandKey(HystrixCommandKey.Factory.asKey(String.format("%s_%d", invocation.getMethodName(),
invocation.getArguments() == null ? 0 : invocation.getArguments().length)))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
//10秒钟内至少19次请求失败,熔断器才发挥起作用
.withCircuitBreakerRequestVolumeThreshold(Integer.parseInt(hystrixMap.get("requestVolume")))
//熔断器中断请求30秒后会进入半打开状态,放部分流量过去重试
.withCircuitBreakerSleepWindowInMilliseconds(Integer.parseInt(hystrixMap.get("sleepMilliseconds")))
//错误率达到50开启熔断保护
.withCircuitBreakerErrorThresholdPercentage(Integer.parseInt(hystrixMap.get("errorPercentage")))
//使用dubbo的超时,禁用这里的超时
.withExecutionTimeoutEnabled(Boolean.valueOf(hystrixMap.get("executionTimeoutEnabled"))))
//线程池为30
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(getThreadPoolCoreSize(invoker.getUrl()))));
this.invoker=invoker;
this.invocation=invocation;
}
示例5: DubboHystrixCommand
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
public DubboHystrixCommand(Invoker<?> invoker,Invocation invocation){
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(invoker.getInterface().getName()))
.andCommandKey(HystrixCommandKey.Factory.asKey(String.format("%s_%d", invocation.getMethodName(),
invocation.getArguments() == null ? 0 : invocation.getArguments().length)))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerRequestVolumeThreshold(invoker.getUrl().getParameter("circuitBreakerRequestVolumeThreshold", circuitBreakerRequestVolumeThreshold))//10秒钟内至少19此请求失败,熔断器才发挥起作用
.withCircuitBreakerSleepWindowInMilliseconds(invoker.getUrl().getParameter("circuitBreakerSleepWindowInMilliseconds",circuitBreakerSleepWindowInMilliseconds))//熔断器中断请求30秒后会进入半打开状态,放部分流量过去重试
.withCircuitBreakerErrorThresholdPercentage(invoker.getUrl().getParameter("circuitBreakerErrorThresholdPercentage",circuitBreakerErrorThresholdPercentage))//错误率达到50开启熔断保护
.withExecutionTimeoutEnabled(false))//使用dubbo的超时,禁用这里的超时
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(invoker.getUrl().getParameter("coreSize",coreSize))));//线程池为30
this.invoker=invoker;
this.invocation=invocation;
}
示例6: HelloWorldCommand3
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
public HelloWorldCommand3(String name) {
super(
Setter.withGroupKey(
HystrixCommandGroupKey.Factory.asKey("HelloWorldGroup"))
.andCommandKey(HystrixCommandKey.Factory.asKey("HelloWorldKey"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
//实行超时
.withExecutionIsolationThreadTimeoutInMilliseconds(
5000)
.withCircuitBreakerRequestVolumeThreshold(2)//10秒钟内至少2此请求失败,熔断器才发挥起作用
.withCircuitBreakerSleepWindowInMilliseconds(3000)//熔断器中断请求30秒后会进入半打开状态,放部分流量过去重试
.withCircuitBreakerErrorThresholdPercentage(50)//错误率达到50开启熔断保护
.withExecutionTimeoutEnabled(false))//使用dubbo的超时,禁用这里的超时
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(3)));//线程池为30
this.name = name;
}
示例7: getCommandSetter
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
/**
* ��·������ �ο� http://hot66hot.iteye.com/blog/2155036
*
* @param joinPoint
* @param cb
* @return
*/
private HystrixCommand.Setter getCommandSetter(ProceedingJoinPoint joinPoint,
com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand cb) {
String name = getHystrixGroupName(joinPoint, cb);
String groupKey = StringUtils.isEmpty(cb.groupKey()) ? name : cb.groupKey();
String commandKey = StringUtils.isEmpty(cb.commandKey()) ? name : cb.commandKey();
HystrixThreadPoolKey hystrixThreadPoolKey = StringUtils.isEmpty(cb.threadPoolKey()) ? null
: HystrixThreadPoolKey.Factory.asKey(cb.threadPoolKey());
HystrixCommandProperties.Setter commandPropertiesDefaults = getHystrixCommandPropertiesSetter(cb);
HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults = getHystrixThreadPoolPropertiesSetter(cb);
return HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey)).andThreadPoolKey(hystrixThreadPoolKey)
.andCommandPropertiesDefaults(commandPropertiesDefaults)
.andThreadPoolPropertiesDefaults(threadPoolPropertiesDefaults);
}
示例8: ManagedHystrixCommandFactory
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
/**
* Creates a new ManagedHystrixCommandFactory
* @param setter the command setter
* @param key The command key
* @param commandPropertySetter the command property setter
* @param threadPoolPropertySetter the thread pool property setter
*/
public ManagedHystrixCommandFactory(final Setter setter, final String key, final HystrixCommandProperties.Setter commandPropertySetter, final HystrixThreadPoolProperties.Setter threadPoolPropertySetter) {
this.setter = setter;
this.key = key;
this.commandPropertySetter = commandPropertySetter;
this.threadPoolPropertySetter = threadPoolPropertySetter;
final HystrixCommand<Object> sampleCommand = new HystrixCommand<Object>(setter) {
@Override
protected Object run() throws Exception {
return null;
}
};
ObjectName tmp = null;
try {
tmp = JMXHelper.objectName(String.format(OBJECT_NAME_TEMPLATE, sampleCommand.getCommandGroup().name(), sampleCommand.getCommandKey().name(), sampleCommand.getThreadPoolKey().name()));
} catch (Exception ex) {
tmp = JMXHelper.objectName(String.format(OBJECT_NAME_TEMPLATE,
ObjectName.quote(sampleCommand.getCommandGroup().name()),
ObjectName.quote(sampleCommand.getCommandKey().name()),
ObjectName.quote(sampleCommand.getThreadPoolKey().name())
));
}
objectName = tmp;
}
示例9: readsDefaultBeanSettingsFromBeanConfiguration
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
@Test
public void readsDefaultBeanSettingsFromBeanConfiguration() throws Throwable {
astrixConfigurer.set(AstrixBeanSettings.CORE_SIZE, AstrixBeanKey.create(Ping.class), 4);
astrixConfigurer.set(AstrixBeanSettings.QUEUE_SIZE_REJECTION_THRESHOLD, AstrixBeanKey.create(Ping.class), 6);
astrixConfigurer.set(AstrixBeanSettings.TIMEOUT, AstrixBeanKey.create(Ping.class), 100);
astrixConfigurer.set(AstrixBeanSettings.MAX_CONCURRENT_REQUESTS, AstrixBeanKey.create(Ping.class), 21);
astrixContext.getBean(Ping.class).ping("foo");
HystrixFaultToleranceFactory hystrixFaultTolerance = getFaultTolerance(astrixContext);
HystrixCommandProperties pingCommandProperties = getHystrixCommandProperties(hystrixFaultTolerance, Ping.class);
HystrixThreadPoolProperties pingThreadPoolProperties = getThreadPoolProperties(hystrixFaultTolerance, Ping.class);
assertEquals(100, pingCommandProperties.executionTimeoutInMilliseconds().get().intValue());
assertEquals(21, pingCommandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get().intValue());
assertEquals(4, pingThreadPoolProperties.coreSize().get().intValue());
assertEquals(6, pingThreadPoolProperties.queueSizeRejectionThreshold().get().intValue());
}
示例10: getTenacityConfiguration
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
public static TenacityConfiguration getTenacityConfiguration(TenacityPropertyKey key) {
final HystrixCommandProperties commandProperties = TenacityCommand.getCommandProperties(key);
final HystrixThreadPoolProperties threadPoolProperties = TenacityCommand.getThreadpoolProperties(key);
return new TenacityConfiguration(
new ThreadPoolConfiguration(
threadPoolProperties.coreSize().get(),
threadPoolProperties.keepAliveTimeMinutes().get(),
threadPoolProperties.maxQueueSize().get(),
threadPoolProperties.queueSizeRejectionThreshold().get(),
threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get(),
threadPoolProperties.metricsRollingStatisticalWindowBuckets().get()),
new CircuitBreakerConfiguration(
commandProperties.circuitBreakerRequestVolumeThreshold().get(),
commandProperties.circuitBreakerSleepWindowInMilliseconds().get(),
commandProperties.circuitBreakerErrorThresholdPercentage().get(),
commandProperties.metricsRollingStatisticalWindowInMilliseconds().get(),
commandProperties.metricsRollingStatisticalWindowBuckets().get()),
new SemaphoreConfiguration(
commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get(),
commandProperties.fallbackIsolationSemaphoreMaxConcurrentRequests().get()),
commandProperties.executionTimeoutInMilliseconds().get(),
commandProperties.executionIsolationStrategy().get());
}
示例11: setter
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
private static Setter setter() {
HystrixCommandGroupKey groupkey = HystrixCommandGroupKey.Factory.asKey("rpc");
HystrixCommandKey commandkey = HystrixCommandKey.Factory.asKey("say");
HystrixThreadPoolKey threadpoolkey = HystrixThreadPoolKey.Factory.asKey("hello-1");
HystrixThreadPoolProperties.Setter threadproperties = HystrixThreadPoolProperties.Setter()//
.withCoreSize(1).withKeepAliveTimeMinutes(1).withMaxQueueSize(1000).withQueueSizeRejectionThreshold(2);
HystrixCommandProperties.Setter commandproperty = HystrixCommandProperties.Setter()//
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD);
return HystrixCommand.Setter.withGroupKey(groupkey).andCommandKey(commandkey)//
.andThreadPoolKey(threadpoolkey).andThreadPoolPropertiesDefaults(threadproperties)//
.andCommandPropertiesDefaults(commandproperty);
}
示例12: TakinHystrixCommand
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
public TakinHystrixCommand(RemotingContext context) {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(context.getProtocol().getDefineClass().getName()))//
.andCommandKey(HystrixCommandKey.Factory.asKey(//
String.format("%s_%d", context.getProtocol().getMethod(), context.getProtocol().getArgs() == null ? 0 : context.getProtocol().getArgs().length)))//
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()//
.withCircuitBreakerRequestVolumeThreshold(20)//10秒钟内至少19此请求失败,熔断器才发挥起作用
.withCircuitBreakerSleepWindowInMilliseconds(30000)//熔断器中断请求30秒后会进入半打开状态,放部分流量过去重试
.withCircuitBreakerErrorThresholdPercentage(50)//错误率达到50开启熔断保护
.withExecutionTimeoutEnabled(false))//使用dubbo的超时,禁用这里的超时
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(DEFAULT_THREADPOOL_CORE_SIZE)));//线程池为30
this.context = context;
logger.info("use TakinHystrixCommand");
}
示例13: setter
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
private static Setter setter() {
HystrixCommandGroupKey groupkey = HystrixCommandGroupKey.Factory.asKey("rpc");
HystrixCommandKey commandkey = HystrixCommandKey.Factory.asKey("say");
HystrixThreadPoolKey threadpoolkey = HystrixThreadPoolKey.Factory.asKey("hello-1");
HystrixThreadPoolProperties.Setter threadproperties = HystrixThreadPoolProperties.Setter()//
.withCoreSize(20).withKeepAliveTimeMinutes(5).withMaxQueueSize(1000).withQueueSizeRejectionThreshold(100);
HystrixCommandProperties.Setter commandproperty = HystrixCommandProperties.Setter()//
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)//
.withExecutionIsolationSemaphoreMaxConcurrentRequests(10);
return HystrixCommand.Setter.withGroupKey(groupkey).andCommandKey(commandkey)//
.andThreadPoolKey(threadpoolkey).andThreadPoolPropertiesDefaults(threadproperties)//
.andCommandPropertiesDefaults(commandproperty);
}
示例14: getHystrixThreadPoolPropertiesSetter
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
public HystrixThreadPoolProperties.Setter getHystrixThreadPoolPropertiesSetter() {
return HystrixThreadPoolProperties.Setter()
.withCoreSize(
coreSize)
.withKeepAliveTimeMinutes(
keepAliveTimeMinutes)
.withMaxQueueSize(
maxQueueSize)
.withMetricsRollingStatisticalWindowBuckets(
metricsRollingStatisticalWindowBuckets)
//.withMetricsRollingStatisticalWindowInMilliseconds(
// metricsRollingStatisticalWindowInMilliseconds)
;
}
示例15: GetCostCentersCommand
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入依赖的package包/类
protected GetCostCentersCommand( final ReadCostCenterDataService service, final ErpConfigContext configContext )
{
super(
HystrixUtil
.getDefaultErpCommandSetter(
GetCostCentersCommand.class,
HystrixUtil.getDefaultErpCommandProperties().withExecutionTimeoutInMilliseconds(5000))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(20)),
configContext);
this.service = service;
}