Examples of HystrixThreadPoolProperties


Examples of com.netflix.hystrix.HystrixThreadPoolProperties

public class TenacityPropertyStore {
    private TenacityPropertyStore() {}

    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(),
View Full Code Here

Examples of com.netflix.hystrix.HystrixThreadPoolProperties

        assertEquals(commandProperties.circuitBreakerSleepWindowInMilliseconds().get().intValue(), overrideConfiguration.getCircuitBreaker().getSleepWindowInMillis());
        assertEquals(commandProperties.metricsRollingStatisticalWindowBuckets().get().intValue(), overrideConfiguration.getCircuitBreaker().getMetricsRollingStatisticalWindowBuckets());
        assertEquals(commandProperties.metricsRollingStatisticalWindowInMilliseconds().get().intValue(), overrideConfiguration.getCircuitBreaker().getMetricsRollingStatisticalWindowInMilliseconds());


        final HystrixThreadPoolProperties threadPoolProperties = successCommand.getThreadpoolProperties();
        final ThreadPoolConfiguration threadPoolConfiguration = overrideConfiguration.getThreadpool();
        assertEquals(threadPoolProperties.coreSize().get().intValue(), threadPoolConfiguration.getThreadPoolCoreSize());
        assertEquals(threadPoolProperties.keepAliveTimeMinutes().get().intValue(), threadPoolConfiguration.getKeepAliveTimeMinutes());
        assertEquals(threadPoolProperties.maxQueueSize().get().intValue(), threadPoolConfiguration.getMaxQueueSize());
        assertEquals(threadPoolProperties.metricsRollingStatisticalWindowBuckets().get().intValue(), threadPoolConfiguration.getMetricsRollingStatisticalWindowBuckets());
        assertEquals(threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get().intValue(), threadPoolConfiguration.getMetricsRollingStatisticalWindowInMilliseconds());
        assertEquals(threadPoolProperties.queueSizeRejectionThreshold().get().intValue(), threadPoolConfiguration.getQueueSizeRejectionThreshold());

        assertEquals(TenacityPropertyStore.getTenacityConfiguration(DependencyKey.OVERRIDE), overrideConfiguration);
    }
View Full Code Here

Examples of com.netflix.hystrix.HystrixThreadPoolProperties

                .isEqualTo(4);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.SHORT_CIRCUITED))
                .isEqualTo(0);

        final HystrixThreadPoolProperties threadPoolProperties = new SleepCommand(DependencyKey.SLEEP).getThreadpoolProperties();

        final ThreadPoolConfiguration threadPoolConfiguration = exampleConfiguration.getThreadpool();
        assertEquals(threadPoolProperties.queueSizeRejectionThreshold().get().intValue(), threadPoolConfiguration.getQueueSizeRejectionThreshold());
        assertEquals(threadPoolProperties.maxQueueSize().get().intValue(), threadPoolConfiguration.getMaxQueueSize());

        assertEquals(TenacityPropertyStore.getTenacityConfiguration(DependencyKey.SLEEP), exampleConfiguration);
    }
View Full Code Here

Examples of com.netflix.hystrix.HystrixThreadPoolProperties

        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.SHORT_CIRCUITED))
                .isEqualTo(sleepCommandMetrics.getCumulativeCount(HystrixRollingNumberEvent.FALLBACK_SUCCESS) -
                           sleepCommandMetrics.getCumulativeCount(HystrixRollingNumberEvent.THREAD_POOL_REJECTED));

        final HystrixThreadPoolProperties threadPoolProperties = new SleepCommand(DependencyKey.EXAMPLE).getThreadpoolProperties();

        //-1 means no limit on the number of items in the queue, which uses the SynchronousBlockingQueue
        assertEquals(threadPoolProperties.maxQueueSize().get().intValue(), -1);
        assertEquals(TenacityPropertyStore.getTenacityConfiguration(DependencyKey.EXAMPLE), new TenacityConfiguration());
    }
View Full Code Here

Examples of com.netflix.hystrix.HystrixThreadPoolProperties

            field.setAccessible(true);
            HystrixThreadPool threadPool = (HystrixThreadPool) field.get(command);

            Field field2 = HystrixThreadPool.HystrixThreadPoolDefault.class.getDeclaredField("properties");
            field2.setAccessible(true);
            HystrixThreadPoolProperties properties = (HystrixThreadPoolProperties) field2.get(threadPool);

            assertEquals(30, (int) properties.coreSize().get());
            assertEquals(101, (int) properties.maxQueueSize().get());
            assertEquals(2, (int) properties.keepAliveTimeMinutes().get());
            assertEquals(15, (int) properties.queueSizeRejectionThreshold().get());
            assertEquals(1440, (int) properties.metricsRollingStatisticalWindowInMilliseconds().get());
            assertEquals(12, (int) properties.metricsRollingStatisticalWindowBuckets().get());
        } finally {
            context.shutdown();
        }
    }
View Full Code Here

Examples of com.netflix.hystrix.HystrixThreadPoolProperties

     */
    public static HystrixThreadPoolProperties getThreadPoolProperties(HystrixThreadPoolKey key, HystrixThreadPoolProperties.Setter builder) {
        HystrixPropertiesStrategy hystrixPropertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
        String cacheKey = hystrixPropertiesStrategy.getThreadPoolPropertiesCacheKey(key, builder);
        if (cacheKey != null) {
            HystrixThreadPoolProperties properties = threadPoolProperties.get(cacheKey);
            if (properties != null) {
                return properties;
            } else {
                if (builder == null) {
                    builder = HystrixThreadPoolProperties.Setter();
                }
                // create new instance
                properties = hystrixPropertiesStrategy.getThreadPoolProperties(key, builder);
                // cache and return
                HystrixThreadPoolProperties existing = threadPoolProperties.putIfAbsent(cacheKey, properties);
                if (existing == null) {
                    return properties;
                } else {
                    return existing;
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.