Java Code Examples for com.netflix.hystrix.HystrixThreadPoolProperties#Setter

The following examples show how to use com.netflix.hystrix.HystrixThreadPoolProperties#Setter . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelloDegrade.java    From TakinRPC with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: HelloBreaker.java    From TakinRPC with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 3
Source File: HelloCommand.java    From TakinRPC with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: HelloSemphor.java    From TakinRPC with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 5
Source File: AstrixThreadPoolProperties.java    From astrix with Apache License 2.0 5 votes vote down vote up
AstrixThreadPoolProperties(BeanConfiguration beanConfiguration, HystrixThreadPoolKey key, HystrixThreadPoolProperties.Setter builder) {
	super(key, builder);
	
	// We create all these property adaptors here as each and every one results in creation of several temporary String objects.
	// The alternative to this, to create the adaptors at call-time in the various methods of this class, results in large amounts
	// of temporary objects and thus heavy GC load in systems with many astrix calls.
	this.queueSizeRejectionThreshold = new DynamicPropertyAdapter<>(beanConfiguration.get(AstrixBeanSettings.QUEUE_SIZE_REJECTION_THRESHOLD));
	this.coreSize = new DynamicPropertyAdapter<>(beanConfiguration.get(AstrixBeanSettings.CORE_SIZE));
	this.keepAliveTimeMinutes = new DynamicPropertyAdapter<>(new DynamicIntProperty(1));
	this.maxQueueSize = new DynamicPropertyAdapter<>(beanConfiguration.get(MAX_QUEUE_SIZE));
	this.metricsRollingStatisticalWindowBuckets = new DynamicPropertyAdapter<>(new DynamicIntProperty(10));
	this.metricsRollingStatisticalWindowInMilliseconds = new DynamicPropertyAdapter<>(new DynamicIntProperty(10_000));
}