com.netflix.hystrix.HystrixThreadPoolKey Java Examples
The following examples show how to use
com.netflix.hystrix.HystrixThreadPoolKey.
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 |
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: HystrixKafkaCircuitBreaker.java From nakadi with MIT License | 6 votes |
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(); }
Example #3
Source File: HystrixConcurrencyStrategyTests.java From servicecomb-pack with Apache License 2.0 | 5 votes |
public TestCircuitBreakerCommand(String name, OmegaContext omegaContext) { super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ThreadPoolTestGroup")) .andCommandKey(HystrixCommandKey.Factory.asKey("testCommandKey")) .andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey(name)) .andThreadPoolPropertiesDefaults( HystrixThreadPoolProperties.Setter() .withMaxQueueSize(10) .withCoreSize(3) .withMaximumSize(3) ) ); this.omegaContext = omegaContext; }
Example #4
Source File: SofaTracerHystrixConcurrencyStrategy.java From sofa-tracer with Apache License 2.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { return this.delegate.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); }
Example #5
Source File: ThreadLocalAwareStrategy.java From spring-microservices-in-action with Apache License 2.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { return existingConcurrencyStrategy != null ? existingConcurrencyStrategy.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue) : super.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); }
Example #6
Source File: ThreadLocalAwareStrategy.java From spring-microservices-in-action with Apache License 2.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { return existingConcurrencyStrategy != null ? existingConcurrencyStrategy.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue) : super.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); }
Example #7
Source File: BladeHystrixConcurrencyStrategy.java From blade-tool with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { return existingConcurrencyStrategy != null ? existingConcurrencyStrategy.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue) : super.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); }
Example #8
Source File: ExecutionContextAwareHystrixStrategy.java From spring-cloud-ribbon-extensions with Apache License 2.0 | 5 votes |
/** * {@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); }
Example #9
Source File: HelloCommand.java From TakinRPC with Apache License 2.0 | 5 votes |
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 #10
Source File: HystrixCommandWithFallbackViaNetwork.java From micro-service with MIT License | 5 votes |
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; }
Example #11
Source File: HelloSemphor.java From TakinRPC with Apache License 2.0 | 5 votes |
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 #12
Source File: SeataHystrixConcurrencyStrategy.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { return this.delegate.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); }
Example #13
Source File: MicrometerMetricsPublisherThreadPool.java From micrometer with Apache License 2.0 | 5 votes |
public MicrometerMetricsPublisherThreadPool( final MeterRegistry meterRegistry, final HystrixThreadPoolKey threadPoolKey, final HystrixThreadPoolMetrics metrics, final HystrixThreadPoolProperties properties, final HystrixMetricsPublisherThreadPool metricsPublisherForThreadPool) { this.meterRegistry = meterRegistry; this.metrics = metrics; this.properties = properties; this.metricsPublisherForThreadPool = metricsPublisherForThreadPool; this.tags = Tags.of("key", threadPoolKey.name()); }
Example #14
Source File: CommandWithFallbackViaNetwork.java From tools-journey with Apache License 2.0 | 5 votes |
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; }
Example #15
Source File: ServiceCombConcurrencyStrategy.java From servicecomb-pack with Apache License 2.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { return existingConcurrencyStrategy != null ? existingConcurrencyStrategy.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue) : super.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); }
Example #16
Source File: ServiceCombConcurrencyStrategy.java From servicecomb-pack with Apache License 2.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolProperties threadPoolProperties) { return existingConcurrencyStrategy != null ? existingConcurrencyStrategy.getThreadPool(threadPoolKey, threadPoolProperties) : super.getThreadPool(threadPoolKey, threadPoolProperties); }
Example #17
Source File: CustomFeignHystrixConcurrencyStrategy.java From spring-microservice-exam with MIT License | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { return this.hystrixConcurrencyStrategy.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); }
Example #18
Source File: CommandWithFallbackViaNetwork.java From javabase with Apache License 2.0 | 5 votes |
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; }
Example #19
Source File: AbstractContextConcurrencyStrategy.java From onetwo with Apache License 2.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { return existingConcurrencyStrategy != null ? existingConcurrencyStrategy.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue) : super.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); }
Example #20
Source File: MultiConcurrencyStrategyDispatcher.java From astrix with Apache License 2.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { if (MultiConfigId.hasMultiSourceId(threadPoolKey)) { return strategies.get(MultiConfigId.readFrom(threadPoolKey)) .getThreadPool(MultiConfigId.decode(threadPoolKey), corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); } else { return underlying().map(strategy -> strategy.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue)) .orElseGet(() -> super.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue)); } }
Example #21
Source File: MultiConfigIdTest.java From astrix with Apache License 2.0 | 5 votes |
@Test public void decode() throws Exception { String name = "com.avanza.test.TestServiceApi.TestService"; assertEquals(HystrixCommandKey.Factory.asKey(name).name(), MultiConfigId.decode(MultiConfigId.create("t-T1").createCommandKey(name)).name()); assertEquals(HystrixThreadPoolKey.Factory.asKey(name).name(), MultiConfigId.decode(MultiConfigId.create("t-T1").createThreadPoolKey(name)).name()); assertEquals(HystrixCollapserKey.Factory.asKey(name).name(), MultiConfigId.decode(MultiConfigId.create("t-T1").createCollapserKey(name)).name()); }
Example #22
Source File: MultiConfigIdTest.java From astrix with Apache License 2.0 | 5 votes |
@Test public void hasMultiSourceId() throws Exception { String name = "com.avanza.test.TestServiceApi.TestService"; assertTrue(MultiConfigId.hasMultiSourceId(MultiConfigId.create("t-T1").createCommandKey(name))); assertTrue(MultiConfigId.hasMultiSourceId(MultiConfigId.create("t-T1").createCollapserKey(name))); assertTrue(MultiConfigId.hasMultiSourceId(MultiConfigId.create("t-T1").createThreadPoolKey(name))); assertFalse(MultiConfigId.hasMultiSourceId(HystrixCommandKey.Factory.asKey(name))); assertFalse(MultiConfigId.hasMultiSourceId(HystrixCollapserKey.Factory.asKey(name))); assertFalse(MultiConfigId.hasMultiSourceId(HystrixThreadPoolKey.Factory.asKey(name))); }
Example #23
Source File: MultiPropertiesStrategyDispatcherTest.java From astrix with Apache License 2.0 | 5 votes |
@Test public void decodesIncomingThreadPoolKeys() throws Exception { HystrixPropertiesStrategy mock = Mockito.mock(HystrixPropertiesStrategy.class); MultiConfigId configId = MultiConfigId.create("t1"); dispatcher.register(configId.toString(), mock); dispatcher.getThreadPoolProperties(configId.createThreadPoolKey("com.avanza.test.TestApi.TestService"), defaultThreadPoolSetter); Mockito.verify(mock).getThreadPoolProperties(HystrixThreadPoolKey.Factory.asKey("com.avanza.test.TestApi.TestService"), defaultThreadPoolSetter); }
Example #24
Source File: ConcurrencyStrategyDispatcher.java From astrix with Apache License 2.0 | 5 votes |
@Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize, HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { return hystrixStrategyMapping.getHystrixStrategies(threadPoolKey) .getHystrixConcurrencyStrategy() .getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); }
Example #25
Source File: HystrixCommandKeyFactory.java From astrix with Apache License 2.0 | 5 votes |
HystrixThreadPoolKey createThreadPoolKey(AstrixBeanKey<?> beanKey) { String commandKeyName = this.commandNamingStrategy.getCommandKeyName(beanKey); if (!astrixContextId.equals("1")) { commandKeyName = commandKeyName + "[" + astrixContextId + "]"; } return HystrixThreadPoolKey.Factory.asKey(commandKeyName); }
Example #26
Source File: AstrixThreadPoolProperties.java From astrix with Apache License 2.0 | 5 votes |
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)); }
Example #27
Source File: PropertiesStrategyDispatcher.java From astrix with Apache License 2.0 | 5 votes |
@Override public HystrixThreadPoolProperties getThreadPoolProperties(HystrixThreadPoolKey threadPoolKey, com.netflix.hystrix.HystrixThreadPoolProperties.Setter builder) { return this.strategyMapping.getHystrixStrategies(threadPoolKey) .getHystrixPropertiesStrategy() .getThreadPoolProperties(threadPoolKey, builder); }
Example #28
Source File: BeanConfigurationPropertiesStrategy.java From astrix with Apache License 2.0 | 5 votes |
@Override public HystrixThreadPoolProperties getThreadPoolProperties(HystrixThreadPoolKey threadPoolKey, com.netflix.hystrix.HystrixThreadPoolProperties.Setter builder) { return this.beanMapping.getBeanKey(threadPoolKey) .flatMap(beanKey -> createThreadPoolProperties(beanKey, threadPoolKey, builder)) .orElse(super.getThreadPoolProperties(threadPoolKey, builder)); }
Example #29
Source File: HystrixCommandConfigurationTest.java From astrix with Apache License 2.0 | 5 votes |
private static HystrixThreadPoolProperties getThreadPoolProperties(HystrixFaultToleranceFactory hystrixFaultTolerance, Class<?> api) { HystrixPropertiesStrategy hystrixPropertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy(); HystrixCommandGroupKey groupKey = hystrixFaultTolerance.getGroupKey(AstrixBeanKey.create(api)); return hystrixPropertiesStrategy.getThreadPoolProperties(HystrixThreadPoolKey.Factory.asKey(groupKey.name()), HystrixThreadPoolProperties.Setter()); }
Example #30
Source File: HystrixCommandInterceptor.java From micro-service with MIT License | 5 votes |
private HystrixCommand.Setter configHystrixCommand(String className, String methodName) { return HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(className + "Group")) .andCommandKey(HystrixCommandKey.Factory.asKey(className + "." + methodName)) .andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey(className + "ThreadPool")) .andCommandPropertiesDefaults(HystrixCommandProperties.Setter() .withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD)) .andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(10)); }