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


Java HystrixThreadPoolProperties类代码示例

本文整理汇总了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);
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:18,代码来源:HelloDegrade.java

示例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);
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:17,代码来源:HelloBreaker.java

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

示例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;
    }
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:23,代码来源:DubboHystrixCommand.java

示例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;
}
 
开发者ID:xiaomin0322,项目名称:dubbo_plus,代码行数:17,代码来源:DubboHystrixCommand.java

示例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;
}
 
开发者ID:xiaomin0322,项目名称:dubbo_plus,代码行数:17,代码来源:HelloWorldCommand3.java

示例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);
}
 
开发者ID:xiaomin0322,项目名称:spring-integration-hystrix,代码行数:25,代码来源:HystrixCommandAspect.java

示例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;
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:31,代码来源:ManagedHystrixCommandFactory.java

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

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

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

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

示例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);
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:15,代码来源:HelloSemphor.java

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

示例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;
}
 
开发者ID:SAP,项目名称:cloud-s4-sdk-examples,代码行数:12,代码来源:GetCostCentersCommand.java


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