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


Java HystrixThreadPoolKey类代码示例

本文整理汇总了Java中com.netflix.hystrix.HystrixThreadPoolKey的典型用法代码示例。如果您正苦于以下问题:Java HystrixThreadPoolKey类的具体用法?Java HystrixThreadPoolKey怎么用?Java HystrixThreadPoolKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HystrixThreadPoolKey类属于com.netflix.hystrix包,在下文中一共展示了HystrixThreadPoolKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setter

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的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.HystrixThreadPoolKey; //导入依赖的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: getCommandSetter

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的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

示例4: getThreadPool

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的package包/类
@Override
public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey,
                                        HystrixProperty<Integer> corePoolSize,
                                        HystrixProperty<Integer> maximumPoolSize,
                                        HystrixProperty<Integer> keepAliveTime,
                                        TimeUnit unit, BlockingQueue<Runnable> workQueue) {

    ThreadFactory threadFactory = lookupManagedThreadFactory(threadPoolKey);
    if (threadFactory != null) {
        return new ThreadPoolExecutor(corePoolSize.get(), maximumPoolSize.get(), keepAliveTime.get(),
                unit, workQueue, threadFactory);
    } else {
        LOGGER.warn("Fallback to Hystrix default thread pool executor.");
        return super.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
    }
}
 
开发者ID:lreimer,项目名称:cloud-native-javaee,代码行数:17,代码来源:HystrixConcurrencyStrategyJsr236.java

示例5: lookupManagedThreadFactory

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的package包/类
private ManagedThreadFactory lookupManagedThreadFactory(HystrixThreadPoolKey threadPoolKey) {
    if (context == null) {
        return null;
    }

    String name = "java:concurrent/" + threadPoolKey.name();

    Object thing = null;
    try {
        thing = context.lookup(name);
    } catch (NamingException e) {
        LOGGER.warn("Unable to lookup managed thread factory.", e);
    }

    if (thing instanceof ManagedThreadFactory) {
        return (ManagedThreadFactory) thing;
    } else if (thing == null) {
        LOGGER.warn("Unable to find a JSR 236 managed thread factory using {} in JDNI.", name);
        return null;
    } else {
        LOGGER.warn("Found thing is not a JSR 236 managed thread factory, it is a {} instead.", thing);
        return null;
    }
}
 
开发者ID:lreimer,项目名称:cloud-native-javaee,代码行数:25,代码来源:HystrixConcurrencyStrategyJsr236.java

示例6: HystrixKafkaCircuitBreaker

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的package包/类
public HystrixKafkaCircuitBreaker(final String brokerId) {
    commandKey = HystrixCommandKey.Factory.asKey(brokerId);
    commandProperties = HystrixPropertiesFactory.getCommandProperties(commandKey, null);
    threadPoolKey = HystrixThreadPoolKey.Factory.asKey(brokerId);
    hystrixCommandMetrics = HystrixCommandMetrics.getInstance(
            commandKey,
            HYSTRIX_CMD_GROUP_KEY,
            threadPoolKey,
            commandProperties);
    circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(
            commandKey,
            HYSTRIX_CMD_GROUP_KEY,
            commandProperties,
            hystrixCommandMetrics);
    concurrentExecutionCount = new AtomicInteger();
}
 
开发者ID:zalando,项目名称:nakadi,代码行数:17,代码来源:HystrixKafkaCircuitBreaker.java

示例7: getThreadPool

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的package包/类
@Override
public ThreadPoolExecutor getThreadPool(final HystrixThreadPoolKey threadPoolKey,
                                        final HystrixProperty<Integer> corePoolSize,
                                        final HystrixProperty<Integer> maximumPoolSize,
                                        final HystrixProperty<Integer> keepAliveTime,
                                        final TimeUnit unit,
                                        final BlockingQueue<Runnable> workQueue) {
    int minPoolSize = 10;
    minPoolSize = (minPoolSize < maximumPoolSize.get()) ? minPoolSize : maximumPoolSize.get();

    ThreadPoolExecutor executor = super.getThreadPool(threadPoolKey,
                                                      HystrixProperty.Factory.asProperty(minPoolSize),
                                                      maximumPoolSize,
                                                      keepAliveTime, unit, workQueue);
    executor.allowCoreThreadTimeOut(true);
    executor.prestartAllCoreThreads();
    return executor;
}
 
开发者ID:signicat,项目名称:hystrix-servlet,代码行数:19,代码来源:ConcurrencyStrategyWithExplicitCoreSize.java

示例8: getSetter

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的package包/类
protected static Setter getSetter(final String commandKey,
		ZuulProperties zuulProperties, IClientConfig config) {

	// @formatter:off
	Setter commandSetter = Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RibbonCommand"))
							.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
	final HystrixCommandProperties.Setter setter = createSetter(config, commandKey, zuulProperties);
	if (zuulProperties.getRibbonIsolationStrategy() == ExecutionIsolationStrategy.SEMAPHORE){
		final String name = ZuulConstants.ZUUL_EUREKA + commandKey + ".semaphore.maxSemaphores";
		// we want to default to semaphore-isolation since this wraps
		// 2 others commands that are already thread isolated
		final DynamicIntProperty value = DynamicPropertyFactory.getInstance()
				.getIntProperty(name, zuulProperties.getSemaphore().getMaxSemaphores());
		setter.withExecutionIsolationSemaphoreMaxConcurrentRequests(value.get());
	} else if (zuulProperties.getThreadPool().isUseSeparateThreadPools()) {
		final String threadPoolKey = zuulProperties.getThreadPool().getThreadPoolKeyPrefix() + commandKey;
		commandSetter.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey(threadPoolKey));
	}
	
	return commandSetter.andCommandPropertiesDefaults(setter);
	// @formatter:on
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:23,代码来源:AbstractRibbonCommand.java

示例9: setter

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的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

示例10: getThreadPool

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的package包/类
@Override
public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey,
        HystrixProperty<Integer> corePoolSize,
        HystrixProperty<Integer> maximumPoolSize,
        HystrixProperty<Integer> keepAliveTime, TimeUnit unit,
        BlockingQueue<Runnable> workQueue) {
    ThreadPoolExecutor pool = poolMap.get(threadPoolKey);
    if (pool == null) {
        ThreadPoolExecutor newPool = 
            executorFactory.createThreadPoolExecutor(
                    corePoolSize.get(), maximumPoolSize.get(),
                    keepAliveTime.get(), unit, workQueue);
        pool = poolMap.putIfAbsent(threadPoolKey, newPool);
        pool = (pool == null) ? newPool : pool;
    }

    return pool;
}
 
开发者ID:WASdev,项目名称:sample.netflixoss.wlp,代码行数:19,代码来源:WsHystrixConcurrencyStrategy.java

示例11: getThreadPool

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey,
                                        HystrixProperty<Integer> corePoolSize,
                                        HystrixProperty<Integer> maximumPoolSize,
                                        HystrixProperty<Integer> keepAliveTime, TimeUnit unit,
                                        BlockingQueue<Runnable> workQueue) {
    return delegate.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:12,代码来源:ExecutionContextAwareHystrixStrategy.java

示例12: setter

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的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

示例13: setter

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的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: getThreadPool

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的package包/类
@Override
public ThreadPoolExecutor getThreadPool(final HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolProperties threadPoolProperties) {
    final int dynamicCoreSize = threadPoolProperties.coreSize().get();
    final int keepAliveTime = threadPoolProperties.keepAliveTimeMinutes().get();
    final int maxQueueSize = threadPoolProperties.maxQueueSize().get();
    final BlockingQueue<Runnable> workQueue = getBlockingQueue(maxQueueSize);

    return new FiberThreadPoolExecutor(dynamicCoreSize, dynamicCoreSize, keepAliveTime, TimeUnit.MINUTES, workQueue);
}
 
开发者ID:pmohankumar,项目名称:fibers,代码行数:10,代码来源:HystrixFiberConcurrencyStrategy.java

示例15: FallbackViaNetwork

import com.netflix.hystrix.HystrixThreadPoolKey; //导入依赖的package包/类
public FallbackViaNetwork(int id) {
	super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceX"))
			.andCommandKey(HystrixCommandKey.Factory.asKey("GetValueFallbackCommand"))
			// use a different threadpool for the fallback command
			// so saturating the RemoteServiceX pool won't prevent
			// fallbacks from executing
			.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey("RemoteServiceXFallback")));
	this.id = id;
}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:10,代码来源:CommandWithFallbackViaNetwork.java


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