本文整理汇总了Java中com.netflix.hystrix.HystrixThreadPoolProperties.Setter方法的典型用法代码示例。如果您正苦于以下问题:Java HystrixThreadPoolProperties.Setter方法的具体用法?Java HystrixThreadPoolProperties.Setter怎么用?Java HystrixThreadPoolProperties.Setter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.hystrix.HystrixThreadPoolProperties
的用法示例。
在下文中一共展示了HystrixThreadPoolProperties.Setter方法的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: 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);
}
示例4: 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;
}
示例5: 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);
}
示例6: 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);
}
示例7: getHystrixThreadPoolPropertiesSetter
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入方法依赖的package包/类
public HystrixThreadPoolProperties.Setter getHystrixThreadPoolPropertiesSetter() {
return HystrixThreadPoolProperties.Setter()
.withCoreSize(
coreSize)
.withKeepAliveTimeMinutes(
keepAliveTimeMinutes)
.withMaxQueueSize(
maxQueueSize)
.withMetricsRollingStatisticalWindowBuckets(
metricsRollingStatisticalWindowBuckets)
//.withMetricsRollingStatisticalWindowInMilliseconds(
// metricsRollingStatisticalWindowInMilliseconds)
;
}
示例8: threadPoolProperties
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入方法依赖的package包/类
private HystrixThreadPoolProperties.Setter threadPoolProperties() {
CircuitBreakerProperty[] properties = onCircuitBreaker.map(a -> a.properties())
.orElseGet(() -> new CircuitBreakerProperty[0]);
HystrixThreadPoolProperties.Setter hystrixThreadPoolProperties = HystrixThreadPoolProperties.defaultSetter();
HystrixCircuitBreakerThreadPoolPropertiesSetter propertiesSetter = new HystrixCircuitBreakerThreadPoolPropertiesSetter(properties);
propertiesSetter.applyTo(hystrixThreadPoolProperties);
return hystrixThreadPoolProperties;
}
示例9: getHystrixThreadPoolPropertiesSetter
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入方法依赖的package包/类
private HystrixThreadPoolProperties.Setter getHystrixThreadPoolPropertiesSetter(
com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand hystrixCommand) {
HystrixThreadPoolProperties.Setter commandPropertiesDefaults = HystrixThreadPoolProperties.defaultSetter();
if (hystrixCommand.threadPoolProperties() == null || hystrixCommand.threadPoolProperties().length == 0) {
return commandPropertiesDefaults;
}
Map<String, Object> commandProperties = new HashMap<String, Object>();
for (HystrixProperty commandProperty : hystrixCommand.threadPoolProperties()) {
commandProperties.put(commandProperty.name(), commandProperty.value());
BeanUtil.setDeclaredProperty(commandPropertiesDefaults, commandProperty.name(),
commandProperty.value());
}
return commandPropertiesDefaults;
}
示例10: buildCustomThreadPoolProperties
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入方法依赖的package包/类
@Override
protected HystrixThreadPoolProperties.Setter buildCustomThreadPoolProperties(String name)
{
return new SpringThreadPoolProperties(
environment,
configPrefix,
HystrixThreadPoolKey.Factory.asKey(name))
.createSetter();
}
示例11: getHystrixThreadPoolProperties
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入方法依赖的package包/类
/**
* Get the hystrix threadpool properties for the given command name. By default
* every command will get the same default settings, unless extending clients
* override the behavior of {@link #buildCustomThreadPoolProperties(String)}.
* @param name Command name
* @return Hystrix thread pool properties to use for the given command name,
* which may be the default.
*/
public HystrixThreadPoolProperties.Setter getHystrixThreadPoolProperties(String name)
{
if(!threadPropertiesMap.containsKey(name))
{
threadPropertiesMap.put(name, buildCustomThreadPoolProperties(name));
}
//
// We shouldn't need the default here, but in the interest of trying
// to avoid null properties we use it anyway.
//
return threadPropertiesMap.getOrDefault(name, buildDefaultThreadPoolProperties());
}
示例12: buildDefaultThreadPoolProperties
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入方法依赖的package包/类
/**
* Returns a reasonable default
* @return for Hystrix thread pool settings. Size is 4 and rolling stats
* window size is 10000ms.
*/
protected HystrixThreadPoolProperties.Setter buildDefaultThreadPoolProperties()
{
return HystrixThreadPoolProperties.Setter()
.withCoreSize(5)
.withMetricsRollingStatisticalWindowInMilliseconds(10000);
}
示例13: AstrixThreadPoolProperties
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入方法依赖的package包/类
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));
}
示例14: applyTo
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入方法依赖的package包/类
public void applyTo(HystrixThreadPoolProperties.Setter hystrixtThreadPoolProperties) {
Arrays.stream(properties)
.forEach(p -> Optional.ofNullable(HYSTRIX_THREAD_POOL_PROPERTIES_SETTERS.get(p.name()))
.ifPresent(s -> s.set(hystrixtThreadPoolProperties, p.value())));
}
示例15: initSetter
import com.netflix.hystrix.HystrixThreadPoolProperties; //导入方法依赖的package包/类
private Setter initSetter(HystrixCommandKey commandKey, Method method, FaultToleranceOperation operation) {
HystrixCommandProperties.Setter propertiesSetter = HystrixCommandProperties.Setter();
if (operation.isAsync()) {
propertiesSetter.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD);
} else {
propertiesSetter.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE);
}
if (nonFallBackEnable && operation.hasTimeout()) {
Long value = Duration.of(operation.getTimeout().get(TimeoutConfig.VALUE), operation.getTimeout().get(TimeoutConfig.UNIT)).toMillis();
if (value > Integer.MAX_VALUE) {
LOGGER.warnf("Max supported value for @Timeout.value() is %s", Integer.MAX_VALUE);
value = Long.valueOf(Integer.MAX_VALUE);
}
propertiesSetter.withExecutionTimeoutInMilliseconds(value.intValue());
} else {
propertiesSetter.withExecutionTimeoutEnabled(false);
}
if (nonFallBackEnable && operation.hasCircuitBreaker()) {
propertiesSetter.withCircuitBreakerEnabled(true)
.withCircuitBreakerRequestVolumeThreshold(operation.getCircuitBreaker().get(CircuitBreakerConfig.REQUEST_VOLUME_THRESHOLD))
.withCircuitBreakerErrorThresholdPercentage(
new Double((Double) operation.getCircuitBreaker().get(CircuitBreakerConfig.FAILURE_RATIO) * 100).intValue())
.withCircuitBreakerSleepWindowInMilliseconds((int) Duration
.of(operation.getCircuitBreaker().get(CircuitBreakerConfig.DELAY), operation.getCircuitBreaker().get(CircuitBreakerConfig.DELAY_UNIT)).toMillis());
} else {
propertiesSetter.withCircuitBreakerEnabled(false);
}
Setter setter = Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("DefaultCommandGroup"))
// Each method must have a unique command key
.andCommandKey(commandKey).andCommandPropertiesDefaults(propertiesSetter);
if (nonFallBackEnable && operation.hasBulkhead()) {
// TODO: these options need further review
BulkheadConfig bulkhead = operation.getBulkhead();
propertiesSetter.withExecutionIsolationSemaphoreMaxConcurrentRequests(bulkhead.get(BulkheadConfig.VALUE));
propertiesSetter.withExecutionIsolationThreadInterruptOnFutureCancel(true);
// Each bulkhead policy needs a dedicated thread pool
setter.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey(commandKey.name()));
HystrixThreadPoolProperties.Setter threadPoolSetter = HystrixThreadPoolProperties.Setter();
threadPoolSetter.withAllowMaximumSizeToDivergeFromCoreSize(true);
threadPoolSetter.withCoreSize(bulkhead.get(BulkheadConfig.VALUE));
threadPoolSetter.withMaximumSize(bulkhead.get(BulkheadConfig.VALUE));
threadPoolSetter.withMaxQueueSize(bulkhead.get(BulkheadConfig.WAITING_TASK_QUEUE));
threadPoolSetter.withQueueSizeRejectionThreshold(bulkhead.get(BulkheadConfig.WAITING_TASK_QUEUE));
setter.andThreadPoolPropertiesDefaults(threadPoolSetter);
}
return setter;
}